mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
Compare commits
1 Commits
2.7.6-beta
...
local-grap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eb23ab5e1 |
8
package-lock.json
generated
8
package-lock.json
generated
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
"@zsviczian/excalidraw": "0.17.6-25",
|
||||
"@zsviczian/excalidraw": "0.17.6-26",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -3315,9 +3315,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@zsviczian/excalidraw": {
|
||||
"version": "0.17.6-25",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.17.6-25.tgz",
|
||||
"integrity": "sha512-Hq/LVJoQHTc8ECKrqLf1hZRh7xEDI5W7SoVjBhLl5vwbhUxrYPu7j83g01kDiqKxybq8YK0kQULhEck64dyh0A==",
|
||||
"version": "0.17.6-26",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.17.6-26.tgz",
|
||||
"integrity": "sha512-UAqr7b7cxIbOvK1u0NKqgAs0wB9KYUsVc6Q2J+yviM4ae+wkTXp8qW/V4mdWADJ3lTG5RgXCb9ausIKfSkPNRg==",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "6.0.2",
|
||||
"@excalidraw/random-username": "1.1.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/excalidraw/element/types";
|
||||
import { DEVICE, REG_LINKINDEX_INVALIDCHARS } from "src/constants/constants";
|
||||
import { getParentOfClass } from "./obsidianUtils";
|
||||
import { TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { App, TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { getLinkParts } from "./utils";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
|
||||
@@ -55,4 +55,15 @@ export const generateEmbeddableLink = (src: string, theme: "light" | "dark"):str
|
||||
}
|
||||
}*/
|
||||
return src;
|
||||
}
|
||||
|
||||
export function setFileToLocalGraph(app: App, file: TFile) {
|
||||
let lgv;
|
||||
app.workspace.iterateAllLeaves((l) => {
|
||||
if (l.view?.getViewType() === "localgraph") lgv = l.view;
|
||||
});
|
||||
if (lgv) {
|
||||
//@ts-ignore
|
||||
lgv.loadFile(file);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { ConstructableWorkspaceSplit, getContainerForDocument, isObsidianThemeDa
|
||||
import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES } from "src/constants/constants";
|
||||
import { ExcalidrawImperativeAPI, UIAppState } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
|
||||
import { processLinkText, patchMobileView } from "src/utils/customEmbeddableUtils";
|
||||
import { processLinkText, patchMobileView, setFileToLocalGraph } from "src/utils/customEmbeddableUtils";
|
||||
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
|
||||
|
||||
declare module "obsidian" {
|
||||
@@ -154,6 +154,15 @@ function RenderObsidianView(
|
||||
}; //cleanup on unmount
|
||||
}, [isActiveRef.current, containerRef.current]);
|
||||
|
||||
//set local graph to view when deactivating embeddables
|
||||
React.useEffect(() => {
|
||||
if(file === view.file) {
|
||||
return;
|
||||
}
|
||||
if(!isActiveRef.current) {
|
||||
setFileToLocalGraph(view.app, view.file);
|
||||
}
|
||||
}, [isActiveRef.current]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//Mount the workspace leaf or the canvas node depending on subpath
|
||||
@@ -408,6 +417,10 @@ function RenderObsidianView(
|
||||
return;
|
||||
}
|
||||
|
||||
if(file !== view.file) {
|
||||
setFileToLocalGraph(view.app, file);
|
||||
}
|
||||
|
||||
if(leafRef.current.leaf?.view?.getViewType() === "markdown") {
|
||||
//Handle markdown leaf
|
||||
//@ts-ignore
|
||||
|
||||
Reference in New Issue
Block a user