You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Logs the current change tracking states of the content controls.
61
+
await Word.run(async (context) => {
62
+
let trackAddedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.added];
63
+
let trackDeletedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.deleted];
64
+
let trackNormalArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.normal];
65
+
66
+
let addedContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackAddedArray);
67
+
let deletedContentControls = context.document.body
68
+
.getContentControls()
69
+
.getByChangeTrackingStates(trackDeletedArray);
70
+
let normalContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackNormalArray);
71
+
72
+
addedContentControls.load();
73
+
deletedContentControls.load();
74
+
normalContentControls.load();
75
+
await context.sync();
76
+
77
+
console.log(`Number of content controls in Added state: ${addedContentControls.items.length}`);
78
+
console.log(`Number of content controls in Deleted state: ${deletedContentControls.items.length}`);
79
+
console.log(`Number of content controls in Normal state: ${normalContentControls.items.length}`);
80
+
});
81
+
}
82
+
83
+
async function setup() {
84
+
// Adds 4 paragraphs then inserts content controls on the first three paragraphs.
85
+
await Word.run(async (context) => {
86
+
const body: Word.Body = context.document.body;
87
+
body.clear();
88
+
body.insertParagraph("One more paragraph.", "Start");
89
+
body.insertParagraph("Inserting another paragraph.", "Start");
90
+
body.insertParagraph(
91
+
"Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.",
92
+
"Start"
93
+
);
94
+
body.paragraphs
95
+
.getLast()
96
+
.insertText(
97
+
"Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.",
0 commit comments