diff --git a/README.md b/README.md index 8e52453..80a9e8a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ Part 6: Intro to Obsidian-Excalidraw: Embedding drawings (2:08) [![Part 6: Intro to Obsidian-Excalidraw: Embedding drawings](https://user-images.githubusercontent.com/14358394/115983954-bbdd6380-a5a4-11eb-9243-f0151451afcd.jpg)](https://youtu.be/JQeJ-Hh-xAI) # Release Notes +## 1.1.10 +- When you CTRL-Click a grouped collection of objects Excalidraw will open the page based on the embedded text. +- I added a setting to disable the CTRL-click functionality should it interfere with default Excalidraw behavior for you. In my experience double-clicking achieves the same outcome as a CTRL-click on an element in a grouped collection of objects, but if you use the CTRL-click feature to select an element of a group frequently, and find the "CTRL-click to open a link" feature annoying, you can now disable it. ## 1.1.9 - I modified the behavior of Excalidraw text element links. diff --git a/manifest.json b/manifest.json index cd47fbe..87b3538 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.1.9", + "version": "1.1.10", "minAppVersion": "0.11.13", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 913dcd6..bbe19d2 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -305,8 +305,16 @@ export default class ExcalidrawView extends TextFileView { if(!excalidrawRef?.current) return null; const selectedElement = excalidrawRef.current.getSceneElements().filter((el:any)=>el.id==Object.keys(excalidrawRef.current.getAppState().selectedElementIds)[0]); if(selectedElement.length==0) return null; - if(selectedElement[0].type != "text") return null; - return selectedElement[0].text; + if(selectedElement[0].type == "text") return selectedElement[0].text; //a text element was selected. Retrun text + if(selectedElement[0].groupIds.length == 0) return null; //is the selected element part of a group? + const group = selectedElement[0].groupIds[0]; //if yes, take the first group it is part of + const textElement = excalidrawRef + .current + .getSceneElements() + .filter((el:any)=>el.groupIds?.includes(group)) + .filter((el:any)=>el.type=="text"); //filter for text elements of the group + if(textElement.length==0) return null; //the group had no text element member + return textElement[0].text; //return text element text }; this.addText = (text:string, fontFamily?:1|2|3) => { @@ -379,6 +387,7 @@ export default class ExcalidrawView extends TextFileView { key: "abc", onClick: (e:MouseEvent):any => { if(!(e.ctrlKey||e.metaKey)) return; + if(!(this.plugin.settings.allowCtrlClick)) return; if(!this.getSelectedText()) return; this.handleLinkClick(this,e); }, diff --git a/src/settings.ts b/src/settings.ts index 9c2275b..80c4c2b 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -14,6 +14,7 @@ export interface ExcalidrawSettings { drawingFilenameDateTime: string, width: string, validLinksOnly: boolean, //valid link as in [[valid Obsidian link]] - how to treat text elements in drawings + allowCtrlClick: boolean, //if disabled only the link button in the view header will open links exportWithTheme: boolean, exportWithBackground: boolean, autoexportSVG: boolean, @@ -33,6 +34,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = { drawingFilenameDateTime: 'YYYY-MM-DD HH.mm.ss', width: '400', validLinksOnly: false, + allowCtrlClick: true, exportWithTheme: true, exportWithBackground: true, autoexportSVG: false, @@ -161,6 +163,16 @@ export class ExcalidrawSettingTab extends PluginSettingTab { this.plugin.reloadIndex(); await this.plugin.saveSettings(); })); + new Setting(containerEl) + .setName('CTRL + CLICK on text to open them as links') + .setDesc('You can turn this feature off if it interferes with default Excalidraw features you want to use. If ' + + 'this is turned off, only the link button in the title bar of the drawing will open links.') + .addToggle(toggle => toggle + .setValue(this.plugin.settings.allowCtrlClick) + .onChange(async (value) => { + this.plugin.settings.allowCtrlClick = value; + await this.plugin.saveSettings(); + })); this.containerEl.createEl('h1', {text: 'Embedded image settings'}); diff --git a/versions.json b/versions.json index 6cc8efa..309dd85 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.1.9": "0.11.13" + "1.1.10": "0.11.13" }