diff --git a/package.json b/package.json index b368a1c..4cf3d50 100644 --- a/package.json +++ b/package.json @@ -23,16 +23,16 @@ "clsx": "^1.2.1", "colormaster": "^1.2.1", "gl-matrix": "^3.4.3", - "lz-string": "^1.4.4", + "lz-string": "^1.5.0", "monkey-around": "^2.3.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "^5.0.1", "roughjs": "^4.5.2", "html2canvas": "^1.4.1", - "@popperjs/core": "^2.11.6", - "nanoid": "^4.0.0", - "lucide-react": "0.259.0" + "@popperjs/core": "^2.11.8", + "nanoid": "^4.0.2", + "lucide-react": "^0.263.1" }, "devDependencies": { "@babel/core": "^7.20.12", @@ -66,9 +66,6 @@ "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 04f8008..4da7873 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -11,7 +11,7 @@ import { StrokeRoundness, RoundnessType, } from "@zsviczian/excalidraw/types/element/types"; -import { normalizePath, Notice, OpenViewState, TFile, WorkspaceLeaf } from "obsidian"; +import { Editor, normalizePath, Notice, OpenViewState, TFile, WorkspaceLeaf } from "obsidian"; import * as obsidian_module from "obsidian"; import ExcalidrawView, { ExportSettings, TextMode } from "src/ExcalidrawView"; import { ExcalidrawData, getMarkdownDrawingSection, REGEX_LINK } from "src/ExcalidrawData"; @@ -171,6 +171,23 @@ export class ExcalidrawAutomate { return getLeaf(this.plugin,origo,modifierKeys); } + public getActiveEmbeddableViewOrEditor (view?:ExcalidrawView): {view:any}|{file:TFile, editor:Editor}|null { + if (!this.targetView && !view) { + return null; + } + view = view ?? this.targetView; + const leafOrNode = view.getActiveEmbeddable(); + if(leafOrNode) { + if(leafOrNode.node && leafOrNode.node.isEditing) { + return {file: leafOrNode.node.file, editor: leafOrNode.node.child.editor}; + } + if(leafOrNode.leaf && leafOrNode.leaf.view) { + return {view: leafOrNode.leaf.view}; + } + } + return null; + } + plugin: ExcalidrawPlugin; elementsDict: {[key:string]:any}; //contains the ExcalidrawElements currently edited in Automate indexed by el.id imagesDict: {[key: FileId]: any}; //the images files including DataURL, indexed by fileId