From 7d98bf691c613993272786fe1560a0217f71e09d Mon Sep 17 00:00:00 2001 From: Zsolt Viczian Date: Sat, 29 Jan 2022 14:20:34 +0100 Subject: [PATCH] 1.5.24 --- docs/API/attributes_functions_overview.md | 17 +- ea-scripts/Add Next Step in Process.md | 8 +- ea-scripts/Convert freedraw to line.md | 62 ++ .../OCR - Optical Character Recognition.md | 10 +- ea-scripts/README.md | 13 +- ea-scripts/Select Elements of Type.md | 44 ++ ... line object by adding a 'shadow' clone.md | 69 ++ ea-scripts/index.md | 21 + manifest.json | 2 +- package.json | 1 - rollup.config.js | 7 +- src/ExcalidrawAutomate.ts | 26 + src/ExcalidrawAutomateFieldSuggestor.ts | 416 ------------ src/FieldSuggestor.ts | 84 ++- src/SuggestorInfo.ts | 592 ++++++++++++++++++ src/constants.ts | 51 -- styles.css | 4 - versions.json | 2 +- yarn.lock | 62 +- 19 files changed, 900 insertions(+), 591 deletions(-) create mode 100644 ea-scripts/Convert freedraw to line.md create mode 100644 ea-scripts/Select Elements of Type.md create mode 100644 ea-scripts/Set background color of unclosed line object by adding a 'shadow' clone.md delete mode 100644 src/ExcalidrawAutomateFieldSuggestor.ts create mode 100644 src/SuggestorInfo.ts diff --git a/docs/API/attributes_functions_overview.md b/docs/API/attributes_functions_overview.md index 95dda5f..e5f0703 100644 --- a/docs/API/attributes_functions_overview.md +++ b/docs/API/attributes_functions_overview.md @@ -134,7 +134,7 @@ export interface ExcalidrawAutomate { }, ): boolean; addElementsToView( //Adds elements from elementsDict to the current view - repositionToCursor?: boolean, //default is false + repositionToCursor?: boolean, //default is false save?: boolean, //default is true //newElementsOnTop controls whether elements created with ExcalidrawAutomate //are added at the bottom of the stack or the top of the stack of elements already in the view @@ -185,13 +185,16 @@ export interface ExcalidrawAutomate { //See OCR plugin for example on how to use scriptSettings activeScript: string; //Set automatically by the ScriptEngine getScriptSettings(): {}; //Returns script settings. Saves settings in plugin settings, under the activeScript key - setScriptSettings(settings:any):Promise; //sets script settings. - openFileInNewOrAdjacentLeaf (file:TFile):WorkspaceLeaf;//Open a file in a new workspaceleaf or reuse an existing adjacent leaf depending on Excalidraw Plugin Settings - measureText(text:string):{ width: number, height: number }; //measure text size based on current style settings + setScriptSettings(settings: any): Promise; //sets script settings. + openFileInNewOrAdjacentLeaf(file: TFile): WorkspaceLeaf; //Open a file in a new workspaceleaf or reuse an existing adjacent leaf depending on Excalidraw Plugin Settings + measureText(text: string): { width: number; height: number }; //measure text size based on current style settings //verifyMinimumPluginVersion returns true if plugin version is >= than required - //recommended use: - //if(!(ea.verifyMinimumPluginVersion && ea.verifyMinimumPluginVersion("1.5.20"))) {new Notice("message");return;} - verifyMinimumPluginVersion(requiredVersion: string):boolean; + //recommended use: + //if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.20")) {new Notice("message");return;} + verifyMinimumPluginVersion(requiredVersion: string): boolean; + selectElementsInView(elements: ExcalidrawElement[]): void; //sets selection in view + generateElementId(): string; //returns an 8 character long random id + cloneElement(element: ExcalidrawElement): ExcalidrawElement; //Returns a clone of the element with a new id } ``` diff --git a/ea-scripts/Add Next Step in Process.md b/ea-scripts/Add Next Step in Process.md index b5d4773..1b304e9 100644 --- a/ea-scripts/Add Next Step in Process.md +++ b/ea-scripts/Add Next Step in Process.md @@ -6,7 +6,7 @@ This script will prompt you for the title of the process step, then will create ```javascript */ -if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.21")) { +if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.24")) { new Notice("This script requires a newer version of Excalidraw. Please install the latest version."); return; } @@ -130,8 +130,4 @@ if(!isFirst) { await ea.addElementsToView(true); } -const API = ea.getExcalidrawAPI(); -st = API.getAppState(); -st.selectedElementIds = {}; -st.selectedElementIds[id] = true; -API.updateScene({appState: st}); +ea.selectElementsInView([ea.getElement(id)]); \ No newline at end of file diff --git a/ea-scripts/Convert freedraw to line.md b/ea-scripts/Convert freedraw to line.md new file mode 100644 index 0000000..ac04f69 --- /dev/null +++ b/ea-scripts/Convert freedraw to line.md @@ -0,0 +1,62 @@ +/* +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-convert-freedraw-to-line.jpg) + +Convert selected freedraw objects into editable lines. This will allow you to adjust your drawings by dragging line points and will also allow you to select shape fill in case of enclosed lines. You can adjust conversion point density in settings. + +```javascript +*/ + +if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.21")) { + new Notice("This script requires a newer version of Excalidraw. Please install the latest version."); + return; +} + +settings = ea.getScriptSettings(); +//set default values on first run +if(!settings["Point density"]) { + settings = { + "Point density" : { + value: "7:1", + valueset: ["1:1","2:1","3:1","4:1","5:1","6:1","7:1","8:1","9:1","10:1","11:1"], + description: "A freedraw object has many points. Converting freedraw to a line with too many points will result in an impractical object that is hard to edit. This setting sepcifies how many points from freedraw should be averaged to form a point on the line" + }, + }; + ea.setScriptSettings(settings); +} + +const setSize = parseInt(settings["Point density"].value[0]); + +const elements = ea.getViewSelectedElements().filter(el=>el.type==="freedraw"); +if(elements.length === 0) { + new Notice("No freedraw object is selected"); +} + + +ea.style.roughness=0; +ea.style.strokeSharpness="round"; + +elements.forEach((el)=>{ + points = []; + points.push(el.points[0]); + for(i=1;i `[[selected folder/original text\|original text]]`|[@zsviczian](https://github.com/zsviczian)| |[Copy Selected Element Styles to Global](Copy%20Selected%20Element%20Styles%20to%20Global)|This script will copy styles of any selected element into Excalidraw's global styles.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-copy-selected-element-styles-to-global.png)|[@1-2-3](https://github.com/1-2-3)| |[Create new markdown file and embed into active drawing](Create%20new%20markdown%20file%20and%20embed%20into%20active%20drawing.md)|The script will prompt you for a filename, then create a new markdown document with the file name provided, open the new markdown document in an adjacent pane, and embed the markdown document into the active Excalidraw drawing.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-create-and-embed-new-markdown-file.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Darken background color](Darken%20background%20color.md)|This script darkens the background color of the selected element by 2% at a time. You can use this script several times until you are satisfied. It is recommended to set a shortcut key for this script so that you can quickly try to DARKEN and LIGHTEN the color effect. In contrast to the `Modify background color opacity` script, the advantage is that the background color of the element is not affected by the canvas color, and the color value does not appear in a strange rgba() form.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/darken-lighten-background-color.png)|[@1-2-3](https://github.com/1-2-3)| -|[Set Dimensions](Set%20Dimensions.md)|Currently 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-dimensions.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Elbow connectors](Elbow%20connectors.md)|This script converts the selected connectors to elbows.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/elbow-connectors.png)|[@1-2-3](https://github.com/1-2-3)| |[Expand rectangles horizontally keep text centered](Expand%20rectangles%20horizontally%20keep%20text20%centered.md)|This script expands the width of the selected rectangles until they are all the same width and keep the text centered.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-expand-rectangles.gif)|[@1-2-3](https://github.com/1-2-3)| |[Expand rectangles horizontally](Expand%20rectangles%20horizontally.md)|This script expands the width of the selected rectangles until they are all the same width.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-expand-rectangles.gif)|[@1-2-3](https://github.com/1-2-3)| @@ -37,15 +37,18 @@ Open the script you are interested in and save it to your Obsidian Vault includi |[Fixed spacing](Fixed%20spacing.md)|The script arranges the selected elements horizontally with a fixed spacing. When we create an architecture diagram or mind map, we often need to arrange a large number of elements in a fixed spacing. `Fixed spacing` and `Fixed vertical Distance` scripts can save us a lot of time.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-fix-space-demo.png)|[@1-2-3](https://github.com/1-2-3)| |[Fixed vertical distance between centers](Fixed%20vertical%20distance%20between%20centers.md)|This script arranges the selected elements vertically with a fixed center spacing.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-fixed-vertical-distance-between-centers.png)|[@1-2-3](https://github.com/1-2-3)| |[Fixed vertical distance](Fixed%20vertical%20distance.md)|The script arranges the selected elements vertically with a fixed spacing. When we create an architecture diagram or mind map, we often need to arrange a large number of elements in a fixed spacing. `Fixed spacing` and `Fixed vertical Distance` scripts can save us a lot of time.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-fixed-vertical-distance.png)|[@1-2-3](https://github.com/1-2-3)| -|[Set Font Family](Set%20Font%20Family.md)|Sets font family of the text block (Virgil, Helvetica, Cascadia). Useful if you want to set a keyboard shortcut for selecting font family.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-font-family.jpg)|[@zsviczian](https://github.com/zsviczian)| -|[Set Grid](Set%20Grid.md)|The 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-grid.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Lighten background color](Lighten%20background%20color.md)|This script lightens the background color of the selected element by 2% at a time. You can use this script several times until you are satisfied. It is recommended to set a shortcut key for this script so that you can quickly try to DARKEN and LIGHTEN the color effect.In contrast to the `Modify background color opacity` script, the advantage is that the background color of the element is not affected by the canvas color, and the color value does not appear in a strange rgba() form.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/darken-lighten-background-color.png)|[@1-2-3](https://github.com/1-2-3)| |[Modify background color opacity](Modify%20background%20color%20opacity.md)|This script changes the opacity of the background color of the selected boxes. The default background color in Excalidraw is so dark that the text is hard to read. You can lighten the color a bit by setting transparency. And you can tweak the transparency over and over again until you're happy with it. Although excalidraw has the opacity option in its native property Settings, it also changes the transparency of the border. Use this script to change only the opacity of the background color without affecting the border.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-modify-background-color-opacity.png)|[@1-2-3](https://github.com/1-2-3)| -|[Set stroke width of selected elements](Set%20Stroke%20Width%20of%20Selected%20Elements.md)|This 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-stroke-width.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Normalize Selected Arrows](Normalize%20Selected%20Arrows.md)|This script will reset the start and end positions of the selected arrows. The arrow will point to the center of the connected box and will have a gap of 8px from the box.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-normalize-selected-arrows.png)|[@1-2-3](https://github.com/1-2-3)| |[OCR - Optical Character Recognition](OCR%20-%20Optical%20Character%20Recognition.md)|The script will 1) send the selected image file to [taskbone.com](https://taskbone.com) to exctract the text from the image, and 2) will add the text to your drawing as a text element.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-ocr.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Reverse arrows](Reverse%20arrows.md)|Reverse the direction of **arrows** within the scope of selected elements.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-reverse-arrow.jpg)|[@zsviczian](https://github.com/zsviczian)| +|[Select Elements of Type](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Select%20Elements%20of%Type.md)|Prompts you with a list of the different element types in the active image. Only elements of the selected type will be selected on the canvas. If nothing is selected when running the script, then the script will process all the elements on the canvas. If some elements are selected when the script is executed, then the script will only process the selected elements.
The script is useful when, for example, you want to bring to front all the arrows, or want to change the color of all the text elements, etc.|![]('https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-select-element-of-type.jpg')|[@zsviczian](https://github.com/zsviczian)| +|[Set background color of unclosed line object by adding a shadow clone](Set%20background%20color%20of%20unclosed%20line%20object%20by%20adding%20a%20shadow%20clone.md)|Use this script to set the background color of unclosed line objects by creating a clone of the line object. The script will setting the stroke color of the clone to transparent and will add a straight line to close the object. Use settings to define the default background color, the fill style, and the strokeWidth of the clone. By default the clone will be grouped with the original object, you can disable this also in settings.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-dimensions.jpg)|[@zsviczian](https://github.com/zsviczian)| +|[Set Dimensions](Set%20Dimensions.md)|Currently 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-dimensions.jpg)|[@zsviczian](https://github.com/zsviczian)| +|[Set Font Family](Set%20Font%20Family.md)|Sets font family of the text block (Virgil, Helvetica, Cascadia). Useful if you want to set a keyboard shortcut for selecting font family.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-font-family.jpg)|[@zsviczian](https://github.com/zsviczian)| +|[Set Grid](Set%20Grid.md)|The 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-grid.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Set Link Alias](Set20%Link20%Alias.md)|Iterates all of the links in the selected TextElements and prompts the user to set or modify the alias for each link found.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-set-link-alias.jpg)|[@zsviczian](https://github.com/zsviczian)| +|[Set stroke width of selected elements](Set%20Stroke%20Width%20of%20Selected%20Elements.md)|This 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.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-stroke-width.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Split text by lines](Split%20text%20by%20lines.md)|Split lines of text into separate text elements for easier reorganization|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-split-lines.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Set Text Alignment](Set%20Text%20Alignment.md)|Sets text alignment of text block (cetner, right, left). Useful if you want to set a keyboard shortcut for selecting text alignment.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-text-align.jpg)|[@zsviczian](https://github.com/zsviczian)| |[Transfer TextElements to Excalidraw markdown metadata](Transfer%20TextElements%20to%20Excalidraw%20markdown%20metadata.md)|The script will delete the selected text elements from the canvas and will copy the text from these text elements into the Excalidraw markdown file as metadata. This means, that the text will no longer be visible in the drawing, however you will be able to search for the text in Obsidian and find the drawing containing this image.|![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-text-to-metadata.jpg)|[@zsviczian](https://github.com/zsviczian)| diff --git a/ea-scripts/Select Elements of Type.md b/ea-scripts/Select Elements of Type.md new file mode 100644 index 0000000..c0a8e01 --- /dev/null +++ b/ea-scripts/Select Elements of Type.md @@ -0,0 +1,44 @@ +/* +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-select-element-of-type.jpg) +Prompts you with a list of the different element types in the active image. Only elements of the selected type will be selected on the canvas. If nothing is selected when running the script, then the script will process all the elements on the canvas. If some elements are selected when the script is executed, then the script will only process the selected elements. + +The script is useful when, for example, you want to bring to front all the arrows, or want to change the color of all the text elements, etc. + +```javascript +*/ + +if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.24")) { + new Notice("This script requires a newer version of Excalidraw. Please install the latest version."); + return; +} + +let elements = ea.getViewSelectedElements(); +if(elements.length === 0) elements = ea.getViewElements(); +if(elements.length === 0) { + new Notice("There are no elements in the view"); + return; +} + +typeSet = new Set(); +elements.forEach(el=>typeSet.add(el.type)); + +const elementType = await utils.suggester( + Array.from(typeSet).map((item) => { + switch(item) { + case "line": return "— line"; + case "ellipse": return "○ ellipse"; + case "rectangle": return "□ rectangle"; + case "diamond": return "◇ diamond"; + case "arrow": return "→ arrow"; + case "freedraw": return "✎ freedraw"; + case "image": return "🖼 image"; + case "text": return "A text"; + default: return item; + } + }), + Array.from(typeSet) +); + +if(!elementType) return; + +ea.selectElementsInView(elements.filter(el=>el.type === elementType)); \ No newline at end of file diff --git a/ea-scripts/Set background color of unclosed line object by adding a 'shadow' clone.md b/ea-scripts/Set background color of unclosed line object by adding a 'shadow' clone.md new file mode 100644 index 0000000..65f3c27 --- /dev/null +++ b/ea-scripts/Set background color of unclosed line object by adding a 'shadow' clone.md @@ -0,0 +1,69 @@ +/* +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-set-background-color-of-unclosed-line.jpg) + +Use this script to set the background color of unclosed line objects by creating a clone of the line object. The script will setting the stroke color of the clone to transparent and will add a straight line to close the object. Use settings to define the default background color, the fill style, and the strokeWidth of the clone. By default the clone will be grouped with the original object, you can disable this also in settings. + +```javascript +*/ + +if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.24")) { + new Notice("This script requires a newer version of Excalidraw. Please install the latest version."); + return; +} + +settings = ea.getScriptSettings(); +//set default values on first run +if(!settings["Background Color"]) { + settings = { + "Background Color" : { + value: "DimGray", + description: "Default background color of the 'shadow' object. Any valid html css color value", + }, + "Fill Style": { + value: "hachure", + valueset: ["hachure","cross-hatch","solid"], + description: "Default fill style of the 'shadow' object." + }, + "Inherit fill stroke width": { + value: true, + description: "This will impact the densness of the hachure or cross-hatch fill. Use the stroke width of the line object for which the shadow is created. If set to false, the script will use a stroke width of 2." + }, + "Group 'shadow' with original": { + value: true, + description: "If the toggle is on then the shadow object that is created will be grouped with the unclosed original object." + } + }; + ea.setScriptSettings(settings); +} + +const inheritStrokeWidth = settings["Inherit fill stroke width"].value; +const backgroundColor = settings["Background Color"].value; +const fillStyle = settings["Fill Style"].value; +const shouldGroup = settings["Group 'shadow' with original"].value; + +const elements = ea.getViewSelectedElements().filter(el=>el.type==="line"); +if(elements.length === 0) { + new Notice("No line object is selected"); +} + +ea.copyViewElementsToEAforEditing(elements); + +elements.forEach((el)=>{ + const newEl = ea.cloneElement(el); + ea.elementsDict[newEl.id] = newEl; + newEl.roughness = 1; + if(!inheritStrokeWidth) newEl.strokeWidth = 2; + newEl.strokeColor = "transparent"; + newEl.backgroundColor = backgroundColor; + newEl.fillStyle = fillStyle; + const i = el.points.length-1; + newEl.points.push([ + //adding an extra point close to the last point in case distance is long from last point to origin and there is a sharp bend. This will avoid a spike due to a tight curve. + el.points[i][0]*0.9, + el.points[i][1]*0.9, + ]); + newEl.points.push([0,0]); + if(shouldGroup) ea.addToGroup([el.id,newEl.id]); +}); + +ea.addElementsToView(); \ No newline at end of file diff --git a/ea-scripts/index.md b/ea-scripts/index.md index a00dde7..939687b 100644 --- a/ea-scripts/index.md +++ b/ea-scripts/index.md @@ -32,6 +32,7 @@ I would love to include your contribution in the script library. If you have a s - [[#Box Selected Elements]] - [[#Change shape of selected elements]] - [[#Connect elements]] +- [[#Convert freedraw to line]] - [[#Convert selected text elements to sticky notes]] - [[#Convert text to link with folder and alias]] - [[#Copy Selected Element Styles to Global]] @@ -52,6 +53,8 @@ I would love to include your contribution in the script library. If you have a s - [[#Normalize Selected Arrows]] - [[#OCR - Optical Character Recognition]] - [[#Reverse arrows]] +- [[#Select Elements of Type]] +- [[#Set background color of unclosed line object by adding a shadow clone]] - [[#Set Dimensions]] - [[#Set Font Family]] - [[#Set Grid]] @@ -104,6 +107,12 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea ```
Author@zsviczian
SourceFile on GitHub
DescriptionThis script will connect two objects with an arrow. If either of the objects are a set of grouped elements (e.g. a text element grouped with an encapsulating rectangle), the script will identify these groups, and connect the arrow to the largest object in the group (assuming you want to connect the arrow to the box around the text element).
+## Convert freedraw to line +```excalidraw-script-install +https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20freedraw%20to%20line.md +``` +
Author@zsviczian
SourceFile on GitHub
DescriptionConvert selected freedraw objects into editable lines. This will allow you to adjust your drawings by dragging line points and will also allow you to select shape fill in case of enclosed lines. You can adjust conversion point density in settings.
+ ## Convert selected text elements to sticky notes ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20selected%20text%20elements%20to%20sticky%20notes.md @@ -224,6 +233,18 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea ```
Author@zsviczian
SourceFile on GitHub
DescriptionReverse the direction of **arrows** within the scope of selected elements.
+## Select Elements of Type +```excalidraw-script-install +https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Select%20Elements%20of%Type.md +``` +
Author@zsviczian
SourceFile on GitHub
DescriptionPrompts you with a list of the different element types in the active image. Only elements of the selected type will be selected on the canvas. If nothing is selected when running the script, then the script will process all the elements on the canvas. If some elements are selected when the script is executed, then the script will only process the selected elements.
The script is useful when, for example, you want to bring to front all the arrows, or want to change the color of all the text elements, etc.
+ +## Set background color of unclosed line object by adding a shadow clone +```excalidraw-script-install +https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20background%20color%20of%20unclosed%20line%20object%20by%20adding%20a%20shadow%20clone.md +``` +
Author@zsviczian
SourceFile on GitHub
DescriptionUse this script to set the background color of unclosed line objects by creating a clone of the line object. The script will setting the stroke color of the clone to transparent and will add a straight line to close the object. Use settings to define the default background color, the fill style, and the strokeWidth of the clone. By default the clone will be grouped with the original object, you can disable this also in settings.
+ ## Set Dimensions ```excalidraw-script-install https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Dimensions.md diff --git a/manifest.json b/manifest.json index 6b9ae90..ed103a5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.5.23", + "version": "1.5.24", "minAppVersion": "0.12.16", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index 0998fb0..f8a28ae 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "obsidian": "^0.13.21", "rollup": "^2.66.0", "rollup-plugin-visualizer": "^5.5.4", - "rollup-plugin-esbuild": "^4.8.2", "tslib": "^2.3.1", "typescript": "^4.5.5", "eslint-config-prettier": "8.3.0", diff --git a/rollup.config.js b/rollup.config.js index 0e50deb..46096b4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,7 +5,6 @@ import { env } from "process"; import babel from '@rollup/plugin-babel'; import replace from "@rollup/plugin-replace"; import visualizer from "rollup-plugin-visualizer"; -import esbuild from 'rollup-plugin-esbuild'; const isProd = (process.env.NODE_ENV === "production"); console.log("Is production", isProd); @@ -16,12 +15,10 @@ export default { dir: '.', sourcemap: 'inline', format: 'cjs', - exports: 'default' + exports: 'default', }, external: ['obsidian'], plugins: [ - typescript({inlineSources: !isProd}), - nodeResolve({ browser: true, preferBuiltins: true }), replace({ preventAssignment: true, "process.env.NODE_ENV": JSON.stringify(env.NODE_ENV), @@ -30,6 +27,8 @@ export default { exclude: "node_modules/**" }), commonjs(), + nodeResolve({ browser: true, preferBuiltins: true }), + typescript({inlineSources: !isProd}), visualizer(), ], }; \ No newline at end of file diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index b18c0a5..829c673 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -36,6 +36,7 @@ import { getMaximumGroups, intersectElementWithLine, } from "@zsviczian/excalidraw"; +import { stringify } from "querystring"; declare type ConnectionPoint = "top" | "bottom" | "left" | "right" | null; const GAP = 4; @@ -229,6 +230,9 @@ export interface ExcalidrawAutomate { //recommended use: //if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.20")) {new Notice("message");return;} verifyMinimumPluginVersion(requiredVersion: string): boolean; + selectElementsInView(elements: ExcalidrawElement[]): void; //sets selection in view + generateElementId(): string; //returns an 8 character long random id + cloneElement(element: ExcalidrawElement): ExcalidrawElement; //Returns a clone of the element with a new id } declare let window: any; @@ -1301,6 +1305,28 @@ export async function initExcalidrawAutomate( const manifest = this.plugin.app.plugins.manifests[PLUGIN_ID]; return manifest.version >= requiredVersion; }, + selectElementsInView(elements: ExcalidrawElement[]):void { + if (!this.targetView || !this.targetView?._loaded) { + errorMessage("targetView not set", "getViewSelectedElements()"); + return; + } + if (!elements || elements.length===0) { + return; + } + const API = this.getExcalidrawAPI(); + let st = API.getAppState(); + st.selectedElementIds = {}; + elements.forEach(el=>st.selectedElementIds[el.id] = true); + API.updateScene({appState: st}); + }, + generateElementId(): string { + return nanoid(); + }, + cloneElement(element: ExcalidrawElement): ExcalidrawElement{ + const newEl = JSON.parse(JSON.stringify(element)); + newEl.id = nanoid(); + return newEl; + } }; await initFonts(); return window.ExcalidrawAutomate; diff --git a/src/ExcalidrawAutomateFieldSuggestor.ts b/src/ExcalidrawAutomateFieldSuggestor.ts deleted file mode 100644 index 1dd51c9..0000000 --- a/src/ExcalidrawAutomateFieldSuggestor.ts +++ /dev/null @@ -1,416 +0,0 @@ -export const EXCALIDRAW_AUTOMATE_INFO = [ - { - field: "plugin", - desc: "The ExcalidrawPlugin object", - after: "", - alt: true, - }, - { - field: "elementsDict", - desc: "The {} dictionary object, contains the ExcalidrawElements currently edited in Automate indexed by el.id", - after: '[""]', - alt: true, - }, - { - field: "imagesDict", - desc: "the images files including DataURL, indexed by fileId", - after: '[""]', - alt: true, - }, - { - field: "style.strokeColor", - desc: "[string]\n\nvalid css color. See https://www.w3schools.com/colors/default.asp for more.", - after: "", - alt: true, - }, - { - field: "style.backgroundColor", - desc: "[string]\n\nvalid css color. See https://www.w3schools.com/colors/default.asp for more.", - after: "", - alt: true, - }, - { - field: "style.angle", - desc: "[number]\n\nrotation of the object in radian", - after: "", - alt: true, - }, - { - field: "style.fillStyle", - desc: "[string]\n\n'hachure' | 'cross-hatch' | 'solid'", - after: "", - alt: true, - }, - { - field: "style.strokeWidth", - desc: "[number]", - after: "", - alt: true, - }, - { - field: "style.strokeStyle", - desc: "[string]\n\n'solid' | 'dashed' | 'dotted'", - after: "", - alt: true, - }, - { - field: "style.roughness", - desc: "[number]\n\n0:Architect\n1:Artist\n2:Cartoonist", - after: "", - alt: true, - }, - { - field: "style.opacity", - desc: "[number]\n\n100: Fully opaque\n0: Fully transparent", - after: "", - alt: true, - }, - { - field: "style.strokeSharpness", - desc: "[string]\n\n'round' | 'sharp'", - after: "", - alt: true, - }, - { - field: "style.fontFamily", - desc: "[number]\n\n1: Virgil, 2:Helvetica, 3:Cascadia, 4:LocalFont", - after: "", - alt: true, - }, - { - field: "style.fontSize", - desc: "[number]", - after: "", - alt: true, - }, - { - field: "style.textAlign", - desc: "[string]\n\n'left' | 'right' | 'center'", - after: "", - alt: true, - }, - { - field: "style.verticalAlign", - desc: "[string]\n\nfor future use, has no effect currently; 'top' | 'bottom' | 'middle'", - after: "", - alt: true, - }, - { - field: "style.startArrowHead", - desc: "[string]\n\n'triangle' | 'dot' | 'arrow' | 'bar' | null", - after: "", - alt: true, - }, - { - field: "style.endArrowHead", - desc: "[string]\n\n'triangle' | 'dot' | 'arrow' | 'bar' | null", - after: "", - alt: true, - }, - { - field: "canvas.theme", - desc: "[string]\n\n'dark' | 'light'", - after: "", - alt: true, - }, - { - field: "canvas.viewBackgroundColor", - desc: "[string]\n\nA valid css color.\nSee https://www.w3schools.com/colors/default.asp for more.", - after: "", - alt: true, - }, - { - field: "canvas.gridSize", - desc: "[number]", - after: "", - alt: true, - }, - { - field: "addToGroup", - desc: "addToGroup(objectIds: []): string;", - after: "", - alt: true, - }, - { - field: "toCliboard", - desc: "toClipboard(templatePath?: string): void;\n\nCopies current elements using template to clipboard, ready to be pasted into an excalidraw canvas", - after: "", - alt: true, - }, - { - field: "getElements", - desc: "getElements(): ExcalidrawElement[];\n\nGet all elements from ExcalidrawAutomate elementsDict", - after: "", - alt: true, - }, - { - field: "getElement", - desc: "getElement(id: string): ExcalidrawElement;\n\nGet single element from ExcalidrawAutomate elementsDict", - after: "", - alt: true, - }, - { - field: "create", - desc: 'create(params?: {\n filename?: string;\n foldername?: string;\n templatePath?: string;\n onNewPane?: boolean;\n frontmatterKeys?: {\n "excalidraw-plugin"?: "raw" | "parsed";\n "excalidraw-link-prefix"?: string;\n "excalidraw-link-brackets"?: boolean;\n "excalidraw-url-prefix"?: string;\n };\n}): Promise;\n\nCreate a drawing and save it to filename.\nIf filename is null: default filename as defined in Excalidraw settings.\nIf folder is null: default folder as defined in Excalidraw settings\n', - after: "", - alt: true, - }, - { - field: "createSVG", - desc: "createSVG(\n templatePath?: string,\n embedFont?: boolean,\n exportSettings?: ExportSettings,\n loader?: EmbeddedFilesLoader,\n theme?: string,\n): Promise;\n\nUse ExcalidrawAutomate.getExportSettings(boolean,boolean) to create an ExportSettings object.\nUse ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) to create an EmbeddedFilesLoader object.", - after: "", - alt: true, - }, - { - field: "createPNG", - desc: "createPNG(\n templatePath?: string,\n scale?: number,\n exportSettings?: ExportSettings,\n loader?: EmbeddedFilesLoader,\n theme?: string,\n): Promise;\n\nUse ExcalidrawAutomate.getExportSettings(boolean,boolean) to create an ExportSettings object.\nUse ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) to create an EmbeddedFilesLoader object.", - after: "", - alt: true, - }, - { - field: "wrapText", - desc: "wrapText(text: string, lineLen: number): string;", - after: "", - alt: true, - }, - { - field: "addRect", - desc: "addRect(topX: number, topY: number, width: number, height: number): string;", - after: "", - alt: true, - }, - { - field: "addDiamond", - desc: "addDiamond(topX: number, topY: number, width: number, height: number): string;", - after: "", - alt: true, - }, - { - field: "addEllipse", - desc: "addEllipse(topX: number, topY: number, width: number, height: number): string;", - after: "", - alt: true, - }, - { - field: "addBlob", - desc: "addBlob(topX: number, topY: number, width: number, height: number): string;", - after: "", - alt: true, - }, - { - field: "addText", - desc: 'addText(\n topX: number,\n topY: number,\n text: string,\n formatting?: {\n wrapAt?: number;\n width?: number;\n height?: number;\n textAlign?: string;\n box?: boolean | "box" | "blob" | "ellipse" | "diamond";\n boxPadding?: number;\n },\n id?: string,\n): string;\n\nif box is !null, then text will be boxed\nThe function returns the id of the TextElement. If the text element is boxed i.e. it is a sticky note, then the id of the container object', - after: "", - alt: true, - }, - { - field: "addLine", - desc: "addLine(points: [[x: number, y: number]]): string;", - after: "", - alt: true, - }, - { - field: "addArrow", - desc: "addArrow(\n points: [[x: number, y: number]],\n formatting?: {\n startArrowHead?: string;\n endArrowHead?: string;\n startObjectId?: string;\n endObjectId?: string;\n },\n): string;", - after: "", - alt: true, - }, - { - field: "addImage", - desc: "addImage(topX: number, topY: number, imageFile: TFile): Promise;", - after: "", - alt: true, - }, - { - field: "addLaTex", - desc: "addLaTex(topX: number, topY: number, tex: string): Promise;", - after: "", - alt: true, - }, - { - field: "connectObjects", - desc: 'connectObjects(\n objectA: string,\n connectionA: ConnectionPoint,\n objectB: string,\n connectionB: ConnectionPoint,\n formatting?: {\n numberOfPoints?: number;\n startArrowHead?: string;\n endArrowHead?: string;\n padding?: number;\n },\n): void;\n\ntype ConnectionPoint = "top" | "bottom" | "left" | "right" | null\nWhen null is passed as ConnectionPoint then Excalidraw will automatically decide\nnumberOfPoints is the number of points on the line. Default is 0 i.e. line will only have a start and end point.\nArrowHead: "triangle"|"dot"|"arrow"|"bar"|null', - after: "", - alt: true, - }, - { - field: "clear", - desc: "clear(): void;\n\nClears elementsDict and imagesDict only", - after: "", - alt: true, - }, - { - field: "reset", - desc: "reset(): void;\n\nclear() + reset all style values to default", - after: "", - alt: true, - }, - { - field: "isExcalidrawFile", - desc: "isExcalidrawFile(f: TFile): boolean;\n\nReturns true if MD file is an Excalidraw file", - after: "", - alt: true, - }, - { - field: "targetView", - desc: "targetView: ExcalidrawView;\n\nThe Obsidian view currently edited", - after: "", - alt: true, - }, - { - field: "setView", - desc: 'setView(view: ExcalidrawView | "first" | "active"): ExcalidrawView;', - after: "", - alt: true, - }, - { - field: "getExcalidrawAPI", - desc: "getExcalidrawAPI(): any;\n\nhttps://github.com/excalidraw/excalidraw/tree/master/src/packages/excalidraw#ref", - after: "", - alt: true, - }, - { - field: "getViewElements", - desc: "getViewElements(): ExcalidrawElement[];\n\nget elements in View", - after: "", - alt: true, - }, - { - field: "deleteViewElements", - desc: "deleteViewElements(el: ExcalidrawElement[]): boolean;", - after: "", - alt: true, - }, - { - field: "getViewSelectedElement", - desc: "getViewSelectedElement(): ExcalidrawElement;\n\nget the selected element in the view, if more are selected, get the first", - after: "", - alt: true, - }, - { - field: "getViewSelectedElements", - desc: "getViewSelectedElements(): ExcalidrawElement[];", - after: "", - alt: true, - }, - { - field: "getViewFileForImageElement", - desc: "getViewFileForImageElement(el: ExcalidrawElement): TFile | null;\n\nReturns the TFile file handle for the image element", - after: "", - alt: true, - }, - { - field: "copyViewElementsToEAforEditing", - desc: "copyViewElementsToEAforEditing(elements: ExcalidrawElement[]): void;\n\nCopies elements from view to elementsDict for editing", - after: "", - alt: true, - }, - { - field: "viewToggleFullScreen", - desc: "viewToggleFullScreen(forceViewMode?: boolean): void;", - after: "", - alt: true, - }, - { - field: "connectObjectWithViewSelectedElement", - desc: 'connectObjectWithViewSelectedElement(\n objectA: string,\n connectionA: ConnectionPoint,\n connectionB: ConnectionPoint,\n formatting?: {\n numberOfPoints?: number;\n startArrowHead?: string;\n endArrowHead?: string;\n padding?: number;\n },\n): boolean;\n\nConnect an object to the selected element in the view\nSee tooltip for connectObjects for details', - after: "", - alt: true, - }, - { - field: "addElementsToView", - desc: "addElementsToView(\n repositionToCursor?: boolean,\n save?: boolean,\n newElementsOnTop?: boolean,\n): Promise;\n\nAdds elements from elementsDict to the current view\nrepositionToCursor: default is false\nsave: default is true\nnewElementsOnTop: default is false, i.e. the new elements get to the bottom of the stack\nnewElementsOnTop controls whether elements created with ExcalidrawAutomate are added at the bottom of the stack or the top of the stack of elements already in the view\nNote that elements copied to the view with copyViewElementsToEAforEditing retain their position in the stack of elements in the view even if modified using EA", - after: "", - alt: true, - }, - { - field: "onDropHook", - desc: 'onDropHook(data: {\n ea: ExcalidrawAutomate;\n event: React.DragEvent;\n draggable: any;\n type: "file" | "text" | "unknown";\n payload: {\n files: TFile[];\n text: string; //string\n };\n excalidrawFile: TFile;\n view: ExcalidrawView;\n pointerPosition: { x: number; y: number };\n}): boolean;\n\nIf set Excalidraw will call this function onDrop events.\nA return of true will stop the default onDrop processing in Excalidraw.\n\ndraggable is the Obsidian draggable object\nfiles is the array of dropped files\nexcalidrawFile is the file receiving the drop event\nview is the excalidraw view receiving the drop.\npointerPosition is the pointer position on canvas at the time of drop.', - after: "", - alt: true, - }, - { - field: "mostRecentMarkdownSVG", - desc: "mostRecentMarkdownSVG: SVGSVGElement;\n\nMarkdown renderer will drop a copy of the most recent SVG here for debugging purposes", - after: "", - alt: true, - }, - { - field: "getEmbeddedFilesLoader", - desc: "getEmbeddedFilesLoader(isDark?: boolean): EmbeddedFilesLoader;\n\nutility function to generate EmbeddedFilesLoader object", - after: "", - alt: true, - }, - { - field: "getExportSettings", - desc: "getExportSettings(\n withBackground: boolean,\n withTheme: boolean,\n): ExportSettings;\n\nutility function to generate ExportSettings object", - after: "", - alt: true, - }, - { - field: "getBoundingBox", - desc: "getBoundingBox(elements: ExcalidrawElement[]): {\n topX: number;\n topY: number;\n width: number;\n height: number;\n};\n\nGets the bounding box of elements. The bounding box is the box encapsulating all of the elements completely.", - after: "", - alt: true, - }, - { - field: "getMaximumGroups", - desc: "getMaximumGroups(elements: ExcalidrawElement[]): ExcalidrawElement[][];\n\nElements grouped by the highest level groups", - after: "", - alt: true, - }, - { - field: "getLargestElement", - desc: "getLargestElement(elements: ExcalidrawElement[]): ExcalidrawElement;\n\nGets the largest element from a group. useful when a text element is grouped with a box, and you want to connect an arrow to the box", - after: "", - alt: true, - }, - { - field: "intersectElementWithLine", - desc: "intersectElementWithLine(\n element: ExcalidrawBindableElement,\n a: readonly [number, number],\n b: readonly [number, number],\n gap?: number,\n): Point[];\n\nIf gap is given, the element is inflated by this value.\nReturns 2 or 0 intersection points between line going through `a` and `b` and the `element`, in ascending order of distance from `a`.", - after: "", - alt: true, - }, - { - field: "getLargestElement", - desc: "getLargestElement(elements: ExcalidrawElement[]): ExcalidrawElement;\n\nGets the largest element from a group. useful when a text element is grouped with a box, and you want to connect an arrow to the box", - after: "", - alt: true, - }, - { - field: "activeScript", - desc: "activeScript: string;\n\nMandatory to set before calling the get and set ScriptSettings functions. Set automatically by the ScriptEngine\nSee for more details: https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html", - after: "", - alt: true, - }, - { - field: "getScriptSettings", - desc: "getScriptSettings(): {};\n\nReturns script settings. Saves settings in plugin settings, under the activeScript key. See for more details: https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html", - after: "", - alt: true, - }, - { - field: "setScriptSettings", - desc: "setScriptSettings(settings: any): Promise;\n\nSets script settings.\nSee for more details: https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html", - after: "", - alt: true, - }, - { - field: "openFileInNewOrAdjacentLeaf", - desc: "openFileInNewOrAdjacentLeaf(file: TFile): WorkspaceLeaf;\n\nOpen a file in a new workspaceleaf or reuse an existing adjacent leaf depending on Excalidraw Plugin Settings", - after: "", - alt: true, - }, - { - field: "measureText", - desc: "measureText(text: string): { width: number; height: number };\n\nMeasures text size based on current style settings", - after: "", - alt: true, - }, - { - field: "verifyMinimumPluginVersion", - desc: 'verifyMinimumPluginVersion(requiredVersion: string): boolean;\n\nreturns true if plugin version is >= than required\nrecommended use:\nif(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.20")) {new Notice("message");return;}', - after: "", - alt: true, - }, -]; diff --git a/src/FieldSuggestor.ts b/src/FieldSuggestor.ts index 8520161..7250b0c 100644 --- a/src/FieldSuggestor.ts +++ b/src/FieldSuggestor.ts @@ -6,13 +6,16 @@ import { EditorSuggestTriggerInfo, TFile, } from "obsidian"; -import { FRONTMATTER_KEYS_INFO } from "./constants"; -import { EXCALIDRAW_AUTOMATE_INFO } from "./ExcalidrawAutomateFieldSuggestor"; +import { FRONTMATTER_KEYS_INFO } from "./SuggestorInfo"; +import { + EXCALIDRAW_AUTOMATE_INFO, + EXCALIDRAW_SCRIPTENGINE_INFO, +} from "./SuggestorInfo"; import type ExcalidrawPlugin from "./main"; export class FieldSuggestor extends EditorSuggest { plugin: ExcalidrawPlugin; - suggestEA: boolean; + suggestType: "ea" | "excalidraw" | "utils"; latestTriggerInfo: EditorSuggestTriggerInfo; constructor(plugin: ExcalidrawPlugin) { @@ -28,13 +31,19 @@ export class FieldSuggestor extends EditorSuggest { if (this.plugin.settings.fieldSuggestor) { const sub = editor.getLine(cursor.line).substring(0, cursor.ch); const match = - sub.match(/^excalidraw-(.*)$/)?.[1] ?? sub.match(/(^ea|\Wea)\.([\w\.]*)$/)?.[2]; + sub.match(/^excalidraw-(.*)$/)?.[1] ?? + sub.match(/(^ea|\Wea)\.([\w\.]*)$/)?.[2] ?? + sub.match(/(^utils|\Wutils)\.([\w\.]*)$/)?.[2]; if (match !== undefined) { - this.suggestEA = !sub.match(/^excalidraw-(.*)$/); + this.suggestType = sub.match(/^excalidraw-(.*)$/) + ? "excalidraw" + : sub.match(/(^ea|\Wea)\.([\w\.]*)$/) + ? "ea" + : "utils"; this.latestTriggerInfo = { end: cursor, start: { - ch: cursor.ch-match.length, + ch: cursor.ch - match.length, line: cursor.line, }, query: match, @@ -47,49 +56,68 @@ export class FieldSuggestor extends EditorSuggest { getSuggestions = (context: EditorSuggestContext) => { const query = context.query.toLowerCase(); - const isEA = this.suggestEA; - const keys = isEA ? EXCALIDRAW_AUTOMATE_INFO : FRONTMATTER_KEYS_INFO; - return keys.map((sug) => sug.field).filter((sug) => - sug.toLowerCase().includes(query), - ); + const keys = + this.suggestType === "ea" + ? EXCALIDRAW_AUTOMATE_INFO + : this.suggestType === "utils" + ? EXCALIDRAW_SCRIPTENGINE_INFO + : FRONTMATTER_KEYS_INFO; + return keys + .map((sug) => sug.field) + .filter((sug) => sug.toLowerCase().includes(query)); }; renderSuggestion(suggestion: string, el: HTMLElement): void { - const isEA = this.suggestEA; - const text = suggestion.replace(isEA ? "ea." : "excalidraw-", ""); - const keys = isEA ? EXCALIDRAW_AUTOMATE_INFO : FRONTMATTER_KEYS_INFO; - el.createDiv({ - text, - cls: "excalidraw-suggester-container", - attr: { - "aria-label": keys.find((f) => f.field === suggestion)?.desc, - "aria-label-position": "right", - "aria-label-classes": "excalidraw-suggester-label" - }, - }); + const text = suggestion.replace( + this.suggestType === "ea" + ? "ea." + : this.suggestType === "utils" + ? "utils." + : "excalidraw-", + "", + ); + const keys = + this.suggestType === "ea" + ? EXCALIDRAW_AUTOMATE_INFO + : this.suggestType === "utils" + ? EXCALIDRAW_SCRIPTENGINE_INFO + : FRONTMATTER_KEYS_INFO; + const value = keys.find((f) => f.field === suggestion); + el.createEl("b", { text}); + el.createEl("br"); + if(value.code) { + el.createEl("code", { text: value.code }); + } + if(value.desc) { + el.createDiv("div",el=>el.innerHTML=value.desc); + } } selectSuggestion(suggestion: string): void { const { context } = this; if (context) { - const isEA = this.suggestEA; - const keys = isEA ? EXCALIDRAW_AUTOMATE_INFO : FRONTMATTER_KEYS_INFO; + const keys = + this.suggestType === "ea" + ? EXCALIDRAW_AUTOMATE_INFO + : this.suggestType === "utils" + ? EXCALIDRAW_SCRIPTENGINE_INFO + : FRONTMATTER_KEYS_INFO; const replacement = `${suggestion}${ keys.find((f) => f.field === suggestion)?.after }`; context.editor.replaceRange( replacement, this.latestTriggerInfo.start, - this.latestTriggerInfo.end + this.latestTriggerInfo.end, ); if (this.latestTriggerInfo.start.ch === this.latestTriggerInfo.end.ch) { // Dirty hack to prevent the cursor being at the - // beginning of the word after completion, + // beginning of the word after completion, // Not sure what's the cause of this bug. const cursor_pos = this.latestTriggerInfo.end; cursor_pos.ch += replacement.length; context.editor.setCursor(cursor_pos); - } + } } } } diff --git a/src/SuggestorInfo.ts b/src/SuggestorInfo.ts new file mode 100644 index 0000000..52062fb --- /dev/null +++ b/src/SuggestorInfo.ts @@ -0,0 +1,592 @@ +import { FRONTMATTER_KEY, FRONTMATTER_KEY_CUSTOM_LINK_BRACKETS, FRONTMATTER_KEY_CUSTOM_PREFIX, FRONTMATTER_KEY_CUSTOM_URL_PREFIX, FRONTMATTER_KEY_DEFAULT_MODE, FRONTMATTER_KEY_FONT, FRONTMATTER_KEY_FONTCOLOR, FRONTMATTER_KEY_MD_STYLE } from "./constants"; + +type SuggestorInfo = { + field: string, + code: string, + desc: string, + after: string, + alt: boolean +} + +export const EXCALIDRAW_AUTOMATE_INFO:SuggestorInfo[] = [ + { + field: "plugin", + code: null, + desc: "The ExcalidrawPlugin object", + after: "", + alt: true, + }, + { + field: "elementsDict", + code: null, + desc: "The {} dictionary object, contains the ExcalidrawElements currently edited in Automate indexed by el.id", + after: '[""]', + alt: true, + }, + { + field: "imagesDict", + code: null, + desc: "the images files including DataURL, indexed by fileId", + after: '[""]', + alt: true, + }, + { + field: "style.strokeColor", + code: "[string]", + desc: "A valid css color. See W3 School Colors for more.", + after: "", + alt: true, + }, + { + field: "style.backgroundColor", + code: "[string]", + desc: "A valid css color. See W3 School Colors for more.", + after: "", + alt: true, + }, + { + field: "style.angle", + code: "[number]", + desc: "Rotation of the object in radian", + after: "", + alt: true, + }, + { + field: "style.fillStyle", + code: "[string]", + desc: "'hachure' | 'cross-hatch' | 'solid'", + after: "", + alt: true, + }, + { + field: "style.strokeWidth", + code: "[number]", + desc: null, + after: "", + alt: true, + }, + { + field: "style.strokeStyle", + code: "[string]", + desc: "'solid' | 'dashed' | 'dotted'", + after: "", + alt: true, + }, + { + field: "style.roughness", + code: "[number]", + desc: "0:Architect\n1:Artist\n2:Cartoonist", + after: "", + alt: true, + }, + { + field: "style.opacity", + code: "[number]", + desc: "100: Fully opaque\n0: Fully transparent", + after: "", + alt: true, + }, + { + field: "style.strokeSharpness", + code: "[string]", + desc: "'round' | 'sharp'", + after: "", + alt: true, + }, + { + field: "style.fontFamily", + code: "[number]", + desc: "1: Virgil, 2:Helvetica, 3:Cascadia, 4:LocalFont", + after: "", + alt: true, + }, + { + field: "style.fontSize", + code: "[number]", + desc: null, + after: "", + alt: true, + }, + { + field: "style.textAlign", + code: "[string]", + desc: "'left' | 'right' | 'center'", + after: "", + alt: true, + }, + { + field: "style.verticalAlign", + code: "[string]", + desc: "For future use, has no effect currently; 'top' | 'bottom' | 'middle'", + after: "", + alt: true, + }, + { + field: "style.startArrowHead", + code: "[string]", + desc: "'triangle' | 'dot' | 'arrow' | 'bar' | null", + after: "", + alt: true, + }, + { + field: "style.endArrowHead", + code: "[string]", + desc: "'triangle' | 'dot' | 'arrow' | 'bar' | null", + after: "", + alt: true, + }, + { + field: "canvas.theme", + code: "[string]", + desc: "'dark' | 'light'", + after: "", + alt: true, + }, + { + field: "canvas.viewBackgroundColor", + code: "[string]", + desc: "A valid css color.\nSee W3 School Colors for more.", + after: "", + alt: true, + }, + { + field: "canvas.gridSize", + code: "[number]", + desc: null, + after: "", + alt: true, + }, + { + field: "addToGroup", + code: "addToGroup(objectIds: []): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "toCliboard", + code: "toClipboard(templatePath?: string): void;", + desc: "Copies current elements using template to clipboard, ready to be pasted into an excalidraw canvas", + after: "", + alt: true, + }, + { + field: "getElements", + code: "getElements(): ExcalidrawElement[];", + desc: "Get all elements from ExcalidrawAutomate elementsDict", + after: "", + alt: true, + }, + { + field: "getElement", + code: "getElement(id: string): ExcalidrawElement;", + desc: "Get single element from ExcalidrawAutomate elementsDict", + after: "", + alt: true, + }, + { + field: "create", + code: 'create(params?: {filename?: string, foldername?: string, templatePath?: string, onNewPane?: boolean, frontmatterKeys?: { "excalidraw-plugin"?: "raw" | "parsed", "excalidraw-link-prefix"?: string, "excalidraw-link-brackets"?: boolean, "excalidraw-url-prefix"?: string,},}): Promise;', + desc: 'Create a drawing and save it to filename.\nIf filename is null: default filename as defined in Excalidraw settings.\nIf folder is null: default folder as defined in Excalidraw settings\n', + after: "", + alt: true, + }, + { + field: "createSVG", + code: "createSVG(templatePath?: string, embedFont?: boolean, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string,): Promise;", + desc: "Use ExcalidrawAutomate.getExportSettings(boolean,boolean) to create an ExportSettings object.\nUse ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) to create an EmbeddedFilesLoader object.", + after: "", + alt: true, + }, + { + field: "createPNG", + code: "createPNG(templatePath?: string, scale?: number, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string,): Promise;", + desc: "Use ExcalidrawAutomate.getExportSettings(boolean,boolean) to create an ExportSettings object.\nUse ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) to create an EmbeddedFilesLoader object.", + after: "", + alt: true, + }, + { + field: "wrapText", + code: "wrapText(text: string, lineLen: number): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addRect", + code: "addRect(topX: number, topY: number, width: number, height: number): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addDiamond", + code: "addDiamond(topX: number, topY: number, width: number, height: number): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addEllipse", + code: "addEllipse(topX: number, topY: number, width: number, height: number): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addBlob", + code: "addBlob(topX: number, topY: number, width: number, height: number): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addText", + code: 'addText(topX: number, topY: number, text: string, formatting?: {wrapAt?: number; width?: number; height?: number; textAlign?: string; box?: boolean | "box" | "blob" | "ellipse" | "diamond"; boxPadding?: number;}, id?: string,): string;', + desc: 'If box is !null, then text will be boxed\nThe function returns the id of the TextElement. If the text element is boxed i.e. it is a sticky note, then the id of the container object', + after: "", + alt: true, + }, + { + field: "addLine", + code: "addLine(points: [[x: number, y: number]]): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addArrow", + code: "addArrow(points: [[x: number, y: number]], formatting?: { startArrowHead?: string; endArrowHead?: string; startObjectId?: string; endObjectId?: string;},): string;", + desc: null, + after: "", + alt: true, + }, + { + field: "addImage", + code: "addImage(topX: number, topY: number, imageFile: TFile): Promise;", + desc: null, + after: "", + alt: true, + }, + { + field: "addLaTex", + code: "addLaTex(topX: number, topY: number, tex: string): Promise;", + desc: null, + after: "", + alt: true, + }, + { + field: "connectObjects", + code: 'connectObjects(objectA: string, connectionA: ConnectionPoint, objectB: string, connectionB: ConnectionPoint, formatting?: {numberOfPoints?: number; startArrowHead?: string; endArrowHead?: string; padding?: number;},): void;', + desc: 'type ConnectionPoint = "top" | "bottom" | "left" | "right" | null\nWhen null is passed as ConnectionPoint then Excalidraw will automatically decide\nnumberOfPoints is the number of points on the line. Default is 0 i.e. line will only have a start and end point.\nArrowHead: "triangle"|"dot"|"arrow"|"bar"|null', + after: "", + alt: true, + }, + { + field: "clear", + code: "clear(): void;", + desc: "Clears elementsDict and imagesDict only", + after: "", + alt: true, + }, + { + field: "reset", + code: "reset(): void;", + desc: "clear() + reset all style values to default", + after: "", + alt: true, + }, + { + field: "isExcalidrawFile", + code: "isExcalidrawFile(f: TFile): boolean;", + desc: "Returns true if MD file is an Excalidraw file", + after: "", + alt: true, + }, + { + field: "targetView", + code: "targetView: ExcalidrawView;", + desc: "The Obsidian view currently edited", + after: "", + alt: true, + }, + { + field: "setView", + code: 'setView(view: ExcalidrawView | "first" | "active"): ExcalidrawView;', + desc: null, + after: "", + alt: true, + }, + { + field: "getExcalidrawAPI", + code: "getExcalidrawAPI(): any;", + desc: "Excalidraw API", + after: "", + alt: true, + }, + { + field: "getViewElements", + code: "getViewElements(): ExcalidrawElement[];", + desc: "Get elements in View", + after: "", + alt: true, + }, + { + field: "deleteViewElements", + code: "deleteViewElements(el: ExcalidrawElement[]): boolean;", + desc: null, + after: "", + alt: true, + }, + { + field: "getViewSelectedElement", + code: "getViewSelectedElement(): ExcalidrawElement;", + desc: "Get the selected element in the view, if more are selected, get the first", + after: "", + alt: true, + }, + { + field: "getViewSelectedElements", + code: "getViewSelectedElements(): ExcalidrawElement[];", + desc: null, + after: "", + alt: true, + }, + { + field: "getViewFileForImageElement", + code: "getViewFileForImageElement(el: ExcalidrawElement): TFile | null;", + desc: "Returns the TFile file handle for the image element", + after: "", + alt: true, + }, + { + field: "copyViewElementsToEAforEditing", + code: "copyViewElementsToEAforEditing(elements: ExcalidrawElement[]): void;", + desc: "Copies elements from view to elementsDict for editing", + after: "", + alt: true, + }, + { + field: "viewToggleFullScreen", + code: "viewToggleFullScreen(forceViewMode?: boolean): void;", + desc: null, + after: "", + alt: true, + }, + { + field: "connectObjectWithViewSelectedElement", + code: "connectObjectWithViewSelectedElement(objectA: string, connectionA: ConnectionPoint, connectionB: ConnectionPoint, formatting?: {numberOfPoints?: number; startArrowHead?: string; endArrowHead?: string; padding?: number;},): boolean;", + desc: "Connect an object to the selected element in the view\nSee tooltip for connectObjects for details", + after: "", + alt: true, + }, + { + field: "addElementsToView", + code: "addElementsToView(repositionToCursor?: boolean, save?: boolean, newElementsOnTop?: boolean,): Promise;", + desc: "Adds elements from elementsDict to the current view\nrepositionToCursor: default is false\nsave: default is true\nnewElementsOnTop: default is false, i.e. the new elements get to the bottom of the stack\nnewElementsOnTop controls whether elements created with ExcalidrawAutomate are added at the bottom of the stack or the top of the stack of elements already in the view\nNote that elements copied to the view with copyViewElementsToEAforEditing retain their position in the stack of elements in the view even if modified using EA", + after: "", + alt: true, + }, + { + field: "onDropHook", + code: 'onDropHook(data: {ea: ExcalidrawAutomate, event: React.DragEvent, draggable: any, type: "file" | "text" | "unknown", payload: {files: TFile[], text: string,}, excalidrawFile: TFile, view: ExcalidrawView, pointerPosition: { x: number, y: number},}): boolean;', + desc: 'If set Excalidraw will call this function onDrop events.\nA return of true will stop the default onDrop processing in Excalidraw.\n\ndraggable is the Obsidian draggable object\nfiles is the array of dropped files\nexcalidrawFile is the file receiving the drop event\nview is the excalidraw view receiving the drop.\npointerPosition is the pointer position on canvas at the time of drop.', + after: "", + alt: true, + }, + { + field: "mostRecentMarkdownSVG", + code: "mostRecentMarkdownSVG: SVGSVGElement;", + desc: "Markdown renderer will drop a copy of the most recent SVG here for debugging purposes", + after: "", + alt: true, + }, + { + field: "getEmbeddedFilesLoader", + code: "getEmbeddedFilesLoader(isDark?: boolean): EmbeddedFilesLoader;", + desc: "Utility function to generate EmbeddedFilesLoader object", + after: "", + alt: true, + }, + { + field: "getExportSettings", + code: "getExportSettings(withBackground: boolean, withTheme: boolean,): ExportSettings;", + desc: "Utility function to generate ExportSettings object", + after: "", + alt: true, + }, + { + field: "getBoundingBox", + code: "getBoundingBox(elements: ExcalidrawElement[]): {topX: number, topY: number, width: number, height: number,};", + desc: "Gets the bounding box of elements. The bounding box is the box encapsulating all of the elements completely.", + after: "", + alt: true, + }, + { + field: "getMaximumGroups", + code: "getMaximumGroups(elements: ExcalidrawElement[]): ExcalidrawElement[][];", + desc: "Elements grouped by the highest level groups", + after: "", + alt: true, + }, + { + field: "getLargestElement", + code: "getLargestElement(elements: ExcalidrawElement[]): ExcalidrawElement;", + desc: "Gets the largest element from a group. useful when a text element is grouped with a box, and you want to connect an arrow to the box", + after: "", + alt: true, + }, + { + field: "intersectElementWithLine", + code: "intersectElementWithLine(element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap?: number,): Point[];", + desc: "If gap is given, the element is inflated by this value.\nReturns 2 or 0 intersection points between line going through `a` and `b` and the `element`, in ascending order of distance from `a`.", + after: "", + alt: true, + }, + { + field: "getLargestElement", + code: "getLargestElement(elements: ExcalidrawElement[]): ExcalidrawElement;", + desc: "Gets the largest element from a group. useful when a text element is grouped with a box, and you want to connect an arrow to the box", + after: "", + alt: true, + }, + { + field: "activeScript", + code: "activeScript: string;", + desc: "Mandatory to set before calling the get and set ScriptSettings functions. Set automatically by the ScriptEngine\nSee for more details: Script Engine Help", + after: "", + alt: true, + }, + { + field: "getScriptSettings", + code: "getScriptSettings(): {};", + desc: "Returns script settings. Saves settings in plugin settings, under the activeScript key. See for more details: Script Engine Help", + after: "", + alt: true, + }, + { + field: "setScriptSettings", + code: "setScriptSettings(settings: any): Promise;", + desc: "Sets script settings.\nSee for more details: Script Engine Help", + after: "", + alt: true, + }, + { + field: "openFileInNewOrAdjacentLeaf", + code: "openFileInNewOrAdjacentLeaf(file: TFile): WorkspaceLeaf;", + desc: "Open a file in a new workspaceleaf or reuse an existing adjacent leaf depending on Excalidraw Plugin Settings", + after: "", + alt: true, + }, + { + field: "measureText", + code: "measureText(text: string): { width: number; height: number };", + desc: "Measures text size based on current style settings", + after: "", + alt: true, + }, + { + field: "verifyMinimumPluginVersion", + code: 'verifyMinimumPluginVersion(requiredVersion: string): boolean;', + desc: 'Returns true if plugin version is >= than required\nrecommended use:\nif(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.5.20")) {new Notice("message");return;}', + after: "", + alt: true, + }, + { + field: "selectElementsInView", + code: "selectElementsInView(elements: ExcalidrawElement[]):void;", + desc: "Elements provided will be set as selected in the targetView.", + after: "", + alt: true, + }, + { + field: "generateElementId", + code: "generateElementId(): string;", + desc: "Returns an 8 character long random id", + after: "", + alt: true, + }, + { + field: "cloneElement", + code: "cloneElement(element: ExcalidrawElement): ExcalidrawElement;", + desc: "Returns a clone of the element with a new element id", + after: "", + alt: true, + }, +]; + +export const EXCALIDRAW_SCRIPTENGINE_INFO:SuggestorInfo[] = [ + { + field: "inputPrompt", + code: "inputPrompt: (header: string, placeholder?: string, value?: string);", + desc: "Opens a prompt that asks for an input.\nReturns a string with the input.\nYou need to await the result of inputPrompt.", + after: "", + alt: true, + }, + { + field: "suggester", + code: "suggester: (displayItems: string[], items: any[], hint?: string, instructions?:Instruction[]);", + desc: "Opens a suggester. Displays the displayItems and returns the corresponding item from items[]\nYou need to await the result of suggester.\nIf the user cancels (ESC), suggester will return undefined\nHint and instructions are optional\n\ninterface Instruction {command: string;purpose: string;}", + after: "", + alt: true, + }, +]; + +export const FRONTMATTER_KEYS_INFO:SuggestorInfo[] = [ + { + field: FRONTMATTER_KEY, + code: null, + desc: "Denotes an excalidraw file. If key is not present, the file will not be recognized as an Excalidarw file. Valid values are 'parsed' and 'raw'", + after: ": parsed", + alt: true, + }, + { + field: FRONTMATTER_KEY_CUSTOM_PREFIX, + code: null, + desc: "Set custom prefix to denote text element containing a valid internal link. Set to empty string if you do not want to show a prefix", + after: ': "📍"', + alt: true, + }, + { + field: FRONTMATTER_KEY_CUSTOM_URL_PREFIX, + code: null, + desc: "Set custom prefix to denote text element containing a valid external link. Set to empty string if you do not want to show a prefix", + after: ': "🌐"', + alt: true, + }, + { + field: FRONTMATTER_KEY_CUSTOM_LINK_BRACKETS, + code: null, + desc: "Set to true, if you want to display [[square brackets]] around the links in Text Elements", + after: ": true", + alt: true, + }, + { + field: FRONTMATTER_KEY_DEFAULT_MODE, + code: null, + desc: "Specifies how Excalidraw should open by default. Valid values are: view|zen", + after: ": view", + alt: true, + }, + { + field: FRONTMATTER_KEY_FONT, + code: null, + desc: "This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: Virgil|Cascadia|font_file_name.extension", + after: ": Virgil", + alt: true, + }, + { + field: FRONTMATTER_KEY_FONTCOLOR, + code: null, + desc: "This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: css-color-name|#HEXcolor|any-other-html-standard-format", + after: ": SteelBlue", + alt: true, + }, + { + field: FRONTMATTER_KEY_MD_STYLE, + code: null, + desc: 'This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: "css-filename|css snippet"', + after: ': ""', + alt: true, + }, +]; \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index 327c16d..a006e29 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -30,57 +30,6 @@ export const FRONTMATTER_KEY_FONT = "excalidraw-font"; export const FRONTMATTER_KEY_FONTCOLOR = "excalidraw-font-color"; export const FRONTMATTER_KEY_MD_STYLE = "excalidraw-css"; -export const FRONTMATTER_KEYS_INFO = [ - { - field: FRONTMATTER_KEY, - desc: "Denotes an excalidraw file. If key is not present, the file will not be recognized as an Excalidarw file. Valid values are 'parsed' and 'raw'", - after: ": parsed", - alt: true, - }, - { - field: FRONTMATTER_KEY_CUSTOM_PREFIX, - desc: "Set custom prefix to denote text element containing a valid internal link. Set to empty string if you do not want to show a prefix", - after: ': "📍"', - alt: true, - }, - { - field: FRONTMATTER_KEY_CUSTOM_URL_PREFIX, - desc: "Set custom prefix to denote text element containing a valid external link. Set to empty string if you do not want to show a prefix", - after: ': "🌐"', - alt: true, - }, - { - field: FRONTMATTER_KEY_CUSTOM_LINK_BRACKETS, - desc: "Set to true, if you want to display [[square brackets]] around the links in Text Elements", - after: ": true", - alt: true, - }, - { - field: FRONTMATTER_KEY_DEFAULT_MODE, - desc: "Specifies how Excalidraw should open by default. Valid values are: view|zen", - after: ": view", - alt: true, - }, - { - field: FRONTMATTER_KEY_FONT, - desc: "This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: Virgil|Cascadia|font_file_name.extension", - after: ": Virgil", - alt: true, - }, - { - field: FRONTMATTER_KEY_FONTCOLOR, - desc: "This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: css-color-name|#HEXcolor|any-other-html-standard-format", - after: ": SteelBlue", - alt: true, - }, - { - field: FRONTMATTER_KEY_MD_STYLE, - desc: 'This key applies to Markdown Embeds. You can control the appearance of the embedded markdown file on a file by file bases by adding the this front matter keys to your markdown document. Valid values are: "css-filename|css snippet"', - after: ': ""', - alt: true, - }, -]; - export const VIEW_TYPE_EXCALIDRAW = "excalidraw"; export const ICON_NAME = "excalidraw-icon"; export const MAX_COLORS = 5; diff --git a/styles.css b/styles.css index 99e36ea..1cd08b2 100644 --- a/styles.css +++ b/styles.css @@ -134,8 +134,4 @@ li[data-testid] { .excalidraw-scriptengine-install .modal { max-height:90%; -} - -.excalidraw-suggester-label { - text-align: left; } \ No newline at end of file diff --git a/versions.json b/versions.json index 1c74e86..baed804 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,4 @@ { - "1.5.23": "0.12.16", + "1.5.24": "0.12.16", "1.4.2": "0.11.13" } diff --git a/yarn.lock b/yarn.lock index 141a743..15309c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1433,14 +1433,6 @@ "estree-walker" "^1.0.1" "picomatch" "^2.2.2" -"@rollup/pluginutils@^4.1.1": - "integrity" "sha512-ROn4qvkxP9SyPeHaf7uQC/GPFY6L/OWy9+bd9AwcjOAWQwxRscoEyAUD8qCY5o5iL4jqQwoLk2kaTKJPb/HwzQ==" - "resolved" "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.2.tgz" - "version" "4.1.2" - dependencies: - "estree-walker" "^2.0.1" - "picomatch" "^2.2.2" - "@rushstack/eslint-patch@^1.1.0": "integrity" "sha512-JLo+Y592QzIE+q7Dl2pMUtt4q8SKYI5jDrZxrozEQxnGVOyYE+GWK9eLkwTaeN9DDctlaRAQ3TBmzZ1qdLE30A==" "resolved" "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.1.0.tgz" @@ -3374,7 +3366,7 @@ dependencies: "ms" "^2.1.1" -"debug@^4.1.0", "debug@^4.1.1", "debug@^4.3.2", "debug@^4.3.3", "debug@4": +"debug@^4.1.0", "debug@^4.1.1", "debug@^4.3.2", "debug@4": "integrity" "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==" "resolved" "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz" "version" "4.3.3" @@ -3746,7 +3738,7 @@ "string.prototype.trimstart" "^1.0.4" "unbox-primitive" "^1.0.1" -"es-module-lexer@^0.9.0", "es-module-lexer@^0.9.3": +"es-module-lexer@^0.9.0": "integrity" "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==" "resolved" "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz" "version" "0.9.3" @@ -3760,35 +3752,6 @@ "is-date-object" "^1.0.1" "is-symbol" "^1.0.2" -"esbuild-windows-64@0.14.14": - "integrity" "sha512-kl3BdPXh0/RD/dad41dtzj2itMUR4C6nQbXQCyYHHo4zoUoeIXhpCrSl7BAW1nv5EFL8stT1V+TQVXGZca5A2A==" - "resolved" "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.14.tgz" - "version" "0.14.14" - -"esbuild@>=0.10.1": - "integrity" "sha512-aiK4ddv+uui0k52OqSHu4xxu+SzOim7Rlz4i25pMEiC8rlnGU0HJ9r+ZMfdWL5bzifg+nhnn7x4NSWTeehYblg==" - "resolved" "https://registry.npmjs.org/esbuild/-/esbuild-0.14.14.tgz" - "version" "0.14.14" - optionalDependencies: - "esbuild-android-arm64" "0.14.14" - "esbuild-darwin-64" "0.14.14" - "esbuild-darwin-arm64" "0.14.14" - "esbuild-freebsd-64" "0.14.14" - "esbuild-freebsd-arm64" "0.14.14" - "esbuild-linux-32" "0.14.14" - "esbuild-linux-64" "0.14.14" - "esbuild-linux-arm" "0.14.14" - "esbuild-linux-arm64" "0.14.14" - "esbuild-linux-mips64le" "0.14.14" - "esbuild-linux-ppc64le" "0.14.14" - "esbuild-linux-s390x" "0.14.14" - "esbuild-netbsd-64" "0.14.14" - "esbuild-openbsd-64" "0.14.14" - "esbuild-sunos-64" "0.14.14" - "esbuild-windows-32" "0.14.14" - "esbuild-windows-64" "0.14.14" - "esbuild-windows-arm64" "0.14.14" - "escalade@^3.1.1": "integrity" "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" "resolved" "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" @@ -5602,11 +5565,6 @@ "import-local" "^3.0.2" "jest-cli" "^27.4.7" -"joycon@^3.0.1": - "integrity" "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==" - "resolved" "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz" - "version" "3.1.1" - "js-tokens@^3.0.0 || ^4.0.0", "js-tokens@^4.0.0": "integrity" "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" "resolved" "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" @@ -5714,11 +5672,6 @@ dependencies: "minimist" "^1.2.5" -"jsonc-parser@^3.0.0": - "integrity" "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==" - "resolved" "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz" - "version" "3.0.0" - "jsonfile@^6.0.1": "integrity" "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==" "resolved" "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz" @@ -7524,17 +7477,6 @@ dependencies: "glob" "^7.1.3" -"rollup-plugin-esbuild@^4.8.2": - "integrity" "sha512-wsaYNOjzTb6dN1qCIZsMZ7Q0LWiPJklYs2TDI8vJA2LUbvtPUY+17TC8C0vSat3jPMInfR9XWKdA7ttuwkjsGQ==" - "resolved" "https://registry.npmjs.org/rollup-plugin-esbuild/-/rollup-plugin-esbuild-4.8.2.tgz" - "version" "4.8.2" - dependencies: - "@rollup/pluginutils" "^4.1.1" - "debug" "^4.3.3" - "es-module-lexer" "^0.9.3" - "joycon" "^3.0.1" - "jsonc-parser" "^3.0.0" - "rollup-plugin-terser@^7.0.0": "integrity" "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==" "resolved" "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz"