Skip to content

Commit

Permalink
Fix bug #72177
Browse files Browse the repository at this point in the history
Fix applying text/para properties when binding content to a content control
  • Loading branch information
KirillovIlya committed Feb 4, 2025
1 parent 0f4eeed commit 805ae69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions word/Editor/Paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion word/Editor/StructuredDocumentTags/BlockLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 805ae69

Please sign in to comment.