Fix duplicated br tags (#2717)

* Adjust test to demo duplicated br tags

* Fix patchDocument duplicating br tags

* Only include w:Pr

* Fix tag condition

---------

Co-authored-by: Dolan <dolan_miu@hotmail.com>
This commit is contained in:
SebKranz
2024-11-20 12:19:25 +01:00
committed by GitHub
parent 7f3c5615c9
commit dece0f58e1
2 changed files with 9 additions and 1 deletions

View File

@ -62,6 +62,10 @@ export const MOCK_JSON = {
name: "w:t",
elements: [{ type: "text", text: "What a {{bold}} text!" }],
},
{
type: "element",
name: "w:br",
},
],
},
],
@ -176,6 +180,10 @@ describe("replacer", () => {
name: "w:t",
elements: [{ type: "text", text: " text!" }],
},
{
name: "w:br",
type: "element",
},
],
},
]);

View File

@ -64,7 +64,7 @@ export const replacer = ({
if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements!.filter(
(e) => e.type === "element" && e.name !== "w:t" && e.name !== "w:br" && e.name !== "w:tab",
(e) => e.type === "element" && e.name === "w:rPr",
);
newRunElements = textJson.map((e) => ({