fix closestVisible
This commit is contained in:
parent
dbb8badc53
commit
62f78c3dd1
|
@ -94,6 +94,7 @@ function createSection({
|
||||||
const cm = cmFactory.create(wrapper => {
|
const cm = cmFactory.create(wrapper => {
|
||||||
el.insertBefore(wrapper, $('.code-label', el).nextSibling);
|
el.insertBefore(wrapper, $('.code-label', el).nextSibling);
|
||||||
}, {value: originalSection.code});
|
}, {value: originalSection.code});
|
||||||
|
el.CodeMirror = cm; // used by getAssociatedEditor
|
||||||
|
|
||||||
const changeListeners = new Set();
|
const changeListeners = new Set();
|
||||||
|
|
||||||
|
|
|
@ -154,9 +154,7 @@ function createSectionsEditor({style, onTitleChanged}) {
|
||||||
function closestVisible(nearbyElement) {
|
function closestVisible(nearbyElement) {
|
||||||
const cm =
|
const cm =
|
||||||
nearbyElement instanceof CodeMirror ? nearbyElement :
|
nearbyElement instanceof CodeMirror ? nearbyElement :
|
||||||
nearbyElement instanceof Node &&
|
nearbyElement instanceof Node && getAssociatedEditor(nearbyElement) || getLastActivatedEditor();
|
||||||
(nearbyElement.closest('#sections > .section') || {}).CodeMirror ||
|
|
||||||
getLastActivatedEditor();
|
|
||||||
if (nearbyElement instanceof Node && cm) {
|
if (nearbyElement instanceof Node && cm) {
|
||||||
const {left, top} = nearbyElement.getBoundingClientRect();
|
const {left, top} = nearbyElement.getBoundingClientRect();
|
||||||
const bounds = cm.display.wrapper.getBoundingClientRect();
|
const bounds = cm.display.wrapper.getBoundingClientRect();
|
||||||
|
@ -228,6 +226,15 @@ function createSectionsEditor({style, onTitleChanged}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAssociatedEditor(nearbyElement) {
|
||||||
|
for (let el = nearbyElement; el; el = el.parentElement) {
|
||||||
|
// added by createSection
|
||||||
|
if (el.CodeMirror) {
|
||||||
|
return el.CodeMirror;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getEditors() {
|
function getEditors() {
|
||||||
return sections.filter(s => !s.isRemoved()).map(s => s.cm);
|
return sections.filter(s => !s.isRemoved()).map(s => s.cm);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user