diff --git a/edit/edit.js b/edit/edit.js index 855e7932..a4d7932a 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -2072,8 +2072,9 @@ function onRuntimeMessage(request) { } break; case 'styleDeleted': - if (styleId && styleId === request.id) { + if (styleId && styleId === request.id || editor && editor.getStyle().id === request.id) { window.onbeforeunload = () => {}; + // FIXME: Scripts may not close windows that were not opened by script. window.close(); break; } diff --git a/edit/source-editor.js b/edit/source-editor.js index ac7e4f2f..e9ab02a7 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -458,5 +458,12 @@ function createSourceEditor(style) { }); } - return {replaceStyle, save, toggleStyle, updateStyleMeta, isDirty: dirty.isDirty}; + return { + replaceStyle, + save, + toggleStyle, + updateStyleMeta, + isDirty: dirty.isDirty, + getStyle: () => style + }; }