Created
September 9, 2021 18:42
-
-
Save ErickPetru/645bb6ed03de45e9cf49b4b328204bec to your computer and use it in GitHub Desktop.
Exibe dinamicamente uma lista de meses para seleção, e mostra o item selecionado no documento Word aberto.
This file contains hidden or 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: Lista de Meses usando Array | |
description: >- | |
Exibe dinamicamente uma lista de meses para seleção, e mostra o item | |
selecionado no documento Word aberto. | |
host: WORD | |
api_set: {} | |
script: | |
content: "const selector = document.getElementById(\"selector\") as HTMLSelectElement;\r\n\r\nconst months = [\r\n \"Janeiro\",\r\n \"Fevereiro\",\r\n \"Março\",\r\n \"Abril\",\r\n \"Maio\",\r\n \"Junho\",\r\n \"Julho\",\r\n \"Agosto\",\r\n \"Setembro\",\r\n \"Outubro\",\r\n \"Novembro\",\r\n \"Dezembro\"\r\n];\r\n\r\nselector.innerHTML = \"<option></option>\";\r\n\r\nfor (let month of months) {\r\n selector.innerHTML += `<option>${month}</option>`;\r\n}\r\n\r\nselector.addEventListener(\"change\", () => {\r\n Word.run(async (context) => {\r\n const body = context.document.body;\r\n body.clear();\r\n\r\n if (selector.value) {\r\n body.insertText(`O mês selecionado foi: ${selector.value}.`, \"Start\");\r\n }\r\n });\r\n});\r\n" | |
language: typescript | |
template: | |
content: "<span>Qual seu mês preferido?</span>\r\n<select id=\"selector\"></select>" | |
language: html | |
style: | |
content: '' | |
language: css | |
libraries: |- | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/client/core.min.js | |
@types/core-js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment