mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
parent
677e1863e5
commit
beb2c7f577
1 changed files with 22 additions and 10 deletions
32
vendors/squire/build/squire-raw.js
vendored
32
vendors/squire/build/squire-raw.js
vendored
|
|
@ -780,24 +780,36 @@ const
|
||||||
},
|
},
|
||||||
|
|
||||||
moveRangeBoundariesDownTree = range => {
|
moveRangeBoundariesDownTree = range => {
|
||||||
let startContainer = range.startContainer,
|
let { startContainer, startOffset, endContainer, endOffset } = range;
|
||||||
startOffset = range.startOffset,
|
let maySkipBR = true,
|
||||||
endContainer = range.endContainer,
|
|
||||||
endOffset = range.endOffset,
|
|
||||||
maySkipBR = true,
|
|
||||||
child;
|
child;
|
||||||
|
|
||||||
while (startContainer.nodeType !== TEXT_NODE) {
|
while (!(startContainer instanceof Text)) {
|
||||||
child = startContainer.childNodes[ startOffset ];
|
child = startContainer.childNodes[startOffset];
|
||||||
if (!child || isLeaf(child)) {
|
if (!child || isLeaf(child)) {
|
||||||
|
if (startOffset) {
|
||||||
|
child = startContainer.childNodes[startOffset - 1];
|
||||||
|
let prev = child.previousSibling;
|
||||||
|
// If we have an empty text node next to another text node,
|
||||||
|
// just skip and remove it.
|
||||||
|
while (child instanceof Text && !child.length && prev && prev instanceof Text) {
|
||||||
|
child.remove();
|
||||||
|
child = prev;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (child instanceof Text) {
|
||||||
|
startContainer = child;
|
||||||
|
startOffset = child.data.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startContainer = child;
|
startContainer = child;
|
||||||
startOffset = 0;
|
startOffset = 0;
|
||||||
}
|
}
|
||||||
if (endOffset) {
|
if (endOffset) {
|
||||||
while (endContainer.nodeType !== TEXT_NODE) {
|
while (!(endContainer instanceof Text)) {
|
||||||
child = endContainer.childNodes[ endOffset - 1 ];
|
child = endContainer.childNodes[endOffset - 1];
|
||||||
if (!child || isLeaf(child)) {
|
if (!child || isLeaf(child)) {
|
||||||
if (maySkipBR && child?.nodeName === 'BR') {
|
if (maySkipBR && child?.nodeName === 'BR') {
|
||||||
--endOffset;
|
--endOffset;
|
||||||
|
|
@ -810,7 +822,7 @@ const
|
||||||
endOffset = getLength(endContainer);
|
endOffset = getLength(endContainer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (endContainer.nodeType !== TEXT_NODE) {
|
while (!(endContainer instanceof Text)) {
|
||||||
child = endContainer.firstChild;
|
child = endContainer.firstChild;
|
||||||
if (!child || isLeaf(child)) {
|
if (!child || isLeaf(child)) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue