diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..19c7bdb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16 \ No newline at end of file diff --git a/manifest.json b/manifest.json index 379b5d8..baf552c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.9.12", + "version": "1.9.13", "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 ddff5db..b368a1c 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,9 @@ "ttypescript": "^1.5.15", "typescript": "^4.9.4" }, + "engines": { + "node": "16.10.0" + }, "resolutions": { "@typescript-eslint/typescript-estree": "5.3.0" }, diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index 7b7d335..04f8008 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -1164,6 +1164,9 @@ export class ExcalidrawAutomate { ); this.elementsDict[id].fileId = fileId; this.elementsDict[id].scale = [1, 1]; + if(!scale && anchor) { + this.elementsDict[id].customData = {isAnchored: true} + }; return id; }; @@ -2504,7 +2507,7 @@ const updateElementLinksToObsidianLinks = ({elements, hostFile}:{ hostFile: TFile; }): ExcalidrawElement[] => { return elements.map((el)=>{ - if(el.link && el.link.startsWith("[")) { + if(el.type!=="embeddable" && el.link && el.link.startsWith("[")) { const partsArray = REGEX_LINK.getResList(el.link)[0]; if(!partsArray?.value) return el; let linkText = REGEX_LINK.getLink(partsArray); diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index dd83d28..040d0f1 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -1464,6 +1464,13 @@ export default class ExcalidrawView extends TextFileView { clearInterval(this.autosaveTimer); this.autosaveTimer = null; } + const path = this.file?.path; + const plugin = this.plugin; + if (path) { + setTimeout(() => { + plugin.triggerEmbedUpdates(path); + }, 300); + } } /** @@ -3173,8 +3180,9 @@ export default class ExcalidrawView extends TextFileView { autoFocus: true, onChange: (et: ExcalidrawElement[], st: AppState) => { const canvasColorChangeHook = () => { - setTimeout(()=>this.updateScene({appState:{gridColor: this.getGridColor(st.viewBackgroundColor)}})); - setDynamicStyle(this.plugin.ea,this,st.viewBackgroundColor,this.plugin.settings.dynamicStyling); + const canvasColor = st.viewBackgroundColor === "transparent" ? "white" : st.viewBackgroundColor; + setTimeout(()=>this.updateScene({appState:{gridColor: this.getGridColor(canvasColor)}})); + setDynamicStyle(this.plugin.ea,this,canvasColor,this.plugin.settings.dynamicStyling); if(this.plugin.ea.onCanvasColorChangeHook) { try { this.plugin.ea.onCanvasColorChangeHook( diff --git a/src/customEmbeddable.tsx b/src/customEmbeddable.tsx index 3735a66..571ff9f 100644 --- a/src/customEmbeddable.tsx +++ b/src/customEmbeddable.tsx @@ -6,7 +6,7 @@ import { ConstructableWorkspaceSplit, getContainerForDocument, isObsidianThemeDa import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES } from "./Constants"; import { ExcalidrawImperativeAPI, UIAppState } from "@zsviczian/excalidraw/types/types"; import { ObsidianCanvasNode } from "./utils/CanvasNodeFactory"; -import { processLinkText, patchMobileView, generateEmbeddableLink } from "./utils/CustomEmbeddableUtils"; +import { processLinkText, patchMobileView } from "./utils/CustomEmbeddableUtils"; declare module "obsidian" { interface Workspace { @@ -172,6 +172,7 @@ function RenderObsidianView( if(subpath && view.canvasNodeFactory.isInitialized()) { setKeepOnTop(); leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id); + view.updateEmbeddableLeafRef(element.id, leafRef.current); } else { (async () => { await leafRef.current.leaf.openFile(file, { diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 8c81ab1..11f0047 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,27 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"1.9.13":` +
+ +
+ +# New +- **Templater support**: You can now execute Templater scripts on an embedded Markdown document when the document is active for editing +- **Interactive image-embeds**: I added a new image embed option "SVG Native". In "SVG Native" mode embedded items such as videos, webpages, and links (including links within the Vault) work. +- **Anchored image resizing**: When you embed an Excalidraw drawing using the Anchor to 100% option, resizing the image will be disabled. + +# Fixed +- when opening a new document in the Excalidraw view while a markdown document was open for editing in an embeddable, Excalidraw terminated with errors +- shift-click to select multiple elements +- dynamic styling when canvas background with transparent + +# New in ExcalidrawAutomate +- added openState to the ${String.fromCharCode(96)}openFileInNewOrAdjacentLeaf${String.fromCharCode(96)}. For details see: [OpenViewState](https://github.com/obsidianmd/obsidian-api/blob/f86f95386d439c19d9a77831d5cac5748d80e7ec/obsidian.d.ts#L2686-L2695) +${String.fromCharCode(96,96,96)}typescript +openFileInNewOrAdjacentLeaf(file: TFile, openState?: OpenViewState): WorkspaceLeaf +${String.fromCharCode(96,96,96)} +`, "1.9.12":` ## New - If you create a Text Element that includes only a transclusion e.g.: ${String.fromCharCode(96)}![[My Image.png]]${String.fromCharCode(96)} then excalidraw will automatically replace the transclusion with the embedded image. diff --git a/src/settings.ts b/src/settings.ts index abf6b72..dc0646f 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1152,6 +1152,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab { .setValue(this.plugin.settings.previewImageType) .onChange((value) => { this.plugin.settings.previewImageType = value as PreviewImageType; + this.requestEmbedUpdate=true; this.applySettingsUpdate(); }) );