Skip to content

Commit 04869e8

Browse files
authored
Merge pull request #2875 from zsviczian/refactor-excalidrawView-1
Refactor: ExcalidrawView
2 parents 6976d09 + b35fea7 commit 04869e8

22 files changed

Lines changed: 2099 additions & 1696 deletions

RefactorPlan.md

Lines changed: 45 additions & 15 deletions
Large diffs are not rendered by default.

docs/AITrainingData/Excalidraw Script Library.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ These are the scripts I use most often. I tried to order them by importance, but
182182
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Link%20to%20Existing%20File%20and%20Open.svg"/></div>|[[#Add Link to Existing File and Open]]|
183183
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Link%20to%20New%20Page%20and%20Open.svg"/></div>|[[#Add Link to New Page and Open]]|
184184
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20text%20to%20link%20with%20folder%20and%20alias.svg"/></div>|[[#Convert text to link with folder and alias]]|
185-
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20DrawIO%20file.svg"/></div>|[[#Create DrawIO file]]|
186185
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20new%20markdown%20file%20and%20embed%20into%20active%20drawing.svg"/></div>|[[#Create new markdown file and embed into active drawing]]|
187186
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Folder%20Note%20Core%20-%20Make%20Current%20Drawing%20a%20Folder.svg"/></div>|[[#Folder Note Core - Make Current Drawing a Folder]]|
188187
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Link%20Alias.svg"/></div>|[[#Set Link Alias]]|
@@ -358,12 +357,6 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
358357
```
359358
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/1-2-3'>@1-2-3</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Copy%20Selected%20Element%20Styles%20to%20Global.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">This script will copy styles of any selected element into Excalidraw's global styles.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-copy-selected-element-styles-to-global.png'></td></tr></table>
360359

361-
## Create DrawIO file
362-
```excalidraw-script-install
363-
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20DrawIO%20file.md
364-
```
365-
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Create%20DrawIO%20file.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">The script will prompt you for a filename, then create a new draw.io diagram file and open the file in the <a href='https://github.com/zapthedingbat/drawio-obsidian'>Diagram plugin</a>, in a new tab.<br><a href="https://www.youtube.com/watch?v=DJcosmN-q2s" target="_blank"><img src ="https://i.ytimg.com/vi/DJcosmN-q2s/maxresdefault.jpg" style="width:400px;"></a></td></tr></table>
366-
367360
## Create new markdown file and embed into active drawing
368361
```excalidraw-script-install
369362
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20new%20markdown%20file%20and%20embed%20into%20active%20drawing.md
@@ -7837,46 +7830,6 @@ if(element.type === 'arrow') {
78377830

78387831
---
78397832

7840-
## Create DrawIO file.md
7841-
<!-- Source: ea-scripts/Create DrawIO file.md -->
7842-
7843-
/*
7844-
Creates a new draw.io diagram file and opens the file in the [Diagram plugin](https://github.com/zapthedingbat/drawio-obsidian) in a new tab.
7845-
```js*/
7846-
7847-
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.9.7")) {
7848-
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
7849-
return;
7850-
}
7851-
7852-
const drawIO = app.plugins.plugins["drawio-obsidian"];
7853-
if(!drawIO || !drawIO?._loaded) {
7854-
new Notice("Can't find the draw.io diagram plugin");
7855-
}
7856-
7857-
filename = await utils.inputPrompt("Diagram name?");
7858-
if(!filename) return;
7859-
filename = filename.toLowerCase().endsWith(".svg") ? filename : filename + ".svg";
7860-
const filepath = await ea.getAttachmentFilepath(filename);
7861-
if(!filepath) return;
7862-
const leaf = app.workspace.getLeaf('tab')
7863-
if(!leaf) return;
7864-
7865-
const file = await this.app.vault.create(filepath, `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!--${ea.generateElementId()}--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="300px" height="300px" viewBox="-0.5 -0.5 1 1" content="&lt;mxGraphModel&gt;&lt;root&gt;&lt;mxCell id=&quot;0&quot;/&gt;&lt;mxCell id=&quot;1&quot; parent=&quot;0&quot;/&gt;&lt;/root&gt;&lt;/mxGraphModel&gt;"></svg>`);
7866-
7867-
await ea.addImage(0,0,file);
7868-
await ea.addElementsToView(true,true);
7869-
7870-
leaf.setViewState({
7871-
type: "diagram-edit",
7872-
state: {
7873-
file: filepath
7874-
}
7875-
});
7876-
```
7877-
7878-
---
7879-
78807833
## Create new markdown file and embed into active drawing.md
78817834
<!-- Source: ea-scripts/Create new markdown file and embed into active drawing.md -->
78827835

docs/AITrainingData/ExcalidrawAutomate full library for LLM training.md

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,7 +4796,6 @@ These are the scripts I use most often. I tried to order them by importance, but
47964796
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Link%20to%20Existing%20File%20and%20Open.svg"/></div>|[[#Add Link to Existing File and Open]]|
47974797
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Link%20to%20New%20Page%20and%20Open.svg"/></div>|[[#Add Link to New Page and Open]]|
47984798
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20text%20to%20link%20with%20folder%20and%20alias.svg"/></div>|[[#Convert text to link with folder and alias]]|
4799-
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20DrawIO%20file.svg"/></div>|[[#Create DrawIO file]]|
48004799
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20new%20markdown%20file%20and%20embed%20into%20active%20drawing.svg"/></div>|[[#Create new markdown file and embed into active drawing]]|
48014800
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Folder%20Note%20Core%20-%20Make%20Current%20Drawing%20a%20Folder.svg"/></div>|[[#Folder Note Core - Make Current Drawing a Folder]]|
48024801
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Link%20Alias.svg"/></div>|[[#Set Link Alias]]|
@@ -4972,12 +4971,6 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
49724971
```
49734972
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/1-2-3'>@1-2-3</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Copy%20Selected%20Element%20Styles%20to%20Global.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">This script will copy styles of any selected element into Excalidraw's global styles.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-copy-selected-element-styles-to-global.png'></td></tr></table>
49744973

