var editorUi;
Draw.loadPlugin(app => editorUi = app)
var editor = editorUi.editor
var graph = editor.graph
... then you can automate changes to the diagram using mxGraph's api [1] on the `graph' variable from the console.Around this plugin mechanism I wrote some dirty hacks for personal use to make the editor behave more to my likings [2] (some features stopped working with recent versions of the desktop app), and an even dirtier Emacs mode for editing labels and having the js REPL available directly from Emacs when I need to run some code to fix my diagrams programmatically [3] (based on Indium [4] + the fact that electron apps can be launched with --remote-debugging-port=...). It's not pretty, but works enough for me, and it's only thanks to the customizability that diagrams.net allows.
[1] https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGr...
[2] https://gitlab.com/spellcard199/drawio-plugin-eight-droves-o...