You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-10 09:22:25 +03:00
remove all non-first-br nodes on new empty line, not just first one
nextSibling returned null after calling removeNode, so get the nextSibling first
This commit is contained in:
@@ -61,12 +61,13 @@ export function renderModel(editor, model) {
|
|||||||
let foundBR = false;
|
let foundBR = false;
|
||||||
let partNode = lineContainer.firstChild;
|
let partNode = lineContainer.firstChild;
|
||||||
while (partNode) {
|
while (partNode) {
|
||||||
|
const nextNode = partNode.nextSibling;
|
||||||
if (!foundBR && partNode.tagName === "BR") {
|
if (!foundBR && partNode.tagName === "BR") {
|
||||||
foundBR = true;
|
foundBR = true;
|
||||||
} else {
|
} else {
|
||||||
lineContainer.removeChild(partNode);
|
lineContainer.removeChild(partNode);
|
||||||
}
|
}
|
||||||
partNode = partNode.nextSibling;
|
partNode = nextNode;
|
||||||
}
|
}
|
||||||
if (!foundBR) {
|
if (!foundBR) {
|
||||||
lineContainer.appendChild(document.createElement("br"));
|
lineContainer.appendChild(document.createElement("br"));
|
||||||
|
|||||||
Reference in New Issue
Block a user