mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
Fixed caret positioning
This commit is contained in:
parent
da7671d9da
commit
105016bd60
2 changed files with 3 additions and 3 deletions
|
@ -3010,7 +3010,7 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const browserSelection = window.getSelection();
|
const browserSelection = targetDoc.getSelection();
|
||||||
if (browserSelection) {
|
if (browserSelection) {
|
||||||
browserSelection.removeAllRanges();
|
browserSelection.removeAllRanges();
|
||||||
if (selection) {
|
if (selection) {
|
||||||
|
@ -3153,7 +3153,7 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
browserSelection.anchorOffset === range.endOffset,
|
browserSelection.anchorOffset === range.endOffset,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (selection.startPoint.node.ownerDocument !== window.document) {
|
if (selection.startPoint.node.ownerDocument !== targetDoc) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
// is represented by the browser
|
// is represented by the browser
|
||||||
export const getPosition = () => {
|
export const getPosition = () => {
|
||||||
const range = getSelectionRange();
|
const range = getSelectionRange();
|
||||||
console.log("Getting range", range)
|
|
||||||
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
||||||
// When there's a <br> or any element that has no height, we can't get the dimension of the
|
// When there's a <br> 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
|
// 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 = () => {
|
const getSelectionRange = () => {
|
||||||
|
console.log("Selection is",window.frameElement)
|
||||||
if (!window.getSelection) {
|
if (!window.getSelection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue