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