4975-
## Create DrawIO file
4976-
```excalidraw-script-install
4977-
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20DrawIO%20file.md
4978-
```
4979-
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Create%20DrawIO%20file.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">The script will prompt you for a filename, then create a new draw.io diagram file and open the file in the <a href='https://github.com/zapthedingbat/drawio-obsidian'>Diagram plugin</a>, in a new tab.<br><a href="YouTube: DJcosmN-q2s" target="_blank"><img src ="https://i.ytimg.com/vi/DJcosmN-q2s/maxresdefault.jpg" style="width:400px;"></a></td></tr></table>
4980-
49814974
## Create new markdown file and embed into active drawing
49824975
```excalidraw-script-install
49834976
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Create%20new%20markdown%20file%20and%20embed%20into%20active%20drawing.md
@@ -12451,46 +12444,6 @@ if(element.type === 'arrow') {
1245112444

1245212445
---
1245312446

12454-
## Create DrawIO file.md
12455-
<!-- Source: ea-scripts/Create DrawIO file.md -->
12456-
12457-
/*
12458-
Creates a new draw.io diagram file and opens the file in the [Diagram plugin](https://github.com/zapthedingbat/drawio-obsidian) in a new tab.
12459-
```js*/
12460-
12461-
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.9.7")) {
12462-
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
12463-
return;
12464-
}
12465-
12466-
const drawIO = app.plugins.plugins["drawio-obsidian"];
12467-
if(!drawIO || !drawIO?._loaded) {
12468-
new Notice("Can't find the draw.io diagram plugin");
12469-
}
12470-
12471-
filename = await utils.inputPrompt("Diagram name?");
12472-
if(!filename) return;
12473-
filename = filename.toLowerCase().endsWith(".svg") ? filename : filename + ".svg";
12474-
const filepath = await ea.getAttachmentFilepath(filename);
12475-
if(!filepath) return;
12476-
const leaf = app.workspace.getLeaf('tab')
12477-
if(!leaf) return;
12478-
12479-
const file = await this.app.vault.create(filepath, `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!--${ea.generateElementId()}--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="300px" height="300px" viewBox="-0.5 -0.5 1 1" content="&lt;mxGraphModel&gt;&lt;root&gt;&lt;mxCell id=&quot;0&quot;/&gt;&lt;mxCell id=&quot;1&quot; parent=&quot;0&quot;/&gt;&lt;/root&gt;&lt;/mxGraphModel&gt;"></svg>`);
12480-
12481-
await ea.addImage(0,0,file);
12482-
await ea.addElementsToView(true,true);
12483-
12484-
leaf.setViewState({
12485-
type: "diagram-edit",
12486-
state: {
12487-
file: filepath
12488-
}
12489-
});
12490-
```
12491-
12492-
---
12493-
1249412447
## Create new markdown file and embed into active drawing.md
1249512448
<!-- Source: ea-scripts/Create new markdown file and embed into active drawing.md -->
1249612449

@@ -46316,4 +46269,3 @@ ea.onSceneChangeHook = {
4631646269
}
4631746270
}
4631846271
};
46319-

0 commit comments

Comments
 (0)