mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
33 lines
874 B
Markdown
33 lines
874 B
Markdown
/*
|
|
Toggles the grid on and off. Especially useful when drawing with just a pen without a mouse or keyboard, as toggling the grid by left-clicking with the pen is sometimes quite tedious.
|
|
|
|
See documentation for more details:
|
|
https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html
|
|
|
|
```javascript
|
|
*/
|
|
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.8.11")) {
|
|
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
|
|
return;
|
|
}
|
|
const api = ea.getExcalidrawAPI();
|
|
let {gridSize, previousGridSize} = api.getAppState();
|
|
|
|
if (!previousGridSize) {
|
|
previousGridSize = 20
|
|
}
|
|
if (!gridSize) {
|
|
gridSize = previousGridSize;
|
|
}
|
|
else
|
|
{
|
|
previousGridSize = gridSize;
|
|
gridSize = null;
|
|
}
|
|
ea.viewUpdateScene({
|
|
appState:{
|
|
gridSize,
|
|
previousGridSize
|
|
},
|
|
commitToHistory:false
|
|
}); |