Fix extra new lines on message sending
This commit is contained in:
parent
94d0ba65c3
commit
832908c758
|
@ -204,12 +204,16 @@ export default function getRichElementValue(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSelected = selNode === node;
|
const pushLine = () => {
|
||||||
const isBlock = BLOCK_TAGS.has(node.tagName);
|
|
||||||
if(isBlock && (line.length || node.tagName === 'BR'/* || (BLOCK_TAGS.has(node.tagName) && lines.length) */)) {
|
|
||||||
lines.push(line.join(''));
|
lines.push(line.join(''));
|
||||||
line.length = 0;
|
line.length = 0;
|
||||||
++offset.offset;
|
++offset.offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isSelected = selNode === node;
|
||||||
|
const isBlock = BLOCK_TAGS.has(node.tagName);
|
||||||
|
if(isBlock && (line.length || node.tagName === 'BR'/* || (BLOCK_TAGS.has(node.tagName) && lines.length) */)) {
|
||||||
|
pushLine();
|
||||||
} else {
|
} else {
|
||||||
const alt = node.dataset.stickerEmoji || (node as HTMLImageElement).alt;
|
const alt = node.dataset.stickerEmoji || (node as HTMLImageElement).alt;
|
||||||
const stickerEmoji = node.dataset.stickerEmoji;
|
const stickerEmoji = node.dataset.stickerEmoji;
|
||||||
|
@ -252,7 +256,8 @@ export default function getRichElementValue(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wasNodeEmpty && lines.length !== wasLinesLength) {
|
// can test on text with list (https://www.who.int/initiatives/sports-and-health)
|
||||||
|
if(wasNodeEmpty && node.textContent?.replace(/[\r\n]/g, '')) {
|
||||||
wasNodeEmpty = false;
|
wasNodeEmpty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,9 +278,7 @@ export default function getRichElementValue(
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isBlock && !wasNodeEmpty) {
|
if(isBlock && !wasNodeEmpty) {
|
||||||
lines.push(line.join(''));
|
pushLine();
|
||||||
line.length = 0;
|
|
||||||
++offset.offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wasNodeEmpty && node.tagName === 'P' && node.nextSibling) {
|
if(!wasNodeEmpty && node.tagName === 'P' && node.nextSibling) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user