2021-12-11 13:45:05 +01:00
/*
2021-12-12 10:27:40 +01:00

2021-12-11 13:45:05 +01:00
The default grid size in Excalidraw is 20. Currently there is no way to change the grid size via the user interface. This script offers a way to bridge this gap.
See documentation for more details:
https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html
```javascript
*/
2023-01-22 14:19:41 +01:00
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.8.11")) {
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
return;
}
2021-12-11 13:45:05 +01:00
const api = ea.getExcalidrawAPI();
let appState = api.getAppState();
2023-01-22 14:19:41 +01:00
const grid = parseInt(await utils.inputPrompt("Grid size?",null,appState.previousGridSize?.toString()??"20"));
if(isNaN(grid)) return; //this is to avoid passing an illegal value to Excalidraw
2021-12-11 13:45:05 +01:00
appState.gridSize = grid;
2023-01-22 14:19:41 +01:00
appState.previousGridSize = grid;
2021-12-11 13:45:05 +01:00
api.updateScene({
appState,
commitToHistory:false
});