This commit is contained in:
Zsolt Viczian
2021-06-21 20:41:15 +02:00
parent 6c75f6d69b
commit 388f6ee92b
5 changed files with 28 additions and 4 deletions

View File

@@ -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.

View File

@@ -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",

View File

@@ -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);
},

View File

@@ -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'});

View File

@@ -1,3 +1,3 @@
{
"1.1.9": "0.11.13"
"1.1.10": "0.11.13"
}