Created
August 14, 2018 07:56
-
-
Save rvanlaak/1f06f8cc82d18d2e948110851522440d to your computer and use it in GitHub Desktop.
Shared with Script Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Blank snippet | |
description: '' | |
author: rvanlaak | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
await Word.run(async (context) => { | |
const range = context.document.getSelection(); | |
const ooxml = range.getOoxml(); | |
// Read the range text | |
range.load('text'); | |
await context.sync(); | |
range.insertOoxml(ooxml.value, 'Replace'); | |
return context.sync().then(function () { | |
console.dir('Comment was added to selected text.'); | |
}); | |
}); | |
} | |
/** Default helper for invoking an action and handling errors. */ | |
async function tryCatch(callback) { | |
try { | |
await callback(); | |
} | |
catch (error) { | |
OfficeHelpers.UI.notify(error); | |
OfficeHelpers.Utilities.log(error); | |
} | |
} | |
language: typescript | |
template: | |
content: | | |
<button id="run" class="ms-Button"> | |
<span class="ms-Button-label">Run</span> | |
</button> | |
language: html | |
style: | |
content: | | |
/* Your style goes here */ | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
@microsoft/[email protected]/dist/office.helpers.min.js | |
@microsoft/[email protected]/dist/office.helpers.d.ts | |
[email protected] | |
@types/jquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment