declare refreshOnView as a standard function

This commit is contained in:
tophf 2020-10-11 13:06:01 +03:00
parent 871e7a3fc5
commit efd68b5b48

View File

@ -57,16 +57,11 @@ function createSectionsEditor({style, onTitleChanged}) {
xo.unobserve(target); xo.unobserve(target);
} }
} }
}, { }, {rootMargin: '100%'});
rootMargin: '100%', const refreshOnView = (cm, force) =>
}); force || !xo ?
CodeMirror.defineExtension('refreshOnView', function () { cm.refresh() :
if (xo) { xo.observe(cm.display.wrapper);
xo.observe(this.display.wrapper);
} else {
this.refresh();
}
});
let sectionOrder = ''; let sectionOrder = '';
const initializing = initSections(style.sections.slice()); const initializing = initSections(style.sections.slice());
@ -563,7 +558,7 @@ function createSectionsEditor({style, onTitleChanged}) {
const {cm} = section; const {cm} = section;
sections.splice(base ? sections.indexOf(base) + 1 : sections.length, 0, section); sections.splice(base ? sections.indexOf(base) + 1 : sections.length, 0, section);
container.insertBefore(section.el, base ? base.el.nextSibling : null); container.insertBefore(section.el, base ? base.el.nextSibling : null);
cm[forceRefresh ? 'refresh' : 'refreshOnView'](); refreshOnView(cm, forceRefresh);
if (!base || init.code) { if (!base || init.code) {
// Fit a) during startup or b) when the clone button is clicked on a section with some code // Fit a) during startup or b) when the clone button is clicked on a section with some code
fitToContent(section); fitToContent(section);