From 805ae69e42aaf2f9eeb295742d829bf33db6394b Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 4 Feb 2025 13:03:25 +0300 Subject: [PATCH] Fix bug #72177 Fix applying text/para properties when binding content to a content control --- word/Editor/Paragraph.js | 14 ++++++++++++++ word/Editor/StructuredDocumentTags/BlockLevel.js | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index 611ae34d92..557c0ea987 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -419,6 +419,20 @@ Paragraph.prototype.GetFirstRunPr = function() return this.Content[0].Pr.Copy(); }; +Paragraph.prototype.GetParaEndPr = function() +{ + return this.TextPr.Value.Copy(); +}; +Paragraph.prototype.SetParaEndPr = function(textPr) +{ + if (!textPr) + return; + + this.TextPr.Set_Value(textPr.Copy()); + let endRun = this.GetParaEndRun(); + if (endRun) + endRun.SetPr(textPr.Copy()); +}; Paragraph.prototype.Get_FirstTextPr = function() { if (this.Content.length <= 0 || para_Run !== this.Content[0].Type) diff --git a/word/Editor/StructuredDocumentTags/BlockLevel.js b/word/Editor/StructuredDocumentTags/BlockLevel.js index f3694b143d..a52199bffa 100644 --- a/word/Editor/StructuredDocumentTags/BlockLevel.js +++ b/word/Editor/StructuredDocumentTags/BlockLevel.js @@ -1585,12 +1585,19 @@ CBlockLevelSdt.prototype.GetInnerText = function() }; CBlockLevelSdt.prototype.SetInnerText = function(text) { - let textPr = this.GetFirstParagraph().GetFirstRunPr(); + let firstParagraph = this.GetFirstParagraph(); + + let textPr = firstParagraph.GetFirstRunPr(); + let endPr = firstParagraph.GetParaEndPr(); + let paraPr = firstParagraph.GetDirectParaPr(); + this.Content.ClearContent(false); let para = new AscWord.Paragraph(); let run = new AscWord.Run(); run.AddText(text); run.SetPr(textPr.Copy()); + para.SetDirectParaPr(paraPr); + para.SetParaEndPr(endPr); para.AddToContent(0, run); this.Content.AddToContent(0, para); };