diff --git a/ea-scripts/Add Next Step in Process.md b/ea-scripts/Add Next Step in Process.md new file mode 100644 index 0000000..2ada614 --- /dev/null +++ b/ea-scripts/Add Next Step in Process.md @@ -0,0 +1,67 @@ +/* +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-add-process-step.jpg) + +This script will prompt you for the title of the process step, then will create a stick note with the text. If an element is selected then the script will connect this new step with an arrow to the previous step (the selected element). If no element is selected, then the script assumes this is the first step in the process and will only output the sticky note with the text that was entered. + +```javascript +*/ +const textPadding = 10; +const gapBetweenElements = 50; +const wrapLineLen = 25; +const text = await utils.inputPrompt("Text?"); +const elements = ea.getViewSelectedElements(); +const isFirst = (!elements || elements.length === 0); + +if(!isFirst) { + const fromElement = ea.getLargestElement(elements); + ea.copyViewElementsToEAforEditing([fromElement]); + + const previousTextElements = elements.filter((el)=>el.type==="text"); + if(previousTextElements.length>0) { + const el = previousTextElements[0]; + ea.style.strokeColor = el.strokeColor; + ea.style.fontSize = el.fontSize; + ea.style.fontFamily = el.fontFamily; + ea.style.strokeWidth = el.strokeWidth; + ea.style.strokeStyle = el.strokeStyle; + ea.style.strokeSharpness = el.strokeSharpness; + } + + const id = ea.addText( + fromElement.x, + fromElement.y+fromElement.height+gapBetweenElements, + text, + { + wrapAt: wrapLineLen, + textAlign: "center", + box: "rectangle", + boxPadding: textPadding + } + ); + + ea.connectObjects( + fromElement.id, + null, + id, + null, + { + endArrowHead: "triangle", + startArrowHead: null, + numberOfPoints: 0 + } + ); + ea.addElementsToView(false); +} else { + ea.addText( + 0, + 0, + text, + { + wrapAt: wrapLineLen, + textAlign: "center", + box: "rectangle", + boxPadding: textPadding + } + ); + ea.addElementsToView(true); +} diff --git a/ea-scripts/index.md b/ea-scripts/index.md index 6d01f68..c6dcf1b 100644 --- a/ea-scripts/index.md +++ b/ea-scripts/index.md @@ -26,6 +26,7 @@ I would love to include your contribution in the script library. If you have a s # List of available scripts - [[#Add Connector Point]] +- [[#Add Next Step in Process]] - [[#Box Each Selected Groups]] - [[#Box Selected Elements]] - [[#Connect elements]] @@ -60,7 +61,14 @@ I would love to include your contribution in the script library. If you have a s ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Connector%20Point.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will add a small circle to the top left of each text element in the selection and add the text and the "connector point" to a group. You can use the connector points to link text elements with an arrow (in for example a Wardley Map).
+
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will add a small circle to the top left of each text element in the selection and add the text and the "connector point" to a group. You can use the connector points to link text elements with an arrow (in for example a Wardley Map).
+ +## Add Next Step in Process +```excalidraw-script-install +https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Add%20Next%20Step%20in%20Process.md +``` +
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will prompt you for the title of the process step, then will create a stick note with the text. If an element is selected then the script will connect this new step with an arrow to the previous step (the selected element). If no element is selected, then the script assumes this is the first step in the process and will only output the sticky note with the text that was entered.
+ ## Box Each Selected Groups ```excalidraw-script-install @@ -186,19 +194,19 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Dimensions.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionCurrently there is no way to specify the exact location and size of objects in Excalidraw. You can bridge this gap with the following simple script.
+
Author@zsviczian
SourceFile on GitHub
DescriptionCurrently there is no way to specify the exact location and size of objects in Excalidraw. You can bridge this gap with the following simple script.
## Set Font Family ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Font%20Family.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionSets font family of the text block (Virgil, Helvetica, Cascadia). Useful if you want to set a keyboard shortcut for selecting font family.
+
Author@zsviczian
SourceFile on GitHub
DescriptionSets font family of the text block (Virgil, Helvetica, Cascadia). Useful if you want to set a keyboard shortcut for selecting font family.
## Set Grid ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Grid.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionThe default grid size in Excalidraw is 20. Currently there is no way to change the grid size via the user interface. This script offers a way to bridge this gap.
+
Author@zsviczian
SourceFile on GitHub
DescriptionThe default grid size in Excalidraw is 20. Currently there is no way to change the grid size via the user interface. This script offers a way to bridge this gap.
## Set Link Alias ```excalidraw-script-install @@ -210,13 +218,13 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Stroke%20Width%20of%20Selected%20Elements.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will set the stroke width of selected elements. This is helpful, for example, when you scale freedraw sketches and want to reduce or increase their line width.
+
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will set the stroke width of selected elements. This is helpful, for example, when you scale freedraw sketches and want to reduce or increase their line width.
## Set Text Alignment ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Text%20Alignment.md ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionSets text alignment of text block (cetner, right, left). Useful if you want to set a keyboard shortcut for selecting text alignment.
+
Author@zsviczian
SourceFile on GitHub
DescriptionSets text alignment of text block (cetner, right, left). Useful if you want to set a keyboard shortcut for selecting text alignment.
## Split text by lines ```excalidraw-script-install diff --git a/images/scripts-add-process-step.jpg b/images/scripts-add-process-step.jpg new file mode 100644 index 0000000..144e3d9 Binary files /dev/null and b/images/scripts-add-process-step.jpg differ