Hello Team,
I am using Word API for developing word add-in.
My Environment
Platform : PC desktop
Host: Word
Office version number: Microsoft® Word for Microsoft 365 MSO (Version 2308 Build 16.0.16731.20182) 64-bit
Operating System: Windows 10 pro
Snippet :
Word.run(async (context) => {
var range = context.document.getSelection();
range.load("text");
await context.sync();
var ctrl = range.insertContentControl();
ctrl.tag ="tempId";
ctrl.load();
await context.sync();
});
When using the provided code snippet to insert content controls into a document, it appears to work correctly in most cases. However, there is an issue with certain paragraphs where selecting the entire paragraph and inserting a content control results in the control being applied only to a specific line within the paragraph, rather than the entire paragraph. How can i resolve this issue ?
Screen short for selected paragraph range:
Paragraph sample 1:

Paragraph sample 2:

Paragraph sample 3:

Word document sample:
document.xml
Note :please change above document extension xml to .docx for word document.
To Reproduce steps:
- Select specified the paragraphs
- Insert content control with above snippet
Could you please provide me with recommendations or solutions for this matter at your earliest convenience?
Thank you...