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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | |
<title>file picker</title> | |
<style> | |
html, | |
body { |
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: Style API - Removing Style | |
description: '' | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
/** | |
* USE CASE: | |
* Removing Style from the current document | |
* |
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: Styles API - Replacing Style | |
description: Example to replace the style in the current document | |
host: WORD | |
api_set: {} | |
script: | |
content: "/**\n * USE CASE:\n * We want to replace a style in the current document with the styles from a base64 docx\n *\n * ISSUES:\n * Replacing a style is nearly not possible because:\n * - When setting some properties like font.color the API throws\n * - You cannot set deeper object properties partially like font.color. You must set the whole object.\n * - Problems loading the font property of a style\n */\n$(\"#replace-style\").click(() => tryCatch(replaceStyle));\n$(\"#apply-style\").click(() => tryCatch(applyStyle));\n\nfunction sourceDocumentStyleName() {\n return $(\"input[name=sourceStyleName]\").val() as string;\n}\n\nfunction targetDocumentStyleName() {\n return $(\"input[name=targetStyleName]\").val() as string;\n}\n\nasync function replaceStyle() {\n const styleName = targetDocumentStyleName();\n const styleNameInSource = sourceDocumentStyleName();\n\n |
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: Styles API - Adding Style | |
description: Adds a style from a source document into the current document | |
host: WORD | |
api_set: {} | |
script: | |
content: "/**\n * USE CASE:\n * We want to add a style from a base64 docx document into the current document\n *\n * ISSUES:\n * - retrieveStylesFromBase64 returns a JSON with UpperCase properties but when settings styles we need lowerCase\n * - setting a style property with null causes errors\n * - settings the font propery often errors\n * - retrieveStylesFromBase64 sometime returns font property with null objects\n */\n\n$(\"#add-style\").click(() => tryCatch(addStyle));\n\nfunction sourceDocumentStyleName() {\n return $(\"input[name=sourceStyleName]\").val() as string;\n}\n\nfunction targetDocumentStyleName() {\n return $(\"input[name=targetStyleName]\").val() as string;\n}\n\nasync function addStyle() {\n const styleToApplyNameLocal = sourceDocumentStyleName();\n\n console.log(`⚙️ Searching for style ${styleToApplyNameLocal} in source document...`);\n\n const st |
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: Preview Styles API Experiment | |
description: '' | |
host: WORD | |
api_set: {} | |
script: | |
content: "$(\"#get-styles-from-base64-document\").click(() => tryCatch(logBase64DocumentStyles));\n$(\"#get-styles-from-current-document\").click(() => tryCatch(logCurrentDocumentStyles));\n$(\"#update-style\").click(() => tryCatch(updateStyle));\n$(\"#add-style\").click(() => tryCatch(addStyle));\n$(\"#remove-style\").click(() => tryCatch(removeStyle));\n$(\"#replace-style\").click(() => tryCatch(replaceStyle));\n\n// PROBLEM: You cannot add style names with spaces or dots\n// const styleName = \"ofaw\";\n// const styleToApplyNameLocal = \"ofaw.styles.1\";\n\n// #region -- LOGGING STYLES INTO CONSOLE --\nasync function logBase64DocumentStyles() {\n const styles = await loadBase64DocumentStyles();\n console.log(styles);\n}\n\nasync function logCurrentDocumentStyles() {\n await Word.run(async (context) => {\n const styles = context.document.getStyles();\n styles.load();\n await context.sync();\n\n console.log(st |
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: ooxml of Content Control with Image Bug | |
description: >- | |
Insert a content control with an image. Then reads the ooxml of the content | |
control | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(() => tryCatch(setup)); | |
$("#get-ooxml").click(() => tryCatch(getOoxml)); |
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: Child Content Control ooxml bug | |
description: >- | |
Creates a content control with a child content control. When you try to get | |
the ooxml of the content control, the child content control is ignored. | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(() => tryCatch(setup)); | |
$("#get-ooxml").click(() => tryCatch(getOoxml)); |
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: 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> </p>\n </div>\n\t</body>\n</html>`;" | |
language: typescript | |
template: | |
content: | | |
<button id="run" class="ms-Button"> |
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: Coop UI Performance Test | |
description: '' | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
$("#insert-html").on("input", function() { | |
insertHtmlIntoCCs((this as HTMLInputElement).value); | |
}); |
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: Insert Docx Resets Content Control | |
description: To demonstrate reset behaviour in Word Onlie | |
host: WORD | |
api_set: {} | |
script: | |
content: > | |
// Preparation | |
// Create a blank document in Word in Windows |
NewerOlder