mirror of https://github.com/vector-im/riot-web
fallback to setting caret on line node for empty lines
instead of setting at the end of the editorpull/21833/head
parent
4fc23022f4
commit
6b680ff681
|
@ -44,14 +44,11 @@ export function setCaretPosition(editor, model, caretPosition) {
|
||||||
let focusNode;
|
let focusNode;
|
||||||
const lineNode = editor.childNodes[lineIndex];
|
const lineNode = editor.childNodes[lineIndex];
|
||||||
if (lineNode) {
|
if (lineNode) {
|
||||||
if (lineNode.childNodes.length === 0 && offset === 0) {
|
focusNode = lineNode.childNodes[nodeIndex];
|
||||||
|
if (!focusNode) {
|
||||||
focusNode = lineNode;
|
focusNode = lineNode;
|
||||||
} else {
|
} else if (focusNode.nodeType === Node.ELEMENT_NODE) {
|
||||||
focusNode = lineNode.childNodes[nodeIndex];
|
focusNode = focusNode.childNodes[0];
|
||||||
|
|
||||||
if (focusNode && focusNode.nodeType === Node.ELEMENT_NODE) {
|
|
||||||
focusNode = focusNode.childNodes[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// node not found, set caret at end
|
// node not found, set caret at end
|
||||||
|
|
Loading…
Reference in New Issue