/* ![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-download-raw.jpg) Download this file and save to your Obsidian Vault including the first line, or open it in "Raw" and copy the entire contents to Obsidian. ![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-box-elements.jpg) This script will add an encapsulating box around the currently selected elements in Excalidraw. See documentation for more details: https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html ```javascript */ //uncomment if you want a prompt for custom padding //const padding = parseInt (await utils.inputPrompt("padding?","number","10")); const padding = 10 elements = ea.getViewSelectedElements(); const box = ea.getBoundingBox(elements); color = ea .getExcalidrawAPI() .getAppState() .currentItemStrokeColor; //uncomment for random color: //color = '#'+(Math.random()*0xFFFFFF<<0).toString(16).padStart(6,"0"); ea.style.strokeColor = color; id = ea.addRect( box.topX - padding, box.topY - padding, box.width + 2*padding, box.height + 2*padding ); ea.copyViewElementsToEAforEditing(elements); ea.addToGroup([id].concat(elements.map((el)=>el.id))); ea.addElementsToView(false);