Fix: don't reinit all editors on save
This commit is contained in:
parent
1a5a206fe6
commit
5ae95a1ad9
|
@ -122,6 +122,7 @@ function createSection({
|
|||
getCode,
|
||||
getModel,
|
||||
remove,
|
||||
destroy,
|
||||
restore,
|
||||
isRemoved: () => removed,
|
||||
onChange,
|
||||
|
@ -271,14 +272,15 @@ function createSection({
|
|||
return cm.getValue();
|
||||
}
|
||||
|
||||
function remove(destroy = false) {
|
||||
function remove() {
|
||||
linter.disableForEditor(cm);
|
||||
el.classList.add('removed');
|
||||
removed = true;
|
||||
appliesTo.forEach(a => a.remove());
|
||||
if (destroy) {
|
||||
cmFactory.destroy(cm);
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
cmFactory.destroy(cm);
|
||||
}
|
||||
|
||||
function restore() {
|
||||
|
|
|
@ -406,11 +406,24 @@ function createSectionsEditor(style) {
|
|||
}
|
||||
API.editSave(newStyle)
|
||||
.then(newStyle => {
|
||||
destroyRemovedSections();
|
||||
sessionStorage.justEditedStyleId = newStyle.id;
|
||||
replaceStyle(newStyle);
|
||||
replaceStyle(newStyle, false);
|
||||
});
|
||||
}
|
||||
|
||||
function destroyRemovedSections() {
|
||||
for (let i = 0; i < sections.length;) {
|
||||
if (!sections[i].isRemoved()) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
sections[i].destroy();
|
||||
sections[i].el.remove();
|
||||
sections.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function updateHeader() {
|
||||
nameEl.value = style.name || '';
|
||||
enabledEl.checked = style.enabled !== false;
|
||||
|
@ -476,7 +489,8 @@ function createSectionsEditor(style) {
|
|||
const index = sections.indexOf(section);
|
||||
sections.splice(index, 1);
|
||||
section.el.remove();
|
||||
section.remove(true);
|
||||
section.remove();
|
||||
section.destroy();
|
||||
} else {
|
||||
const lines = [];
|
||||
const MAX_LINES = 10;
|
||||
|
@ -486,7 +500,7 @@ function createSectionsEditor(style) {
|
|||
lines.slice(0, MAX_LINES).map(s => clipString(s, 100)).join('\n') +
|
||||
(lines.length > MAX_LINES ? '\n...' : '');
|
||||
$('.deleted-section', section.el).title = title;
|
||||
section.remove(false);
|
||||
section.remove();
|
||||
}
|
||||
dirty.remove(section, section);
|
||||
updateSectionOrder();
|
||||
|
|
Loading…
Reference in New Issue
Block a user