show sections on compact->normal layout switch
This commit is contained in:
parent
39c51435ca
commit
ebb5fcafbc
10
edit/edit.js
10
edit/edit.js
|
@ -24,7 +24,6 @@ baseInit.ready.then(async () => {
|
||||||
editor.ready = true;
|
editor.ready = true;
|
||||||
editor.dirty.onChange(editor.updateDirty);
|
editor.dirty.onChange(editor.updateDirty);
|
||||||
|
|
||||||
prefs.subscribe('editor.toc.expanded', (k, val) => val && editor.updateToc(), {runNow: true});
|
|
||||||
prefs.subscribe('editor.linter', (key, value) => {
|
prefs.subscribe('editor.linter', (key, value) => {
|
||||||
document.body.classList.toggle('linter-disabled', value === '');
|
document.body.classList.toggle('linter-disabled', value === '');
|
||||||
linterMan.run();
|
linterMan.run();
|
||||||
|
@ -33,9 +32,14 @@ baseInit.ready.then(async () => {
|
||||||
// enabling after init to prevent flash of validation failure on an empty name
|
// enabling after init to prevent flash of validation failure on an empty name
|
||||||
$('#name').required = !editor.isUsercss;
|
$('#name').required = !editor.isUsercss;
|
||||||
$('#save-button').onclick = editor.save;
|
$('#save-button').onclick = editor.save;
|
||||||
|
|
||||||
|
const elSec = $('#sections-list');
|
||||||
// editor.toc.expanded pref isn't saved in compact-layout so prefs.subscribe won't work
|
// editor.toc.expanded pref isn't saved in compact-layout so prefs.subscribe won't work
|
||||||
$('#sections-list').on('click', () => $('.compact-layout') && setTimeout(editor.updateToc),
|
if (elSec.open) editor.updateToc();
|
||||||
{once: true});
|
// and we also toggle `open` directly in other places e.g. in detectLayout()
|
||||||
|
new MutationObserver(() => elSec.open && editor.updateToc())
|
||||||
|
.observe(elSec, {attributes: true, attributeFilter: ['open']});
|
||||||
|
|
||||||
$('#toc').onclick = e =>
|
$('#toc').onclick = e =>
|
||||||
editor.jumpToEditor([...$('#toc').children].indexOf(e.target));
|
editor.jumpToEditor([...$('#toc').children].indexOf(e.target));
|
||||||
$('#keyMap-help').onclick = () =>
|
$('#keyMap-help').onclick = () =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user