Please check out my YouTube video Create a library of your downloaded icons with Excalidraw Automate in Obsidian, it provides a detailed walkthrough of this code.
To save these files into your Vault, either download them, or switch to RAW mode to copy/paste them into your Obsidian Vault. You may need to use CTRL+SHIFT+V to paste.
Icons created by the script are locked in the scene, you can right click them to select and copy them. Locking the eleemnts avoids the need for switching to view mode and ensures the file does not get accidently modified, thus the images in the image library are not actually saved to the image library causing unwanted links in your Vault.
I use the script with LOCK_ICONS=true; because in this case I won't accidently move items in the image library causing it to save the icons in the file and creating unwanted links in Excalibrain pointing back to the icon library. If you lock icons then you need to right click the selected icon to copy it to the clipboard, however, when you paste the icon to your drawing it will be locked - which is not convenient. For this reason I've also configured an onPaste event handler via the Excalidraw startup script. This automatically unlocks all elements on paste.
ea.onPasteHook = (data) => {
if(data?.payload?.elements) {
data.payload.elements.filter(el=>el.locked).forEach(el=>{el.locked = false;});
}
};


Ok, now that's kind of weird. I inserted ' console.log(icons);' after the first command, now it works fine and I can see the (correct) number of icons in the console AND in the drawing.
Removed the console.log command and it still works perfectly.
I have no idea, what went wrong in my first attempts. And I promise, I didn't change anything (at least not knowingly). 🙈
So, thank you for your effort to help out and again 1.000++ thanks for your great plugins and videos!!! 🙏