Created
August 3, 2022 06:29
-
-
Save xuruiyao-msft/fbd5098a66cdef1c1db21f75c0b4a271 to your computer and use it in GitHub Desktop.
Create a new snippet from a blank template.
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: FootEndNote | |
description: Create a new snippet from a blank template. | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
OfficeExtension.config.extendedErrorLogging = true; | |
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
await Word.run(async (context) => { | |
// const body = context.document.getFootnoteBody(); | |
// body.load(); | |
// await context.sync(); | |
const range = context.document.getSelection(); | |
// let footnote = range.insertFootnote("222"); | |
let endnote = range.insertEndnote("endnote"); | |
// footnote.load(); | |
endnote.load(); | |
await context.sync(); | |
// console.log("type: "+ footnote.type); | |
console.log("endnote type: "+ endnote.type); | |
let endnoteRange = endnote.body.getRange(); | |
endnoteRange.load(); | |
await context.sync(); | |
console.log("endnote body.range.text: " + endnoteRange.text); | |
let body = endnote.body; | |
body.load(); | |
await context.sync(); | |
// body.insertContentControl(); | |
await context.sync(); | |
console.log("body text: " + body.text); | |
// console.log("body type: " + body.type); | |
// // const body = context.document.body; | |
// // body.load(); | |
// // await context.sync(); | |
// const footnotes = body.footnotes; | |
// footnotes.load("item"); | |
// await context.sync(); | |
// console.log("footnotes length: " + footnotes.items.length); | |
// const footnote = footnotes.items[0]; | |
// footnote.load(); | |
// const ref = footnote.reference; | |
// ref.load(); | |
// await context.sync(); | |
// ref.select(); | |
// console.log("footnote reference text: " + ref.text); | |
// const fn = footnotes.items[0]; | |
// fn.load("type"); | |
// await context.sync(); | |
// console.log("footnote type: "+ fn.type); | |
// const comments = context.document.body.getComments(); | |
// comments.load(); | |
// await context.sync(); | |
// console.log("comments length: " + comments.items.length); | |
// const comment = comments.items[0]; | |
// comment.load(); | |
// await context.sync(); | |
// console.log("comment type: " + comment.creationDate); | |
// const sections = context.document.sections; | |
// sections.load(); | |
// await context.sync(); | |
// console.log("section 1: "+ sections.items[0]); | |
// console.log("section 2: "+ sections.items[1]); | |
}); | |
} | |
/** Default helper for invoking an action and handling errors. */ | |
async function tryCatch(callback) { | |
try { | |
await callback(); | |
} catch (error) { | |
// Note: In a production add-in, you'd want to notify the user through your add-in's UI. | |
console.error(error); | |
} | |
} | |
language: typescript | |
template: | |
content: | | |
<button id="run" class="ms-Button"> | |
<span class="ms-Button-label">Run</span> | |
</button> | |
language: html | |
style: | |
content: |- | |
section.samples { | |
margin-top: 20px; | |
} | |
section.samples .ms-Button, section.setup .ms-Button { | |
display: block; | |
margin-bottom: 5px; | |
margin-left: 20px; | |
min-width: 80px; | |
} | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css | |
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css | |
core-js@2.4.1/client/core.min.js | |
@types/core-js | |
jquery@3.1.1 | |
@types/jquery@3.3.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment