Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barisbikmaz/2e12f8c9f6284cb8890a0c73d606d80d to your computer and use it in GitHub Desktop.
Save barisbikmaz/2e12f8c9f6284cb8890a0c73d606d80d to your computer and use it in GitHub Desktop.
name: Style Ignored in Word Online (2)
description: ''
host: WORD
api_set: {}
script:
content: "$(\"#run\").click(() => tryCatch(run));\n\nasync function run() {\n await Word.run(async (context) => {\n const range = context.document.getSelection();\n range.insertHtml(html, \"Replace\");\n await context.sync();\n });\n}\n\n/** Default helper for invoking an action and handling errors. */\nasync function tryCatch(callback) {\n try {\n await callback();\n } catch (error) {\n // Note: In a production add-in, you'd want to notify the user through your add-in's UI.\n console.error(error);\n }\n}\n\nconst html = `<html>\n\t<body>\n <div>\n <h1>This line has Heading 1 style</h1>\n <p class=MsoTitle>This line has Title style</p>\n <p>&nbsp;</p>\n </div>\n\t</body>\n</html>`;"
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
name: Style Ignored in Word Online
description: ''
host: WORD
api_set: {}
script:
content: "$(\"#run\").click(() => tryCatch(run));\n\nasync function run() {\n await Word.run(async (context) => {\n const range = context.document.getSelection();\n range.insertHtml(html, \"Replace\");\n await context.sync();\n });\n}\n\n/** Default helper for invoking an action and handling errors. */\nasync function tryCatch(callback) {\n try {\n await callback();\n } catch (error) {\n // Note: In a production add-in, you'd want to notify the user through your add-in's UI.\n console.error(error);\n }\n}\n\n\nconst html =`<html>\n\t<body>\n\t\t<div>\n\t\t\t<p class=MsoTitle>This line should be formatted with the MsoTitle style</p>\n\t\t\t<p class=MsoNormal>&nbsp;</p>\n\t\t</div>\n\t</body>\n</html>`"
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