Fix: source editor is not closed when style is removed

This commit is contained in:
eight 2017-09-19 08:49:38 +08:00
parent 2b6404cb11
commit a4e3fba968
2 changed files with 10 additions and 2 deletions

View File

@ -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;
}

View File

@ -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
};
}