diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index f2966203c..dd83f36d3 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3010,7 +3010,7 @@ function Ace2Inner(editorInfo, cssManagers) { }; } }; - const browserSelection = window.getSelection(); + const browserSelection = targetDoc.getSelection(); if (browserSelection) { browserSelection.removeAllRanges(); if (selection) { @@ -3153,7 +3153,7 @@ function Ace2Inner(editorInfo, cssManagers) { browserSelection.anchorOffset === range.endOffset, }; - if (selection.startPoint.node.ownerDocument !== window.document) { + if (selection.startPoint.node.ownerDocument !== targetDoc) { return null; } diff --git a/src/static/js/caretPosition.ts b/src/static/js/caretPosition.ts index 23e956d30..236584a4c 100644 --- a/src/static/js/caretPosition.ts +++ b/src/static/js/caretPosition.ts @@ -5,7 +5,6 @@ // is represented by the browser export const getPosition = () => { const range = getSelectionRange(); - console.log("Getting range", range) if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null; // When there's a
or any element that has no height, we can't get the dimension of the // element where the caret is. As we can't get the element height, we create a text node to get @@ -190,6 +189,7 @@ const getDimensionOfFirstBrowserLineOfRepLine = (line, rep) => { }; const getSelectionRange = () => { + console.log("Selection is",window.frameElement) if (!window.getSelection) { return; }