Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Mar 7, 2024
1 parent 78f8906 commit f1f4c74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/word-plugin/src/taskpane/taskpane.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ <h2 class="ms-font-xl">Please <a target="_blank" href="https://learn.microsoft.c
</div>

<div style="display: block; margin-top: 30px;">
<span role="button" id="runDemo" class="ms-Button ms-Button--hero ms-font-xl">
<span class="ms-Button-label" style="background-color: rgb(187, 102, 32); color: #fff; padding: 14px;">Demo</span>
</span>

<span role="button" id="run1" class="ms-Button ms-Button--hero ms-font-xl">
<span class="ms-Button-label" style="background-color: rgb(0, 69, 160); color: #fff; padding: 20px;">Run V1</span>
<span class="ms-Button-label" style="background-color: rgb(0, 69, 160); color: #fff; padding: 14px;">Run V1</span>
</span>

<span role="button" id="run2" class="ms-Button ms-Button--hero ms-font-xl">
<span class="ms-Button-label" style="background-color: rgb(0, 153, 64); color: #fff; padding: 20px;">Run V2</span>
<span class="ms-Button-label" style="background-color: rgb(0, 153, 64); color: #fff; padding: 14px;">Run V2</span>
</span>
</div>

Expand Down
23 changes: 20 additions & 3 deletions src/word-plugin/src/taskpane/taskpane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,27 @@ Office.onReady((info) => {
console.log(`AddIn - V${addinVersion}`);
document.getElementById("sideload-msg").style.display = "none";
document.getElementById("app-body").style.display = "flex";
document.getElementById("runDemo").onclick = insertTextIntoRange;
document.getElementById("run1").onclick = run1;
document.getElementById("run2").onclick = run2;
}
});

export async function insertTextIntoRange() {
await Word.run(async (context) => {
const doc = context.document;
const originalRange = doc.getSelection();
originalRange.insertText(" (M365)", Word.InsertLocation.end);

originalRange.load("text");
await context.sync();

doc.body.insertParagraph("Original range: " + originalRange.text, Word.InsertLocation.end);

await context.sync();
});
}

export async function run1() {
console.log(`Run V1 - (V${addinVersion})`);
return await Word.run(async (context) => {
Expand Down Expand Up @@ -137,9 +153,10 @@ export async function run2() {
const paragraphs = context.document.body.paragraphs;

// load text
//paragraphs.load("$all");
paragraphs.load(["text", "items"]);
await context.sync();
paragraphs.load("$all");
//paragraphs.load(["text", "items"]);
//await context.sync();
await paragraphs.context.sync();

document.getElementById("progressbar").style.width = "10%";

Expand Down

0 comments on commit f1f4c74

Please sign in to comment.