don't preview unsaved styles

This commit is contained in:
tophf 2018-01-12 14:11:24 +03:00
parent bb34538da0
commit 9affcd13bc

View File

@ -540,6 +540,17 @@ onDOMscriptReady('/codemirror.js').then(() => {
setTimeout(setupLivePreview); setTimeout(setupLivePreview);
return; return;
} }
if (!styleId) {
new MutationObserver((_, observer) => {
if (!styleId) return;
observer.disconnect();
setupLivePreview();
}).observe($('#preview-label'), {
attributes: true,
attributeFilter: ['class'],
});
return;
}
$('#editor.livePreview').onchange = function () { $('#editor.livePreview').onchange = function () {
const previewing = this.checked; const previewing = this.checked;
editors.forEach(cm => cm[previewing ? 'on' : 'off']('changes', updatePreview)); editors.forEach(cm => cm[previewing ? 'on' : 'off']('changes', updatePreview));