diff --git a/manifest.json b/manifest.json index c4cddfa..d16942c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.1.1", + "version": "2.1.2", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index 33ee190..023f6cb 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.8", - "@zsviczian/excalidraw": "0.17.1-obsidian-19", + "@zsviczian/excalidraw": "0.17.1-obsidian-20", "chroma-js": "^2.4.2", "clsx": "^2.0.0", "colormaster": "^1.2.1", diff --git a/src/CodeMirrorExtension/EditorHandler.ts b/src/CodeMirrorExtension/EditorHandler.ts index 85eca0d..4334508 100644 --- a/src/CodeMirrorExtension/EditorHandler.ts +++ b/src/CodeMirrorExtension/EditorHandler.ts @@ -3,8 +3,6 @@ import ExcalidrawPlugin from "src/main"; import { HideTextBetweenCommentsExtension } from "./Fadeout"; export const EDITOR_FADEOUT = "fadeOutExcalidrawMarkup"; -export let excalidrawPlugin: ExcalidrawPlugin = null; - const editorExtensions: {[key:string]:Extension}= { [EDITOR_FADEOUT]: HideTextBetweenCommentsExtension, } @@ -12,9 +10,7 @@ const editorExtensions: {[key:string]:Extension}= { export class EditorHandler { private activeEditorExtensions: Extension[] = []; - constructor(private plugin: ExcalidrawPlugin) { - excalidrawPlugin = plugin; - } + constructor(private plugin: ExcalidrawPlugin) {} setup(): void { this.plugin.registerEditorExtension(this.activeEditorExtensions); diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index c9f9ce3..c7d3598 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -137,6 +137,7 @@ import { CustomMutationObserver, isDebugMode } from "./utils/DebugHelper"; import { extractCodeBlocks, postOpenAI } from "./utils/AIUtils"; import { Mutable } from "@zsviczian/excalidraw/types/excalidraw/utility-types"; import { SelectCard } from "./dialogs/SelectCard"; +import { link } from "fs"; declare const PLUGIN_VERSION:string; @@ -948,20 +949,27 @@ export default class ExcalidrawView extends TextFileView { let linkText: string = null; if (selectedText?.id || selectedElementWithLink?.id) { + const selectedTextElement = selectedText.id + ? this.excalidrawAPI.getSceneElements().find((el:ExcalidrawElement)=>el.id === selectedText.id) + : null; + linkText = selectedElementWithLink?.text ?? (this.textMode === TextMode.parsed ? this.excalidrawData.getRawText(selectedText.id) : selectedText.text); + const partsArray = REGEX_LINK.getResList(linkText); + if (!linkText || partsArray.length === 0) { + linkText = selectedTextElement?.link; + } + if (!linkText) { - return; + return; } linkText = linkText.replaceAll("\n", ""); //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/187 - const id = selectedText.id??selectedElementWithLink.id; - const el = this.excalidrawAPI.getSceneElements().filter((el:ExcalidrawElement)=>el.id === id)[0]; - if(this.handleLinkHookCall(el,linkText,ev)) return; + if(this.handleLinkHookCall(selectedTextElement,linkText,ev)) return; if(openExternalLink(linkText, this.app)) return; const result = await linkPrompt(linkText, this.app, this); diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 3c43913..228b6f4 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -2,8 +2,13 @@ import { customAlphabet } from "nanoid"; import { DeviceType } from "../types"; import { ExcalidrawLib } from "../ExcalidrawLib"; import { moment } from "obsidian"; +import ExcalidrawPlugin from "src/main"; //This is only for backward compatibility because an early version of obsidian included an encoding to avoid fantom links from littering Obsidian graph view declare const PLUGIN_VERSION:string; +export let EXCALIDRAW_PLUGIN: ExcalidrawPlugin = null; +export const setExcalidrawPlugin = (plugin: ExcalidrawPlugin) => { + EXCALIDRAW_PLUGIN = plugin; +}; export const MD_TEXTELEMENTS = "# Text Elements"; export const MD_JSON_START = "```json\n"; export const MD_JSON_END = "```"; diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index e58f046..9068ebc 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,16 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"2.1.2":` +## Quality of Life Improvements +- The "Insert Any File" option that disappeared from the Command Palette is now restored. [#1690](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1690) +- Improved two-finger pan speed. +- Fixed text wrapping issue that caused text to jump around when editing text in a sticky note when the Obsidian zoom level was not set to 100%. +- Mask Generation in [ExcaliAI](https://youtu.be/3G8hsV-V-gQ) Edit Image now works properly again. [#1684](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1684) +- Fixed aspect ratio change for .jpg, .png, .bmp, .webp, .SVG (non-Excalidraw) images. Previously, if the image was distorted (i.e. you held SHIFT while resizing it), it would revert to the original aspect ratio upon saving the drawing. Resetting the aspect ratio is the desired behavior for nested Excalidraw drawings since you might have changed the source image and want it to still display with the correct aspect ratio, however for other image files, the behavior is not desired. [#1698](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1698) +- The command palette action "Set selected image element size to 100% of original" now works even on freshly pasted images, not just after saving the drawing. ([#1695](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1698)) +- If a text element has an element link (CTRL/CMD+K), but the link was not reflected in the Element Text, then CTRL/CMD+clicking the text element did not navigate to the link, only clicking the link indicator did. Now you can also CTRL/CMD click anywhere on the text element and it will navigate. Note, however, that links in the text element text take precedence over element links. +`, "2.1.1":` ## Fixed - Printing a markdown page that has an Excalidraw drawing on the back side, resulted in an empty PDF. This is now resolved. diff --git a/src/dialogs/Prompt.ts b/src/dialogs/Prompt.ts index 52098a1..a9db7cf 100644 --- a/src/dialogs/Prompt.ts +++ b/src/dialogs/Prompt.ts @@ -707,19 +707,22 @@ export const linkPrompt = async (linkText:string, app: App, view?: ExcalidrawVie let subpath: string = null; let file: TFile = null; let parts = partsArray[0]; - if (partsArray.length > 1) { - parts = await ScriptEngine.suggester( - app, - partsArray.filter(p=>Boolean(p.value)).map(p => { - const alias = REGEX_LINK.getAliasOrLink(p); - return alias === "100%" ? REGEX_LINK.getLink(p) : alias; - }), - partsArray.filter(p=>Boolean(p.value)), - message, - ); - if(!parts) return; - } - if(!parts) return; + if (partsArray.length > 1) { + parts = await ScriptEngine.suggester( + app, + partsArray.filter(p=>Boolean(p.value)).map(p => { + const alias = REGEX_LINK.getAliasOrLink(p); + return alias === "100%" ? REGEX_LINK.getLink(p) : alias; + }), + partsArray.filter(p=>Boolean(p.value)), + message, + ); + if(!parts) return; + } + + if(!parts) { + return; + } if (!parts.value) { openTagSearch(linkText, app); diff --git a/src/dialogs/UniversalInsertFileModal.ts b/src/dialogs/UniversalInsertFileModal.ts index 10a4922..677782d 100644 --- a/src/dialogs/UniversalInsertFileModal.ts +++ b/src/dialogs/UniversalInsertFileModal.ts @@ -86,7 +86,7 @@ export class UniversalInsertFileModal extends Modal { const isPDF = file && file.extension === "pdf"; const isExcalidraw = file && ea.isExcalidrawFile(file); - const sections = file && file.extension === "md" + const sections = (file && file.extension === "md") ? (await this.plugin.app.metadataCache.blockCache .getForFile({ isCancelled: () => false },file)) .blocks.filter((b: any) => b.display && b.node?.type === "heading") diff --git a/src/main.ts b/src/main.ts index 9f065bb..4529b6f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,7 @@ import { LOCALE, IMAGE_TYPES, MD_TEXTELEMENTS, + setExcalidrawPlugin } from "./constants/constants"; import { VIRGIL_FONT, @@ -89,7 +90,6 @@ import { getListOfTemplateFiles, getNewUniqueFilepath, getURLImageExtension, - splitFolderAndFilename, } from "./utils/FileUtils"; import { getFontDataURL, @@ -192,6 +192,7 @@ export default class ExcalidrawPlugin extends Plugin { >(); this.equationsMaster = new Map