diff --git a/images/excalidraw-modifiers.png b/images/excalidraw-modifiers.png index 4797ddf..c43364f 100644 Binary files a/images/excalidraw-modifiers.png and b/images/excalidraw-modifiers.png differ diff --git a/manifest.json b/manifest.json index 61e5599..ace9ae8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.8.14", + "version": "1.8.16", "minAppVersion": "1.0.0", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 8e4f002..54ab5d5 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -107,7 +107,7 @@ import { ICONS, saveIcon } from "./menu/ActionIcons"; //import {WelcomeScreen} from "@zsviczian/excalidraw"; import { ExportDialog } from "./dialogs/ExportDialog"; import { getEA } from "src"; -import { externalDragModifierType, internalDragModifierType, isALT, isCTRL, isMETA, isSHIFT, linkClickModifierType, mdPropModifier, ModifierKeys } from "./utils/ModifierkeyHelper"; +import { emulateCTRLClickForLinks, externalDragModifierType, internalDragModifierType, isALT, isCTRL, isMETA, isSHIFT, linkClickModifierType, mdPropModifier, ModifierKeys } from "./utils/ModifierkeyHelper"; type SelectedElementWithLink = { id: string; text: string }; type SelectedImage = { id: string; fileId: FileId }; @@ -2866,7 +2866,7 @@ export default class ExcalidrawView extends TextFileView { case "image-fullsize": msg = "Embed image @100%"; break; case "link": msg = "Insert link"; break; } - } else if(e.dataTransfer.types.includes("Files")) { + } else if(e.dataTransfer.types.length === 1 && e.dataTransfer.types.includes("Files")) { //drag from OS file manager msg = "External file" } else { @@ -2878,7 +2878,7 @@ export default class ExcalidrawView extends TextFileView { } } if(this.draginfoDiv.innerText !== msg) this.draginfoDiv.innerText = msg; - const top = `${e.clientY-parseFloat(getComputedStyle(this.draginfoDiv).fontSize)*3}px`; + const top = `${e.clientY-parseFloat(getComputedStyle(this.draginfoDiv).fontSize)*8}px`; const left = `${e.clientX-this.draginfoDiv.clientWidth/2}px`; if(this.draginfoDiv.style.top !== top) this.draginfoDiv.style.top = top; if(this.draginfoDiv.style.left !== left) this.draginfoDiv.style.left = left; @@ -3448,12 +3448,7 @@ export default class ExcalidrawView extends TextFileView { null, null, {id: element.id, text: element.link}, - { - shiftKey: event.shitKey, - ctrlKey: event.ctrlKey || !(DEVICE.isIOS || DEVICE.isMacOS), - metaKey: event.metaKey || (DEVICE.isIOS || DEVICE.isMacOS), - altKey: event.altKey - } + emulateCTRLClickForLinks(event) ); return; }, diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 70684c7..6e2f513 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,20 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"1.8.16": ` +**!!! Modifier keys have changed, please review the table below !!!** +[Click this to see the new shortcuts overview image](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/excalidraw-modifiers.png) + +## Fixed +- This version was extensively tested and developed on MacOS to remove usability issues. +- New command palette action to create a new drawing in a new tab +- Modifier keys to open links in the active window, splitting the current view to the right, in a new tab, or in a popout window now behave consistently both in Excalidraw and when clicking a drawing that is embedded in a markdown note. +- Drag & Drop properly works from within Obsidian, from a web browser, and from the OS file explorer + +
+ +
+`, "1.8.14":` ## Fixed - text element link gets deleted when the drawing is reloaded diff --git a/src/main.ts b/src/main.ts index 8afa370..9f9e95c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,6 +41,7 @@ import { VIRGIL_FONT, VIRGIL_DATAURL, EXPORT_TYPES, + DEVICE, } from "./Constants"; import ExcalidrawView, { TextMode, getTextMode } from "./ExcalidrawView"; import { @@ -106,7 +107,7 @@ import { ScriptInstallPrompt } from "./dialogs/ScriptInstallPrompt"; import { check } from "prettier"; import Taskbone from "./ocr/Taskbone"; import { hoverEvent_Legacy, initializeMarkdownPostProcessor_Legacy, markdownPostProcessor_Legacy, observer_Legacy } from "./MarkdownPostProcessor_Legacy"; -import { isCTRL, PaneTarget } from "./utils/ModifierkeyHelper"; +import { emulateCTRLClickForLinks, isCTRL, linkClickModifierType, PaneTarget } from "./utils/ModifierkeyHelper"; declare module "obsidian" { @@ -706,8 +707,8 @@ export default class ExcalidrawPlugin extends Plugin { this.addRibbonIcon(ICON_NAME, t("CREATE_NEW"), async (e) => { this.createAndOpenDrawing( getDrawingFilename(this.settings), - isCTRL(e)?"new-pane":"active-pane", - ); //.ctrlKey||e.metaKey); + linkClickModifierType(emulateCTRLClickForLinks(e)), + ); }); const fileMenuHandlerCreateNew = (menu: Menu, file: TFile) => { @@ -715,7 +716,7 @@ export default class ExcalidrawPlugin extends Plugin { item .setTitle(t("CREATE_NEW")) .setIcon(ICON_NAME) - .onClick(() => { + .onClick((e) => { let folderpath = file.path; if (file instanceof TFile) { folderpath = normalizePath( @@ -724,7 +725,7 @@ export default class ExcalidrawPlugin extends Plugin { } this.createAndOpenDrawing( getDrawingFilename(this.settings), - "active-pane", + linkClickModifierType(emulateCTRLClickForLinks(e)), folderpath, ); }); @@ -2166,6 +2167,9 @@ export default class ExcalidrawPlugin extends Plugin { active: boolean = false, subpath?: string ) { + if(location === "md-properties") { + location = "new-tab"; + } let leaf: WorkspaceLeaf; if(location === "popout-window") { leaf = app.workspace.openPopoutLeaf(); diff --git a/src/utils/ModifierkeyHelper.ts b/src/utils/ModifierkeyHelper.ts index 9d8f92c..2b7f9de 100644 --- a/src/utils/ModifierkeyHelper.ts +++ b/src/utils/ModifierkeyHelper.ts @@ -44,4 +44,13 @@ export const internalDragModifierType = (ev: KeyEvent):InternalDragAction => { if(!isSHIFT(ev) && isCTRL(ev) && !isALT(ev) && !isMETA(ev)) return "image"; if(scaleToFullsizeModifier(ev)) return "image-fullsize"; return "link"; +} + +export const emulateCTRLClickForLinks = (e:KeyEvent) => { + return { + shiftKey: e.shiftKey, + ctrlKey: e.ctrlKey || !(DEVICE.isIOS || DEVICE.isMacOS), + metaKey: e.metaKey || (DEVICE.isIOS || DEVICE.isMacOS), + altKey: e.altKey + } } \ No newline at end of file