Skip to content

Instantly share code, notes, and snippets.

@zsviczian
Created November 9, 2023 21:40
Show Gist options
  • Save zsviczian/d8f06a95c9ae628fe0d33bc5d9a6d7a5 to your computer and use it in GitHub Desktop.
Save zsviczian/d8f06a95c9ae628fe0d33bc5d9a6d7a5 to your computer and use it in GitHub Desktop.
ExcalidrawAutomate onFileOpenHook
https://youtu.be/OX5_UYjXEvc
![Thumbnail - 20231109 Excalidraw on-load script (Custom)](https://github.com/zsviczian/obsidian-excalidraw-plugin/assets/14358394/8d741faf-9ce6-4d83-bb7a-fdc887a30918)
<%*
/*
```js*/
let watchdog = 0; //watchdog ensures we don't get into an infinite loop in case Excalidraw does not start up
while(!window.ExcalidrawAutomate && watchdog++<50) await sleep(50);
if(!window.ExcalidrawAutomate) return;
window.ExcalidrawAutomate.onFileOpenHook = (data) => {
const {ea, excalidrawFile, view} = data; //not needed now, including this just for information.
app.commands.executeCommandById("obsidian-excalidraw-plugin:Downloaded/Set Grid");
}
console.log("Excalidraw onFileOpenHook is installed");
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment