focus code on opening standard editor immediately
This commit is contained in:
parent
8ca7c36380
commit
b9f6095db5
14
edit/edit.js
14
edit/edit.js
|
@ -1384,12 +1384,14 @@ function addSections(sections, onAdded = () => {}) {
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
const divs = [];
|
const divs = [];
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
return new Promise(function run(resolve) {
|
return new Promise(function run(resolve) {
|
||||||
while (index < sections.length) {
|
while (index < sections.length) {
|
||||||
const div = addSection(null, sections[index]);
|
const div = addSection(null, sections[index]);
|
||||||
maximizeCodeHeight(div, index === sections.length - 1);
|
maximizeCodeHeight(div, index === sections.length - 1);
|
||||||
onAdded(div, index);
|
onAdded(div, index);
|
||||||
divs.push(div);
|
divs.push(div);
|
||||||
|
maybeFocusFirstCM();
|
||||||
index++;
|
index++;
|
||||||
const elapsed = performance.now() - t0;
|
const elapsed = performance.now() - t0;
|
||||||
if (elapsed > 500) {
|
if (elapsed > 500) {
|
||||||
|
@ -1401,15 +1403,19 @@ function addSections(sections, onAdded = () => {}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (divs[0]) {
|
|
||||||
makeSectionVisible(divs[0].CodeMirror);
|
|
||||||
divs[0].CodeMirror.focus();
|
|
||||||
}
|
|
||||||
editors.last.state.renderLintReportNow = true;
|
editors.last.state.renderLintReportNow = true;
|
||||||
addSections.running = false;
|
addSections.running = false;
|
||||||
setGlobalProgress();
|
setGlobalProgress();
|
||||||
resolve(divs);
|
resolve(divs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function maybeFocusFirstCM() {
|
||||||
|
const isPageLocked = document.documentElement.style.pointerEvents;
|
||||||
|
if (divs[0] && (isPageLocked ? index === sections.length : index === 0)) {
|
||||||
|
makeSectionVisible(divs[0].CodeMirror);
|
||||||
|
divs[0].CodeMirror.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupOptionsExpand() {
|
function setupOptionsExpand() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user