-function drawEventInit() {
- if (!onInit) return;
- onInit().then(xml => {
- drawPostMessage({action: 'load', autosave: 1, xml: xml});
- });
-}
+/**
+ * Show the draw.io editor.
+ * onSaveCallback must return a promise that resolves on successful save and errors on failure.
+ * onInitCallback must return a promise with the xml to load for the editor.
+ * Will attempt to provide an option to restore unsaved changes if found to exist.
+ * @param {String} drawioUrl
+ * @param {Function<Promise<String>>} onInitCallback
+ * @param {Function<Promise>} onSaveCallback - Is called with the drawing data on save.
+ */
+export async function show(drawioUrl, onInitCallback, onSaveCallback) {
+ onInit = onInitCallback;
+ onSave = onSaveCallback;