Skip to content

Commit

Permalink
add cyan sticker
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitzhermes committed Nov 16, 2023
1 parent cd454ad commit 0d7de4f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
2 changes: 0 additions & 2 deletions src/taskpane/base64image.ts

This file was deleted.

12 changes: 3 additions & 9 deletions src/taskpane/taskpane.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@
<img width="90" height="90" src="../../assets/logo-filled.png" alt="Contoso" title="Contoso" />
<h1 class="ms-font-su">Welcome</h1>
</header>
<main id="app-body" class="ms-welcome__main" style="display: none;">
<div class="padding">
<!-- TODO3: Create the insert-text button. -->
<!-- TODO4: Create the get-slide-metadata button. -->
<!-- TODO5: Create the add-slides and go-to-slide buttons. -->
</div>
</main>
<section id="display-msg" class="ms-welcome__main">
<div class="padding">
<h3>Message2</h3>
<h3>Sticker</h3>
<div id="message"></div>
<button class="ms-Button" id="insert-image">Insert Image</button><br/><br/>
<button class="ms-Button" id="yellow-sticker">Yellow</button><br/><br/>
<button class="ms-Button" id="cyan-sticker">Cyan</button><br/><br/>
</div>
</section>
</body>
Expand Down
24 changes: 4 additions & 20 deletions src/taskpane/taskpane.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { base64Image } from "./base64image";

/*
* Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
* See LICENSE in the project root for license information.
Expand All @@ -9,26 +7,12 @@ import { base64Image } from "./base64image";

Office.onReady((info) => {
if (info.host === Office.HostType.PowerPoint) {
document.getElementById("insert-image").onclick = run;
document.getElementById("yellow-sticker").onclick = () => insertSticker("yellow");
document.getElementById("cyan-sticker").onclick = () => insertSticker("#00ffff");
}
});

export async function insertImage() {
// Call Office.js to insert the image into the document.
Office.context.document.setSelectedDataAsync(
base64Image,
{
coercionType: Office.CoercionType.Image
},
(asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
//setMessage("Error: " + asyncResult.error.message);
}
}
);
}

export async function run() {
export async function insertSticker(color) {
await PowerPoint.run(async (context) => {

const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes
Expand All @@ -38,7 +22,7 @@ export async function run() {
textbox.height = 50;
textbox.width = 150;
textbox.name = "Square";
textbox.fill.setSolidColor("yellow")
textbox.fill.setSolidColor(color)
textbox.textFrame.textRange.font.bold = true
textbox.textFrame.textRange.font.name = "Arial"
textbox.textFrame.textRange.font.size = 12
Expand Down

0 comments on commit 0d7de4f

Please sign in to comment.