mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
safeguard if the offsetnode is null when determining caret position
This commit is contained in:
parent
c141335b6a
commit
9dd93c52b0
@ -92,6 +92,10 @@ function getSelectionOffsetAndText(editor, selectionNode, selectionOffset) {
|
||||
// gets the caret position details, ignoring and adjusting to
|
||||
// the ZWS if you're typing in a caret node
|
||||
function getCaret(node, offsetToNode, offsetWithinNode) {
|
||||
// if no node is selected, return an offset at the start
|
||||
if (!node) {
|
||||
return new DocumentOffset(0, false);
|
||||
}
|
||||
let atNodeEnd = offsetWithinNode === node.textContent.length;
|
||||
if (node.nodeType === Node.TEXT_NODE && isCaretNode(node.parentElement)) {
|
||||
const zwsIdx = node.nodeValue.indexOf(CARET_NODE_CHAR);
|
||||
|
Loading…
Reference in New Issue
Block a user