diff --git a/.github/images/chili-peppers.jpg b/.github/images/chili-peppers.jpg new file mode 100644 index 000000000..4645d4e04 Binary files /dev/null and b/.github/images/chili-peppers.jpg differ diff --git a/.github/images/crustacean.jpg b/.github/images/crustacean.jpg new file mode 100644 index 000000000..121835e5a Binary files /dev/null and b/.github/images/crustacean.jpg differ diff --git a/.github/images/dried-legume.jpg b/.github/images/dried-legume.jpg new file mode 100644 index 000000000..9e2889b05 Binary files /dev/null and b/.github/images/dried-legume.jpg differ diff --git a/.github/images/fruit.jpg b/.github/images/fruit.jpg new file mode 100644 index 000000000..a487e83b5 Binary files /dev/null and b/.github/images/fruit.jpg differ diff --git a/.github/images/green-leaf.jpg b/.github/images/green-leaf.jpg new file mode 100644 index 000000000..0b96fbfcf Binary files /dev/null and b/.github/images/green-leaf.jpg differ diff --git a/.github/images/microsoft-logo.png b/.github/images/microsoft-logo.png new file mode 100644 index 000000000..06600fee7 Binary files /dev/null and b/.github/images/microsoft-logo.png differ diff --git a/.github/images/msn-logo.png b/.github/images/msn-logo.png new file mode 100644 index 000000000..87619f937 Binary files /dev/null and b/.github/images/msn-logo.png differ diff --git a/.github/images/xbox-logo.png b/.github/images/xbox-logo.png new file mode 100644 index 000000000..fbe7abfad Binary files /dev/null and b/.github/images/xbox-logo.png differ diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml new file mode 100644 index 000000000..4cacb51af --- /dev/null +++ b/.github/policies/resourceManagement.yml @@ -0,0 +1,155 @@ +id: +name: GitOps.PullRequestIssueManagement +description: GitOps.PullRequestIssueManagement primitive +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: + frequencies: + - hourly: + hour: 3 + filters: + - isIssue + - isOpen + - hasLabel: + label: 'Needs: author feedback' + - noActivitySince: + days: 4 + - isNotLabeledWith: + label: 'Status: no recent activity' + actions: + - addLabel: + label: 'Status: no recent activity' + - addReply: + reply: This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**. Thank you for your interest in Office Add-ins! + - description: + frequencies: + - hourly: + hour: 3 + filters: + - isIssue + - isOpen + - hasLabel: + label: 'Needs: author feedback' + - hasLabel: + label: 'Status: no recent activity' + - noActivitySince: + days: 3 + actions: + - addReply: + reply: This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue. + - closeIssue + - description: + frequencies: + - hourly: + hour: 3 + filters: + - isIssue + - isOpen + - hasLabel: + label: 'Type: programming question' + actions: + - addReply: + reply: Thanks for your interest in Office Add-ins development! Feedback here is intended for reporting problems with Script Lab *snippets*. Can you please post your question to Stack Overflow with the [office-js](https://stackoverflow.com/questions/tagged/office-js) tag? By posting how-to questions like this to Stack Overflow, you'll not only be able to reach a broader audience of folks who have expertise in the area, but will also enable others to benefit from any answers that are provided there. Thanks! + - closeIssue + - description: + frequencies: + - hourly: + hour: 3 + filters: + - isIssue + - isOpen + - hasLabel: + label: 'Type: product feature request' + actions: + - addReply: + reply: Thanks for your interest in Office Add-ins development! Feedback here is intended for reporting problems with Script Lab *snippets*. Can you please post this feature request to the [Microsoft 365 Developer Platform Tech Community](https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform)? Feature Requests submitted to Tech Community are regularly reviewed by the product teams as they plan future releases. Thanks! + - closeIssue + eventResponderTasks: + - if: + - payloadType: Issues + - isAction: + action: Opened + - not: isAssignedToSomeone + then: + - addLabel: + label: 'Needs: triage :mag:' + description: + - if: + - payloadType: Issues + - not: + isAction: + action: Closed + - hasLabel: + label: 'Status: no recent activity' + then: + - removeLabel: + label: 'Status: no recent activity' + description: + - if: + - payloadType: Issue_Comment + - hasLabel: + label: 'Status: no recent activity' + then: + - removeLabel: + label: 'Status: no recent activity' + description: + - if: + - payloadType: Issue_Comment + - isAction: + action: Created + - isActivitySender: + issueAuthor: True + - hasLabel: + label: 'Needs: author feedback' + then: + - addLabel: + label: 'Needs: attention :wave:' + - removeLabel: + label: 'Needs: author feedback' + description: + - if: + - payloadType: Pull_Request + then: + - inPrLabel: + label: 'Status: in PR' + description: + - if: + - payloadType: Issues + - labelAdded: + label: 'Status: in PR' + - hasLabel: + label: 'Status: under investigation' + then: + - removeLabel: + label: 'Status: under investigation' + description: + triggerOnOwnActions: true + - if: + - payloadType: Issues + - labelAdded: + label: 'Status: in PR' + - hasLabel: + label: 'Status: in backlog' + then: + - removeLabel: + label: 'Status: in backlog' + description: + triggerOnOwnActions: true + - if: + - payloadType: Issues + - labelAdded: + label: 'Status: in PR' + - hasLabel: + label: 'Needs: attention :wave:' + then: + - removeLabel: + label: 'Needs: attention :wave:' + description: + triggerOnOwnActions: true +onFailure: +onSuccess: diff --git a/.github/workflows/auto-publish.yml b/.github/workflows/auto-publish.yml new file mode 100644 index 000000000..72a284cc6 --- /dev/null +++ b/.github/workflows/auto-publish.yml @@ -0,0 +1,39 @@ +name: auto-publish +run-name: Automatically publish snippets +on: + schedule: + - cron: '15 10 * * TUE' + - cron: '15 10 * * THU' +jobs: + auto-publish: + runs-on: ubuntu-latest + permissions: + contents: write + defaults: + run: + shell: bash + working-directory: ./ + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check out main + run: | + echo "Checking out main branch" + git config user.name github-actions + git config user.email github-actions@github.com + git checkout main + - name: Check out prod + run: | + echo "Checking out prod branch" + git checkout prod + - name: Merge from main into prod + run: | + echo "Merging from main to prod" + git merge main + - name: Push changes + run: | + echo "Pushing changes to prod branch" + git push origin prod + diff --git a/.gitignore b/.gitignore index a133b9391..2d2f29ea5 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ npm-debug.log* ~$* # Used to ignore "playlists", but having those checked-in for diffing purposes is very useful, so undoing the ignore: -# playlists/** \ No newline at end of file +# playlists/** + +package-lock.json \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bddd72420..000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: node_js - -cache: - directories: - - node_modules - -git: - depth: 3 - -node_js: -- 6.10.0 - -before_install: -- npm i -g npm@6.14.6 - -install: -- npm install - -before_script: -- npm run lint -- npm run tsc - -script: -- npm run build -- npm run deploy - -notifications: - webhooks: - urls: - - https://outlook.office.com/webhook/cd954b0a-08e5-4935-933b-a1cda4e6d5e9@72f988bf-86f1-41af-91ab-2d7cd011db47/TravisCI/c7d4bdd9ff6d4f2e8bce8919d416a064/5bf9ad7e-4cad-45e8-9812-e553da1c05c6 - on_success: change - on_failure: always - on_start: change \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 21798b350..e414c1f67 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,7 +23,7 @@ // "outFiles": [], // "env": { // "TRAVIS": "true", - // "TRAVIS_BRANCH": "master", + // "TRAVIS_BRANCH": "main", // "TRAVIS_PULL_REQUEST": "false", // "TRAVIS_COMMIT_MESSAGE": "Deploy", // "GH_ACCOUNT": "OfficeDev", diff --git a/.yarnrc b/.yarnrc deleted file mode 100644 index efdac8b82..000000000 --- a/.yarnrc +++ /dev/null @@ -1 +0,0 @@ ---install.frozen-lockfile true \ No newline at end of file diff --git a/README.md b/README.md index 5e731800e..0fe20ada1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Build Status](https://travis-ci.org/OfficeDev/office-js-snippets.svg?branch=master)](https://travis-ci.org/OfficeDev/office-js-snippets) - # Office JS Snippets A collection of code snippets built with [Script Lab](//github.com/OfficeDev/script-lab) @@ -13,92 +11,91 @@ A collection of code snippets built with [Script Lab](//github.com/OfficeDev/scr ### One-time tasks 1. [Fork](https://help.github.com/articles/about-forks/) this project into your GitHub account. -2. Clone your fork to your development computer. -3. Ensure that you have Node, version 6.10+, installed. (To check the version run the command `node -v`.) -4. Install `yarn` as a global package `npm install yarn --global`. -5. Be sure your CLI is in the root of the office-js-snippets repo and run `yarn install`. (It is similar to `npm install`.) -6. Set up the original \OfficeDev\office-js-snippets as the upstream repo for your local repo by following the steps in [Configuring a remote for a fork](https://help.github.com/articles/configuring-a-remote-for-a-fork/). -7. If you'll be using Visual Studio Code as your editor, install the [TSLint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) extension for Visual Studio Code. +1. Clone your fork to your development computer. +1. Ensure that you have Node, version 6.10+, installed. (To check the version run the command `node -v`.) +1. Be sure your CLI is in the root of the office-js-snippets repo and run `npm install` to install all dependencies. +1. Set up the original \OfficeDev\office-js-snippets as the upstream repo for your local repo by following the steps in [Configuring a remote for a fork](https://help.github.com/articles/configuring-a-remote-for-a-fork/). +1. If you'll be using Visual Studio Code as your editor, install the [TSLint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) extension for Visual Studio Code. ### Adding a new sample > For the git tasks in this procedure, the instructions assume that you're using a CLI. You are welcome to use a GUI git client. Consult the client's help to learn how to carry out the same tasks. -1. Create a snippet using [Script Lab](https://github.com/OfficeDev/script-lab/blob/master/README.md#what-is). Ensure that the name and description are what you want to be shown publicly. Use standard TypeScript indentation. Improper indentation can cause a failure of the build that you run in a later step. See also the [**Style guidelines**](#style-guidelines) section below. -2. Choose the Share icon, and then choose **Copy to Clipboard**. -3. Paste the contents into a text editor. -4. Near the top of the file, you will see the line `api_set: {}`. This needs to be changed to specify the host API version of the most recently added API that is used in your snippet. For example, if the snippet is for Excel and it uses some APIs that were introduced in Excel API 1.3, some in 1.4, and some in 1.5, then you need to specify `ExcelApi 1.5` as the value of the `api_set` property. Put a line break and four spaces before the value and no {} characters. To continue the example, when you're done the property would look like this: +1. Create a snippet using [Script Lab](https://github.com/OfficeDev/script-lab/blob/master/README.md#what-is). Ensure that the name and description are what you want to be shown publicly. Make sure to keep your snippet small. Use standard TypeScript indentation. Improper indentation can cause a failure of the build that you run in a later step. See also the [**Style guidelines**](#style-guidelines) and [**Size restrictions**](#size-restrictions) sections below. +1. Choose the Share icon, and then choose **Copy to Clipboard**. +1. Paste the contents into a text editor. +1. Near the top of the file, you will see the line `api_set: {}`. This needs to be changed to specify the host API version of the most recently added API that is used in your snippet. For example, if the snippet is for Excel and it uses some APIs that were introduced in Excel API 1.3, some in 1.4, and some in 1.5, then you need to specify `ExcelApi 1.5` as the value of the `api_set` property. Put a line break and four spaces before the value and no {} characters. To continue the example, when you're done the property would look like this: ```yaml api_set: ExcelApi: '1.5' ``` -5. Check the name and description property values, also near the top of the file, and edit as needed. -6. Save the file **somewhere outside of the office-js-snippets project**. (You will move it into the project in a later step.) The file name must have a ".yaml" extension and it must be in [`kebab-case`](http://wiki.c2.com/?KebabCase). For examples, see the existing *.yaml files in the subfolders of the `samples` folder of the project. -7. Make sure the master branch of your fork is in sync with the master branch of the upstream \OfficeDev\office-js-snippets repo by following the steps in [Syncing a fork](https://help.github.com/articles/syncing-a-fork/). -8. Create a new branch at the **office-js-snippets** root folder of your local repo by running the command `git checkout -b {name_of_your_new_branch}`. (This will create and checkout the new branch. *Stay in this branch for all the remaining steps.*) Each snippet should have its own branch. Suggestion: use the name of the yaml file that you created above (without the extension) as the branch name. -9. Decide the folder where your snippet should be added. All snippet files must reside within the appropriate subfolder inside the `samples` folder. Within the `samples` folder, the structure of subfolders is as follows: +1. Check the name and description property values, also near the top of the file, and edit as needed. +1. Save the file **somewhere outside of the office-js-snippets project**. (You will move it into the project in a later step.) The file name must have a ".yaml" extension and it must be in [`kebab-case`](http://wiki.c2.com/?KebabCase). For examples, see the existing *.yaml files in the subfolders of the `samples` folder of the project. +1. Make sure the main branch of your fork is in sync with the main branch of the upstream \OfficeDev\office-js-snippets repo by following the steps in [Syncing a fork](https://help.github.com/articles/syncing-a-fork/). +1. Create a new branch at the **office-js-snippets** root folder of your local repo by running the command `git checkout -b {name_of_your_new_branch}`. (This will create and checkout the new branch. *Stay in this branch for all the remaining steps.*) Each snippet should have its own branch. Suggestion: use the name of the yaml file that you created above (without the extension) as the branch name. +1. Decide the folder where your snippet should be added. All snippet files must reside within the appropriate subfolder inside the `samples` folder. Within the `samples` folder, the structure of subfolders is as follows: - - The base folders such as `excel`, `word`, etc. primarily represent the various host applications. - - Within each base folder, group folders organize snippets into various categories. - - Within each group folder, each .yaml file represents a snippet. + - The base folders such as `excel`, `word`, etc. primarily represent the various host applications. + - Within each base folder, group folders organize snippets into various categories. + - Within each group folder, each .yaml file represents a snippet. - > **Note**: If your snippet doesn't fit with any existing group folder, create a new group folder inside the base folder. If the existing folders in the base folder begin with numbers, such as `03-range`, then your new folder should also begin with a number. Since the numbers determine the sequence of the groups in Script Lab, use a number between the numbers of the groups between which you want the new folder to appear. + > **Note**: If your snippet doesn't fit with any existing group folder, create a new group folder inside the base folder. If the existing folders in the base folder begin with numbers, such as `03-range`, then your new folder should also begin with a number. Since the numbers determine the sequence of the groups in Script Lab, use a number between the numbers of the groups between which you want the new folder to appear. -10. Open one of the `.yaml` files already in the group folder. If it has an `order` property near the top, then the snippets in the group folder are ordered in a particular sequence in Script Lab. Add an `order` property to the top of your `.yaml` file and give it a number that is between the order numbers of the snippets between which you want it to appear. -11. Copy your `.yaml` file to the chosen group folder. -12. Run `yarn start`. If there are no problems, the output will end with a `Done!`. If there are errors, review the output to check what caused the build validation to fail, and fix as needed. See [**Known errors and fixes**](#known-errors-and-fixes-in-the-build-tool) for more information. +1. Open one of the `.yaml` files already in the group folder. If it has an `order` property near the top, then the snippets in the group folder are ordered in a particular sequence in Script Lab. Add an `order` property to the top of your `.yaml` file and give it a number that is between the order numbers of the snippets between which you want it to appear. +1. Copy your `.yaml` file to the chosen group folder. +1. Run `npm start`. If there are no problems, the output will end with a `Done!`. If there are errors, review the output to check what caused the build validation to fail, and fix as needed. See [**Known errors and fixes**](#known-errors-and-fixes-in-the-build-tool) for more information. - > **Note**: The `yarn start` command adds an `id` property to the top of the file. + > **Note**: The `npm start` command adds an `id` property to the top of the file. -13. Re-run `yarn start`, and fix errors, until the build succeeds. -14. Run `git status`. You should see that, in addition to your new `.yaml` file (or possibly new folder), a `playlist\{host}.yaml` file (where `{host}` is `excel`, `word`, etc.) has also been changed. This is expected. The build tool you just ran added a reference to your new snippet to this file. -15. Run the following two commands. The commit message should be a brief description of what the snippet demonstrates; for example, `"shows how to use getWhatever method"`. +1. Re-run `npm start`, and fix errors, until the build succeeds. +1. Run `git status`. You should see that, in addition to your new `.yaml` file (or possibly new folder), a `playlist\{host}.yaml` file (where `{host}` is `excel`, `word`, etc.) has also been changed. This is expected. The build tool you just ran added a reference to your new snippet to this file. +1. Run the following two commands. The commit message should be a brief description of what the snippet demonstrates; for example, `"shows how to use getWhatever method"`. ``` git add -A git commit -m "{commit message}" ``` -16. Push the snippet to your fork by running: +1. Push the snippet to your fork by running: ``` git push --set-upstream origin {name_of_your_new_branch} ``` -17. You now create a [pull request](https://help.github.com/articles/about-pull-requests/). In your fork on GitHub, *switch to your new branch*. -18. Choose **New pull request**. -19. On the **Open a pull request** page, verify that: +1. You now create a [pull request](https://help.github.com/articles/about-pull-requests/). In your fork on GitHub, *switch to your new branch*. +1. Choose **New pull request**. +1. On the **Open a pull request** page, verify that: - - the base fork is `OfficeDev/office-js-snippets` - - the base branch is `master` - - the head fork is `{your-GitHub-account}/office-js-snippets` - - the "compare" branch is `{name_of_your_new_branch}`. + - the base fork is `OfficeDev/office-js-snippets` + - the base branch is `main` + - the head fork is `{your-GitHub-account}/office-js-snippets` + - the "compare" branch is `{name_of_your_new_branch}`. -20. The title of the pull request defaults to your commit message. Change it as needed and optionally add a comment to provide additional information about the pull request to the reviewers. -21. All pull requests to office-js-snippets must be approved by at least one reviewer. On the right side of the page is a **Reviewers** section. You can optionally suggest one or more people to review the pull request. (GitHub sometimes lists one or more admins of the repo by default, but it is not consistent in doing this.) Your pull request will be reviewed even if you don't suggest anyone. -22. Choose **Create pull request**. The page for your pull request will open. There will initially be a message on the page saying **Some checks haven’t completed yet**. An online version of the same build tool that you ran locally is testing the files again. It usually takes a few minutes. +1. The title of the pull request defaults to your commit message. Change it as needed and optionally add a comment to provide additional information about the pull request to the reviewers. +1. All pull requests to office-js-snippets must be approved by at least one reviewer. On the right side of the page is a **Reviewers** section. You can optionally suggest one or more people to review the pull request. (GitHub sometimes lists one or more admins of the repo by default, but it is not consistent in doing this.) Your pull request will be reviewed even if you don't suggest anyone. +1. Choose **Create pull request**. The page for your pull request will open. There will initially be a message on the page saying **Some checks haven’t completed yet**. An online version of the same build tool that you ran locally is testing the files again. It usually takes a few minutes. - > **Note**: Since your pull request passed locally, it should pass the online test too. Once in a while, the online test fails when the local test passed. This is usually a bug in the online test service. If this happens, cancel the pull request, wait a few hours, and then repeat the steps for creating a pull request. + > **Note**: Since your pull request passed locally, it should pass the online test too. Once in a while, the online test fails when the local test passed. This is usually a bug in the online test service. If this happens, cancel the pull request, wait a few hours, and then repeat the steps for creating a pull request. -23. The reviewers may make comments on your pull request and ask you to make changes. Make changes in Script Lab and then repeat the process of creating the `.yaml` file. You do not have to create the new branch again, but make sure it is checked out when you copy the changed `.yaml` file over the previous version. After you commit and push the changed version to your fork, the new version is automatically added to your existing pull request. *Do **not** create a new pull request.* -24. When the reviewers are satisfied, your pull request will be merged to the `master` branch and the pull request will be closed. +1. The reviewers may make comments on your pull request and ask you to make changes. Make changes in Script Lab and then repeat the process of creating the `.yaml` file. You do not have to create the new branch again, but make sure it is checked out when you copy the changed `.yaml` file over the previous version. After you commit and push the changed version to your fork, the new version is automatically added to your existing pull request. *Do **not** create a new pull request.* +1. When the reviewers are satisfied, your pull request will be merged to the `main` branch and the pull request will be closed. - > **Note**: In a few days, the repo admins will merge your snippet into the `prod` branch. It will then appear in **Samples** area of Script Lab. (It is in the **My Snippets** area as soon as you create it.) + > **Note**: In a few days, the repo admins will merge your snippet into the `prod` branch. It will then appear in **Samples** area of Script Lab. (It is in the **My Snippets** area as soon as you create it.) -25. Optionally, you can delete the branch you created from your fork and/or your local clone. +1. Optionally, you can delete the branch you created from your fork and/or your local clone. #### Known errors and fixes in the build tool - An error saying that `name` has upper-case letters or other disallowed characters is *not* referring to the `name` property in the file. It is referring to the file name itself. You'll also get this error, if the file extension is not `.yaml`. -## Style guidelines: +## Style guidelines Basic snippet structure is as follows: ```ts -$("#run").click(() => tryCatch(run)); +$("#run").on("click", () => tryCatch(run)); async function run() { await Word.run(async (context) => { @@ -123,19 +120,35 @@ async function tryCatch(callback) { A few style rules to observe: -* Use standard TypeScript indentation. -* For each button, define a corresponding `async` function to be run when the button is clicked. The `async` function can be called "run" if there is only one button on the page -- otherwise, name it as you will. -* Each button-click handler should invoke the `tryCatch` function, passing in the name of the `async` function to be executed when the button is clicked. -* All HTML IDs should be `all-lower-case-and-hyphenated`. -* Unless you are explicitly showing pretty UI, you don't have to do the popup notification except for one or two samples. It's a lot of HTML & JS code, and also not strictly Fabric-y (there is a more "correct" way of doing this with components). -* Strings should be in double-quotes. -* Don't forget the semicolons. -* `Libraries` in snippets must have a specific version. Eg. `jquery@3.1.1`. +- Use standard TypeScript indentation. +- For each button, define a corresponding `async` function to be run when the button is clicked. The `async` function can be called "run" if there is only one button on the page -- otherwise, name it as you will. +- Each button-click handler should invoke the `tryCatch` function, passing in the name of the `async` function to be executed when the button is clicked. +- All HTML IDs should be `all-lower-case-and-hyphenated`. +- Unless you are explicitly showing pretty UI, you don't have to do the popup notification except for one or two samples. It's a lot of HTML & JS code, and also not strictly Fabric-y (there is a more "correct" way of doing this with components). +- Strings should be in double-quotes. +- Don't forget the semicolons. +- `Libraries` in snippets must have a specific version. Eg. `jquery@3.1.1`. + +## Size restrictions + +Script Lab is designed for you to play with small code samples. Generally, a snippet should be at most a few hundred lines and a few thousand characters. + +Your snippet can use hard-coded data. A small amount of data (say, a few hundred characters) is OK to hard code in Script Lab. However, for larger pieces of data, we recommend that you store those externally then load them at runtime with a command like `fetch`. + +Keep your snippets and hard-coded data small since storing several large snippets could exceed Script Lab's storage and cause issues when loading Script Lab. ## Debugging the build script -* The scripts for building/validating the snippets are under the `config` folder -- in particular, under `build.ts`. There is also a `deploy.ts` for copying the built files to their final location. +- The scripts for building/validating the snippets are under the `config` folder -- in particular, under `build.ts`. > **Note**: If debugging in Visual Studio Code, you can use "F5" to attach the debugger, but be sure to run `npm run tsc` before you do (and after any code change!). `F5` is not set to recompile! +## Join the Microsoft 365 Developer Program + +Join the [Microsoft 365 Developer Program](https://aka.ms/m365devprogram) to get resources and information to help you build solutions for the Microsoft 365 platform, including recommendations tailored to your areas of interest. + +You might also qualify for a free developer subscription that's renewable for 90 days and comes configured with sample data; for details, see the [FAQ](https://learn.microsoft.com/office/developer-program/microsoft-365-developer-program-faq#who-qualifies-for-a-microsoft-365-e5-developer-subscription-). + +--- + This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..4a0f12f81 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how a threat actor might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). + + diff --git a/config/build.documentation.ts b/config/build.documentation.ts index 956b59c3e..ee9d8f653 100644 --- a/config/build.documentation.ts +++ b/config/build.documentation.ts @@ -3,17 +3,17 @@ import * as fs from 'fs'; import * as jsyaml from 'js-yaml'; import { Dictionary } from './helpers'; -import { SnippetProcessedData, banner, readDir, officeHostsToAppNames, writeFile, rmRf, mkDir } from './helpers'; +import { SnippetProcessedData, readDir, writeFile, rmRf, mkDir } from './helpers'; import { status } from './status'; -import parseXlsx from 'excel'; +const ExcelJS = require('exceljs'); const SNIPPET_EXTRACTOR_METADATA_FOLDER_NAME = 'snippet-extractor-metadata'; interface MappingFileRowData { - class: string; member: string; memberId: string, snippetId: string; snippetFunction: string + package: string, class: string; member: string; memberId: string, snippetId: string; snippetFunction: string } const headerNames: (keyof MappingFileRowData)[] = - ['class', 'member', 'memberId', 'snippetId', 'snippetFunction']; + ['package', 'class', 'member', 'memberId', 'snippetId', 'snippetFunction']; export async function buildReferenceDocSnippetExtracts( @@ -36,7 +36,7 @@ export async function buildReferenceDocSnippetExtracts( await rmRf('snippet-extractor-output'); await mkDir('snippet-extractor-output'); - const contents = snippetExtractsPerHost.map(extracts => jsyaml.safeDump(extracts)).join(''); + const contents = snippetExtractsPerHost.map(extracts => jsyaml.dump(extracts)).join(''); await writeFile(path.resolve(`snippet-extractor-output/snippets.yaml`), contents); } @@ -45,46 +45,40 @@ async function buildSnippetExtractsPerHost( snippetIdsToFilenames: { [key: string]: string }, accumulatedErrors: Array ): Promise<{ [key: string]: string[] }> { - const hostName = officeHostsToAppNames[ - filename.substr(0, filename.length - '.xlsx'.length).toUpperCase()]; - - banner(`Extracting reference-doc snippet bits for ${hostName}`); const lines: MappingFileRowData[] = - await new Promise((resolve: (data: MappingFileRowData[]) => void, reject) => { + await new Promise(async (resolve: (data: MappingFileRowData[]) => void, reject) => { const fullFilePath = path.join( path.resolve(SNIPPET_EXTRACTOR_METADATA_FOLDER_NAME), filename ); - parseXlsx(fullFilePath).then((data) => { - if (data.length < 2) { - reject(new Error('No data rows found')); - } - - if (data[0].length !== headerNames.length) { - reject( - new Error('Unexpected number of columns. Expecting the following ' + - headerNames.length + ' columns: ' + - headerNames.map(name => `"${name}"`).join(', ') - ) - ); - } - - // Remove the first line, since it's the header line - data.splice(0, 1); + const workbook = new ExcelJS.Workbook(); + await workbook.xlsx.readFile(fullFilePath); + const worksheet = workbook.worksheets[0]; + if (worksheet.rowCount < 2) { + reject(new Error('No data rows found')); + } - resolve(data.map((row: string[]) => { - if (row.find(text => text.startsWith('//'))) { - return null; - } + if (worksheet.getRow(1).cellCount !== headerNames.length) { + reject( + new Error('Unexpected number of columns. Expecting the following ' + + headerNames.length + ' columns: ' + + headerNames.map(name => `"${name}"`).join(', ') + ) + ); + } + let mappedRowData: MappingFileRowData[] = []; + worksheet.eachRow((row, rowNumber) => { + if (rowNumber !== 1 && !row.getCell(1).value.startsWith('//')) { let result: MappingFileRowData = {} as any; - row.forEach((column: string, index) => { - result[headerNames[index]] = column; + row.eachCell((cell, index) => { + result[headerNames[index - 1]] = cell.value; }); - return result; - }).filter(item => item)); + mappedRowData.push(result); + } }); + resolve(mappedRowData.filter(item => item)); }); const allSnippetData: { [key: string]: string[] } = {}; @@ -93,16 +87,23 @@ async function buildSnippetExtractsPerHost( .filter(item => item) .forEach((text, index) => { const row = lines[index]; - let fullName = `${hostName}.${row.class.trim()}#${row.member.trim()}:member`; - if (row.memberId) { - fullName += `(${row.memberId})`; + let hostName = row.package; + + let fullName; + if (row.member) { /* If the mapping is for a field */ + fullName = `${hostName}.${row.class.trim()}#${row.member.trim()}:member`; + if (row.memberId) { + fullName += `(${row.memberId})`; + } + } else { /* If the mapping is for a top-level sample (like an enum) */ + fullName = `${hostName}.${row.class.trim()}:${row.memberId.trim()}`; } + if (!allSnippetData[fullName]) { allSnippetData[fullName] = []; } allSnippetData[fullName].push(text); }); - return allSnippetData; } @@ -118,7 +119,7 @@ function getExtractedDataFromSnippet( const filename = snippetIdsToFilenames[row.snippetId]; if (filename) { try { - const script = (jsyaml.safeLoad(fs.readFileSync(filename).toString()) as ISnippet).script.content; + const script = (jsyaml.load(fs.readFileSync(filename).toString()) as ISnippet).script.content; const fullSnippetTextArray = script.split('\n') .map(line => line.replace(/\r/, '')); @@ -128,13 +129,28 @@ function getExtractedDataFromSnippet( if (arrayIndex < 0) { throw new Error(`Invalid entry in the metadata mapping file -- snippet function "${row.snippetFunction}" does not exist within snippet "${filename}"`); } + + let jsDocCommentIndex = -1; + if (arrayIndex > 0 && fullSnippetTextArray[arrayIndex - 1].indexOf('*/') >= 0) { + for (let i = arrayIndex - 1; i >= 0; i--) { + if (fullSnippetTextArray[i].indexOf('/**') >= 0) { + jsDocCommentIndex = i; + break; + } + } + } + const functionDeclarationLine = fullSnippetTextArray[arrayIndex]; const functionHasNoParams = functionDeclarationLine.indexOf(targetText + ')') >= 0; const spaceFollowedByWordsRegex = /^(\s*)(.*)$/; const preWhitespaceCount = spaceFollowedByWordsRegex.exec(functionDeclarationLine)[1].length; const targetClosingText = ' '.repeat(preWhitespaceCount) + '}'; - fullSnippetTextArray.splice(0, arrayIndex + (functionHasNoParams ? 1 : 0)); + if (jsDocCommentIndex >= 0) { + fullSnippetTextArray.splice(0, jsDocCommentIndex); + } else { + fullSnippetTextArray.splice(0, arrayIndex + (functionHasNoParams ? 1 : 0)); + } const closingIndex = fullSnippetTextArray.findIndex(text => text.indexOf(targetClosingText) === 0); if (closingIndex < 0) { @@ -145,13 +161,13 @@ function getExtractedDataFromSnippet( const whitespaceCountOnFirstLine = spaceFollowedByWordsRegex.exec(fullSnippetTextArray[0])[1].length; // Place snippet location as comment. - const editedFilename = filename.substr(filename.lastIndexOf('samples')).replace(/\\/g, '/'); - text = '// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/' + editedFilename + '\n'; + const editedFilename = filename.substring(filename.lastIndexOf('samples')).replace(/\\/g, '/'); + text = '// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/' + editedFilename + '\n\n'; text += indented .map(line => { - if (line.substr(0, whitespaceCountOnFirstLine).trim().length === 0) { - return line.substr(whitespaceCountOnFirstLine); + if (line.substring(0, whitespaceCountOnFirstLine).trim().length === 0) { + return line.substring(whitespaceCountOnFirstLine); } else { return line; } diff --git a/config/build.ts b/config/build.ts index 304f96a29..042846a8e 100644 --- a/config/build.ts +++ b/config/build.ts @@ -2,23 +2,22 @@ import * as path from 'path'; import { isNil, isString, isArray, isEmpty, sortBy, cloneDeep } from 'lodash'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; +import escapeStringRegexp from 'escape-string-regexp'; import { status } from './status'; import { SnippetFileInput, SnippetProcessedData, - getDestinationBranch, followsNamingGuidelines, isCUID, - rmRf, mkDir, getFiles, writeFile, banner, getPrintableDetails, Dictionary + followsNamingGuidelines, isCUID, + rmRf, mkDir, readDir, getFiles, writeFile, banner, getPrintableDetails, Dictionary } from './helpers'; import { buildReferenceDocSnippetExtracts } from './build.documentation'; import { getShareableYaml } from './snippet.helpers'; import { processLibraries } from './libraries.processor'; import { startCase, groupBy, map } from 'lodash'; import * as jsyaml from 'js-yaml'; -import escapeStringRegexp = require('escape-string-regexp'); import * as fsx from 'fs-extra'; -const { GH_ACCOUNT, GH_REPO, TRAVIS_BRANCH } = process.env; const PRIVATE_SAMPLES = 'private-samples'; const PUBLIC_SAMPLES = 'samples'; const snippetFilesToUpdate: Array<{ path: string; contents: string }> = []; @@ -48,6 +47,7 @@ const defaultApiSets = { .then(updateModifiedFiles) .then(() => checkSnippetsForUniqueIDs(processedSnippets)) .then(() => generatePlaylists(processedSnippets)) + .then(copyAndUpdatePlaylistFolders) .then(() => buildReferenceDocSnippetExtracts(processedSnippets, accumulatedErrors)) .then(() => { if (accumulatedErrors.length > 0) { @@ -84,7 +84,7 @@ async function processSnippets(processedSnippets: Dictionary{}; additionalFields.id = snippet.id; additionalFields.api_set = snippet.api_set; - additionalFields.author = snippet.author; + + // Only set author field if it has a value + if (snippet.author) { + additionalFields.author = snippet.author; + } if ((typeof (snippet as any).order) !== 'undefined') { // # for ordering, if present (used for samples only) @@ -123,18 +127,19 @@ async function processSnippets(processedSnippets: Dictionary'}/${GH_REPO || ''}/${getDestinationBranch(TRAVIS_BRANCH) || ''}` + + `OfficeDev/office-js-snippets/main` + `/${dir}/${file.host}/${file.group}/${file.file_name}`; if (messages.findIndex(item => item instanceof Error) >= 0) { accumulatedErrors.push(`One or more critical errors on ${file.relativePath}`); } - // Define dictionary of words in file.group that require special casing + // Define dictionary of words in file.group that require special casing or punctuation let dictionary = { 'Apis': 'APIs', 'Pivottable': 'PivotTable', - 'Xml': 'XML' + 'Xml': 'XML', + 'On Premises': 'On-Premises' }; let groupName = replaceUsingDictionary(dictionary, startCase(file.group)); @@ -163,6 +168,15 @@ async function processSnippets(processedSnippets: Dictionary dictionary[item] || item); return parts.join(' '); } @@ -170,8 +184,8 @@ async function processSnippets(processedSnippets: Dictionary reference.trim()); - if (libs.indexOf('office-ui-fabric-js@1.4.0/dist/css/fabric.min.css') >= 0) { - if (libs.indexOf('office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css') <= 0) { + if (libs.indexOf('office-ui-fabric-core@11.1.0/dist/css/fabric.min.css') >= 0) { + if (libs.indexOf('office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css') <= 0) { throw new Error('Fabric reference is specified, without a reference to a corresponding "fabric.components.min.css". Please add this second Fabric reference as well.'); } } @@ -222,8 +236,8 @@ async function processSnippets(processedSnippets: Dictionary= 0; const canonicalOfficeJsReference = 'https://appsforoffice.microsoft.com/lib/1/hosted/office.js'; const betaOfficeJsReference = 'https://appsforoffice.microsoft.com/lib/beta/hosted/office.js'; - const officeDTS = '@types/office-js'; - const betaOfficeDTS = '@types/office-js-preview'; + const officeDTS = 'https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts'; + const betaOfficeDTS = 'https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts'; const officeJsReferences = snippet.libraries.split('\n') @@ -233,14 +247,12 @@ async function processSnippets(processedSnippets: Dictionary reference.trim()) - .filter(reference => reference.match(/.*((@types\/office-js(-preview)?)|(office\.d\.ts))$/gi)); + .filter(reference => reference.match(/.*((@types\/office-js(-preview)?)|((index|office)\.d\.ts))$/gi)); /* Note: regex matches: - - @types/office-js - - @types/office-js-preview - - https://unpkg.com/etc/office.d.ts + - https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + - https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts But not: - - @types/office-jsfake - - https://unpkg.com/etc/office.d.ts.ish + - https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.tsfake - office.d.ts.unrelated */ @@ -363,11 +375,12 @@ async function processSnippets(processedSnippets: Dictionary { const creatingStatusText = `Creating ${host}.yaml`; status.add(creatingStatusText); - items = sortBy(items, sortingCriteria); + items = sortBy(items, sortingCriteria) as any; /* Having sorted the items -- which may have included a number in the group name! -- remove the group number if any @@ -536,7 +549,7 @@ async function generatePlaylists(processedSnippets: Dictionary { const creatingStatusText = `Creating ${host}.json`; status.add(creatingStatusText); - items = sortBy(items, sortingCriteria); + items = sortBy(items, sortingCriteria) as any; let hostMapping = {} as { [id: string]: string }; items.forEach(item => { @@ -576,6 +589,50 @@ async function generatePlaylists(processedSnippets: Dictionary updateCopiedFile(playlistsProdFolderPath, file)))); + + /* Copying view directory */ + let viewProdFolderName = `view-prod`; + status.add(`Creating \'${viewProdFolderName}\' folder`); + await rmRf(viewProdFolderName); + let viewProdFolderPath = await mkDir(viewProdFolderName); + status.complete(true /*success*/, `Creating \'${viewProdFolderName}\' folder`); + + await fsx.copy('view', viewProdFolderName); + let viewFiles = await readDir(viewProdFolderPath); + (await Promise.all(viewFiles.map(file => updateCopiedFile(viewProdFolderPath, file)))); +} + +// helper for copyAndUpdatePlaylistFolders +async function updateCopiedFile(folderPath: string, filePath: string) { + const fullPath = path.resolve(folderPath, filePath); + let content = fsx.readFileSync(fullPath).toString().trim().replace( + /\/OfficeDev\/office-js-snippets\/main/g, + '/OfficeDev/office-js-snippets/prod'); + const fileUpdates = []; + fileUpdates.push( + Promise.resolve() + .then(async () => { + const updatingStatusText = `Updating copied file ${fullPath}`; + status.add(updatingStatusText); + await writeFile(fullPath, content); + status.complete(true /*succeeded*/, updatingStatusText); + }) + ); +} + function handleError(error: any | any[]) { if (!isArray(error)) { error = [error]; diff --git a/config/deploy.ts b/config/deploy.ts deleted file mode 100644 index 82bcf41d4..000000000 --- a/config/deploy.ts +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env node --harmony - -import * as chalk from 'chalk'; -import * as shell from 'shelljs'; -import { forIn } from 'lodash'; -import { isString } from 'lodash'; -import { banner, getDestinationBranch } from './helpers'; - -interface IEnvironmentVariables { - TRAVIS: string, - TRAVIS_BRANCH: string, - TRAVIS_PULL_REQUEST: string, - TRAVIS_COMMIT_MESSAGE: string, - GH_ACCOUNT: string, - GH_REPO: string, - GH_TOKEN: string -} - -const environmentVariables: IEnvironmentVariables = process.env as any; - -(() => { - try { - // Note, if precheck fails, it will do its own banner, so only need to focus on the true case. - if (precheck()) { - const destinationBranch = getDestinationBranch(environmentVariables.TRAVIS_BRANCH); - const repoUrl = `https://github.com/${environmentVariables.GH_ACCOUNT}/${environmentVariables.GH_REPO}/tree/${destinationBranch}`; - banner('Starting deployment', repoUrl); - - const start = Date.now(); - shell.exec('git config --add user.name "Travis CI"'); - shell.exec('git config --add user.email "travis.ci@microsoft.com"'); - shell.exec('git checkout --orphan newbranch'); - shell.exec('git reset'); - - execCommand('git add -f samples private-samples playlists view snippet-extractor-output README.md'); - execCommand(`git commit -m "Travis auto-deploy of ${environmentVariables.TRAVIS_COMMIT_MESSAGE.replace(/\W/g, '_')} [skip ci]"`); - - const tokenizedGitHubGitUrl = `https://<<>>@github.com/${environmentVariables.GH_ACCOUNT}/${environmentVariables.GH_REPO}.git`; - execCommand(`git push ${tokenizedGitHubGitUrl} -f -u HEAD:refs/heads/${destinationBranch}`, { - token: environmentVariables.GH_TOKEN - }); - - const end = Date.now(); - - banner('Deployment succeeded', `Successfully deployed to ${repoUrl} in ${(end - start) / 1000} seconds.`, chalk.bold.green); - } - } - catch (error) { - banner('An error has occurred', error.message || error, chalk.bold.red); - banner('DEPLOYMENT DID NOT GET TRIGGERED', error.message || error, chalk.bold.red); - - // Even though deployment failure does not imply dev failure, we want to break the build - // to make it obvious that the deployment went wrong - process.exit(1); - } - - process.exit(0); -})(); - - -function precheck() { - /* Check if the code is running inside of travis.ci. If not abort immediately. */ - if (!environmentVariables.TRAVIS) { - banner('Deployment skipped', 'Not running inside of Travis.', chalk.yellow.bold); - return false; - } - - // Careful! Need this check because otherwise, a pull request against master would immediately trigger a deployment. - if (environmentVariables.TRAVIS_PULL_REQUEST !== 'false') { - banner('Deployment skipped', 'Skipping deploy for pull requests.', chalk.yellow.bold); - return false; - } - - if (getDestinationBranch(environmentVariables.TRAVIS_BRANCH) == null) { - banner('Deployment skipped', 'Skipping deploy for pull requests.', chalk.yellow.bold); - return false; - } - - /* Check if the username is configured. If not abort immediately. */ - const requiredFields: Array = ['GH_ACCOUNT', 'GH_REPO', 'GH_TOKEN']; - requiredFields.forEach(key => { - if (!isString(environmentVariables[key])) { - throw new Error(`"${key}" is a required global variables.`); - } - }); - - return true; -} - -/** - * Execute a shell command. - * @param originalSanitizedCommand - The command to execute. Note that if it contains something secret, put it in triple <<>> syntax, as the command itself will get echo-ed. - * @param secretSubstitutions - key-value pairs to substitute into the command when executing. Having any secret substitutions will automatically make the command run silently. - */ -function execCommand(originalSanitizedCommand: string, secretSubstitutions = {}) { - console.log(originalSanitizedCommand); - - let hadSecrets = false; - let command = originalSanitizedCommand; - forIn(secretSubstitutions, (value, key) => { - hadSecrets = true; - command = replaceAll(command, '<<<' + key + '>>>', value); - }); - - if (hadSecrets) { - console.log(chalk.yellow('Command contained secret substitution values; running the `shell.exec` silently')); - } - - let result: any = shell.exec(command, hadSecrets ? { silent: true } : null); - if (result.code !== 0) { - throw new Error(`An error occurred while executing "${originalSanitizedCommand}"`); - } -} - -function replaceAll(source, search, replacement) { - return source.split(search).join(replacement); -} diff --git a/config/helpers.ts b/config/helpers.ts index e297ae06d..d0798f6bb 100644 --- a/config/helpers.ts +++ b/config/helpers.ts @@ -1,22 +1,11 @@ import * as path from 'path'; import * as fs from 'fs'; import * as os from 'os'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as jsyaml from 'js-yaml'; -import { console } from './status'; -import * as rimraf from 'rimraf'; +import { rimraf } from 'rimraf'; import { isObject, isNil, isString, isEmpty } from 'lodash'; -export const officeHostsToAppNames = { - 'ACCESS': 'Access', - 'EXCEL': 'Excel', - 'ONENOTE': 'OneNote', - 'OUTLOOK': 'Office', - 'POWERPOINT': 'PowerPoint', - 'PROJECT': 'Project', - 'WORD': 'Word' -}; - export interface SnippetFileInput { file_name: string; relativePath: string; @@ -49,7 +38,7 @@ export interface SnippetProcessedData { * @param message Message of the banner. * @param chalkFunction Chalk color function. */ -export const banner = (title: string, message: string = null, chalkFn: chalk.ChalkChain = null) => { +export const banner = (title: string, message: string = null, chalkFn: any = null) => { if (!chalkFn) { chalkFn = chalk.bold; } @@ -65,7 +54,7 @@ export const banner = (title: string, message: string = null, chalkFn: chalk.Cha }; export function getPrintableDetails(item: any, indent: number) { - const details = jsyaml.safeDump(item, { + const details = jsyaml.dump(item, { indent: 4, lineWidth: -1, skipInvalid: true @@ -74,18 +63,6 @@ export function getPrintableDetails(item: any, indent: number) { return details.split('\n').map(line => new Array(indent).join(' ') + line).join('\n'); } -export const getDestinationBranch = (sourceBranch: 'master' | 'prod' | any): 'deploy-beta' | 'deploy-prod' | null => { - if (sourceBranch === 'master') { - return 'deploy-beta'; - } - else if (sourceBranch === 'prod') { - return 'deploy-prod'; - } - else { - return null; - } -}; - /** * Creates a folder. * @param dir An absolute path to the directory. @@ -105,16 +82,11 @@ export const mkDir = (dir: string) => * Deletes a folder. * @param dir An absolute path to the directory. */ -export const rmRf = (dir: string) => - new Promise((resolve, reject) => { - const location = path.resolve(dir); - rimraf(location, (err) => { - if (err) { - return reject(err); - } - return resolve(location); - }); - }); +export const rmRf = async (dir: string): Promise => { + const location = path.resolve(dir); + await rimraf(location); + return location; +}; /** * Load all the files and folders in a given directory. @@ -136,7 +108,7 @@ export const readDir = (dir: string) => * @param contents */ export const writeFile = (filename: string, contents: string) => - new Promise((resolve, reject) => { + new Promise((resolve, reject) => { fs.writeFile(filename, contents, (err) => { if (err) { return reject(err); @@ -176,7 +148,7 @@ export function getFileMetadata(fullPath: string, root: string): SnippetFileInpu /* Additional must be null or empty */ if (additional && additional.length > 0) { - throw new Error(`Invalid folder structure at ${chalk.bold.red(relativePath)}.File ${chalk.bold.yellow(name)} was located too deep.`); + throw new Error(`Invalid folder structure at ${chalk.bold.red(relativePath)}.File ${chalk.bold.yellow(file_name)} was located too deep.`); } if (host == null) { @@ -208,21 +180,22 @@ export function getFiles(root: string): SnippetFileInput[] { // Helper function syncRecurseThroughDirectory(dir: string) { fs.readdirSync(dir) - .forEach(file => { - const fullPath = path.join(dir, file); - const withoutExt = file.replace('.yaml', ''); - - /* Check for file/folder naming guidelines */ - if (!followsNamingGuidelines(withoutExt)) { - throw new Error(`Invalid name at ${chalk.bold.red(fullPath)}. Name must only contain lowercase letters, numbers, and hyphens.`); - } - - if (fs.statSync(fullPath).isDirectory()) { - syncRecurseThroughDirectory(fullPath); - } else { - files.push(getFileMetadata(fullPath, root)); - } - }); + .filter(file => !['.DS_Store'].includes(file)) + .forEach(file => { + const fullPath = path.join(dir, file); + const withoutExt = file.replace('.yaml', ''); + + /* Check for file/folder naming guidelines */ + if (!followsNamingGuidelines(withoutExt)) { + throw new Error(`Invalid name at ${chalk.bold.red(fullPath)}. Name must only contain lowercase letters, numbers, and hyphens.`); + } + + if (fs.statSync(fullPath).isDirectory()) { + syncRecurseThroughDirectory(fullPath); + } else { + files.push(getFileMetadata(fullPath, root)); + } + }); } } @@ -230,14 +203,12 @@ export function getFiles(root: string): SnippetFileInput[] { Naming guidelines: only allow lowercase letters, numbers, and hyphens OK: - sample sample-with-hyphen sample-es5 BAD: - sample with space Any-uppercase anyWhere diff --git a/config/snippet.helpers.ts b/config/snippet.helpers.ts index f2574957d..449e40d59 100644 --- a/config/snippet.helpers.ts +++ b/config/snippet.helpers.ts @@ -91,7 +91,7 @@ function scrubCarriageReturns(snippet: ISnippet) { export function getScrubbedSnippet(snippet: ISnippet, keep: SnippetFieldType): ISnippet { let copy = {}; forIn(snippetFields, (fieldType, fieldName) => { - if (fieldType & keep) { + if (fieldType & keep && snippet[fieldName] !== undefined) { copy[fieldName] = snippet[fieldName]; } }); @@ -103,7 +103,7 @@ export function getShareableYaml(rawSnippet: ISnippet, additionalFields: ISnippe const snippet = { ...getScrubbedSnippet(rawSnippet, SnippetFieldType.PUBLIC), ...additionalFields }; scrubCarriageReturns(snippet); - return jsyaml.safeDump(snippet, { + return jsyaml.dump(snippet, { indent: 4, lineWidth: -1, sortKeys: ((a, b) => snippetFieldSortingOrder[a] - snippetFieldSortingOrder[b]), diff --git a/config/status.ts b/config/status.ts index 44003309c..2f953ee73 100644 --- a/config/status.ts +++ b/config/status.ts @@ -1,6 +1,5 @@ -import * as nodeStatus from 'node-status'; -import * as chalk from 'chalk'; -import { isString, find, isNil, isArray } from 'lodash'; +import chalk from 'chalk'; +import { isString, isNil, isArray } from 'lodash'; interface IStage { steps: any[]; @@ -13,16 +12,29 @@ export class Status { steps: { [step: string]: boolean } = {}; get console() { - return nodeStatus.console(); + // Return the global console object methods + return { + log: global.console.log.bind(global.console), + error: global.console.error.bind(global.console), + warn: global.console.warn.bind(global.console), + info: global.console.info.bind(global.console) + }; } constructor() { - /* Initialize the status library */ - this.stages = nodeStatus.addItem('stages', { - steps: [] - }); + /* Initialize the simple status system */ + this.stages = { + steps: [], + count: 0, + doneStep: this.doneStep.bind(this) + }; + } - nodeStatus.start(); + private doneStep(completed: boolean, message?: string): void { + const symbol = completed ? chalk.green('✓') : chalk.red('✗'); + if (message) { + global.console.log(`${symbol} ${message}`); + } } /** @@ -37,22 +49,18 @@ export class Status { success = success && additionalDetails.findIndex(item => item instanceof Error) < 0; const messageArray = getDetailsArray(); + const symbol = success ? chalk.green('✓') : chalk.red('✗'); - if (messageArray.length === 0) { - this.stages.doneStep(success); - } else { - // Add a newline before - messageArray.splice(0, 0, ''); - this.stages.doneStep(success, messageArray.join('\n * ') + '\n'); - //FIXME `${chalk.bold.red('WARNING: one of the messages above was an error')}`) - } - - this.steps[stage] = false; + // Log the completion with symbol + global.console.log(`${symbol} ${stage}`); - if (!find(this.steps as any, (item) => item === true)) { - nodeStatus.stop(); + if (messageArray.length > 0) { + messageArray.forEach(msg => { + global.console.log(` * ${msg}`); + }); } + this.steps[stage] = false; // Helper: function getDetailsArray() { @@ -82,12 +90,13 @@ export class Status { } /** - * Add a new stage and complete the previous stage. + * Add a new stage and mark it as started. * @param stage Name of the stage. */ add(stage: string) { this.stages.steps.push(stage); this.steps[stage] = true; + global.console.log(chalk.cyan(`○ ${stage}`)); } } diff --git a/package.json b/package.json index a3dd39282..457b9471d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "start": "npm run tsc && npm run build && npm run lint", "tsc": "tsc -p tsconfig.json", "build": "node config/build.js", - "deploy": "node config/deploy.js", "lint": "tslint --project tsconfig.json" }, "repository": { @@ -24,25 +23,22 @@ }, "homepage": "https://github.com/OfficeDev/office-js-snippets#readme", "dependencies": { - "chalk": "1.1.3", - "escape-string-regexp": "^2.0.0", - "excel": "^1.0.1", - "fs-extra": "3.0.1", - "js-yaml": "^3.13.1", - "lodash": "^4.17.19", - "node-status": "^1.0.0", - "npm": "^6.14.6", - "rimraf": "^3.0.0", - "shelljs": "^0.8.3" + "chalk": "^4.1.2", + "escape-string-regexp": "^4.0.0", + "exceljs": "^4.4.0", + "fs-extra": "11.3.2", + "js-yaml": "^4.1.0", + "lodash": "^4.17.21", + "rimraf": "^6.0.1", + "shelljs": "^0.10.0" }, "devDependencies": { - "@types/chalk": "0.4.31", - "@types/fs-extra": "3.0.1", - "@types/js-yaml": "^3.12.0", - "@types/lodash": "^4.14.122", - "@types/node": "^11.10.5", - "@types/shelljs": "^0.8.3", - "tslint": "^6.1.0", - "typescript": "^3.3.3333" + "@types/fs-extra": "^11.0.4", + "@types/js-yaml": "^4.0.9", + "@types/lodash": "^4.17.20", + "@types/node": "^24.5.2", + "@types/shelljs": "^0.8.17", + "tslint": "^6.1.3", + "typescript": "^5.9.2" } } diff --git a/playlists-prod/excel.yaml b/playlists-prod/excel.yaml new file mode 100644 index 000000000..059d3893b --- /dev/null +++ b/playlists-prod/excel.yaml @@ -0,0 +1,1436 @@ +- id: excel-basics-basic-api-call + name: Basic API call (TypeScript) + fileName: basic-api-call.yaml + description: Performs a basic Excel API call using TypeScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-api-call.yaml + group: Basics + api_set: + ExcelApi: '1.1' +- id: excel-basics-basic-api-call-es5 + name: Basic API call (JavaScript) + fileName: basic-api-call-es5.yaml + description: Performs a basic Excel API call using plain JavaScript & Promises. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-api-call-es5.yaml + group: Basics + api_set: + ExcelApi: '1.1' +- id: excel-basics-basic-common-api-call + name: Basic API call (Office 2013) + fileName: basic-common-api-call.yaml + description: >- + Performs a basic Excel API call using JavaScript with the "common API" + syntax (compatible with Office 2013). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-common-api-call.yaml + group: Basics + api_set: + Selection: 1.1 +- id: excel-chart-axis + name: Axis details + fileName: chart-axis.yaml + description: Gets, sets, and removes axis unit, label, and title in a chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-axis-formatting + name: Axis formatting + fileName: chart-axis-formatting.yaml + description: Formats the vertical and horizontal axes in a chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis-formatting.yaml + group: Chart + api_set: + ExcelApi: '1.8' +- id: excel-chart-data-table + name: Chart data table + fileName: chart-data-table.yaml + description: Add a data table to a chart and then format that data table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + group: Chart + api_set: + ExcelApi: '1.14' +- id: excel-chart-bubble-chart + name: Create bubble chart + fileName: chart-bubble-chart.yaml + description: >- + Creates a bubble chart with each data row represented as a single chart + series (bubble). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml + group: Chart + api_set: + ExcelApi: '1.12' +- id: excel-chart-create-several-charts + name: Create charts + fileName: chart-create-several-charts.yaml + description: >- + Creates column-clustered, line, XY-scatter, area, radar, pie, 3D, cylinder, + and 100% charts. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-create-several-charts.yaml + group: Chart + api_set: + ExcelApi: '1.4' +- id: excel-chart-create-doughnut-chart + name: Doughnut chart + fileName: create-doughnut-chart.yaml + description: Creates a doughnut chart and adjusts its size. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/create-doughnut-chart.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-formatting + name: Formatting + fileName: chart-formatting.yaml + description: Formats labels and lines of a slope chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-formatting.yaml + group: Chart + api_set: + ExcelApi: '1.8' +- id: excel-chart-legend + name: Legend + fileName: chart-legend.yaml + description: Formats the legend's font. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-legend.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-point + name: Points + fileName: chart-point.yaml + description: Sets the color of a point on the chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-point.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-series + name: Series + fileName: chart-series.yaml + description: Adds and deletes series in a chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-series-markers + name: Series markers + fileName: chart-series-markers.yaml + description: Sets the chart series marker properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-series-plotorder + name: Series plot order + fileName: chart-series-plotorder.yaml + description: Orders the plotting of series in a chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-plotorder.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-title-format + name: Title format + fileName: chart-title-format.yaml + description: Adjust a chart title's format. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-title-format.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-data-source + name: Chart series data source + fileName: chart-data-source.yaml + description: >- + This sample shows how to get information about the data source of a chart + series. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml + group: Chart + api_set: + ExcelApi: '1.15' +- id: excel-chart-trendlines + name: Trendlines + fileName: chart-trendlines.yaml + description: Adds, gets, and formats trendlines in a chart. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml + group: Chart + api_set: + ExcelApi: '1.7' +- id: excel-chart-data-labels + name: Data labels + fileName: chart-data-labels.yaml + description: Add and style data labels for your charts. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml + group: Chart + api_set: + ExcelApi: '1.19' +- id: excel-chart-leader-lines + name: Leader lines + fileName: chart-leader-lines.yaml + description: Show and hide leader lines for chart labels. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + group: Chart + api_set: + ExcelApi: '1.19' +- id: excel-comment-basics + name: Comment basics + fileName: comment-basics.yaml + description: Adds, edits, and removes comments. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.10' +- id: excel-comment-mentions + name: Comment mentions + fileName: comment-mentions.yaml + description: Mentions someone in a comment. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.11' +- id: excel-comment-replies + name: Comment replies + fileName: comment-replies.yaml + description: Adds, edits, and removes comment replies. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.10' +- id: excel-comment-resolution + name: Comment resolution + fileName: comment-resolution.yaml + description: Resolves and reopens a comment thread. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.10' +- id: excel-note-basics + name: Notes + fileName: excel-note-basics.yaml + description: Adds, edits, and removes notes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.18' +- id: excel-range-conditional-formatting-basic + name: Basic conditional formatting + fileName: conditional-formatting-basic.yaml + description: Applies common types of conditional formatting to ranges. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + group: Conditional Formatting + api_set: + ExcelApi: '1.6' +- id: excel-range-conditional-formatting-advanced + name: Advanced conditional formatting + fileName: conditional-formatting-advanced.yaml + description: Applies more than one conditional format on the same range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml + group: Conditional Formatting + api_set: + ExcelApi: '1.6' +- id: excel-custom-functions-basic + name: Basic custom function + fileName: basic-function.yaml + description: Calculates the volume of a sphere. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/basic-function.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.1 +- id: excel-custom-functions-volatile + name: Volatile function + fileName: volatile-function.yaml + description: Rolls a 6 sided die that returns a possible new value every calculation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/volatile-function.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.1 +- id: excel-custom-functions-streaming + name: Streaming function + fileName: streaming-function.yaml + description: A streaming function that continuously increments the cell value. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/streaming-function.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.1 +- id: excel-custom-functions-web-call + name: Web request to GitHub API + fileName: web-call-function.yaml + description: Calls the GitHub API to get the star count for an org/user and repository. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/web-call-function.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.1 +- id: excel-custom-functions-errors + name: Custom functions errors + fileName: custom-functions-errors.yaml + description: Returns the "#NUM!" error as part of a 2-dimensional array. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/custom-functions-errors.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.2 +- id: excel-data-types-custom-functions + name: 'Data types: Custom functions' + fileName: data-types-custom-functions.yaml + description: >- + This sample shows how to write custom functions that return entity value + data types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/data-types-custom-functions.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.4 +- id: excel-custom-functions-custom-enum + name: Function with custom enums + fileName: custom-enum.yaml + description: >- + Use custom enums as parameters in a custom function that searches for + flights. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/custom-enum.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.5 +- id: excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts + name: Using custom XML parts + fileName: create-set-get-and-delete-custom-xml-parts.yaml + description: Creates, sets, gets, and deletes a custom XML part. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + group: Custom XML Parts + api_set: + ExcelApi: '1.5' +- id: excel-custom-xml-parts-test-xml-for-unique-namespace + name: Unique namespaces in custom XML + fileName: test-xml-for-unique-namespace.yaml + description: Tests to see if there is only one XML part for a specified namespace. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + group: Custom XML Parts + api_set: + ExcelApi: '1.5' +- id: excel-data-types-doubles + name: 'Data types: Formatted numbers' + fileName: data-types-formatted-number.yaml + description: >- + This sample shows how to set and get formatted numbers using double data + types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-web-image + name: 'Data types: Web images' + fileName: data-types-web-image.yaml + description: >- + This sample shows how to set and get web images in a worksheet using data + types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-entity-values + name: 'Data types: Create entity cards from data in a table' + fileName: data-types-entity-values.yaml + description: >- + This sample shows how to create entity cards for each row in a table. An + entity is a container for data types, similar to an object in + object-oriented programming. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-values.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-error-values + name: 'Data types: Set and change error values' + fileName: data-types-error-values.yaml + description: >- + This sample shows how to set a cell value to an error data type, and then + update the value of cells that contain an error data type. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-icons + name: 'Data types: Create entity icons' + fileName: data-types-entity-icons.yaml + description: Display all the icons available for entity data types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-icons.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-entity-attribution + name: 'Data types: Entity value attribution properties' + fileName: data-types-entity-attribution.yaml + description: >- + This sample shows how to set data provider attributions on entity values in + the card layout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-references + name: 'Data types: Entity values with references' + fileName: data-types-references.yaml + description: >- + This sample shows how to create entity values with references to other + entity values. An entity value is a container for data, and this container + can reference (or contain) other entities within the original entity. One + entity can contain multiple additional entities. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-references.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-basic-types + name: Basic types with metadata + fileName: data-types-basic-types.yaml + description: This sample shows how to work with metadata on basic types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-basic-types.yaml + group: Data Types + api_set: + ExcelApi: '1.19' +- id: excel-data-validation + name: Data validation + fileName: data-validation.yaml + description: >- + Sets data validation rules on ranges, prompts users to enter valid data, and + displays messages when invalid data is entered. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + group: Data Validation + api_set: + ExcelApi: '1.8' +- id: excel-document-get-file-in-slices-async + name: Get file using slicing + fileName: get-file-in-slices-async.yaml + description: >- + Uses slicing to get the byte array and Base64-encoded string that represent + the current document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/get-file-in-slices-async.yaml + group: Document + api_set: + ExcelApi: '1.4' +- id: excel-document-properties + name: Properties + fileName: properties.yaml + description: Gets and sets document properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/properties.yaml + group: Document + api_set: + ExcelApi: '1.7' +- id: excel-document-custom-properties + name: Custom properties + fileName: custom-properties.yaml + description: Gets and sets custom properties at the document and worksheet levels. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml + group: Document + api_set: + ExcelAPI: '1.12' +- id: excel-events-chartcollection-added-activated + name: Chart collection events + fileName: events-chartcollection-added-activated.yaml + description: >- + Registers event handlers on a worksheet's chart collection that run when any + chart within is activated or deactivated, as well as when charts are added + to or deleted from the collection. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chartcollection-added-activated.yaml + group: Events + api_set: + ExcelApi: '1.8' +- id: excel-events-chart-activated + name: Chart events + fileName: events-chart-activated.yaml + description: >- + Registers event handlers on an individual chart that run when the chart is + activated or deactivated. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + group: Events + api_set: + ExcelApi: '1.8' +- id: excel-event-column-and-row-sort + name: Column and row sort events + fileName: event-column-and-row-sort.yaml + description: >- + Registers event handlers that run when column or row sorting events occur in + the current worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + group: Events + api_set: + ExcelApi: '1.10' +- id: excel-events-comments + name: Comment events + fileName: events-comment-event-handler.yaml + description: >- + Registers event handlers to listen for comment additions, changes, and + deletions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + group: Events + api_set: + ExcelAPI: '1.12' +- id: excel-events-data-changed + name: Data changed event + fileName: data-changed.yaml + description: Registers an event handler that runs when data is changed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-changed.yaml + group: Events + api_set: + ExcelApi: '1.4' +- id: excel-data-change-event-details + name: Data changed event details + fileName: data-change-event-details.yaml + description: Uses the onChanged event of a table to determine the specifics of changes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-change-event-details.yaml + group: Events + api_set: + ExcelApi: '1.9' +- id: excel-events-disable-events + name: Enable and disable events + fileName: events-disable-events.yaml + description: Toggles event firing on and off. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-disable-events.yaml + group: Events + api_set: + ExcelApi: '1.8' +- id: excel-events-formula-changed + name: Formula changed event + fileName: events-formula-changed.yaml + description: Registers an event handler to detect changes to formulas. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-formula-changed.yaml + group: Events + api_set: + ExcelAPI: '1.13' +- id: excel-selection-changed-events + name: Selection changed events + fileName: selection-changed-events.yaml + description: >- + Registers handlers all the different `onSelectionChanged` events and + displays how each event reports the selected addresses. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/selection-changed-events.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-events-tablecollection-changed + name: Table collection events + fileName: events-tablecollection-changed.yaml + description: Registers an event handler that runs when a table collection is changed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-tablecollection-changed.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-event-worksheet-single-click + name: Single click event + fileName: event-worksheet-single-click.yaml + description: >- + Registers an event handler that runs when a single-click event occurs in the + current worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-worksheet-single-click.yaml + group: Events + api_set: + ExcelApi: '1.10' +- id: excel-events-table-changed + name: Table events + fileName: events-table-changed.yaml + description: Registers event handlers that run when a table is changed or selected. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-table-changed.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-events-workbook-activated + name: Workbook activated event + fileName: events-workbook-activated.yaml + description: This sample shows how to register a workbook activated event handler. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-activated.yaml + group: Events + api_set: + ExcelAPI: '1.13' +- id: excel-events-workbook-and-worksheet-collection + name: Workbook and worksheet collection events + fileName: events-workbook-and-worksheet-collection.yaml + description: >- + Registers event handlers that run when a worksheet is added, activated, or + deactivated, or when the settings of a workbook are changed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-events-worksheet + name: Worksheet events + fileName: events-worksheet.yaml + description: >- + Registers event handlers that run when data is changed in worksheet, the + selected range changes in a worksheet, or the worksheet is recalculated. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-events-worksheet-protection + name: Worksheet protection events + fileName: events-worksheet-protection.yaml + description: >- + Registers an event handler to listen for worksheet protection status + changes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + group: Events + api_set: + ExcelAPI: '1.14' +- id: excel-named-item-create-and-remove-named-item + name: Create, access, and remove + fileName: create-and-remove-named-item.yaml + description: Creates, accesses, and removes named items in a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml + group: Named Item + api_set: + ExcelApi: '1.4' +- id: excel-update-named-item + name: Update + fileName: update-named-item.yaml + description: Creates and then updates a named item. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/update-named-item.yaml + group: Named Item + api_set: + ExcelApi: '1.7' +- id: excel-pivottable-calculations + name: Calculations + fileName: pivottable-calculations.yaml + description: Changes the calculations the PivotTable performs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml + group: PivotTable + api_set: + ExcelApi: '1.8' +- id: excel-pivottable-create-and-modify + name: Create and modify + fileName: pivottable-create-and-modify.yaml + description: Creates and modifies a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + group: PivotTable + api_set: + ExcelApi: '1.8' +- id: excel-pivottable-filters-and-summaries + name: Filters and summaries + fileName: pivottable-filters-and-summaries.yaml + description: Filters PivotTable data and shows different summarizations. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + group: PivotTable + api_set: + ExcelApi: '1.8' +- id: excel-pivottables-get-pivottables + name: Get PivotTables + fileName: pivottable-get-pivottables.yaml + description: >- + Get existing PivotTables in the workbook through their collections and + through the ranges they occupy. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + group: PivotTable + api_set: + ExcelAPI: '1.12' +- id: excel-pivottables-pivotfilters + name: PivotFilters + fileName: pivottable-pivotfilters.yaml + description: Applies PivotFilters to a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + group: PivotTable + api_set: + ExcelAPI: '1.12' +- id: excel-pivottable-pivotlayout + name: PivotLayout + fileName: pivottable-pivotlayout.yaml + description: Sets PivotTable layout settings through the PivotLayout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + group: PivotTable + api_set: + ExcelAPI: '1.13' +- id: excel-pivottable-data-source + name: PivotTable data source + fileName: pivottable-source-data.yaml + description: Gets information about the data source of a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-source-data.yaml + group: PivotTable + api_set: + ExcelApi: '1.15' +- id: excel-pivottable-refresh + name: Refresh + fileName: pivottable-refresh.yaml + description: Refreshes a PivotTable based on table row additions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-refresh.yaml + group: PivotTable + api_set: + ExcelApi: '1.8' +- id: excel-pivottable-slicer + name: Slicer + fileName: pivottable-slicer.yaml + description: Adds a slicer to a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + group: PivotTable + api_set: + ExcelApi: '1.10' +- id: excel-range-auto-fill + name: Auto fill + fileName: range-auto-fill.yaml + description: Writes to cells with the auto fill feature. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-auto-fill.yaml + group: Range + api_set: + ExcelApi: '1.10' +- id: excel-range-copyfrom + name: Copy and paste ranges + fileName: range-copyfrom.yaml + description: Copies or moves data and formatting from one range to another. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-copyfrom.yaml + group: Range + api_set: + ExcelApi: '1.10' +- id: excel-range-areas + name: Discontiguous ranges (RangeAreas) and special cells + fileName: range-areas.yaml + description: >- + Creates and uses RangeAreas, which are sets of ranges that need not be + contiguous, through user selection and programmatic selection of special + cells. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml + group: Range + api_set: + ExcelApi: '1.9' +- id: excel-range-find + name: Find text matches within a range + fileName: range-find.yaml + description: Finds a cell within a range based on string matching. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-find.yaml + group: Range + api_set: + ExcelApi: '1.9' +- id: excel-range-formatting + name: Formatting + fileName: formatting.yaml + description: Formats a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/formatting.yaml + group: Range + api_set: + ExcelApi: '1.4' +- id: excel-range-cell-properties + name: Get and set cell properties + fileName: cell-properties.yaml + description: Sets different properties across a range then retrieves those properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + group: Range + api_set: + ExcelApi: '1.9' +- id: excel-range-hyperlink + name: Hyperlinks + fileName: range-hyperlink.yaml + description: Creates, updates, and clears hyperlinks in a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + group: Range + api_set: + ExcelApi: '1.7' +- id: excel-range-insert-delete-and-clear-range + name: Insert, delete, and clear + fileName: insert-delete-clear-range.yaml + description: Inserts, deletes, and clears a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/insert-delete-clear-range.yaml + group: Range + api_set: + ExcelApi: '1.4' +- id: excel-outline + name: Outline + fileName: outline.yaml + description: Creates an outline by grouping rows and columns. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml + group: Range + api_set: + ExcelApi: '1.10' +- id: excel-range-range-relationships + name: Range relationships + fileName: range-relationships.yaml + description: >- + Shows relationships between ranges, such as bounding rectangles and + intersections. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-relationships.yaml + group: Range + api_set: + ExcelApi: '1.4' +- id: excel-range-remove-duplicates + name: Remove duplicates + fileName: range-remove-duplicates.yaml + description: Removes duplicate entries from a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-remove-duplicates.yaml + group: Range + api_set: + ExcelApi: '1.9' +- id: excel-range-selected-range + name: Selected range + fileName: selected-range.yaml + description: Gets and sets the currently selected range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/selected-range.yaml + group: Range + api_set: + ExcelApi: '1.1' +- id: excel-precedents + name: Precedents + fileName: precedents.yaml + description: >- + This sample shows how to find and highlight the precedents of the currently + selected cell. Precedents are cells referenced by the formula in a cell. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/precedents.yaml + group: Range + api_set: + ExcelApi: '1.14' +- id: excel-range-style + name: Style + fileName: style.yaml + description: >- + Creates a custom style, applies a custom and built-in styles to a range, + gets style properties, and deletes the custom style. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + group: Range + api_set: + ExcelApi: '1.7' +- id: excel-range-text-orientation + name: Text orientation + fileName: range-text-orientation.yaml + description: Gets and sets the text orientation within a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-text-orientation.yaml + group: Range + api_set: + ExcelApi: '1.7' +- id: excel-range-dynamic-arrays + name: Dynamic arrays + fileName: dynamic-arrays.yaml + description: >- + Applies formulas that use dynamic arrays and displays information about the + ranges used to display the data. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/dynamic-arrays.yaml + group: Range + api_set: + ExcelAPI: '1.12' +- id: excel-range-used-range + name: Used range + fileName: used-range.yaml + description: >- + Tests for a used range and creates a chart from a table only if there's data + in the table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/used-range.yaml + group: Range + api_set: + ExcelApi: '1.4' +- id: excel-range-values-and-formulas + name: Values and formulas + fileName: set-get-values.yaml + description: Gets and sets values and formulas for a range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/set-get-values.yaml + group: Range + api_set: + ExcelApi: '1.4' +- id: excel-merged-ranges + name: Merged ranges + fileName: range-merged-ranges.yaml + description: This sample shows how to create and find merged ranges in a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-merged-ranges.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-range-get-range-edge + name: Select used range edge + fileName: range-get-range-edge.yaml + description: >- + This sample shows how to select the edges of the used range, based on the + currently selected range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-direct-dependents + name: Direct dependents + fileName: range-direct-dependents.yaml + description: >- + This sample shows how to find and highlight the direct dependents of the + currently selected cell. Dependent cells contain formulas that refer to + other cells. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-direct-dependents.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-range-dependents + name: Dependents + fileName: range-dependents.yaml + description: >- + This sample shows how to find and highlight the dependents of the currently + selected cell. Dependent cells contain formulas that refer to other cells. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-dependents.yaml + group: Range + api_set: + ExcelAPI: '1.15' +- id: excel-cell-controls + name: Checkboxes + fileName: range-cell-control.yaml + description: This sample shows how to add and remove checkboxes from a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + group: Range + api_set: + ExcelApi: '1.18' +- id: excel-shape-create-and-delete + name: Create and delete geometric shapes + fileName: shape-create-and-delete.yaml + description: >- + Creates a few different geometric shapes and deletes them from the + worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-images + name: Image shapes + fileName: shape-images.yaml + description: Creates and adjusts image-based shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-lines + name: Lines + fileName: shape-lines.yaml + description: Creates and modifies line shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-move-and-order + name: Move and order shapes + fileName: shape-move-and-order.yaml + description: Moves created shapes around the worksheet and adjusts their z-order. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-groups + name: Shape groups + fileName: shape-groups.yaml + description: Groups and ungroups shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-groups.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-textboxes + name: Textboxes + fileName: shape-textboxes.yaml + description: Creates a textbox shape and works with the text in it and other shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml + group: Shape + api_set: + ExcelApi: '1.9' +- id: excel-shape-get-active + name: Get active shape image + fileName: shape-get-active.yaml + description: Get an image of the active shape in your workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-get-active.yaml + group: Shape + api_set: + ExcelApi: '1.19' +- id: excel-table-add-rows-and-columns-to-a-table + name: Add rows and columns + fileName: add-rows-and-columns-to-a-table.yaml + description: Adds rows and columns to a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/add-rows-and-columns-to-a-table.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-convert-range-to-table + name: Convert a range + fileName: convert-range-to-table.yaml + description: Converts a range to a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/convert-range-to-table.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-create-table + name: Create a table + fileName: create-table.yaml + description: Creates a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/create-table.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-filter-data + name: Filter data + fileName: filter-data.yaml + description: Filters table data. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/filter-data.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-formatting + name: Formatting + fileName: formatting.yaml + description: Formats a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/formatting.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-get-data-from-table + name: Get data + fileName: get-data-from-table.yaml + description: Gets data from a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/get-data-from-table.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-get-visible-range-of-a-filtered-table + name: Get visible range + fileName: get-visible-range-of-a-filtered-table.yaml + description: Gets the visible range from a filtered table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-import-json-data + name: Import JSON data + fileName: import-json-data.yaml + description: Imports JSON data into a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/import-json-data.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-sort-data + name: Sort data + fileName: sort-data.yaml + description: Sorts the data within a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/sort-data.yaml + group: Table + api_set: + ExcelApi: '1.4' +- id: excel-table-resize + name: Resize a table + fileName: resize-table.yaml + description: This sample shows how to resize a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/resize-table.yaml + group: Table + api_set: + ExcelAPI: '1.13' +- id: excel-workbook-get-active-cell + name: Active cell + fileName: workbook-get-active-cell.yaml + description: Gets the active cell of the entire workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-get-active-cell.yaml + group: Workbook + api_set: + ExcelApi: '1.7' +- id: excel-settings-create-get-change-delete-settings + name: Add-in settings + fileName: create-get-change-delete-settings.yaml + description: >- + Creates, gets, changes, and deletes settings that are unique to the specific + workbook and add-in combination. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-get-change-delete-settings.yaml + group: Workbook + api_set: + ExcelApi: '1.4' +- id: excel-workbook-calculation + name: Calculations + fileName: workbook-calculation.yaml + description: >- + Demonstrates the calculation APIs of the workbook: events for when the + worksheet recalculates and application-level calculation controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-calculation.yaml + group: Workbook + api_set: + ExcelApi: '1.11' +- id: excel-workbook-create-workbook + name: Create workbook + fileName: create-workbook.yaml + description: >- + Creates a new, empty workbook and creates a new workbook by copying an + existing one. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-workbook.yaml + group: Workbook + api_set: + ExcelApi: '1.8' +- id: excel-culture-info + name: Culture info + fileName: culture-info.yaml + description: >- + This sample shows how to apply the cultural settings APIs to help normalize + data. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml + group: Workbook + api_set: + ExcelApi: '1.11' +- id: excel-culture-info-date-time + name: 'Culture info: date and time' + fileName: culture-info-date-time.yaml + description: >- + This sample shows how to use the read-only cultural settings APIs to + retrieve system date and time settings. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info-date-time.yaml + group: Workbook + api_set: + ExcelAPI: '1.12' +- id: excel-workbook-data-protection + name: Data protection + fileName: data-protection.yaml + description: Protects data in a worksheet and the workbook structure. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml + group: Workbook + api_set: + ExcelApi: '1.7' +- id: excel-workbook-save-and-close + name: Save and close + fileName: workbook-save-and-close.yaml + description: Saves and closes a workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml + group: Workbook + api_set: + ExcelAPI: '1.11' +- id: excel-workbook-insert-external-worksheets + name: Insert external worksheets + fileName: workbook-insert-external-worksheets.yaml + description: Inserts worksheets from another workbook into the current workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml + group: Workbook + api_set: + ExcelAPI: '1.13' +- id: excel-workbook-built-in-function + name: Use built-in Excel functions + fileName: workbook-built-in-functions.yaml + description: Use the VLOOKUP and SUM built-in Excel functions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-built-in-functions.yaml + group: Workbook + api_set: + ExcelAPI: '1.2' +- id: excel-worksheet-active-worksheet + name: Active worksheet + fileName: active-worksheet.yaml + description: Gets and sets the active worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/active-worksheet.yaml + group: Worksheet + api_set: + ExcelApi: '1.1' +- id: excel-worksheet-add-delete-rename-move-worksheet + name: Add, delete, rename, and move worksheet + fileName: add-delete-rename-move-worksheet.yaml + description: Adds, deletes, renames, and moves a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml + group: Worksheet + api_set: + ExcelApi: '1.1' +- id: excel-worksheet-auto-filter + name: AutoFilter + fileName: worksheet-auto-filter.yaml + description: Adds an AutoFilter to a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + group: Worksheet + api_set: + ExcelApi: '1.9' +- id: excel-worksheet-copy + name: Copy worksheet + fileName: worksheet-copy.yaml + description: Copies the active worksheet to the specified location. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-copy.yaml + group: Worksheet + api_set: + ExcelApi: '1.7' +- id: excel-worksheet-find-all + name: Find text matches within a worksheet + fileName: worksheet-find-all.yaml + description: Finds cells within a worksheet based on string matching. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-find-all.yaml + group: Worksheet + api_set: + ExcelApi: '1.9' +- id: excel-worksheet-freeze-panes + name: Frozen panes + fileName: worksheet-freeze-panes.yaml + description: >- + Freezes columns, rows, and a range of cells. Gets the address of the frozen + pane. Unfreezes frozen panes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + group: Worksheet + api_set: + ExcelApi: '1.7' +- id: excel-worksheet-worksheet-range-cell + name: Get range or cell + fileName: worksheet-range-cell.yaml + description: >- + Gets the used range, the entire range of a worksheet, the specified range, + and the specified cell. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-range-cell.yaml + group: Worksheet + api_set: + ExcelApi: '1.4' +- id: excel-worksheet-gridlines + name: Gridlines + fileName: gridlines.yaml + description: Hides and shows a worksheet's gridlines. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/gridlines.yaml + group: Worksheet + api_set: + ExcelApi: '1.8' +- id: excel-worksheet-list-worksheets + name: List worksheets + fileName: list-worksheets.yaml + description: Lists the worksheets in the workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/list-worksheets.yaml + group: Worksheet + api_set: + ExcelApi: '1.1' +- id: excel-worksheet-page-layout + name: Page layout and print settings + fileName: worksheet-page-layout.yaml + description: Changes the page layout and other settings for printing a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + group: Worksheet + api_set: + ExcelApi: '1.9' +- id: excel-worksheet-reference-worksheets-by-relative-position + name: Reference worksheets by relative position + fileName: reference-worksheets-by-relative-position.yaml + description: Gets a worksheet by using its relative position within the workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + group: Worksheet + api_set: + ExcelApi: '1.5' +- id: excel-worksheet-tab-color + name: Tab color + fileName: tab-color.yaml + description: Gets and sets the tab color of a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/tab-color.yaml + group: Worksheet + api_set: + ExcelApi: '1.7' +- id: excel-worksheet-visibility + name: Visibility + fileName: worksheet-visibility.yaml + description: Hides and unhides a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-visibility.yaml + group: Worksheet + api_set: + ExcelApi: '1.1' +- id: excel-performance-optimization + name: Performance optimization + fileName: performance-optimization.yaml + description: >- + Optimizes performance by untracking ranges, turning off screen painting, and + switching the calculation mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/performance-optimization.yaml + group: Scenarios + api_set: + ExcelApi: '1.9' +- id: excel-scenarios-report-generation + name: Report generation + fileName: report-generation.yaml + description: >- + Writes data to the workbook, reads and applies basic formatting, and adds a + chart bound to that data. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/report-generation.yaml + group: Scenarios + api_set: + ExcelApi: '1.1' +- id: excel-scenarios-multiple-property-set + name: Set multiple properties + fileName: multiple-property-set.yaml + description: Sets multiple properties at once with the API object set() method. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/multiple-property-set.yaml + group: Scenarios + api_set: + ExcelApi: '1.4' +- id: excel-scenarios-working-with-dates + name: Working with dates + fileName: working-with-dates.yaml + description: >- + Shows how to work with dates by using the Moment JavaScript library with the + Moment-MSDate plug-in. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/working-with-dates.yaml + group: Scenarios + api_set: + ExcelApi: '1.4' +- id: excel-scenarios-currency-converter + name: Currency Converter + fileName: currency-converter.yaml + description: >- + Uses an exchange rate API to convert currency values based on their original + transaction times. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/currency-converter.yaml + group: Scenarios + api_set: + ExcelApi: '1.4' +- id: excel-just-for-fun-patterns + name: Colorful Patterns + fileName: patterns.yaml + description: >- + Uses range formatting to draw interesting pattern. Contributed by Alexander + Zlatkovski. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/patterns.yaml + group: Just For Fun + api_set: + ExcelApi: '1.4' +- id: excel-just-for-fun-gradient + name: Gradient + fileName: gradient.yaml + description: >- + Uses range formatting and external libraries to draw a colorful gradient + within a range. Contributed by Alexander Zlatkovski. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/gradient.yaml + group: Just For Fun + api_set: + ExcelApi: '1.4' +- id: excel-just-for-fun-path-finder-game + name: Path finder + fileName: path-finder-game.yaml + description: >- + Uses range formatting to play a "pathfinder game". Contributed by Alexander + Zlatkovski. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/path-finder-game.yaml + group: Just For Fun + api_set: + ExcelApi: '1.4' +- id: excel-just-for-fun-tetrominos + name: Tetromino stacking + fileName: tetrominos.yaml + description: Arrange moving tetromino shapes to form lines. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/tetrominos.yaml + group: Just For Fun + api_set: + ExcelApi: '1.9' +- id: excel-just-for-fun-color-wheel + name: Wheel of colors + fileName: color-wheel.yaml + description: >- + Uses chart formatting to draw a wheel with changing colors. Contributed by + Alexander Zlatkovski. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/color-wheel.yaml + group: Just For Fun + api_set: + ExcelApi: '1.4' \ No newline at end of file diff --git a/playlists-prod/outlook.yaml b/playlists-prod/outlook.yaml new file mode 100644 index 000000000..9a1b827bc --- /dev/null +++ b/playlists-prod/outlook.yaml @@ -0,0 +1,843 @@ +- id: outlook-roaming-settings-roaming-settings + name: Use add-in settings + fileName: roaming-settings.yaml + description: Gets, sets, saves, and removes add-in roaming settings. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml + group: Roaming Settings + api_set: + Mailbox: '1.1' +- id: outlook-item-custom-properties-load-set-get-save + name: Work with item custom properties + fileName: load-set-get-save.yaml + description: >- + Gets the custom properties that the add-in placed on the current item, sets + a new one, gets it, removes it, and saves all custom properties back to the + item. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + group: Item Custom Properties + api_set: + Mailbox: '1.1' +- id: outlook-item-body-get-selected-data + name: Get selected text (Compose) + fileName: get-selected-data.yaml + description: Gets the selected text in the item body or subject in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-selected-data.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-replace-selected-text + name: Replace selected text in item body + fileName: replace-selected-text.yaml + description: >- + Replaces selected text in a message or appointment's body with specified + text. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/replace-selected-text.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-add-inline-base64-image + name: Add inline Base64-encoded image to message or appointment body (Compose) + fileName: add-inline-base64-image.yaml + description: >- + Add an inline Base64-encoded image to the body of a message or appointment + being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/add-inline-base64-image.yaml + group: Item Body + api_set: + Mailbox: '1.8' +- id: outlook-item-body-get-body-format + name: Get the item's body format + fileName: get-body-format.yaml + description: Gets a message or appointment's body format (plain text or HTML). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-body-format.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-append-text-on-send + name: Append text to item body on send + fileName: append-text-on-send.yaml + description: Appends text to the end of the message or appointment's body once it's sent. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/append-text-on-send.yaml + group: Item Body + api_set: + Mailbox: '1.9' +- id: outlook-item-body-prepend-text-to-item-body + name: Prepend text to item body + fileName: prepend-text-to-item-body.yaml + description: Adds text to the beginning of the message or appointment's body. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-to-item-body.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-prepend-text-on-send + name: Prepend text to item body on send + fileName: prepend-text-on-send.yaml + description: >- + Prepends text to the beginning of the message or appointment's body once + it's sent. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-on-send.yaml + group: Item Body + api_set: + Mailbox: '1.13' +- id: outlook-item-save-and-close-close + name: Close the item + fileName: close.yaml + description: Closes the item (compose mode) + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close.yaml + group: Item Save And Close + api_set: + Mailbox: '1.3' +- id: outlook-close-async + name: Close the current message and discard changes (Message Compose) + fileName: close-async.yaml + description: Closes the current message and discards any unsaved changes when specified. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close-async.yaml + group: Item Save And Close + api_set: + Mailbox: '1.14' +- id: outlook-item-save-and-close-save + name: Save the item + fileName: save.yaml + description: Saves the item (compose mode) + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/save.yaml + group: Item Save And Close + api_set: + Mailbox: '1.3' +- id: outlook-recipients-and-attendees-get-from-message-read + name: Get from (Message Read) + fileName: get-from-message-read.yaml + description: Gets who the message is from in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-from-message-compose + name: Get from (Message Compose) + fileName: get-from-message-compose.yaml + description: Gets who the message is from in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.7' +- id: outlook-recipients-and-attendees-get-to-message-read + name: Get to (Message Read) + fileName: get-to-message-read.yaml + description: Gets the To line recipients of the message in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-set-to-message-compose + name: Get and set to (Message Compose) + fileName: get-set-to-message-compose.yaml + description: Gets and sets the To line recipients of the message in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-cc-message-read + name: Get cc (Message Read) + fileName: get-cc-message-read.yaml + description: Gets the Cc line recipients of the message in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-set-cc-message-compose + name: Get and set cc (Message Compose) + fileName: get-set-cc-message-compose.yaml + description: Gets and sets the Cc line recipients of the message in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-set-bcc-message-compose + name: Get and set bcc (Message Compose) + fileName: get-set-bcc-message-compose.yaml + description: Gets and sets the Bcc line recipients of the message in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-sender-message-read + name: Get sender (Message Read) + fileName: get-sender-message-read.yaml + description: Gets the sender in Message Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-required-attendees-appointment-attendee + name: Get required attendees (Appointment Attendee) + fileName: get-required-attendees-appointment-attendee.yaml + description: Gets the required attendees in Appointment Attendee mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: >- + outlook-recipients-and-attendees-get-set-required-attendees-appointment-organizer + name: Get and set required attendees (Appointment Organizer) + fileName: get-set-required-attendees-appointment-organizer.yaml + description: Gets and sets the required attendees in Appointment Organizer mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-optional-attendees-appointment-attendee + name: Get optional attendees (Appointment Attendee) + fileName: get-optional-attendees-appointment-attendee.yaml + description: Gets the optional attendees in Appointment Attendee mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: >- + outlook-recipients-and-attendees-get-set-optional-attendees-appointment-organizer + name: Get and set optional attendees (Appointment Organizer) + fileName: get-set-optional-attendees-appointment-organizer.yaml + description: Gets and sets the optional attendees in Appointment Organizer mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-organizer-appointment-attendee + name: Get organizer (Appointment Attendee) + fileName: get-organizer-appointment-attendee.yaml + description: Gets the organizer in Appointment Attendee mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.1' +- id: outlook-recipients-and-attendees-get-organizer-appointment-organizer + name: Get organizer (Appointment Organizer) + fileName: get-organizer-appointment-organizer.yaml + description: Gets the organizer in Appointment Organizer mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.7' +- id: outlook-recipients-and-attendees-get-all-attendees + name: Get all attendees + fileName: get-all-attendees.yaml + description: Gets all appointment attendees and organizes them by their response. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.7' +- id: outlook-notifications-add-getall-remove + name: Work with notification messages + fileName: add-getall-remove.yaml + description: >- + Adds different kinds of notification messages, gets all notifications, and + replaces and removes an individual notification message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + group: Notifications + api_set: + Mailbox: '1.10' +- id: outlook-attachments-attachments-compose + name: Manipulate attachments (Item Compose) + fileName: attachments-compose.yaml + description: >- + Adds, gets, and removes attachments from a message or an appointment in + Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + group: Attachments + api_set: + Mailbox: '1.8' +- id: outlook-attachments-get-attachment-content + name: Get attachment content + fileName: get-attachment-content.yaml + description: Gets the attachment content in read or compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + group: Attachments + api_set: + Mailbox: '1.8' +- id: outlook-attachments-get-attachments-read + name: Get attachments (Item Read) + fileName: get-attachments-read.yaml + description: Gets the attachments of a message or an appointment in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml + group: Attachments + api_set: + Mailbox: '1.1' +- id: outlook-categories-work-with-categories + name: Work with item categories + fileName: work-with-categories.yaml + description: Gets, adds, and removes categories assigned to the item. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + group: Categories + api_set: + Mailbox: '1.8' +- id: outlook-categories-work-with-master-categories + name: Work with the categories master list + fileName: work-with-master-categories.yaml + description: Gets, adds, and removes categories in the master list for the mailbox. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + group: Categories + api_set: + Mailbox: '1.8' +- id: outlook-recurrence-get-series-id + name: Get the series ID + fileName: get-series-id.yaml + description: Gets the series ID. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml + group: Recurrence + api_set: + Mailbox: '1.7' +- id: outlook-recurrence-get-recurrence-read + name: Get recurrence (Read) + fileName: get-recurrence-read.yaml + description: Gets the recurrence pattern of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-recurrence-read.yaml + group: Recurrence + api_set: + Mailbox: '1.7' +- id: outlook-recurrence-get-set-recurrence-appointment-organizer + name: Get and set recurrence (Appointment Organizer) + fileName: get-set-recurrence-appointment-organizer.yaml + description: Gets and sets the recurrence pattern in Appointment Organizer mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + group: Recurrence + api_set: + Mailbox: '1.7' +- id: outlook-display-items-display-new-message + name: Create a new message + fileName: display-new-message.yaml + description: >- + Opens a new message form with a sample content, recipients, and an inline + image attachment + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-message.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-new-appointment + name: Create a new appointment + fileName: display-new-appointment.yaml + description: Opens a new appointment form with sample content and a few fields populated. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-appointment.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-existing-message + name: Open a message + fileName: display-existing-message.yaml + description: Displays an existing message in a separate window + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-message.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-existing-appointment + name: Open an appointment + fileName: display-existing-appointment.yaml + description: Displays existing appointment in a separate window + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-appointment.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-reply-forms + name: Create replies + fileName: display-reply-forms.yaml + description: Opens reply and reply-all message forms with sample reply content. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-reply-with-attachments + name: Create a reply with attachments + fileName: display-reply-with-attachments.yaml + description: Opens a reply or reply-all message form and adds sample attachments. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-sensitivity-labels-sensitivity-labels-catalog + name: Work with the sensitivity labels catalog + fileName: sensitivity-labels-catalog.yaml + description: >- + Determines if sensitivity labels are enabled on the mailbox and retrieves + all available labels from the catalog. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml + group: Sensitivity Label + api_set: + Mailbox: '1.13' +- id: outlook-sensitivity-labels-sensitivity-label + name: Work with sensitivity labels (Compose) + fileName: sensitivity-label.yaml + description: >- + Gets and sets the sensitivity label on a message or appointment in compose + mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + group: Sensitivity Label + api_set: + Mailbox: '1.13' +- id: outlook-delegates-and-shared-folders-get-shared-properties + name: Identify a shared folder or shared mailbox context + fileName: get-shared-properties.yaml + description: >- + Identifies whether the current mail item is in a shared folder or shared + mailbox by getting its properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + group: Delegates And Shared Folders + api_set: + Mailbox: '1.13' +- id: outlook-mime-headers-get-internet-headers-message-read + name: Get internet headers + fileName: get-internet-headers-message-read.yaml + description: Gets internet headers on a message in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml + group: Mime Headers + api_set: + Mailbox: '1.8' +- id: outlook-mime-headers-manage-custom-internet-headers-message-compose + name: Work with custom internet headers + fileName: manage-custom-internet-headers-message-compose.yaml + description: >- + Sets, gets, and removes custom internet headers on a message in Compose + mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + group: Mime Headers + api_set: + Mailbox: '1.8' +- id: outlook-regex-matches-contextual + name: Get regex matches (Item Read, contextual) + fileName: contextual.yaml + description: Gets regex matches when the add-in is opened as a contextual add-in. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + group: Regex Matches + api_set: + Mailbox: '1.6' +- id: outlook-events-drag-drop-item + name: Drag and drop an item into the task pane + fileName: drag-drop-item.yaml + description: >- + Handles the drag-and-drop event when a user drags and drops messages and + file attachments into the add-in task pane. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + group: Events + api_set: + Mailbox: '1.5' +- id: outlook-tokens-and-service-calls-ids-and-urls + name: Endpoint URLs and item IDs in Exchange on-premises environments + fileName: ids-and-urls.yaml + description: >- + Retrieves the Exchange Web Services (EWS) endpoint URL and item IDs and + converts item IDs for different protocols. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.5' +- id: outlook-tokens-and-service-calls-user-identity-token + name: Get a user identity token in Exchange on-premises environments + fileName: user-identity-token.yaml + description: >- + Gets a user identity token for authentication flows in an Exchange + on-premises environment. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' +- id: outlook-tokens-and-service-calls-user-callback-token + name: Get a callback token in Exchange on-premises environments + fileName: user-callback-token.yaml + description: >- + Gets a callback token to call Outlook services from an add-in's backend + service in an Exchange on-premises environment. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' +- id: outlook-tokens-and-service-calls-make-ews-request-async + name: >- + Get a message using Exchange Web Services (EWS) in Exchange on-premises + environments + fileName: make-ews-request-async.yaml + description: >- + Uses EWS in an Exchange on-premises environment to get a message without any + backend code. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' +- id: outlook-tokens-and-service-calls-send-message-using-make-ews-request-async + name: >- + Send a message using Exchange Web Services (EWS) in Exchange on-premises + environments + fileName: send-message-using-make-ews-request-async.yaml + description: >- + Uses EWS in an Exchange on-premises environment to send a message without + any backend code. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' +- id: outlook-tokens-and-service-calls-get-icaluid-as-organizer + name: Get an appointment's iCalUId as the organizer (Exchange on-premises only) + fileName: get-icaluid-as-organizer.yaml + description: >- + Uses Exchange Web Services (EWS) in an Exchange on-premises environment to + get an appointment's iCalUId value where the user is the organizer. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.3' +- id: outlook-tokens-and-service-calls-get-icaluid-as-attendee + name: Get an appointment's iCalUId as an attendee (Exchange on-premises only) + fileName: get-icaluid-as-attendee.yaml + description: >- + Uses Exchange Web Services (EWS) in an Exchange on-premises environment to + get an appointment's iCalUId value where the user is an attendee. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-subject-read + name: Get the subject (Read) + fileName: get-subject-read.yaml + description: Gets the subject of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-subject-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-set-subject-compose + name: Get and set the subject (Compose) + fileName: get-set-subject-compose.yaml + description: Gets and sets the subject of an item in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-item-body-set-selected-data + name: Replace selected text in item body or subject (Compose) + fileName: set-selected-data.yaml + description: Replaces the selected text in the item body or subject in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/set-selected-data.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-internet-message-id-read + name: Get the internet message ID (Message Read) + fileName: get-internet-message-id-read.yaml + description: Gets the internet message ID of a message in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-item-class-read + name: Get the item class (Read) + fileName: get-item-class-read.yaml + description: Gets the item class of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-item-type + name: Get the item type + fileName: get-item-type.yaml + description: Gets the item type. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-start-read + name: Get the start date and time (Read) + fileName: get-start-read.yaml + description: Gets the start date and time of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-set-start-appointment-organizer + name: Get and set the start date and time (Appointment Organizer) + fileName: get-set-start-appointment-organizer.yaml + description: Gets and sets the start date and time of an appointment in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-end-read + name: Get the end date and time (Read) + fileName: get-end-read.yaml + description: Gets the end date and time of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-set-end-appointment-organizer + name: Get and set the end date and time (Appointment Organizer) + fileName: get-set-end-appointment-organizer.yaml + description: Gets and sets the end date and time of an appointment in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-location-read + name: Get the location (Read) + fileName: get-location-read.yaml + description: Gets the location of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-location-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-set-location-appointment-organizer + name: Get and set the location (Appointment Organizer) + fileName: get-set-location-appointment-organizer.yaml + description: Gets and sets the location of an appointment in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-add-remove-enhancedlocation-appointment + name: Manage the locations of an appointment + fileName: get-add-remove-enhancedlocation-appointment.yaml + description: Gets, adds, and removes locations on an appointment (enhancedLocation API). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + group: Other Item APIs + api_set: + Mailbox: '1.8' +- id: outlook-other-item-apis-get-normalized-subject-read + name: Get the normalized subject (Read) + fileName: get-normalized-subject-read.yaml + description: Gets the normalized subject of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-conversation-id-message + name: Get the conversation ID (Message) + fileName: get-conversation-id-message.yaml + description: Gets the conversation ID of a message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-date-time-created-read + name: Get the creation date and time (Read) + fileName: get-date-time-created-read.yaml + description: Gets the creation date and time of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-date-time-modified-read + name: Get the last-modified date and time (Read) + fileName: get-date-time-modified-read.yaml + description: Gets the last-modified date and time of an item in Read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-get-diagnostic-information + name: Get mailbox diagnostic information + fileName: get-diagnostic-information.yaml + description: Gets a mailbox's diagnostic information. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-work-with-client-signatures + name: Work with client signatures (Compose) + fileName: work-with-client-signatures.yaml + description: >- + Checks if the client signature is enabled, disables the client signature, + gets the compose type, and sets a signature in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + group: Other Item APIs + api_set: + Mailbox: '1.10' +- id: outlook-other-item-apis-session-data-apis + name: Work with session data APIs (Compose) + fileName: session-data-apis.yaml + description: Sets, gets, gets all, removes, and clears session data in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + group: Other Item APIs + api_set: + Mailbox: '1.11' +- id: outlook-delay-message-delivery + name: Get and set message delivery (Message Compose) + fileName: delay-message-delivery.yaml + description: Gets and sets the delivery date and time of a message in compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml + group: Other Item APIs + api_set: + Mailbox: '1.13' +- id: outlook-other-item-apis-get-message-properties + name: Get properties of selected messages (Message Compose, Message Read) + fileName: get-message-properties.yaml + description: Gets the properties of multiple selected messages. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-message-properties.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-other-item-apis-get-set-sensitivity-level + name: Get and set the sensitivity level (Appointment Organizer) + fileName: get-set-sensitivity-level.yaml + description: Gets and sets the sensitivity level of an appointment being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-eml-format + name: Get the Base64-encoded EML format of a message (Message Read) + fileName: get-eml-format.yaml + description: Gets the Base64-encoded EML format of a message in read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-eml-format.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-in-reply-to + name: Get the ID of the message being replied to (Message Compose) + fileName: get-in-reply-to.yaml + description: Retrieves the ID of the message being replied to by the current message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-in-reply-to.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-conversation-index + name: Get the position of a message in a conversation (Message Compose) + fileName: get-conversation-index.yaml + description: >- + Retrieves the Base64-encoded position of the current message in a + conversation thread. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-index.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-item-class-async + name: Get item class (Message Compose) + fileName: get-item-class-async.yaml + description: Retrieves the item class property of the message being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-async.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-other-item-apis-item-id-compose + name: Get an item ID in compose mode + fileName: item-id-compose.yaml + description: Gets an item ID in compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/item-id-compose.yaml + group: Other Item APIs + api_set: + Mailbox: '1.8' +- id: outlook-send-async + name: Send the current message or appointment (Compose) + fileName: send-async.yaml + description: Sends the current message or appointment. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/send-async.yaml + group: Other Item APIs + api_set: + Mailbox: '1.15' +- id: outlook-other-item-apis-get-loaded-message-properties + name: Get properties of a loaded message (Message Compose, Message Read) + fileName: get-loaded-message-properties.yaml + description: Gets the properties of the currently loaded message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml + group: Other Item APIs + api_set: + Mailbox: '1.15' +- id: outlook-get-set-isalldayevent + name: Get and set the isAllDayEvent property (Appointment Organizer) + fileName: get-set-isalldayevent.yaml + description: Gets and sets the isAllDayEvent property of an appointment being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml + group: Preview APIs + api_set: + Mailbox: preview +- id: outlook-set-displayed-body-subject + name: Temporarily set the body or subject displayed in a message (Message Read) + fileName: set-displayed-body-subject.yaml + description: >- + Temporarily sets the content displayed in the body or subject of a message + in read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + group: Preview APIs + api_set: + Mailbox: preview \ No newline at end of file diff --git a/playlists-prod/powerpoint.yaml b/playlists-prod/powerpoint.yaml new file mode 100644 index 000000000..910edb0af --- /dev/null +++ b/playlists-prod/powerpoint.yaml @@ -0,0 +1,189 @@ +- id: powerpoint-basics-basic-api-call-ts + name: Basic API call (TypeScript) + fileName: basic-api-call-ts.yaml + description: Performs a basic PowerPoint API call using TypeScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-api-call-ts.yaml + group: Basics + api_set: + PowerPointApi: '1.4' +- id: powerpoint-basics-basic-api-call-js + name: Basic API call (JavaScript) + fileName: basic-api-call-js.yaml + description: Performs a basic PowerPoint API call using JavaScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-api-call-js.yaml + group: Basics + api_set: + PowerPointApi: '1.4' +- id: powerpoint-basics-basic-common-api-call + name: Basic API call (Office 2013) + fileName: basic-common-api-call.yaml + description: >- + Executes a basic PowerPoint API call using the "common API" syntax + (compatible with Office 2013). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-common-api-call.yaml + group: Basics + api_set: + Selection: '1.1' +- id: powerpoint-create-presentation + name: Create presentation + fileName: create-presentation.yaml + description: >- + Creates a new, empty presentation and creates a new presentation by copying + an existing one. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/document/create-presentation.yaml + group: Document + api_set: + PowerPointApi: '1.1' +- id: powerpoint-hyperlinks-manage-hyperlinks + name: Get hyperlinks + fileName: manage-hyperlinks.yaml + description: Gets the hyperlinks found in a slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml + group: Hyperlinks + api_set: + PowerPointApi: '1.6' +- id: powerpoint-basics-insert-image + name: Insert Image + fileName: insert-image.yaml + description: Inserts an image to the current slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/images/insert-image.yaml + group: Images + api_set: {} +- id: powerpoint-basics-insert-svg + name: Insert SVG + fileName: insert-svg.yaml + description: Inserts an SVG image using an XML string. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/images/insert-svg.yaml + group: Images + api_set: {} +- id: powerpoint-scenarios-searches-wikipedia-api + name: Search Wikipedia + fileName: searches-wikipedia-api.yaml + description: Searches Wikipedia based on the selected text in the presentation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/scenarios/searches-wikipedia-api.yaml + group: Scenarios + api_set: {} +- id: powerpoint-shapes + name: Insert shape, line, and text box + fileName: shapes.yaml + description: Inserts geometric shapes, lines, and text boxes to a slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.4' +- id: powerpoint-shapes-get-set-shapes + name: Get, set, load, and save shapes + fileName: get-set-shapes.yaml + description: Get and set one or more selected shapes. Load and save one or more shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.5' +- id: powerpoint-shapes-get-shapes-by-type + name: Select shapes by type + fileName: get-shapes-by-type.yaml + description: Gets shapes in a slide based on their type, such as GeometricShape or Line. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + group: Shapes + api_set: + PowerPointApi: '1.4' +- id: powerpoint-shapes-add-modify-tables + name: Add and modify tables + fileName: add-modify-tables.yaml + description: Shows how to add and modify tables in a presentation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-shapes-binding-to-shapes + name: Binding to shapes + fileName: binding-to-shapes.yaml + description: Shows how to create binding references for images and work with z-order. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-shapes-group-ungroup-shapes + name: Group and ungroup shapes + fileName: group-ungroup-shapes.yaml + description: Shows how to create two shapes then group and ungroup them. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-add-slides + name: Add slides to a presentation + fileName: add-slides.yaml + description: Adds a slide and optionally specifies the slide master and layout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.3' +- id: powerpoint-insert-slides + name: Insert slides from other presentation + fileName: insert-slides.yaml + description: Inserts slides from another PowerPoint file into the current presentation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.5' +- id: powerpoint-basics-get-slide-metadata + name: Get slide metadata + fileName: get-slide-metadata.yaml + description: Gets the title, index, and ID of the selected slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-slide-metadata.yaml + group: Slide Management + api_set: {} +- id: powerpoint-slide-management-get-set-slides + name: Get, set, load, and save slides + fileName: get-set-slides.yaml + description: Get and set one or more selected slides. Load and save one or more slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.5' +- id: powerpoint-slide-management-export-import-slide + name: Export and import slide + fileName: export-import-slide.yaml + description: Shows how to export and import a slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/export-import-slide.yaml + group: Slide Management + api_set: + PowerPointApi: '1.8' +- id: powerpoint-tags + name: Work with tags + fileName: tags.yaml + description: Use tags to process subsets of slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + group: Tags + api_set: + PowerPointApi: '1.3' +- id: powerpoint-text-get-set-textrange + name: Work with text range selections + fileName: get-set-textrange.yaml + description: Get, set, load, and save text range selections. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + group: Text + api_set: + PowerPointApi: '1.5' \ No newline at end of file diff --git a/playlists-prod/project.yaml b/playlists-prod/project.yaml new file mode 100644 index 000000000..ac477f709 --- /dev/null +++ b/playlists-prod/project.yaml @@ -0,0 +1,11 @@ +- id: project-basics-basic-common-api-call + name: Basic API call (Office 2013) + fileName: basic-common-api-call.yaml + description: >- + Executes a basic Project API call using the "common API" syntax (compatible + with Office 2013). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/project/basics/basic-common-api-call.yaml + group: Basics + api_set: + Selection: 1.1 \ No newline at end of file diff --git a/playlists-prod/word.yaml b/playlists-prod/word.yaml new file mode 100644 index 000000000..f55d4a138 --- /dev/null +++ b/playlists-prod/word.yaml @@ -0,0 +1,638 @@ +- id: word-basics-basic-api-call + name: Basic API call (TypeScript) + fileName: basic-api-call.yaml + description: Performs a basic Word API call using TypeScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-api-call.yaml + group: Basics + api_set: + WordApi: '1.1' +- id: word-basics-api-call-es5 + name: Basic API call (JavaScript) + fileName: basic-api-call-es5.yaml + description: Performs a basic Word API call using plain JavaScript & Promises. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-api-call-es5.yaml + group: Basics + api_set: + WordApi: '1.1' +- id: word-basics-basic-common-api-call + name: Basic API call (Office 2013) + fileName: basic-common-api-call.yaml + description: >- + Performs a basic Word API call using JavaScript with the "common API" syntax + (compatible with Office 2013). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-common-api-call.yaml + group: Basics + api_set: + Selection: 1.1 +- id: word-content-controls-insert-and-change-content-controls + name: Content control basics + fileName: insert-and-change-content-controls.yaml + description: Inserts, updates, and retrieves content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml + group: Content Controls + api_set: + WordApi: '1.1' +- id: word-content-controls-content-control-onadded-event + name: On adding content controls + fileName: content-control-onadded-event.yaml + description: >- + Registers, triggers, and deregisters onAdded event that tracks the addition + of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onentered-event + name: On entering content controls + fileName: content-control-onentered-event.yaml + description: >- + Registers, triggers, and deregisters onEntered event that tracks when the + cursor is placed within content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onselectionchanged-event + name: On changing selection in content controls + fileName: content-control-onselectionchanged-event.yaml + description: >- + Registers, triggers, and deregisters onSelectionChanged event that tracks + when selections are changed in content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-ondatachanged-event + name: On changing data in content controls + fileName: content-control-ondatachanged-event.yaml + description: >- + Registers, triggers, and deregisters onDataChanged event that tracks when + data is changed in content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onexited-event + name: On exiting content controls + fileName: content-control-onexited-event.yaml + description: >- + Registers, triggers, and deregisters onExited event that tracks when the + cursor is removed from within content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-ondeleted-event + name: On deleting content controls + fileName: content-control-ondeleted-event.yaml + description: >- + Registers, triggers, and deregisters onDeleted event that tracks the removal + of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-insert-and-change-checkbox-content-control + name: Manage checkbox content controls + fileName: insert-and-change-checkbox-content-control.yaml + description: Inserts, updates, retrieves, and deletes checkbox content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.7' +- id: word-content-controls-insert-and-change-combo-box-content-control + name: Manage combo box content controls + fileName: insert-and-change-combo-box-content-control.yaml + description: Inserts, updates, and deletes combo box content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.9' +- id: word-content-controls-insert-and-change-dropdown-list-content-control + name: Manage dropdown list content controls + fileName: insert-and-change-dropdown-list-content-control.yaml + description: Inserts, updates, and deletes dropdown list content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.9' +- id: word-content-controls-get-change-tracking-states + name: Get change tracking states of content controls + fileName: get-change-tracking-states.yaml + description: Gets change tracking states of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/get-change-tracking-states.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-images-insert-and-get-pictures + name: Use inline pictures + fileName: insert-and-get-pictures.yaml + description: Inserts and gets inline pictures. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml + group: Images + api_set: + WordApiDesktop: '1.1' +- id: word-lists-insert-list + name: Create a list + fileName: insert-list.yaml + description: Inserts a new list into the document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml + group: Lists + api_set: + WordApi: '1.3' +- id: word-lists-manage-styles + name: Get list styles + fileName: manage-list-styles.yaml + description: This sample shows how to get the list styles in the current document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml + group: Lists + api_set: + WordApiDesktop: '1.1' +- id: word-lists-organize-list + name: Organize a list + fileName: organize-list.yaml + description: Shows how to create and organize a list. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml + group: Lists + api_set: + WordApi: '1.3' +- id: word-paragraph-get-paragraph-on-insertion-point + name: Get paragraph from insertion point + fileName: get-paragraph-on-insertion-point.yaml + description: Gets the full paragraph containing the insertion point. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-insert-line-and-page-breaks + name: Insert breaks + fileName: insert-line-and-page-breaks.yaml + description: Inserts page and line breaks in a document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-line-and-page-breaks.yaml + group: Paragraph + api_set: + WordApi: '1.2' +- id: word-paragraph-insert-in-different-locations + name: Insert content at different locations + fileName: insert-in-different-locations.yaml + description: Inserts content at different document locations. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-in-different-locations.yaml + group: Paragraph + api_set: + WordApi: '1.2' +- id: word-paragraph-insert-formatted-text + name: Insert formatted text + fileName: insert-formatted-text.yaml + description: Formats text with pre-built and custom styles. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-formatted-text.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-insert-header-and-footer + name: Insert headers and footers + fileName: insert-header-and-footer.yaml + description: Inserts headers and footers in the document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-header-and-footer.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-paragraph-properties + name: Paragraph properties + fileName: paragraph-properties.yaml + description: Sets indentation, space between paragraphs, and other paragraph properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-search + name: Search + fileName: search.yaml + description: Shows basic and advanced search capabilities. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/search.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-get-word-count + name: Get word count + fileName: get-word-count.yaml + description: Counts how many times a word or term appears in the document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-word-count.yaml + group: Paragraph + api_set: + WordApi: '1.1' +- id: word-paragraph-get-text + name: Get text + fileName: get-text.yaml + description: >- + Shows how to get paragraph text, including hidden text and text marked for + deletion. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-text.yaml + group: Paragraph + api_set: + WordApi: '1.7' +- id: word-paragraph-onadded-event + name: On adding paragraphs + fileName: onadded-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphAdded event that tracks + the addition of paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' +- id: word-paragraph-onchanged-event + name: On changing content in paragraphs + fileName: onchanged-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphChanged event that + tracks when content is changed in paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' +- id: word-paragraph-ondeleted-event + name: On deleting paragraphs + fileName: ondeleted-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphDeleted event that + tracks the removal of paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' +- id: word-properties-get-built-in-properties + name: Built-in document properties + fileName: get-built-in-properties.yaml + description: Gets built-in document properties. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/get-built-in-properties.yaml + group: Properties + api_set: + WordApi: '1.1' +- id: word-properties-read-write-custom-document-properties + name: Custom document properties + fileName: read-write-custom-document-properties.yaml + description: Adds and reads custom document properties of different types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml + group: Properties + api_set: + WordApi: '1.3' +- id: word-ranges-scroll-to-range + name: Scroll to a range + fileName: scroll-to-range.yaml + description: Scrolls to a range with and without selection. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml + group: Ranges + api_set: + WordApi: '1.2' +- id: word-ranges-split-words-of-first-paragraph + name: Split a paragraph into ranges + fileName: split-words-of-first-paragraph.yaml + description: >- + Splits a paragraph into word ranges and then traverses all the ranges to + format each word, producing a "karaoke" effect. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/split-words-of-first-paragraph.yaml + group: Ranges + api_set: + WordApi: '1.3' +- id: word-ranges-compare-location + name: Compare range locations + fileName: compare-location.yaml + description: This sample shows how to compare the locations of two ranges. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/compare-location.yaml + group: Ranges + api_set: + WordApi: '1.3' +- id: word-ranges-get-pages + name: Work with pages, panes, and windows + fileName: get-pages.yaml + description: Shows how to work with pages, panes, and windows. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml + group: Ranges + api_set: + WordApiDesktop: '1.2' +- id: word-tables-table-cell-access + name: Create and access a table + fileName: table-cell-access.yaml + description: Creates a table and accesses a specific cell. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml + group: Tables + api_set: + WordApi: '1.3' +- id: word-tables-manage-formatting + name: Table formatting + fileName: manage-formatting.yaml + description: >- + Gets the formatting details of a table, a table row, and a table cell, + including borders, alignment, and cell padding. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + group: Tables + api_set: + WordApi: '1.3' +- id: word-tables-manage-custom-style + name: Manage custom table style + fileName: manage-custom-style.yaml + description: >- + Shows how to manage primarily margins and alignments of a custom table style + in the current document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml + group: Tables + api_set: + WordApiDesktop: '1.1' +- id: word-shapes-manage-shapes-text-boxes + name: Work with shapes and text boxes + fileName: manage-shapes-text-boxes.yaml + description: Shows how to work with shapes and text boxes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-manage-geometric-shapes + name: Manage geometric shapes + fileName: manage-geometric-shapes.yaml + description: Shows how to work with geometric shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-group-ungroup + name: Group and ungroup shapes + fileName: group-ungroup.yaml + description: Shows how to group and ungroup shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-manage-canvases + name: Work with canvases + fileName: manage-canvases.yaml + description: Shows how to work with canvases. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-canvases.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-document-manage-body + name: Manage body + fileName: manage-body.yaml + description: Shows how to manage the document body. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml + group: Document + api_set: + WordApi: '1.2' +- id: word-document-insert-section-breaks + name: Add a section + fileName: insert-section-breaks.yaml + description: Shows how to insert section breaks in the document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-section-breaks.yaml + group: Document + api_set: + WordApi: '1.1' +- id: word-document-insert-external-document + name: Insert an external document + fileName: insert-external-document.yaml + description: >- + Inserts the content (with or without settings) of an external document into + the current document. Settings include formatting, change-tracking mode, + custom properties, and XML parts. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml + group: Document + api_set: + WordApi: '1.7' +- id: word-document-manage-change-tracking + name: Track changes + fileName: manage-change-tracking.yaml + description: >- + This sample shows how to get and set the change tracking mode and get the + before and after of reviewed text. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-tracked-changes + name: Manage tracked changes + fileName: manage-tracked-changes.yaml + description: >- + This samples shows how to manage tracked changes, including accepting and + rejecting changes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + group: Document + api_set: + WordApi: '1.6' +- id: word-document-manage-comments + name: Manage comments + fileName: manage-comments.yaml + description: >- + This sample shows how to perform basic comments operations, including + insert, reply, get, edit, resolve, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-footnotes + name: Manage footnotes + fileName: manage-footnotes.yaml + description: >- + This sample shows how to perform basic footnote operations, including + insert, get, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-fields + name: Manage fields + fileName: manage-fields.yaml + description: >- + This sample shows how to perform basic operations on fields, including + insert, get, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-settings + name: Manage settings + fileName: manage-settings.yaml + description: >- + This sample shows how to add, edit, get, and delete custom settings on a + document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-custom-xml-part-ns + name: Manage a CustomXmlPart with the namespace + fileName: manage-custom-xml-part-ns.yaml + description: >- + This sample shows how to add, query, replace, edit, and delete a custom XML + part in a document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-custom-xml-part + name: Manage a CustomXmlPart without the namespace + fileName: manage-custom-xml-part.yaml + description: >- + This sample shows how to add, query, edit, and delete a custom XML part in a + document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-styles + name: Manage styles + fileName: manage-styles.yaml + description: >- + This sample shows how to perform operations on the styles in the current + document and how to add and delete custom styles. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml + group: Document + api_set: + WordApiDesktop: '1.1' +- id: word-document-get-external-styles + name: Get styles from external document + fileName: get-external-styles.yaml + description: This sample shows how to get styles from an external document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/get-external-styles.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-save-close + name: Manage document save and close + fileName: save-close.yaml + description: Shows how to manage saving and closing document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-annotations + name: Manage annotations + fileName: manage-annotations.yaml + description: >- + Shows how to leverage the Writing Assistance API to manage annotations and + use annotation events. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + group: Document + api_set: + WordApi: '1.8' +- id: word-document-compare-documents + name: Compare documents + fileName: compare-documents.yaml + description: Compares two documents (the current one and a specified external one). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/compare-documents.yaml + group: Document + api_set: + WordApiDesktop: '1.1' +- id: word-scenarios-doc-assembly + name: Document assembly + fileName: doc-assembly.yaml + description: Composes different parts of a Word document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml + group: Scenarios + api_set: + WordApi: '1.1' +- id: word-scenarios-multiple-property-set + name: Set multiple properties at once + fileName: multiple-property-set.yaml + description: Sets multiple properties at once with the API object set() method. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/multiple-property-set.yaml + group: Scenarios + api_set: + WordApi: '1.3' +- id: word-scenarios-correlated-objects-pattern + name: Correlated objects pattern + fileName: correlated-objects-pattern.yaml + description: Shows the performance benefits of avoiding `context.sync` calls in a loop. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/correlated-objects-pattern.yaml + group: Scenarios + api_set: + WordApi: '1.4' +- id: word-close-document-window + name: Close document window + fileName: close-document-window.yaml + description: Shows how to close document window. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/close-document-window.yaml + group: Preview APIs + api_set: + WordApi: '1.10' +- id: word-insert-and-change-content-controls + name: Content control basics + fileName: insert-and-change-content-controls.yaml + description: Inserts, updates, and retrieves content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml + group: Preview APIs + api_set: + WordApi: '1.10' +- id: word-manage-comments + name: Manage comments + fileName: manage-comments.yaml + description: >- + This sample shows how to perform operations on comments (including insert, + reply, get, edit, resolve, and delete) and use comment events. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml + group: Preview APIs + api_set: + WordApi: '1.10' \ No newline at end of file diff --git a/playlists/excel.yaml b/playlists/excel.yaml index d34f52272..5aa863380 100644 --- a/playlists/excel.yaml +++ b/playlists/excel.yaml @@ -3,7 +3,7 @@ fileName: basic-api-call.yaml description: Performs a basic Excel API call using TypeScript. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/01-basics/basic-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-api-call.yaml group: Basics api_set: ExcelApi: '1.1' @@ -12,7 +12,7 @@ fileName: basic-api-call-es5.yaml description: Performs a basic Excel API call using plain JavaScript & Promises. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/01-basics/basic-api-call-es5.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-api-call-es5.yaml group: Basics api_set: ExcelApi: '1.1' @@ -23,16 +23,16 @@ Performs a basic Excel API call using JavaScript with the "common API" syntax (compatible with Office 2013). rawUrl: >- - https://raw.githubusercontent.com////samples/excel/01-basics/basic-common-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-common-api-call.yaml group: Basics api_set: Selection: 1.1 - id: excel-chart-axis name: Axis details fileName: chart-axis.yaml - description: 'Gets, sets, and removes axis unit, label, and title in a chart.' + description: Gets, sets, and removes axis unit, label, and title in a chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-axis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-axis.yaml group: Chart api_set: ExcelApi: '1.7' @@ -41,10 +41,19 @@ fileName: chart-axis-formatting.yaml description: Formats the vertical and horizontal axes in a chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-axis-formatting.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-axis-formatting.yaml group: Chart api_set: ExcelApi: '1.8' +- id: excel-chart-data-table + name: Chart data table + fileName: chart-data-table.yaml + description: Add a data table to a chart and then format that data table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-table.yaml + group: Chart + api_set: + ExcelApi: '1.14' - id: excel-chart-bubble-chart name: Create bubble chart fileName: chart-bubble-chart.yaml @@ -52,7 +61,7 @@ Creates a bubble chart with each data row represented as a single chart series (bubble). rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-bubble-chart.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-bubble-chart.yaml group: Chart api_set: ExcelApi: '1.12' @@ -63,7 +72,7 @@ Creates column-clustered, line, XY-scatter, area, radar, pie, 3D, cylinder, and 100% charts. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-create-several-charts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-create-several-charts.yaml group: Chart api_set: ExcelApi: '1.4' @@ -72,7 +81,7 @@ fileName: create-doughnut-chart.yaml description: Creates a doughnut chart and adjusts its size. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/create-doughnut-chart.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/create-doughnut-chart.yaml group: Chart api_set: ExcelApi: '1.7' @@ -81,7 +90,7 @@ fileName: chart-formatting.yaml description: Formats labels and lines of a slope chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-formatting.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-formatting.yaml group: Chart api_set: ExcelApi: '1.8' @@ -90,7 +99,7 @@ fileName: chart-legend.yaml description: Formats the legend's font. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-legend.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-legend.yaml group: Chart api_set: ExcelApi: '1.7' @@ -99,7 +108,7 @@ fileName: chart-point.yaml description: Sets the color of a point on the chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-point.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-point.yaml group: Chart api_set: ExcelApi: '1.7' @@ -108,7 +117,7 @@ fileName: chart-series.yaml description: Adds and deletes series in a chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-series.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series.yaml group: Chart api_set: ExcelApi: '1.7' @@ -117,7 +126,7 @@ fileName: chart-series-markers.yaml description: Sets the chart series marker properties. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-series-markers.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series-markers.yaml group: Chart api_set: ExcelApi: '1.7' @@ -126,7 +135,7 @@ fileName: chart-series-plotorder.yaml description: Orders the plotting of series in a chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-series-plotorder.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series-plotorder.yaml group: Chart api_set: ExcelApi: '1.7' @@ -135,26 +144,55 @@ fileName: chart-title-format.yaml description: Adjust a chart title's format. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-title-format.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-title-format.yaml group: Chart api_set: ExcelApi: '1.7' +- id: excel-chart-data-source + name: Chart series data source + fileName: chart-data-source.yaml + description: >- + This sample shows how to get information about the data source of a chart + series. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-source.yaml + group: Chart + api_set: + ExcelApi: '1.15' - id: excel-chart-trendlines name: Trendlines fileName: chart-trendlines.yaml - description: 'Adds, gets, and formats trendlines in a chart.' + description: Adds, gets, and formats trendlines in a chart. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/10-chart/chart-trendlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-trendlines.yaml group: Chart api_set: ExcelApi: '1.7' +- id: excel-chart-data-labels + name: Data labels + fileName: chart-data-labels.yaml + description: Add and style data labels for your charts. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-labels.yaml + group: Chart + api_set: + ExcelApi: '1.19' +- id: excel-chart-leader-lines + name: Leader lines + fileName: chart-leader-lines.yaml + description: Show and hide leader lines for chart labels. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-leader-lines.yaml + group: Chart + api_set: + ExcelApi: '1.19' - id: excel-comment-basics name: Comment basics fileName: comment-basics.yaml - description: 'Adds, edits, and removes comments.' + description: Adds, edits, and removes comments. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/12-comment/comment-basics.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-basics.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-mentions @@ -162,17 +200,17 @@ fileName: comment-mentions.yaml description: Mentions someone in a comment. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/12-comment/comment-mentions.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-mentions.yaml + group: Comments And Notes api_set: ExcelApi: '1.11' - id: excel-comment-replies name: Comment replies fileName: comment-replies.yaml - description: 'Adds, edits, and removes comment replies.' + description: Adds, edits, and removes comment replies. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/12-comment/comment-replies.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-replies.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-resolution @@ -180,16 +218,25 @@ fileName: comment-resolution.yaml description: Resolves and reopens a comment thread. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/12-comment/comment-resolution.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-resolution.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' +- id: excel-note-basics + name: Notes + fileName: excel-note-basics.yaml + description: Adds, edits, and removes notes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/excel-note-basics.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.18' - id: excel-range-conditional-formatting-basic name: Basic conditional formatting fileName: conditional-formatting-basic.yaml description: Applies common types of conditional formatting to ranges. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml group: Conditional Formatting api_set: ExcelApi: '1.6' @@ -198,7 +245,7 @@ fileName: conditional-formatting-advanced.yaml description: Applies more than one conditional format on the same range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml group: Conditional Formatting api_set: ExcelApi: '1.6' @@ -207,7 +254,7 @@ fileName: basic-function.yaml description: Calculates the volume of a sphere. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/16-custom-functions/basic-function.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/basic-function.yaml group: Custom Functions api_set: CustomFunctionsRuntime: 1.1 @@ -216,7 +263,7 @@ fileName: volatile-function.yaml description: Rolls a 6 sided die that returns a possible new value every calculation. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/16-custom-functions/volatile-function.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/volatile-function.yaml group: Custom Functions api_set: CustomFunctionsRuntime: 1.1 @@ -225,7 +272,7 @@ fileName: streaming-function.yaml description: A streaming function that continuously increments the cell value. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/16-custom-functions/streaming-function.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/streaming-function.yaml group: Custom Functions api_set: CustomFunctionsRuntime: 1.1 @@ -234,16 +281,47 @@ fileName: web-call-function.yaml description: Calls the GitHub API to get the star count for an org/user and repository. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/16-custom-functions/web-call-function.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/web-call-function.yaml group: Custom Functions api_set: CustomFunctionsRuntime: 1.1 +- id: excel-custom-functions-errors + name: Custom functions errors + fileName: custom-functions-errors.yaml + description: Returns the "#NUM!" error as part of a 2-dimensional array. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/custom-functions-errors.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.2 +- id: excel-data-types-custom-functions + name: 'Data types: Custom functions' + fileName: data-types-custom-functions.yaml + description: >- + This sample shows how to write custom functions that return entity value + data types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/data-types-custom-functions.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.4 +- id: excel-custom-functions-custom-enum + name: Function with custom enums + fileName: custom-enum.yaml + description: >- + Use custom enums as parameters in a custom function that searches for + flights. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/custom-enum.yaml + group: Custom Functions + api_set: + CustomFunctionsRuntime: 1.5 - id: excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts name: Using custom XML parts fileName: create-set-get-and-delete-custom-xml-parts.yaml - description: 'Creates, sets, gets, and deletes a custom XML part.' + description: Creates, sets, gets, and deletes a custom XML part. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml group: Custom XML Parts api_set: ExcelApi: '1.5' @@ -252,10 +330,97 @@ fileName: test-xml-for-unique-namespace.yaml description: Tests to see if there is only one XML part for a specified namespace. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml group: Custom XML Parts api_set: ExcelApi: '1.5' +- id: excel-data-types-doubles + name: 'Data types: Formatted numbers' + fileName: data-types-formatted-number.yaml + description: >- + This sample shows how to set and get formatted numbers using double data + types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-formatted-number.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-web-image + name: 'Data types: Web images' + fileName: data-types-web-image.yaml + description: >- + This sample shows how to set and get web images in a worksheet using data + types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-web-image.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-entity-values + name: 'Data types: Create entity cards from data in a table' + fileName: data-types-entity-values.yaml + description: >- + This sample shows how to create entity cards for each row in a table. An + entity is a container for data types, similar to an object in + object-oriented programming. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-values.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-error-values + name: 'Data types: Set and change error values' + fileName: data-types-error-values.yaml + description: >- + This sample shows how to set a cell value to an error data type, and then + update the value of cells that contain an error data type. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-error-values.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-icons + name: 'Data types: Create entity icons' + fileName: data-types-entity-icons.yaml + description: Display all the icons available for entity data types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-icons.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-entity-attribution + name: 'Data types: Entity value attribution properties' + fileName: data-types-entity-attribution.yaml + description: >- + This sample shows how to set data provider attributions on entity values in + the card layout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-attribution.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-references + name: 'Data types: Entity values with references' + fileName: data-types-references.yaml + description: >- + This sample shows how to create entity values with references to other + entity values. An entity value is a container for data, and this container + can reference (or contain) other entities within the original entity. One + entity can contain multiple additional entities. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-references.yaml + group: Data Types + api_set: + ExcelApi: '1.16' +- id: excel-data-types-basic-types + name: Basic types with metadata + fileName: data-types-basic-types.yaml + description: This sample shows how to work with metadata on basic types. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-basic-types.yaml + group: Data Types + api_set: + ExcelApi: '1.19' - id: excel-data-validation name: Data validation fileName: data-validation.yaml @@ -263,7 +428,7 @@ Sets data validation rules on ranges, prompts users to enter valid data, and displays messages when invalid data is entered. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/22-data-validation/data-validation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/22-data-validation/data-validation.yaml group: Data Validation api_set: ExcelApi: '1.8' @@ -271,10 +436,10 @@ name: Get file using slicing fileName: get-file-in-slices-async.yaml description: >- - Uses slicing to get the byte array and base64-encoded string that represent + Uses slicing to get the byte array and Base64-encoded string that represent the current document. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/26-document/get-file-in-slices-async.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/get-file-in-slices-async.yaml group: Document api_set: ExcelApi: '1.4' @@ -283,7 +448,7 @@ fileName: properties.yaml description: Gets and sets document properties. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/26-document/properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/properties.yaml group: Document api_set: ExcelApi: '1.7' @@ -292,7 +457,7 @@ fileName: custom-properties.yaml description: Gets and sets custom properties at the document and worksheet levels. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/26-document/custom-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/custom-properties.yaml group: Document api_set: ExcelAPI: '1.12' @@ -304,7 +469,7 @@ chart within is activated or deactivated, as well as when charts are added to or deleted from the collection. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-chartcollection-added-activated.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-chartcollection-added-activated.yaml group: Events api_set: ExcelApi: '1.8' @@ -315,7 +480,7 @@ Registers event handlers on an individual chart that run when the chart is activated or deactivated. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-chart-activated.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-chart-activated.yaml group: Events api_set: ExcelApi: '1.8' @@ -326,25 +491,36 @@ Registers event handlers that run when column or row sorting events occur in the current worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/event-column-and-row-sort.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/event-column-and-row-sort.yaml group: Events api_set: ExcelApi: '1.10' +- id: excel-events-comments + name: Comment events + fileName: events-comment-event-handler.yaml + description: >- + Registers event handlers to listen for comment additions, changes, and + deletions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-comment-event-handler.yaml + group: Events + api_set: + ExcelAPI: '1.12' - id: excel-events-data-changed - name: Data change event + name: Data changed event fileName: data-changed.yaml description: Registers an event handler that runs when data is changed. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/data-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/data-changed.yaml group: Events api_set: ExcelApi: '1.4' - id: excel-data-change-event-details - name: Data change event details + name: Data changed event details fileName: data-change-event-details.yaml description: Uses the onChanged event of a table to determine the specifics of changes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/data-change-event-details.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/data-change-event-details.yaml group: Events api_set: ExcelApi: '1.9' @@ -353,18 +529,36 @@ fileName: events-disable-events.yaml description: Toggles event firing on and off. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-disable-events.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-disable-events.yaml group: Events api_set: ExcelApi: '1.8' +- id: excel-events-formula-changed + name: Formula changed event + fileName: events-formula-changed.yaml + description: Registers an event handler to detect changes to formulas. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-formula-changed.yaml + group: Events + api_set: + ExcelAPI: '1.13' - id: excel-selection-changed-events - name: Selection change events + name: Selection changed events fileName: selection-changed-events.yaml description: >- Registers handlers all the different `onSelectionChanged` events and displays how each event reports the selected addresses. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/selection-changed-events.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/selection-changed-events.yaml + group: Events + api_set: + ExcelApi: '1.7' +- id: excel-events-tablecollection-changed + name: Table collection events + fileName: events-tablecollection-changed.yaml + description: Registers an event handler that runs when a table collection is changed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-tablecollection-changed.yaml group: Events api_set: ExcelApi: '1.7' @@ -375,28 +569,28 @@ Registers an event handler that runs when a single-click event occurs in the current worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/event-worksheet-single-click.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/event-worksheet-single-click.yaml group: Events api_set: ExcelApi: '1.10' -- id: excel-events-tablecollection-changed - name: Table collection events - fileName: events-tablecollection-changed.yaml - description: Registers an event handler that runs when a table collection is changed. - rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-tablecollection-changed.yaml - group: Events - api_set: - ExcelApi: '1.7' - id: excel-events-table-changed name: Table events fileName: events-table-changed.yaml description: Registers event handlers that run when a table is changed or selected. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-table-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-table-changed.yaml group: Events api_set: ExcelApi: '1.7' +- id: excel-events-workbook-activated + name: Workbook activated event + fileName: events-workbook-activated.yaml + description: This sample shows how to register a workbook activated event handler. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-workbook-activated.yaml + group: Events + api_set: + ExcelAPI: '1.13' - id: excel-events-workbook-and-worksheet-collection name: Workbook and worksheet collection events fileName: events-workbook-and-worksheet-collection.yaml @@ -404,7 +598,7 @@ Registers event handlers that run when a worksheet is added, activated, or deactivated, or when the settings of a workbook are changed. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml group: Events api_set: ExcelApi: '1.7' @@ -415,27 +609,27 @@ Registers event handlers that run when data is changed in worksheet, the selected range changes in a worksheet, or the worksheet is recalculated. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-worksheet.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-worksheet.yaml group: Events api_set: ExcelApi: '1.7' -- id: excel-events-comments - name: Comment events - fileName: events-comment-event-handler.yaml +- id: excel-events-worksheet-protection + name: Worksheet protection events + fileName: events-worksheet-protection.yaml description: >- - Registers event handlers to listen for comment additions, changes, and - deletions. + Registers an event handler to listen for worksheet protection status + changes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-worksheet-protection.yaml group: Events api_set: - ExcelAPI: '1.12' + ExcelAPI: '1.14' - id: excel-named-item-create-and-remove-named-item - name: 'Create, access, and remove' + name: Create, access, and remove fileName: create-and-remove-named-item.yaml - description: 'Creates, accesses, and removes named items in a worksheet.' + description: Creates, accesses, and removes named items in a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/34-named-item/create-and-remove-named-item.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/34-named-item/create-and-remove-named-item.yaml group: Named Item api_set: ExcelApi: '1.4' @@ -444,7 +638,7 @@ fileName: update-named-item.yaml description: Creates and then updates a named item. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/34-named-item/update-named-item.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/34-named-item/update-named-item.yaml group: Named Item api_set: ExcelApi: '1.7' @@ -453,7 +647,7 @@ fileName: pivottable-calculations.yaml description: Changes the calculations the PivotTable performs. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-calculations.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-calculations.yaml group: PivotTable api_set: ExcelApi: '1.8' @@ -462,7 +656,7 @@ fileName: pivottable-create-and-modify.yaml description: Creates and modifies a PivotTable. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-create-and-modify.yaml group: PivotTable api_set: ExcelApi: '1.8' @@ -471,7 +665,7 @@ fileName: pivottable-filters-and-summaries.yaml description: Filters PivotTable data and shows different summarizations. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml group: PivotTable api_set: ExcelApi: '1.8' @@ -482,34 +676,61 @@ Get existing PivotTables in the workbook through their collections and through the ranges they occupy. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-get-pivottables.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-get-pivottables.yaml group: PivotTable api_set: ExcelAPI: '1.12' -- id: excel-pivottable-slicer - name: Slicer - fileName: pivottable-slicer.yaml - description: Adds a slicer to a PivotTable. - rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-slicer.yaml - group: PivotTable - api_set: - ExcelApi: '1.10' - id: excel-pivottables-pivotfilters name: PivotFilters fileName: pivottable-pivotfilters.yaml description: Applies PivotFilters to a PivotTable. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-pivotfilters.yaml group: PivotTable api_set: ExcelAPI: '1.12' +- id: excel-pivottable-pivotlayout + name: PivotLayout + fileName: pivottable-pivotlayout.yaml + description: Sets PivotTable layout settings through the PivotLayout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + group: PivotTable + api_set: + ExcelAPI: '1.13' +- id: excel-pivottable-data-source + name: PivotTable data source + fileName: pivottable-source-data.yaml + description: Gets information about the data source of a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-source-data.yaml + group: PivotTable + api_set: + ExcelApi: '1.15' +- id: excel-pivottable-refresh + name: Refresh + fileName: pivottable-refresh.yaml + description: Refreshes a PivotTable based on table row additions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-refresh.yaml + group: PivotTable + api_set: + ExcelApi: '1.8' +- id: excel-pivottable-slicer + name: Slicer + fileName: pivottable-slicer.yaml + description: Adds a slicer to a PivotTable. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-slicer.yaml + group: PivotTable + api_set: + ExcelApi: '1.10' - id: excel-range-auto-fill name: Auto fill fileName: range-auto-fill.yaml description: Writes to cells with the auto fill feature. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-auto-fill.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-auto-fill.yaml group: Range api_set: ExcelApi: '1.10' @@ -518,7 +739,7 @@ fileName: range-copyfrom.yaml description: Copies or moves data and formatting from one range to another. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-copyfrom.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-copyfrom.yaml group: Range api_set: ExcelApi: '1.10' @@ -530,7 +751,7 @@ contiguous, through user selection and programmatic selection of special cells. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-areas.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-areas.yaml group: Range api_set: ExcelApi: '1.9' @@ -539,7 +760,7 @@ fileName: range-find.yaml description: Finds a cell within a range based on string matching. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-find.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-find.yaml group: Range api_set: ExcelApi: '1.9' @@ -548,7 +769,7 @@ fileName: formatting.yaml description: Formats a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/formatting.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/formatting.yaml group: Range api_set: ExcelApi: '1.4' @@ -557,25 +778,25 @@ fileName: cell-properties.yaml description: Sets different properties across a range then retrieves those properties. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/cell-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/cell-properties.yaml group: Range api_set: ExcelApi: '1.9' - id: excel-range-hyperlink name: Hyperlinks fileName: range-hyperlink.yaml - description: 'Creates, updates, and clears hyperlinks in a range.' + description: Creates, updates, and clears hyperlinks in a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-hyperlink.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-hyperlink.yaml group: Range api_set: ExcelApi: '1.7' - id: excel-range-insert-delete-and-clear-range - name: 'Insert, delete, and clear' + name: Insert, delete, and clear fileName: insert-delete-clear-range.yaml - description: 'Inserts, deletes, and clears a range.' + description: Inserts, deletes, and clears a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/insert-delete-clear-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/insert-delete-clear-range.yaml group: Range api_set: ExcelApi: '1.4' @@ -584,7 +805,7 @@ fileName: outline.yaml description: Creates an outline by grouping rows and columns. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/outline.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/outline.yaml group: Range api_set: ExcelApi: '1.10' @@ -595,7 +816,7 @@ Shows relationships between ranges, such as bounding rectangles and intersections. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-relationships.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-relationships.yaml group: Range api_set: ExcelApi: '1.4' @@ -604,7 +825,7 @@ fileName: range-remove-duplicates.yaml description: Removes duplicate entries from a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-remove-duplicates.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-remove-duplicates.yaml group: Range api_set: ExcelApi: '1.9' @@ -613,21 +834,21 @@ fileName: selected-range.yaml description: Gets and sets the currently selected range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/selected-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/selected-range.yaml group: Range api_set: ExcelApi: '1.1' -- id: excel-direct-precedents - name: Direct precedents - fileName: direct-precedents.yaml +- id: excel-precedents + name: Precedents + fileName: precedents.yaml description: >- This sample shows how to find and highlight the precedents of the currently selected cell. Precedents are cells referenced by the formula in a cell. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/direct-precedents.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/precedents.yaml group: Range api_set: - ExcelAPI: '1.12' + ExcelApi: '1.14' - id: excel-range-style name: Style fileName: style.yaml @@ -635,7 +856,7 @@ Creates a custom style, applies a custom and built-in styles to a range, gets style properties, and deletes the custom style. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/style.yaml group: Range api_set: ExcelApi: '1.7' @@ -644,7 +865,7 @@ fileName: range-text-orientation.yaml description: Gets and sets the text orientation within a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/range-text-orientation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-text-orientation.yaml group: Range api_set: ExcelApi: '1.7' @@ -655,7 +876,7 @@ Applies formulas that use dynamic arrays and displays information about the ranges used to display the data. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/dynamic-arrays.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/dynamic-arrays.yaml group: Range api_set: ExcelAPI: '1.12' @@ -666,7 +887,7 @@ Tests for a used range and creates a chart from a table only if there's data in the table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/used-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/used-range.yaml group: Range api_set: ExcelApi: '1.4' @@ -675,10 +896,62 @@ fileName: set-get-values.yaml description: Gets and sets values and formulas for a range. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/42-range/set-get-values.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/set-get-values.yaml group: Range api_set: ExcelApi: '1.4' +- id: excel-merged-ranges + name: Merged ranges + fileName: range-merged-ranges.yaml + description: This sample shows how to create and find merged ranges in a worksheet. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-merged-ranges.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-range-get-range-edge + name: Select used range edge + fileName: range-get-range-edge.yaml + description: >- + This sample shows how to select the edges of the used range, based on the + currently selected range. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-get-range-edge.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-direct-dependents + name: Direct dependents + fileName: range-direct-dependents.yaml + description: >- + This sample shows how to find and highlight the direct dependents of the + currently selected cell. Dependent cells contain formulas that refer to + other cells. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-direct-dependents.yaml + group: Range + api_set: + ExcelAPI: '1.13' +- id: excel-range-dependents + name: Dependents + fileName: range-dependents.yaml + description: >- + This sample shows how to find and highlight the dependents of the currently + selected cell. Dependent cells contain formulas that refer to other cells. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-dependents.yaml + group: Range + api_set: + ExcelAPI: '1.15' +- id: excel-cell-controls + name: Checkboxes + fileName: range-cell-control.yaml + description: This sample shows how to add and remove checkboxes from a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-cell-control.yaml + group: Range + api_set: + ExcelApi: '1.18' - id: excel-shape-create-and-delete name: Create and delete geometric shapes fileName: shape-create-and-delete.yaml @@ -686,7 +959,7 @@ Creates a few different geometric shapes and deletes them from the worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-create-and-delete.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-create-and-delete.yaml group: Shape api_set: ExcelApi: '1.9' @@ -695,7 +968,7 @@ fileName: shape-images.yaml description: Creates and adjusts image-based shapes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-images.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-images.yaml group: Shape api_set: ExcelApi: '1.9' @@ -704,7 +977,7 @@ fileName: shape-lines.yaml description: Creates and modifies line shapes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-lines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-lines.yaml group: Shape api_set: ExcelApi: '1.9' @@ -713,7 +986,7 @@ fileName: shape-move-and-order.yaml description: Moves created shapes around the worksheet and adjusts their z-order. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-move-and-order.yaml group: Shape api_set: ExcelApi: '1.9' @@ -722,7 +995,7 @@ fileName: shape-groups.yaml description: Groups and ungroups shapes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-groups.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-groups.yaml group: Shape api_set: ExcelApi: '1.9' @@ -731,16 +1004,25 @@ fileName: shape-textboxes.yaml description: Creates a textbox shape and works with the text in it and other shapes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/44-shape/shape-textboxes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-textboxes.yaml group: Shape api_set: ExcelApi: '1.9' +- id: excel-shape-get-active + name: Get active shape image + fileName: shape-get-active.yaml + description: Get an image of the active shape in your workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-get-active.yaml + group: Shape + api_set: + ExcelApi: '1.19' - id: excel-table-add-rows-and-columns-to-a-table name: Add rows and columns fileName: add-rows-and-columns-to-a-table.yaml description: Adds rows and columns to a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/add-rows-and-columns-to-a-table.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/add-rows-and-columns-to-a-table.yaml group: Table api_set: ExcelApi: '1.4' @@ -749,7 +1031,7 @@ fileName: convert-range-to-table.yaml description: Converts a range to a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/convert-range-to-table.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/convert-range-to-table.yaml group: Table api_set: ExcelApi: '1.4' @@ -758,7 +1040,7 @@ fileName: create-table.yaml description: Creates a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/create-table.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/create-table.yaml group: Table api_set: ExcelApi: '1.4' @@ -767,7 +1049,7 @@ fileName: filter-data.yaml description: Filters table data. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/filter-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/filter-data.yaml group: Table api_set: ExcelApi: '1.4' @@ -776,7 +1058,7 @@ fileName: formatting.yaml description: Formats a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/formatting.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/formatting.yaml group: Table api_set: ExcelApi: '1.4' @@ -785,7 +1067,7 @@ fileName: get-data-from-table.yaml description: Gets data from a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/get-data-from-table.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/get-data-from-table.yaml group: Table api_set: ExcelApi: '1.4' @@ -794,7 +1076,7 @@ fileName: get-visible-range-of-a-filtered-table.yaml description: Gets the visible range from a filtered table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml group: Table api_set: ExcelApi: '1.4' @@ -803,7 +1085,7 @@ fileName: import-json-data.yaml description: Imports JSON data into a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/import-json-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/import-json-data.yaml group: Table api_set: ExcelApi: '1.4' @@ -812,16 +1094,25 @@ fileName: sort-data.yaml description: Sorts the data within a table. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/46-table/sort-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/sort-data.yaml group: Table api_set: ExcelApi: '1.4' +- id: excel-table-resize + name: Resize a table + fileName: resize-table.yaml + description: This sample shows how to resize a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/resize-table.yaml + group: Table + api_set: + ExcelAPI: '1.13' - id: excel-workbook-get-active-cell name: Active cell fileName: workbook-get-active-cell.yaml description: Gets the active cell of the entire workbook. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/workbook-get-active-cell.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-get-active-cell.yaml group: Workbook api_set: ExcelApi: '1.7' @@ -832,7 +1123,7 @@ Creates, gets, changes, and deletes settings that are unique to the specific workbook and add-in combination. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/create-get-change-delete-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/create-get-change-delete-settings.yaml group: Workbook api_set: ExcelApi: '1.4' @@ -843,7 +1134,7 @@ Demonstrates the calculation APIs of the workbook: events for when the worksheet recalculates and application-level calculation controls. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/workbook-calculation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-calculation.yaml group: Workbook api_set: ExcelApi: '1.11' @@ -854,7 +1145,7 @@ Creates a new, empty workbook and creates a new workbook by copying an existing one. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/create-workbook.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/create-workbook.yaml group: Workbook api_set: ExcelApi: '1.8' @@ -865,7 +1156,7 @@ This sample shows how to apply the cultural settings APIs to help normalize data. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/culture-info.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/culture-info.yaml group: Workbook api_set: ExcelApi: '1.11' @@ -876,7 +1167,7 @@ This sample shows how to use the read-only cultural settings APIs to retrieve system date and time settings. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/culture-info-date-time.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/culture-info-date-time.yaml group: Workbook api_set: ExcelAPI: '1.12' @@ -885,7 +1176,7 @@ fileName: data-protection.yaml description: Protects data in a worksheet and the workbook structure. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/data-protection.yaml group: Workbook api_set: ExcelApi: '1.7' @@ -894,25 +1185,43 @@ fileName: workbook-save-and-close.yaml description: Saves and closes a workbook. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/50-workbook/workbook-save-and-close.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-save-and-close.yaml group: Workbook api_set: ExcelAPI: '1.11' +- id: excel-workbook-insert-external-worksheets + name: Insert external worksheets + fileName: workbook-insert-external-worksheets.yaml + description: Inserts worksheets from another workbook into the current workbook. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml + group: Workbook + api_set: + ExcelAPI: '1.13' +- id: excel-workbook-built-in-function + name: Use built-in Excel functions + fileName: workbook-built-in-functions.yaml + description: Use the VLOOKUP and SUM built-in Excel functions. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-built-in-functions.yaml + group: Workbook + api_set: + ExcelAPI: '1.2' - id: excel-worksheet-active-worksheet name: Active worksheet fileName: active-worksheet.yaml description: Gets and sets the active worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/active-worksheet.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/active-worksheet.yaml group: Worksheet api_set: ExcelApi: '1.1' - id: excel-worksheet-add-delete-rename-move-worksheet - name: 'Add, delete, rename, and move worksheet' + name: Add, delete, rename, and move worksheet fileName: add-delete-rename-move-worksheet.yaml - description: 'Adds, deletes, renames, and moves a worksheet.' + description: Adds, deletes, renames, and moves a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml group: Worksheet api_set: ExcelApi: '1.1' @@ -921,7 +1230,7 @@ fileName: worksheet-auto-filter.yaml description: Adds an AutoFilter to a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-auto-filter.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-auto-filter.yaml group: Worksheet api_set: ExcelApi: '1.9' @@ -930,7 +1239,7 @@ fileName: worksheet-copy.yaml description: Copies the active worksheet to the specified location. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-copy.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-copy.yaml group: Worksheet api_set: ExcelApi: '1.7' @@ -939,7 +1248,7 @@ fileName: worksheet-find-all.yaml description: Finds cells within a worksheet based on string matching. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-find-all.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-find-all.yaml group: Worksheet api_set: ExcelApi: '1.9' @@ -950,7 +1259,7 @@ Freezes columns, rows, and a range of cells. Gets the address of the frozen pane. Unfreezes frozen panes. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-freeze-panes.yaml group: Worksheet api_set: ExcelApi: '1.7' @@ -961,7 +1270,7 @@ Gets the used range, the entire range of a worksheet, the specified range, and the specified cell. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-range-cell.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-range-cell.yaml group: Worksheet api_set: ExcelApi: '1.4' @@ -970,7 +1279,7 @@ fileName: gridlines.yaml description: Hides and shows a worksheet's gridlines. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/gridlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/gridlines.yaml group: Worksheet api_set: ExcelApi: '1.8' @@ -979,7 +1288,7 @@ fileName: list-worksheets.yaml description: Lists the worksheets in the workbook. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/list-worksheets.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/list-worksheets.yaml group: Worksheet api_set: ExcelApi: '1.1' @@ -988,7 +1297,7 @@ fileName: worksheet-page-layout.yaml description: Changes the page layout and other settings for printing a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-page-layout.yaml group: Worksheet api_set: ExcelApi: '1.9' @@ -997,7 +1306,7 @@ fileName: reference-worksheets-by-relative-position.yaml description: Gets a worksheet by using its relative position within the workbook. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml group: Worksheet api_set: ExcelApi: '1.5' @@ -1006,7 +1315,7 @@ fileName: tab-color.yaml description: Gets and sets the tab color of a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/tab-color.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/tab-color.yaml group: Worksheet api_set: ExcelApi: '1.7' @@ -1015,25 +1324,18 @@ fileName: worksheet-visibility.yaml description: Hides and unhides a worksheet. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/54-worksheet/worksheet-visibility.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-visibility.yaml group: Worksheet api_set: ExcelApi: '1.1' -- id: excel-workbook-insert-external-worksheets - name: Insert external worksheets - fileName: workbook-insert-external-worksheets.yaml - description: Inserts worksheets from another workbook into the current workbook. - rawUrl: >- - https://raw.githubusercontent.com////samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml - group: Preview APIs - api_set: - ExcelAPI: '1.13' - id: excel-performance-optimization name: Performance optimization fileName: performance-optimization.yaml - description: Optimizes performance by untracking ranges and turning off screen painting. + description: >- + Optimizes performance by untracking ranges, turning off screen painting, and + switching the calculation mode. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/90-scenarios/performance-optimization.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/performance-optimization.yaml group: Scenarios api_set: ExcelApi: '1.9' @@ -1044,7 +1346,7 @@ Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/90-scenarios/report-generation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/report-generation.yaml group: Scenarios api_set: ExcelApi: '1.1' @@ -1053,7 +1355,7 @@ fileName: multiple-property-set.yaml description: Sets multiple properties at once with the API object set() method. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/90-scenarios/multiple-property-set.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/multiple-property-set.yaml group: Scenarios api_set: ExcelApi: '1.4' @@ -1064,7 +1366,7 @@ Shows how to work with dates by using the Moment JavaScript library with the Moment-MSDate plug-in. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/90-scenarios/working-with-dates.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/working-with-dates.yaml group: Scenarios api_set: ExcelApi: '1.4' @@ -1075,7 +1377,7 @@ Uses an exchange rate API to convert currency values based on their original transaction times. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/90-scenarios/currency-converter.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/currency-converter.yaml group: Scenarios api_set: ExcelApi: '1.4' @@ -1086,7 +1388,7 @@ Uses range formatting to draw interesting pattern. Contributed by Alexander Zlatkovski. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/99-just-for-fun/patterns.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/patterns.yaml group: Just For Fun api_set: ExcelApi: '1.4' @@ -1097,7 +1399,7 @@ Uses range formatting and external libraries to draw a colorful gradient within a range. Contributed by Alexander Zlatkovski. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/99-just-for-fun/gradient.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/gradient.yaml group: Just For Fun api_set: ExcelApi: '1.4' @@ -1108,7 +1410,7 @@ Uses range formatting to play a "pathfinder game". Contributed by Alexander Zlatkovski. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/99-just-for-fun/path-finder-game.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/path-finder-game.yaml group: Just For Fun api_set: ExcelApi: '1.4' @@ -1117,7 +1419,7 @@ fileName: tetrominos.yaml description: Arrange moving tetromino shapes to form lines. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/99-just-for-fun/tetrominos.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/tetrominos.yaml group: Just For Fun api_set: ExcelApi: '1.9' @@ -1128,7 +1430,7 @@ Uses chart formatting to draw a wheel with changing colors. Contributed by Alexander Zlatkovski. rawUrl: >- - https://raw.githubusercontent.com////samples/excel/99-just-for-fun/color-wheel.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/color-wheel.yaml group: Just For Fun api_set: ExcelApi: '1.4' diff --git a/playlists/outlook.yaml b/playlists/outlook.yaml index 95a8d0930..557b89f9a 100644 --- a/playlists/outlook.yaml +++ b/playlists/outlook.yaml @@ -1,9 +1,9 @@ - id: outlook-roaming-settings-roaming-settings name: Use add-in settings fileName: roaming-settings.yaml - description: 'Gets, sets, and saves add-in roaming settings' + description: Gets, sets, saves, and removes add-in roaming settings. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/10-roaming-settings/roaming-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/10-roaming-settings/roaming-settings.yaml group: Roaming Settings api_set: Mailbox: '1.1' @@ -15,7 +15,7 @@ a new one, gets it, removes it, and saves all custom properties back to the item. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/15-item-custom-properties/load-set-get-save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/15-item-custom-properties/load-set-get-save.yaml group: Item Custom Properties api_set: Mailbox: '1.1' @@ -24,34 +24,94 @@ fileName: get-selected-data.yaml description: Gets the selected text in the item body or subject in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/20-item-body/get-selected-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/get-selected-data.yaml group: Item Body api_set: Mailbox: '1.1' -- id: outlook-item-body-set-selected-data - name: Set selected text (Compose) - fileName: set-selected-data.yaml - description: Replaces the selected text in the item body or subject in Compose mode. +- id: outlook-item-body-replace-selected-text + name: Replace selected text in item body + fileName: replace-selected-text.yaml + description: >- + Replaces selected text in a message or appointment's body with specified + text. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/replace-selected-text.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-add-inline-base64-image + name: Add inline Base64-encoded image to message or appointment body (Compose) + fileName: add-inline-base64-image.yaml + description: >- + Add an inline Base64-encoded image to the body of a message or appointment + being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/add-inline-base64-image.yaml + group: Item Body + api_set: + Mailbox: '1.8' +- id: outlook-item-body-get-body-format + name: Get the item's body format + fileName: get-body-format.yaml + description: Gets a message or appointment's body format (plain text or HTML). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/get-body-format.yaml + group: Item Body + api_set: + Mailbox: '1.1' +- id: outlook-item-body-append-text-on-send + name: Append text to item body on send + fileName: append-text-on-send.yaml + description: Appends text to the end of the message or appointment's body once it's sent. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/append-text-on-send.yaml + group: Item Body + api_set: + Mailbox: '1.9' +- id: outlook-item-body-prepend-text-to-item-body + name: Prepend text to item body + fileName: prepend-text-to-item-body.yaml + description: Adds text to the beginning of the message or appointment's body. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/20-item-body/set-selected-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/prepend-text-to-item-body.yaml group: Item Body api_set: Mailbox: '1.1' +- id: outlook-item-body-prepend-text-on-send + name: Prepend text to item body on send + fileName: prepend-text-on-send.yaml + description: >- + Prepends text to the beginning of the message or appointment's body once + it's sent. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/prepend-text-on-send.yaml + group: Item Body + api_set: + Mailbox: '1.13' - id: outlook-item-save-and-close-close name: Close the item fileName: close.yaml description: Closes the item (compose mode) rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/25-item-save-and-close/close.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/close.yaml group: Item Save And Close api_set: Mailbox: '1.3' +- id: outlook-close-async + name: Close the current message and discard changes (Message Compose) + fileName: close-async.yaml + description: Closes the current message and discards any unsaved changes when specified. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/close-async.yaml + group: Item Save And Close + api_set: + Mailbox: '1.14' - id: outlook-item-save-and-close-save name: Save the item fileName: save.yaml description: Saves the item (compose mode) rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/25-item-save-and-close/save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/save.yaml group: Item Save And Close api_set: Mailbox: '1.3' @@ -60,7 +120,7 @@ fileName: get-from-message-read.yaml description: Gets who the message is from in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -69,7 +129,7 @@ fileName: get-from-message-compose.yaml description: Gets who the message is from in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml group: Recipients And Attendees api_set: Mailbox: '1.7' @@ -78,7 +138,7 @@ fileName: get-to-message-read.yaml description: Gets the To line recipients of the message in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -87,7 +147,7 @@ fileName: get-set-to-message-compose.yaml description: Gets and sets the To line recipients of the message in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -96,7 +156,7 @@ fileName: get-cc-message-read.yaml description: Gets the Cc line recipients of the message in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -105,7 +165,7 @@ fileName: get-set-cc-message-compose.yaml description: Gets and sets the Cc line recipients of the message in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -114,7 +174,7 @@ fileName: get-set-bcc-message-compose.yaml description: Gets and sets the Bcc line recipients of the message in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -123,7 +183,7 @@ fileName: get-sender-message-read.yaml description: Gets the sender in Message Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -132,7 +192,7 @@ fileName: get-required-attendees-appointment-attendee.yaml description: Gets the required attendees in Appointment Attendee mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -142,7 +202,7 @@ fileName: get-set-required-attendees-appointment-organizer.yaml description: Gets and sets the required attendees in Appointment Organizer mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -151,7 +211,7 @@ fileName: get-optional-attendees-appointment-attendee.yaml description: Gets the optional attendees in Appointment Attendee mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -161,7 +221,7 @@ fileName: get-set-optional-attendees-appointment-organizer.yaml description: Gets and sets the optional attendees in Appointment Organizer mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -170,7 +230,7 @@ fileName: get-organizer-appointment-attendee.yaml description: Gets the organizer in Appointment Attendee mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml group: Recipients And Attendees api_set: Mailbox: '1.1' @@ -179,7 +239,16 @@ fileName: get-organizer-appointment-organizer.yaml description: Gets the organizer in Appointment Organizer mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + group: Recipients And Attendees + api_set: + Mailbox: '1.7' +- id: outlook-recipients-and-attendees-get-all-attendees + name: Get all attendees + fileName: get-all-attendees.yaml + description: Gets all appointment attendees and organizes them by their response. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml group: Recipients And Attendees api_set: Mailbox: '1.7' @@ -187,13 +256,13 @@ name: Work with notification messages fileName: add-getall-remove.yaml description: >- - Adds different kinds of notification messages, gets all, and replaces and - removes an individual notification message. + Adds different kinds of notification messages, gets all notifications, and + replaces and removes an individual notification message. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/35-notifications/add-getall-remove.yaml group: Notifications api_set: - Mailbox: '1.3' + Mailbox: '1.10' - id: outlook-attachments-attachments-compose name: Manipulate attachments (Item Compose) fileName: attachments-compose.yaml @@ -201,16 +270,16 @@ Adds, gets, and removes attachments from a message or an appointment in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/attachments-compose.yaml group: Attachments api_set: - Mailbox: '1.1' + Mailbox: '1.8' - id: outlook-attachments-get-attachment-content name: Get attachment content fileName: get-attachment-content.yaml - description: Gets the attachment content. + description: Gets the attachment content in read or compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/40-attachments/get-attachment-content.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/get-attachment-content.yaml group: Attachments api_set: Mailbox: '1.8' @@ -219,25 +288,25 @@ fileName: get-attachments-read.yaml description: Gets the attachments of a message or an appointment in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/40-attachments/get-attachments-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/get-attachments-read.yaml group: Attachments api_set: Mailbox: '1.1' - id: outlook-categories-work-with-categories name: Work with item categories fileName: work-with-categories.yaml - description: 'Gets, adds, and removes categories assigned to the item.' + description: Gets, adds, and removes categories assigned to the item. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/45-categories/work-with-categories.yaml group: Categories api_set: Mailbox: '1.8' - id: outlook-categories-work-with-master-categories name: Work with the categories master list fileName: work-with-master-categories.yaml - description: 'Gets, adds, and removes categories in the master list for the mailbox.' + description: Gets, adds, and removes categories in the master list for the mailbox. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/45-categories/work-with-master-categories.yaml group: Categories api_set: Mailbox: '1.8' @@ -246,7 +315,7 @@ fileName: get-series-id.yaml description: Gets the series ID. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/50-recurrence/get-series-id.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-series-id.yaml group: Recurrence api_set: Mailbox: '1.7' @@ -255,7 +324,7 @@ fileName: get-recurrence-read.yaml description: Gets the recurrence pattern of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/50-recurrence/get-recurrence-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-recurrence-read.yaml group: Recurrence api_set: Mailbox: '1.7' @@ -264,25 +333,18 @@ fileName: get-set-recurrence-appointment-organizer.yaml description: Gets and sets the recurrence pattern in Appointment Organizer mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml group: Recurrence api_set: Mailbox: '1.7' -- id: outlook-display-items-display-existing-appointment - name: Open an appointment - fileName: display-existing-appointment.yaml - description: Displays existing appointment in a separate window - rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-existing-appointment.yaml - group: Display Items - api_set: - Mailbox: '1.9' -- id: outlook-display-items-display-existing-message - name: Open a message - fileName: display-existing-message.yaml - description: Displays an existing message in a separate window +- id: outlook-display-items-display-new-message + name: Create a new message + fileName: display-new-message.yaml + description: >- + Opens a new message form with a sample content, recipients, and an inline + image attachment rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-existing-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-new-message.yaml group: Display Items api_set: Mailbox: '1.9' @@ -291,18 +353,25 @@ fileName: display-new-appointment.yaml description: Opens a new appointment form with sample content and a few fields populated. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-new-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-new-appointment.yaml group: Display Items api_set: Mailbox: '1.9' -- id: outlook-display-items-display-new-message - name: Create a new message - fileName: display-new-message.yaml - description: >- - Opens a new message form with a sample content, recipients, and an inline - image attachment +- id: outlook-display-items-display-existing-message + name: Open a message + fileName: display-existing-message.yaml + description: Displays an existing message in a separate window + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-existing-message.yaml + group: Display Items + api_set: + Mailbox: '1.9' +- id: outlook-display-items-display-existing-appointment + name: Open an appointment + fileName: display-existing-appointment.yaml + description: Displays existing appointment in a separate window rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-new-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-existing-appointment.yaml group: Display Items api_set: Mailbox: '1.9' @@ -311,132 +380,179 @@ fileName: display-reply-forms.yaml description: Opens reply and reply-all message forms with sample reply content. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-reply-forms.yaml group: Display Items api_set: Mailbox: '1.9' - id: outlook-display-items-display-reply-with-attachments - name: 'Create a reply, with attachments' + name: Create a reply with attachments fileName: display-reply-with-attachments.yaml - description: Opens a reply message forms and adds sample attachments. + description: Opens a reply or reply-all message form and adds sample attachments. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/55-display-items/display-reply-with-attachments.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-reply-with-attachments.yaml group: Display Items api_set: Mailbox: '1.9' +- id: outlook-sensitivity-labels-sensitivity-labels-catalog + name: Work with the sensitivity labels catalog + fileName: sensitivity-labels-catalog.yaml + description: >- + Determines if sensitivity labels are enabled on the mailbox and retrieves + all available labels from the catalog. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml + group: Sensitivity Label + api_set: + Mailbox: '1.13' +- id: outlook-sensitivity-labels-sensitivity-label + name: Work with sensitivity labels (Compose) + fileName: sensitivity-label.yaml + description: >- + Gets and sets the sensitivity label on a message or appointment in compose + mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + group: Sensitivity Label + api_set: + Mailbox: '1.13' - id: outlook-delegates-and-shared-folders-get-shared-properties - name: Perform an operation as delegate + name: Identify a shared folder or shared mailbox context fileName: get-shared-properties.yaml description: >- - Gets shared properties for an item, checks delegate permissions and performs - an operation as delegate. + Identifies whether the current mail item is in a shared folder or shared + mailbox by getting its properties. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml group: Delegates And Shared Folders api_set: - Mailbox: '1.8' -- id: outlook-entities-and-regex-matches-basic-entities - name: Entities (Item Read) - fileName: basic-entities.yaml - description: Gets extracted entities. + Mailbox: '1.13' +- id: outlook-mime-headers-get-internet-headers-message-read + name: Get internet headers + fileName: get-internet-headers-message-read.yaml + description: Gets internet headers on a message in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/75-entities-and-regex-matches/basic-entities.yaml - group: Entities And Regex Matches + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml + group: Mime Headers api_set: - Mailbox: '1.1' -- id: outlook-entities-and-regex-matches-contextual - name: 'Entities and Regex matches (Item Read, contextual)' - fileName: contextual.yaml + Mailbox: '1.8' +- id: outlook-mime-headers-manage-custom-internet-headers-message-compose + name: Work with custom internet headers + fileName: manage-custom-internet-headers-message-compose.yaml description: >- - Gets extracted entities and regex matches when the add-in is opened as a - contextual add-in. + Sets, gets, and removes custom internet headers on a message in Compose + mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/75-entities-and-regex-matches/contextual.yaml - group: Entities And Regex Matches + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + group: Mime Headers api_set: - Mailbox: '1.1' -- id: outlook-entities-and-regex-matches-selected - name: 'Selected entities and Regex matches (Item Read, contextual)' - fileName: selected.yaml - description: Gets selected entities and regex matches. + Mailbox: '1.8' +- id: outlook-regex-matches-contextual + name: Get regex matches (Item Read, contextual) + fileName: contextual.yaml + description: Gets regex matches when the add-in is opened as a contextual add-in. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/75-entities-and-regex-matches/selected.yaml - group: Entities And Regex Matches + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/75-regex-matches/contextual.yaml + group: Regex Matches api_set: Mailbox: '1.6' +- id: outlook-events-drag-drop-item + name: Drag and drop an item into the task pane + fileName: drag-drop-item.yaml + description: >- + Handles the drag-and-drop event when a user drags and drops messages and + file attachments into the add-in task pane. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/80-events/drag-drop-item.yaml + group: Events + api_set: + Mailbox: '1.5' - id: outlook-tokens-and-service-calls-ids-and-urls - name: Endpoint URLs and item IDs + name: Endpoint URLs and item IDs in Exchange on-premises environments fileName: ids-and-urls.yaml description: >- - Retrieves and displays REST and EWS endpoint URLs and item IDs, and converts - item IDs for different protocols. + Retrieves the Exchange Web Services (EWS) endpoint URL and item IDs and + converts item IDs for different protocols. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + group: Tokens For Exchange On-Premises api_set: Mailbox: '1.5' - id: outlook-tokens-and-service-calls-user-identity-token - name: Get a user identity token + name: Get a user identity token in Exchange on-premises environments fileName: user-identity-token.yaml - description: Gets a user identity token to use in authentication flows. + description: >- + Gets a user identity token for authentication flows in an Exchange + on-premises environment. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml + group: Tokens For Exchange On-Premises api_set: Mailbox: '1.1' - id: outlook-tokens-and-service-calls-user-callback-token - name: Get a callback token + name: Get a callback token in Exchange on-premises environments fileName: user-callback-token.yaml description: >- - Gets a callback token to use for calling outlook services from add-in's - backend service. + Gets a callback token to call Outlook services from an add-in's backend + service in an Exchange on-premises environment. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml + group: Tokens For Exchange On-Premises api_set: Mailbox: '1.1' -- id: outlook-tokens-and-service-calls-basic-rest-cors - name: Get a message using REST - fileName: basic-rest-cors.yaml - description: Gets a message using REST without any back-end code. - rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml - group: Tokens And Service Calls - api_set: - Mailbox: '1.5' - id: outlook-tokens-and-service-calls-make-ews-request-async - name: Get a message using EWS + name: >- + Get a message using Exchange Web Services (EWS) in Exchange on-premises + environments fileName: make-ews-request-async.yaml - description: Gets a message using EWS without any back-end code. + description: >- + Uses EWS in an Exchange on-premises environment to get a message without any + backend code. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml + group: Tokens For Exchange On-Premises api_set: Mailbox: '1.1' - id: outlook-tokens-and-service-calls-send-message-using-make-ews-request-async - name: Send a message using EWS + name: >- + Send a message using Exchange Web Services (EWS) in Exchange on-premises + environments fileName: send-message-using-make-ews-request-async.yaml - description: Sends a message using EWS without any back-end code. + description: >- + Uses EWS in an Exchange on-premises environment to send a message without + any backend code. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml + group: Tokens For Exchange On-Premises api_set: Mailbox: '1.1' -- id: outlook-tokens-and-service-calls-item-id-compose - name: Get an item ID in compose mode - fileName: item-id-compose.yaml - description: 'Gets an item ID in compose mode, to use in certain delegate scenarios.' +- id: outlook-tokens-and-service-calls-get-icaluid-as-organizer + name: Get an appointment's iCalUId as the organizer (Exchange on-premises only) + fileName: get-icaluid-as-organizer.yaml + description: >- + Uses Exchange Web Services (EWS) in an Exchange on-premises environment to + get an appointment's iCalUId value where the user is the organizer. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml - group: Tokens And Service Calls + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml + group: Tokens For Exchange On-Premises api_set: - Mailbox: '1.8' + Mailbox: '1.3' +- id: outlook-tokens-and-service-calls-get-icaluid-as-attendee + name: Get an appointment's iCalUId as an attendee (Exchange on-premises only) + fileName: get-icaluid-as-attendee.yaml + description: >- + Uses Exchange Web Services (EWS) in an Exchange on-premises environment to + get an appointment's iCalUId value where the user is an attendee. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml + group: Tokens For Exchange On-Premises + api_set: + Mailbox: '1.1' - id: outlook-other-item-apis-get-subject-read name: Get the subject (Read) fileName: get-subject-read.yaml description: Gets the subject of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-subject-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-subject-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -445,7 +561,16 @@ fileName: get-set-subject-compose.yaml description: Gets and sets the subject of an item in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-item-body-set-selected-data + name: Replace selected text in item body or subject (Compose) + fileName: set-selected-data.yaml + description: Replaces the selected text in the item body or subject in Compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/set-selected-data.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -454,7 +579,7 @@ fileName: get-internet-message-id-read.yaml description: Gets the internet message ID of a message in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -463,7 +588,7 @@ fileName: get-item-class-read.yaml description: Gets the item class of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-item-class-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-class-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -472,7 +597,7 @@ fileName: get-item-type.yaml description: Gets the item type. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-item-type.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-type.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -481,7 +606,7 @@ fileName: get-start-read.yaml description: Gets the start date and time of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-start-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-start-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -490,7 +615,7 @@ fileName: get-set-start-appointment-organizer.yaml description: Gets and sets the start date and time of an appointment in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -499,7 +624,7 @@ fileName: get-end-read.yaml description: Gets the end date and time of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-end-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-end-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -508,7 +633,7 @@ fileName: get-set-end-appointment-organizer.yaml description: Gets and sets the end date and time of an appointment in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -517,7 +642,7 @@ fileName: get-location-read.yaml description: Gets the location of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-location-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-location-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -526,16 +651,16 @@ fileName: get-set-location-appointment-organizer.yaml description: Gets and sets the location of an appointment in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml group: Other Item APIs api_set: Mailbox: '1.1' - id: outlook-other-item-apis-get-add-remove-enhancedlocation-appointment name: Manage the locations of an appointment fileName: get-add-remove-enhancedlocation-appointment.yaml - description: 'Gets, adds, and removes locations on an appointment (enhancedLocation API).' + description: Gets, adds, and removes locations on an appointment (enhancedLocation API). rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml group: Other Item APIs api_set: Mailbox: '1.8' @@ -544,7 +669,7 @@ fileName: get-normalized-subject-read.yaml description: Gets the normalized subject of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -553,7 +678,7 @@ fileName: get-conversation-id-message.yaml description: Gets the conversation ID of a message. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -562,7 +687,7 @@ fileName: get-date-time-created-read.yaml description: Gets the creation date and time of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' @@ -571,38 +696,148 @@ fileName: get-date-time-modified-read.yaml description: Gets the last-modified date and time of an item in Read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml group: Other Item APIs api_set: Mailbox: '1.1' -- id: outlook-calendar-properties-apis - name: Work with calendar properties APIs (Compose) - fileName: calendar-properties-apis.yaml +- id: outlook-other-item-apis-get-diagnostic-information + name: Get mailbox diagnostic information + fileName: get-diagnostic-information.yaml + description: Gets a mailbox's diagnostic information. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml + group: Other Item APIs + api_set: + Mailbox: '1.1' +- id: outlook-other-item-apis-work-with-client-signatures + name: Work with client signatures (Compose) + fileName: work-with-client-signatures.yaml description: >- - Gets and sets isAllDayEvent and sensitivity properties of an appointment in - Compose mode. + Checks if the client signature is enabled, disables the client signature, + gets the compose type, and sets a signature in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/99-preview-apis/calendar-properties-apis.yaml - group: Preview APIs + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + group: Other Item APIs api_set: - Mailbox: preview -- id: outlook-session-data-apis + Mailbox: '1.10' +- id: outlook-other-item-apis-session-data-apis name: Work with session data APIs (Compose) fileName: session-data-apis.yaml - description: 'Set, get, get all, remove, and clear session data in Compose mode.' + description: Sets, gets, gets all, removes, and clears session data in Compose mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/session-data-apis.yaml + group: Other Item APIs + api_set: + Mailbox: '1.11' +- id: outlook-delay-message-delivery + name: Get and set message delivery (Message Compose) + fileName: delay-message-delivery.yaml + description: Gets and sets the delivery date and time of a message in compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/delay-message-delivery.yaml + group: Other Item APIs + api_set: + Mailbox: '1.13' +- id: outlook-other-item-apis-get-message-properties + name: Get properties of selected messages (Message Compose, Message Read) + fileName: get-message-properties.yaml + description: Gets the properties of multiple selected messages. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-message-properties.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-other-item-apis-get-set-sensitivity-level + name: Get and set the sensitivity level (Appointment Organizer) + fileName: get-set-sensitivity-level.yaml + description: Gets and sets the sensitivity level of an appointment being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-eml-format + name: Get the Base64-encoded EML format of a message (Message Read) + fileName: get-eml-format.yaml + description: Gets the Base64-encoded EML format of a message in read mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-eml-format.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-in-reply-to + name: Get the ID of the message being replied to (Message Compose) + fileName: get-in-reply-to.yaml + description: Retrieves the ID of the message being replied to by the current message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-in-reply-to.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-conversation-index + name: Get the position of a message in a conversation (Message Compose) + fileName: get-conversation-index.yaml + description: >- + Retrieves the Base64-encoded position of the current message in a + conversation thread. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-conversation-index.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-get-item-class-async + name: Get item class (Message Compose) + fileName: get-item-class-async.yaml + description: Retrieves the item class property of the message being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-class-async.yaml + group: Other Item APIs + api_set: + Mailbox: '1.14' +- id: outlook-other-item-apis-item-id-compose + name: Get an item ID in compose mode + fileName: item-id-compose.yaml + description: Gets an item ID in compose mode. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/item-id-compose.yaml + group: Other Item APIs + api_set: + Mailbox: '1.8' +- id: outlook-send-async + name: Send the current message or appointment (Compose) + fileName: send-async.yaml + description: Sends the current message or appointment. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/send-async.yaml + group: Other Item APIs + api_set: + Mailbox: '1.15' +- id: outlook-other-item-apis-get-loaded-message-properties + name: Get properties of a loaded message (Message Compose, Message Read) + fileName: get-loaded-message-properties.yaml + description: Gets the properties of the currently loaded message. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml + group: Other Item APIs + api_set: + Mailbox: '1.15' +- id: outlook-get-set-isalldayevent + name: Get and set the isAllDayEvent property (Appointment Organizer) + fileName: get-set-isalldayevent.yaml + description: Gets and sets the isAllDayEvent property of an appointment being composed. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml group: Preview APIs api_set: Mailbox: preview -- id: outlook-work-with-client-signatures - name: Work with client signatures (Compose) - fileName: work-with-client-signatures.yaml +- id: outlook-set-displayed-body-subject + name: Temporarily set the body or subject displayed in a message (Message Read) + fileName: set-displayed-body-subject.yaml description: >- - Check if the client signature is enabled, disable the client signature, get - the compose type, and set a signature in Compose mode. + Temporarily sets the content displayed in the body or subject of a message + in read mode. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml group: Preview APIs api_set: Mailbox: preview diff --git a/playlists/powerpoint.yaml b/playlists/powerpoint.yaml index 11420003b..810bc5be0 100644 --- a/playlists/powerpoint.yaml +++ b/playlists/powerpoint.yaml @@ -1,3 +1,21 @@ +- id: powerpoint-basics-basic-api-call-ts + name: Basic API call (TypeScript) + fileName: basic-api-call-ts.yaml + description: Performs a basic PowerPoint API call using TypeScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-api-call-ts.yaml + group: Basics + api_set: + PowerPointApi: '1.4' +- id: powerpoint-basics-basic-api-call-js + name: Basic API call (JavaScript) + fileName: basic-api-call-js.yaml + description: Performs a basic PowerPoint API call using JavaScript. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-api-call-js.yaml + group: Basics + api_set: + PowerPointApi: '1.4' - id: powerpoint-basics-basic-common-api-call name: Basic API call (Office 2013) fileName: basic-common-api-call.yaml @@ -5,10 +23,10 @@ Executes a basic PowerPoint API call using the "common API" syntax (compatible with Office 2013). rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/basics/basic-common-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-common-api-call.yaml group: Basics api_set: - Selection: 1.1 + Selection: '1.1' - id: powerpoint-create-presentation name: Create presentation fileName: create-presentation.yaml @@ -16,39 +34,156 @@ Creates a new, empty presentation and creates a new presentation by copying an existing one. rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/basics/create-presentation.yaml - group: Basics + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/document/create-presentation.yaml + group: Document api_set: - PowerPoint: 1.1 -- id: powerpoint-basics-get-slide-metadata - name: Get slide metadata - fileName: get-slide-metadata.yaml - description: 'Gets the title, index, and ID of the selected slide(s).' + PowerPointApi: '1.1' +- id: powerpoint-hyperlinks-manage-hyperlinks + name: Get hyperlinks + fileName: manage-hyperlinks.yaml + description: Gets the hyperlinks found in a slide. rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/basics/get-slide-metadata.yaml - group: Basics - api_set: {} + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml + group: Hyperlinks + api_set: + PowerPointApi: '1.6' - id: powerpoint-basics-insert-image name: Insert Image fileName: insert-image.yaml description: Inserts an image to the current slide. rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/basics/insert-image.yaml - group: Basics + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/images/insert-image.yaml + group: Images api_set: {} - id: powerpoint-basics-insert-svg name: Insert SVG fileName: insert-svg.yaml description: Inserts an SVG image using an XML string. rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/basics/insert-svg.yaml - group: Basics + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/images/insert-svg.yaml + group: Images api_set: {} - id: powerpoint-scenarios-searches-wikipedia-api name: Search Wikipedia fileName: searches-wikipedia-api.yaml description: Searches Wikipedia based on the selected text in the presentation. rawUrl: >- - https://raw.githubusercontent.com////samples/powerpoint/scenarios/searches-wikipedia-api.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/scenarios/searches-wikipedia-api.yaml group: Scenarios api_set: {} +- id: powerpoint-shapes + name: Insert shape, line, and text box + fileName: shapes.yaml + description: Inserts geometric shapes, lines, and text boxes to a slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.4' +- id: powerpoint-shapes-get-set-shapes + name: Get, set, load, and save shapes + fileName: get-set-shapes.yaml + description: Get and set one or more selected shapes. Load and save one or more shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/get-set-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.5' +- id: powerpoint-shapes-get-shapes-by-type + name: Select shapes by type + fileName: get-shapes-by-type.yaml + description: Gets shapes in a slide based on their type, such as GeometricShape or Line. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/get-shapes-by-type.yaml + group: Shapes + api_set: + PowerPointApi: '1.4' +- id: powerpoint-shapes-add-modify-tables + name: Add and modify tables + fileName: add-modify-tables.yaml + description: Shows how to add and modify tables in a presentation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/add-modify-tables.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-shapes-binding-to-shapes + name: Binding to shapes + fileName: binding-to-shapes.yaml + description: Shows how to create binding references for images and work with z-order. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/binding-to-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-shapes-group-ungroup-shapes + name: Group and ungroup shapes + fileName: group-ungroup-shapes.yaml + description: Shows how to create two shapes then group and ungroup them. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/group-ungroup-shapes.yaml + group: Shapes + api_set: + PowerPointApi: '1.8' +- id: powerpoint-add-slides + name: Add slides to a presentation + fileName: add-slides.yaml + description: Adds a slide and optionally specifies the slide master and layout. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/add-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.3' +- id: powerpoint-insert-slides + name: Insert slides from other presentation + fileName: insert-slides.yaml + description: Inserts slides from another PowerPoint file into the current presentation. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/insert-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.5' +- id: powerpoint-basics-get-slide-metadata + name: Get slide metadata + fileName: get-slide-metadata.yaml + description: Gets the title, index, and ID of the selected slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/get-slide-metadata.yaml + group: Slide Management + api_set: {} +- id: powerpoint-slide-management-get-set-slides + name: Get, set, load, and save slides + fileName: get-set-slides.yaml + description: Get and set one or more selected slides. Load and save one or more slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/get-set-slides.yaml + group: Slide Management + api_set: + PowerPointApi: '1.5' +- id: powerpoint-slide-management-export-import-slide + name: Export and import slide + fileName: export-import-slide.yaml + description: Shows how to export and import a slide. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/export-import-slide.yaml + group: Slide Management + api_set: + PowerPointApi: '1.8' +- id: powerpoint-tags + name: Work with tags + fileName: tags.yaml + description: Use tags to process subsets of slides. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/tags/tags.yaml + group: Tags + api_set: + PowerPointApi: '1.3' +- id: powerpoint-text-get-set-textrange + name: Work with text range selections + fileName: get-set-textrange.yaml + description: Get, set, load, and save text range selections. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/text/get-set-textrange.yaml + group: Text + api_set: + PowerPointApi: '1.5' diff --git a/playlists/project.yaml b/playlists/project.yaml index 165ac7d8c..a28427026 100644 --- a/playlists/project.yaml +++ b/playlists/project.yaml @@ -5,7 +5,7 @@ Executes a basic Project API call using the "common API" syntax (compatible with Office 2013). rawUrl: >- - https://raw.githubusercontent.com////samples/project/basics/basic-common-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/project/basics/basic-common-api-call.yaml group: Basics api_set: Selection: 1.1 diff --git a/playlists/word.yaml b/playlists/word.yaml index 2d9498bc1..d36dd59b1 100644 --- a/playlists/word.yaml +++ b/playlists/word.yaml @@ -3,7 +3,7 @@ fileName: basic-api-call.yaml description: Performs a basic Word API call using TypeScript. rawUrl: >- - https://raw.githubusercontent.com////samples/word/01-basics/basic-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-api-call.yaml group: Basics api_set: WordApi: '1.1' @@ -12,7 +12,7 @@ fileName: basic-api-call-es5.yaml description: Performs a basic Word API call using plain JavaScript & Promises. rawUrl: >- - https://raw.githubusercontent.com////samples/word/01-basics/basic-api-call-es5.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-api-call-es5.yaml group: Basics api_set: WordApi: '1.1' @@ -23,34 +23,154 @@ Performs a basic Word API call using JavaScript with the "common API" syntax (compatible with Office 2013). rawUrl: >- - https://raw.githubusercontent.com////samples/word/01-basics/basic-common-api-call.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-common-api-call.yaml group: Basics api_set: Selection: 1.1 - id: word-content-controls-insert-and-change-content-controls name: Content control basics fileName: insert-and-change-content-controls.yaml - description: 'Inserts, updates, and retrieves content controls.' + description: Inserts, updates, and retrieves content controls. rawUrl: >- - https://raw.githubusercontent.com////samples/word/10-content-controls/insert-and-change-content-controls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-content-controls.yaml group: Content Controls api_set: WordApi: '1.1' +- id: word-content-controls-content-control-onadded-event + name: On adding content controls + fileName: content-control-onadded-event.yaml + description: >- + Registers, triggers, and deregisters onAdded event that tracks the addition + of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onadded-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onentered-event + name: On entering content controls + fileName: content-control-onentered-event.yaml + description: >- + Registers, triggers, and deregisters onEntered event that tracks when the + cursor is placed within content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onentered-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onselectionchanged-event + name: On changing selection in content controls + fileName: content-control-onselectionchanged-event.yaml + description: >- + Registers, triggers, and deregisters onSelectionChanged event that tracks + when selections are changed in content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-ondatachanged-event + name: On changing data in content controls + fileName: content-control-ondatachanged-event.yaml + description: >- + Registers, triggers, and deregisters onDataChanged event that tracks when + data is changed in content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-ondatachanged-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-onexited-event + name: On exiting content controls + fileName: content-control-onexited-event.yaml + description: >- + Registers, triggers, and deregisters onExited event that tracks when the + cursor is removed from within content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onexited-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-content-control-ondeleted-event + name: On deleting content controls + fileName: content-control-ondeleted-event.yaml + description: >- + Registers, triggers, and deregisters onDeleted event that tracks the removal + of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-ondeleted-event.yaml + group: Content Controls + api_set: + WordApi: '1.5' +- id: word-content-controls-insert-and-change-checkbox-content-control + name: Manage checkbox content controls + fileName: insert-and-change-checkbox-content-control.yaml + description: Inserts, updates, retrieves, and deletes checkbox content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.7' +- id: word-content-controls-insert-and-change-combo-box-content-control + name: Manage combo box content controls + fileName: insert-and-change-combo-box-content-control.yaml + description: Inserts, updates, and deletes combo box content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.9' +- id: word-content-controls-insert-and-change-dropdown-list-content-control + name: Manage dropdown list content controls + fileName: insert-and-change-dropdown-list-content-control.yaml + description: Inserts, updates, and deletes dropdown list content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml + group: Content Controls + api_set: + WordApi: '1.9' +- id: word-content-controls-get-change-tracking-states + name: Get change tracking states of content controls + fileName: get-change-tracking-states.yaml + description: Gets change tracking states of content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/get-change-tracking-states.yaml + group: Content Controls + api_set: + WordApi: '1.5' - id: word-images-insert-and-get-pictures name: Use inline pictures fileName: insert-and-get-pictures.yaml description: Inserts and gets inline pictures. rawUrl: >- - https://raw.githubusercontent.com////samples/word/15-images/insert-and-get-pictures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/15-images/insert-and-get-pictures.yaml group: Images api_set: - WordApi: '1.1' + WordApiDesktop: '1.1' - id: word-lists-insert-list name: Create a list fileName: insert-list.yaml description: Inserts a new list into the document. rawUrl: >- - https://raw.githubusercontent.com////samples/word/20-lists/insert-list.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/insert-list.yaml + group: Lists + api_set: + WordApi: '1.3' +- id: word-lists-manage-styles + name: Get list styles + fileName: manage-list-styles.yaml + description: This sample shows how to get the list styles in the current document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/manage-list-styles.yaml + group: Lists + api_set: + WordApiDesktop: '1.1' +- id: word-lists-organize-list + name: Organize a list + fileName: organize-list.yaml + description: Shows how to create and organize a list. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/organize-list.yaml group: Lists api_set: WordApi: '1.3' @@ -59,7 +179,7 @@ fileName: get-paragraph-on-insertion-point.yaml description: Gets the full paragraph containing the insertion point. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml group: Paragraph api_set: WordApi: '1.1' @@ -68,7 +188,7 @@ fileName: insert-line-and-page-breaks.yaml description: Inserts page and line breaks in a document. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/insert-line-and-page-breaks.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-line-and-page-breaks.yaml group: Paragraph api_set: WordApi: '1.2' @@ -77,7 +197,7 @@ fileName: insert-in-different-locations.yaml description: Inserts content at different document locations. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/insert-in-different-locations.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-in-different-locations.yaml group: Paragraph api_set: WordApi: '1.2' @@ -86,34 +206,34 @@ fileName: insert-formatted-text.yaml description: Formats text with pre-built and custom styles. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/insert-formatted-text.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-formatted-text.yaml group: Paragraph api_set: WordApi: '1.1' - id: word-paragraph-insert-header-and-footer - name: Insert a header and footer + name: Insert headers and footers fileName: insert-header-and-footer.yaml - description: Inserts a header and a footer in the document. + description: Inserts headers and footers in the document. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/insert-header-and-footer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-header-and-footer.yaml group: Paragraph api_set: WordApi: '1.1' - id: word-paragraph-paragraph-properties name: Paragraph properties fileName: paragraph-properties.yaml - description: 'Sets indentation, space between paragraphs, and other paragraph properties.' + description: Sets indentation, space between paragraphs, and other paragraph properties. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/paragraph-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/paragraph-properties.yaml group: Paragraph api_set: - WordApi: '1.2' + WordApi: '1.1' - id: word-paragraph-search name: Search fileName: search.yaml description: Shows basic and advanced search capabilities. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/search.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/search.yaml group: Paragraph api_set: WordApi: '1.1' @@ -122,16 +242,60 @@ fileName: get-word-count.yaml description: Counts how many times a word or term appears in the document. rawUrl: >- - https://raw.githubusercontent.com////samples/word/25-paragraph/get-word-count.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-word-count.yaml group: Paragraph api_set: WordApi: '1.1' +- id: word-paragraph-get-text + name: Get text + fileName: get-text.yaml + description: >- + Shows how to get paragraph text, including hidden text and text marked for + deletion. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-text.yaml + group: Paragraph + api_set: + WordApi: '1.7' +- id: word-paragraph-onadded-event + name: On adding paragraphs + fileName: onadded-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphAdded event that tracks + the addition of paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/onadded-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' +- id: word-paragraph-onchanged-event + name: On changing content in paragraphs + fileName: onchanged-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphChanged event that + tracks when content is changed in paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/onchanged-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' +- id: word-paragraph-ondeleted-event + name: On deleting paragraphs + fileName: ondeleted-event.yaml + description: >- + Registers, triggers, and deregisters the onParagraphDeleted event that + tracks the removal of paragraphs. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/ondeleted-event.yaml + group: Paragraph + api_set: + WordApi: '1.6' - id: word-properties-get-built-in-properties name: Built-in document properties fileName: get-built-in-properties.yaml description: Gets built-in document properties. rawUrl: >- - https://raw.githubusercontent.com////samples/word/30-properties/get-built-in-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/30-properties/get-built-in-properties.yaml group: Properties api_set: WordApi: '1.1' @@ -140,7 +304,7 @@ fileName: read-write-custom-document-properties.yaml description: Adds and reads custom document properties of different types. rawUrl: >- - https://raw.githubusercontent.com////samples/word/30-properties/read-write-custom-document-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/30-properties/read-write-custom-document-properties.yaml group: Properties api_set: WordApi: '1.3' @@ -149,7 +313,7 @@ fileName: scroll-to-range.yaml description: Scrolls to a range with and without selection. rawUrl: >- - https://raw.githubusercontent.com////samples/word/35-ranges/scroll-to-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/scroll-to-range.yaml group: Ranges api_set: WordApi: '1.2' @@ -160,25 +324,268 @@ Splits a paragraph into word ranges and then traverses all the ranges to format each word, producing a "karaoke" effect. rawUrl: >- - https://raw.githubusercontent.com////samples/word/35-ranges/split-words-of-first-paragraph.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/split-words-of-first-paragraph.yaml + group: Ranges + api_set: + WordApi: '1.3' +- id: word-ranges-compare-location + name: Compare range locations + fileName: compare-location.yaml + description: This sample shows how to compare the locations of two ranges. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/compare-location.yaml group: Ranges api_set: WordApi: '1.3' +- id: word-ranges-get-pages + name: Work with pages, panes, and windows + fileName: get-pages.yaml + description: Shows how to work with pages, panes, and windows. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/get-pages.yaml + group: Ranges + api_set: + WordApiDesktop: '1.2' - id: word-tables-table-cell-access name: Create and access a table fileName: table-cell-access.yaml description: Creates a table and accesses a specific cell. rawUrl: >- - https://raw.githubusercontent.com////samples/word/40-tables/table-cell-access.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/table-cell-access.yaml group: Tables api_set: WordApi: '1.3' +- id: word-tables-manage-formatting + name: Table formatting + fileName: manage-formatting.yaml + description: >- + Gets the formatting details of a table, a table row, and a table cell, + including borders, alignment, and cell padding. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/manage-formatting.yaml + group: Tables + api_set: + WordApi: '1.3' +- id: word-tables-manage-custom-style + name: Manage custom table style + fileName: manage-custom-style.yaml + description: >- + Shows how to manage primarily margins and alignments of a custom table style + in the current document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/manage-custom-style.yaml + group: Tables + api_set: + WordApiDesktop: '1.1' +- id: word-shapes-manage-shapes-text-boxes + name: Work with shapes and text boxes + fileName: manage-shapes-text-boxes.yaml + description: Shows how to work with shapes and text boxes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-shapes-text-boxes.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-manage-geometric-shapes + name: Manage geometric shapes + fileName: manage-geometric-shapes.yaml + description: Shows how to work with geometric shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-geometric-shapes.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-group-ungroup + name: Group and ungroup shapes + fileName: group-ungroup.yaml + description: Shows how to group and ungroup shapes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/group-ungroup.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-shapes-manage-canvases + name: Work with canvases + fileName: manage-canvases.yaml + description: Shows how to work with canvases. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-canvases.yaml + group: Shapes + api_set: + WordApiDesktop: '1.2' +- id: word-document-manage-body + name: Manage body + fileName: manage-body.yaml + description: Shows how to manage the document body. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-body.yaml + group: Document + api_set: + WordApi: '1.2' +- id: word-document-insert-section-breaks + name: Add a section + fileName: insert-section-breaks.yaml + description: Shows how to insert section breaks in the document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/insert-section-breaks.yaml + group: Document + api_set: + WordApi: '1.1' +- id: word-document-insert-external-document + name: Insert an external document + fileName: insert-external-document.yaml + description: >- + Inserts the content (with or without settings) of an external document into + the current document. Settings include formatting, change-tracking mode, + custom properties, and XML parts. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/insert-external-document.yaml + group: Document + api_set: + WordApi: '1.7' +- id: word-document-manage-change-tracking + name: Track changes + fileName: manage-change-tracking.yaml + description: >- + This sample shows how to get and set the change tracking mode and get the + before and after of reviewed text. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-change-tracking.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-tracked-changes + name: Manage tracked changes + fileName: manage-tracked-changes.yaml + description: >- + This samples shows how to manage tracked changes, including accepting and + rejecting changes. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-tracked-changes.yaml + group: Document + api_set: + WordApi: '1.6' +- id: word-document-manage-comments + name: Manage comments + fileName: manage-comments.yaml + description: >- + This sample shows how to perform basic comments operations, including + insert, reply, get, edit, resolve, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-comments.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-footnotes + name: Manage footnotes + fileName: manage-footnotes.yaml + description: >- + This sample shows how to perform basic footnote operations, including + insert, get, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-footnotes.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-fields + name: Manage fields + fileName: manage-fields.yaml + description: >- + This sample shows how to perform basic operations on fields, including + insert, get, and delete. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-fields.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-settings + name: Manage settings + fileName: manage-settings.yaml + description: >- + This sample shows how to add, edit, get, and delete custom settings on a + document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-settings.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-custom-xml-part-ns + name: Manage a CustomXmlPart with the namespace + fileName: manage-custom-xml-part-ns.yaml + description: >- + This sample shows how to add, query, replace, edit, and delete a custom XML + part in a document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-custom-xml-part-ns.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-custom-xml-part + name: Manage a CustomXmlPart without the namespace + fileName: manage-custom-xml-part.yaml + description: >- + This sample shows how to add, query, edit, and delete a custom XML part in a + document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-custom-xml-part.yaml + group: Document + api_set: + WordApi: '1.4' +- id: word-document-manage-styles + name: Manage styles + fileName: manage-styles.yaml + description: >- + This sample shows how to perform operations on the styles in the current + document and how to add and delete custom styles. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-styles.yaml + group: Document + api_set: + WordApiDesktop: '1.1' +- id: word-document-get-external-styles + name: Get styles from external document + fileName: get-external-styles.yaml + description: This sample shows how to get styles from an external document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/get-external-styles.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-save-close + name: Manage document save and close + fileName: save-close.yaml + description: Shows how to manage saving and closing document. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/save-close.yaml + group: Document + api_set: + WordApi: '1.5' +- id: word-document-manage-annotations + name: Manage annotations + fileName: manage-annotations.yaml + description: >- + Shows how to leverage the Writing Assistance API to manage annotations and + use annotation events. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-annotations.yaml + group: Document + api_set: + WordApi: '1.8' +- id: word-document-compare-documents + name: Compare documents + fileName: compare-documents.yaml + description: Compares two documents (the current one and a specified external one). + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/compare-documents.yaml + group: Document + api_set: + WordApiDesktop: '1.1' - id: word-scenarios-doc-assembly name: Document assembly fileName: doc-assembly.yaml description: Composes different parts of a Word document. rawUrl: >- - https://raw.githubusercontent.com////samples/word/90-scenarios/doc-assembly.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/doc-assembly.yaml group: Scenarios api_set: WordApi: '1.1' @@ -187,7 +594,45 @@ fileName: multiple-property-set.yaml description: Sets multiple properties at once with the API object set() method. rawUrl: >- - https://raw.githubusercontent.com////samples/word/90-scenarios/multiple-property-set.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/multiple-property-set.yaml group: Scenarios api_set: WordApi: '1.3' +- id: word-scenarios-correlated-objects-pattern + name: Correlated objects pattern + fileName: correlated-objects-pattern.yaml + description: Shows the performance benefits of avoiding `context.sync` calls in a loop. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/correlated-objects-pattern.yaml + group: Scenarios + api_set: + WordApi: '1.4' +- id: word-close-document-window + name: Close document window + fileName: close-document-window.yaml + description: Shows how to close document window. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/close-document-window.yaml + group: Preview APIs + api_set: + WordApi: '1.10' +- id: word-insert-and-change-content-controls + name: Content control basics + fileName: insert-and-change-content-controls.yaml + description: Inserts, updates, and retrieves content controls. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/insert-and-change-content-controls.yaml + group: Preview APIs + api_set: + WordApi: '1.10' +- id: word-manage-comments + name: Manage comments + fileName: manage-comments.yaml + description: >- + This sample shows how to perform operations on comments (including insert, + reply, get, edit, resolve, and delete) and use comment events. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/manage-comments.yaml + group: Preview APIs + api_set: + WordApi: '1.10' diff --git a/private-samples/excel/20-chart/chart-title-ts.yaml b/private-samples/excel/20-chart/chart-title-ts.yaml index 29e777b3b..4c046d4e0 100644 --- a/private-samples/excel/20-chart/chart-title-ts.yaml +++ b/private-samples/excel/20-chart/chart-title-ts.yaml @@ -7,14 +7,14 @@ api_set: ExcelApi: 1.1 script: content: | - $("#setup").click(() => tryCatch(setup)); + $("#setup").on("click", () => tryCatch(setup)); - $("#set-title").click(() => tryCatch(setTitle)); - $("#get-title").click(() => tryCatch(getTitle)); + $("#set-title").on("click", () => tryCatch(setTitle)); + $("#get-title").on("click", () => tryCatch(getTitle)); async function setTitle() { await Excel.run(async (ctx) => { - var chart = ctx.workbook.worksheets.getItem("Sample").charts.getItem("Chart1"); + const chart = ctx.workbook.worksheets.getItem("Sample").charts.getItem("Chart1"); chart.title.text = "My Chart"; chart.title.visible = true; @@ -28,7 +28,7 @@ script: async function getTitle() { await Excel.run(async (ctx) => { - var chart = ctx.workbook.worksheets.getItem("Sample").charts.getItem("Chart1"); + const chart = ctx.workbook.worksheets.getItem("Sample").charts.getItem("Chart1"); chart.load('title/text'); await ctx.sync(); @@ -94,18 +94,18 @@ script: language: typescript template: content: |- -
+

This sample shows how to set and get the title of a chart using the Excel JavaScript API.

-
+

Set up

-
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -51,15 +50,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-axis-formatting.yaml b/samples/excel/10-chart/chart-axis-formatting.yaml index 36cadc25a..d6cec75ad 100644 --- a/samples/excel/10-chart/chart-axis-formatting.yaml +++ b/samples/excel/10-chart/chart-axis-formatting.yaml @@ -6,10 +6,10 @@ host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#format-horizontal-axis").click(() => tryCatch(formatHorizontalAxis)); - $("#format-vertical-axis").click(() => tryCatch(formatVerticalAxis)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("format-horizontal-axis").addEventListener("click", () => tryCatch(formatHorizontalAxis)); + document.getElementById("format-vertical-axis").addEventListener("click", () => tryCatch(formatVerticalAxis)); async function formatHorizontalAxis() { await Excel.run(async (context) => { @@ -118,33 +118,29 @@ script: language: typescript template: content: |- - -
+

This sample shows how to format the vertical and horizontal axis in a chart.

- -
+

Set up

- -
+

Try it out

- -
+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -158,13 +154,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-axis.yaml b/samples/excel/10-chart/chart-axis.yaml index f37d4ee45..788450358 100644 --- a/samples/excel/10-chart/chart-axis.yaml +++ b/samples/excel/10-chart/chart-axis.yaml @@ -1,18 +1,18 @@ order: 1 id: excel-chart-axis name: Axis details -description: 'Gets, sets, and removes axis unit, label, and title in a chart.' +description: Gets, sets, and removes axis unit, label, and title in a chart. host: EXCEL api_set: ExcelApi: '1.7' script: content: |- - $("#setup").click(() => tryCatch(setup)); - $("#get-axis-unit").click(() => tryCatch(getAxisUnit)); - $("#change-axis-unit").click(() => tryCatch(changeAxisUnit)); - $("#remove-axis-label").click(() => tryCatch(removeAxisLabel)); - $("#show-axis-label").click(() => tryCatch(showAxisLabel)); - $("#set-axis-title").click(() => tryCatch(setAxisTitle)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("get-axis-unit").addEventListener("click", () => tryCatch(getAxisUnit)); + document.getElementById("change-axis-unit").addEventListener("click", () => tryCatch(changeAxisUnit)); + document.getElementById("remove-axis-label").addEventListener("click", () => tryCatch(removeAxisLabel)); + document.getElementById("show-axis-label").addEventListener("click", () => tryCatch(showAxisLabel)); + document.getElementById("set-axis-title").addEventListener("click", () => tryCatch(setAxisTitle)); async function getAxisUnit() { await Excel.run(async (context) => { @@ -170,50 +170,44 @@ script: language: typescript template: content: |- -
+

This sample shows how to get, set, and remove axis unit, label and title in a chart.

- -
+

Set up

- -
+

Try it out

- -
+
- -
+
- -
+
- -
+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -225,15 +219,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/10-chart/chart-bubble-chart.yaml b/samples/excel/10-chart/chart-bubble-chart.yaml index 9c5228e59..9a80e9d81 100644 --- a/samples/excel/10-chart/chart-bubble-chart.yaml +++ b/samples/excel/10-chart/chart-bubble-chart.yaml @@ -1,4 +1,4 @@ -order: 3 +order: 4 id: excel-chart-bubble-chart name: Create bubble chart description: Creates a bubble chart with each data row represented as a single chart series (bubble). @@ -7,8 +7,11 @@ host: EXCEL api_set: ExcelApi: '1.12' script: - content: | - $("#setup").click(() => tryCatch(setup)); $("#create-bubble-chart").click(() => tryCatch(createBubbleChart)); $("#get-chart-series-dimension-values").click(() => tryCatch(getChartSeriesDimensionValues)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-bubble-chart").addEventListener("click", () => tryCatch(createBubbleChart)); + document.getElementById("get-chart-series-dimension-values").addEventListener("click", () => tryCatch(getChartSeriesDimensionValues)); + async function createBubbleChart() { await Excel.run(async (context) => { /* @@ -55,6 +58,7 @@ script: await context.sync(); }); } + async function getChartSeriesDimensionValues() { await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getItem("Sample"); @@ -115,18 +119,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to create a bubble chart, with each chart series (or bubble) representing a single table row.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -150,15 +152,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-create-several-charts.yaml b/samples/excel/10-chart/chart-create-several-charts.yaml index 10a7a11cd..f76ef24c9 100644 --- a/samples/excel/10-chart/chart-create-several-charts.yaml +++ b/samples/excel/10-chart/chart-create-several-charts.yaml @@ -1,26 +1,26 @@ -order: 4 +order: 5 id: excel-chart-create-several-charts name: Create charts -description: 'Creates column-clustered, line, XY-scatter, area, radar, pie, 3D, cylinder, and 100% charts.' +description: Creates column-clustered, line, XY-scatter, area, radar, pie, 3D, cylinder, and 100% charts. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#create-column-clustered-chart").click(() => tryCatch(createColumnClusteredChart)); - $("#create-line-chart").click(() => tryCatch(createLineChart)); - $("#create-xy-scatter-chart").click(() => tryCatch(createXYScatterChart)); - $("#create-area-chart").click(() => tryCatch(createAreaStackedChart)); - $("#create-radar-chart").click(() => tryCatch(createRadarFilledChart)); - $("#create-pie-chart").click(() => tryCatch(createPieChart)); - $("#create-3d-chart").click(() => tryCatch(create3DChart)); - $("#create-cylinder-chart").click(() => tryCatch(createCylinderChart)); - $("#create-bar-100-chart").click(() => tryCatch(createBar100Chart)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-column-clustered-chart").addEventListener("click", () => tryCatch(createColumnClusteredChart)); + document.getElementById("create-line-chart").addEventListener("click", () => tryCatch(createLineChart)); + document.getElementById("create-xy-scatter-chart").addEventListener("click", () => tryCatch(createXYScatterChart)); + document.getElementById("create-area-chart").addEventListener("click", () => tryCatch(createAreaStackedChart)); + document.getElementById("create-radar-chart").addEventListener("click", () => tryCatch(createRadarFilledChart)); + document.getElementById("create-pie-chart").addEventListener("click", () => tryCatch(createPieChart)); + document.getElementById("create-3d-chart").addEventListener("click", () => tryCatch(create3DChart)); + document.getElementById("create-cylinder-chart").addEventListener("click", () => tryCatch(createCylinderChart)); + document.getElementById("create-bar-100-chart").addEventListener("click", () => tryCatch(createBar100Chart)); async function createColumnClusteredChart() { - await Excel.run(async (context) => { + await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getItem("Sample"); const salesTable = sheet.tables.getItem("SalesTable"); @@ -40,279 +40,266 @@ script: points.getItemAt(1).format.fill.setSolidColor("indigo"); await context.sync(); - }); + }); } async function createLineChart() { - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); - - let dataRange = sheet.getRange("A1:E7"); - let chart = sheet.charts.add("Line", dataRange, "Auto"); - - chart.setPosition("A22", "F35"); - chart.legend.position = "Right" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.title.text = "Bicycle Parts Quarterly Sales"; - - await context.sync(); - }); + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + + let dataRange = sheet.getRange("A1:E7"); + let chart = sheet.charts.add(Excel.ChartType.line, dataRange, "Auto"); + + chart.setPosition("A22", "F35"); + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.title.text = "Bicycle Parts Quarterly Sales"; + + await context.sync(); + }); } async function createXYScatterChart() { - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); - let dataRange = sheet.getRange("A1:E7"); + let dataRange = sheet.getRange("A1:E7"); - // Create an XY scatter chart. - let chart = sheet.charts.add("XYScatter", dataRange, "Auto"); - chart.title.text = "Bicycle Parts Quarterly Sales"; - chart.setPosition("A36", "F48"); + // Create an XY scatter chart. + let chart = sheet.charts.add(Excel.ChartType.xyscatter, dataRange, "Auto"); + chart.title.text = "Bicycle Parts Quarterly Sales"; + chart.setPosition("A36", "F48"); - await context.sync(); - }); + await context.sync(); + }); } async function createAreaStackedChart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("AreaStacked", dataRange, "Auto"); - - chart.setPosition("H1", "M15"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.series.getItemAt(0).name = "Q1"; - chart.series.getItemAt(1).name = "Q2"; - chart.series.getItemAt(2).name = "Q3"; - chart.series.getItemAt(3).name = "Q4"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add(Excel.ChartType.areaStacked, dataRange, "Auto"); + + chart.setPosition("H1", "M15"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.series.getItemAt(0).name = "Q1"; + chart.series.getItemAt(1).name = "Q2"; + chart.series.getItemAt(2).name = "Q3"; + chart.series.getItemAt(3).name = "Q4"; + + await context.sync(); + }); } async function createRadarFilledChart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("RadarFilled", dataRange, "Auto"); - - chart.setPosition("H17", "M35"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.series.getItemAt(0).name = "Q1"; - chart.series.getItemAt(1).name = "Q2"; - chart.series.getItemAt(2).name = "Q3"; - chart.series.getItemAt(3).name = "Q4"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add(Excel.ChartType.radarFilled, dataRange, "Auto"); + + chart.setPosition("H17", "M35"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.series.getItemAt(0).name = "Q1"; + chart.series.getItemAt(1).name = "Q2"; + chart.series.getItemAt(2).name = "Q3"; + chart.series.getItemAt(3).name = "Q4"; + + await context.sync(); + }); } async function createPieChart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("Pie", dataRange, "Auto"); - - chart.setPosition("H37", "M52"); - chart.title.text = "1st Quarter sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add("Pie", dataRange, "Auto"); + + chart.setPosition("H37", "M52"); + chart.title.text = "1st Quarter sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + + await context.sync(); + }); } async function create3DChart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("3DBarClustered", dataRange, "Auto"); - - chart.setPosition("O1", "T20"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.series.getItemAt(0).name = "Q1"; - chart.series.getItemAt(1).name = "Q2"; - chart.series.getItemAt(2).name = "Q3"; - chart.series.getItemAt(3).name = "Q4"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add(Excel.ChartType._3DBarClustered, dataRange, "Auto"); + + chart.setPosition("O1", "T20"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.series.getItemAt(0).name = "Q1"; + chart.series.getItemAt(1).name = "Q2"; + chart.series.getItemAt(2).name = "Q3"; + chart.series.getItemAt(3).name = "Q4"; + + await context.sync(); + }); } async function createCylinderChart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("CylinderCol", dataRange, "Auto"); - - chart.setPosition("O22", "T36"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.series.getItemAt(0).name = "Q1"; - chart.series.getItemAt(1).name = "Q2"; - chart.series.getItemAt(2).name = "Q3"; - chart.series.getItemAt(3).name = "Q4"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add(Excel.ChartType.cylinderCol, dataRange, "Auto"); + + chart.setPosition("O22", "T36"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.series.getItemAt(0).name = "Q1"; + chart.series.getItemAt(1).name = "Q2"; + chart.series.getItemAt(2).name = "Q3"; + chart.series.getItemAt(3).name = "Q4"; + + await context.sync(); + }); } async function createBar100Chart() { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - let chart = sheet.charts.add("BarStacked100", dataRange, "Auto"); - - chart.setPosition("O38", "T50"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Bottom" - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; - chart.series.getItemAt(0).name = "Q1"; - chart.series.getItemAt(1).name = "Q2"; - chart.series.getItemAt(2).name = "Q3"; - chart.series.getItemAt(3).name = "Q4"; - - await context.sync(); - }); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + let chart = sheet.charts.add(Excel.ChartType.barStacked100, dataRange, "Auto"); + + chart.setPosition("O38", "T50"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Bottom"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.series.getItemAt(0).name = "Q1"; + chart.series.getItemAt(1).name = "Q2"; + chart.series.getItemAt(2).name = "Q3"; + chart.series.getItemAt(3).name = "Q4"; + + await context.sync(); + }); } async function setup() { - await Excel.run(async (context) => { - context.workbook.worksheets.getItemOrNullObject("Sample").delete(); - const sheet = context.workbook.worksheets.add("Sample"); - - let expensesTable = sheet.tables.add("A1:E1", true); - expensesTable.name = "SalesTable"; - expensesTable.getHeaderRowRange().values = [ - ["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"] - ]; - - expensesTable.rows.add(null, [ - ["Frames", 5000, 7000, 6544, 4377], - ["Saddles", 400, 323, 276, 651], - ["Brake levers", 12000, 8766, 8456, 9812], - ["Chains", 1550, 1088, 692, 853], - ["Mirrors", 225, 600, 923, 544], - ["Spokes", 6005, 7634, 4589, 8765] - ]); - - sheet.getUsedRange().format.autofitColumns(); - sheet.getUsedRange().format.autofitRows(); - - sheet.activate(); - await context.sync(); - }); + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + let expensesTable = sheet.tables.add("A1:E1", true); + expensesTable.name = "SalesTable"; + expensesTable.getHeaderRowRange().values = [["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"]]; + + expensesTable.rows.add(null, [ + ["Frames", 5000, 7000, 6544, 4377], + ["Saddles", 400, 323, 276, 651], + ["Brake levers", 12000, 8766, 8456, 9812], + ["Chains", 1550, 1088, 692, 853], + ["Mirrors", 225, 600, 923, 544], + ["Spokes", 6005, 7634, 4589, 8765] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + await context.sync(); + }); } /** 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); - } + 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: |- -
+

This sample shows how to create column-clustered, line, XY-scatter, area, radar, pie, 3D, cylinder, and 100% charts.

- -
+

Set up

- -
+

Try it out

-

-

-

-

-

-

-

-

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -324,15 +311,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/10-chart/chart-data-labels.yaml b/samples/excel/10-chart/chart-data-labels.yaml new file mode 100644 index 000000000..5e3113b8c --- /dev/null +++ b/samples/excel/10-chart/chart-data-labels.yaml @@ -0,0 +1,278 @@ +order: 16 +id: excel-chart-data-labels +name: Data labels +description: Add and style data labels for your charts. +host: EXCEL +api_set: + ExcelApi: '1.19' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-data-labels").addEventListener("click", () => tryCatch(addDataLabels)); + document.getElementById("style-data-label-substrings").addEventListener("click", () => tryCatch(styleDataLabelSubstrings)); + document.getElementById("change-label-to-round-rectangle").addEventListener("click", () => tryCatch(changeLabelShapesToRoundRectangle)); + document.getElementById("change-label-to-assorted").addEventListener("click", () => tryCatch(changeLabelShapesToAssorted)); + + // Define the worksheet name for the sample. + const sheetName = "Sample"; + + async function addDataLabels() { + // This function adds data labels to specific chart points + // and sets their text and position. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.points.load("dataLabel"); + await context.sync(); + + // Define properties for data label positioning and shape. + const labelProperties = [ + { + top: 70, + geometricShapeType: Excel.GeometricShapeType.rectangle + }, + { + top: 200, + geometricShapeType: Excel.GeometricShapeType.rectangle + } + ]; + + // Add data labels to specific chart points and set their text and properties. + for (let i = 0; i < dataLabelInfo.length; i++) { + const point = series.points.getItemAt(dataLabelInfo[i].index); + point.hasDataLabel = true; + + const dataLabel = point.dataLabel; + dataLabel.text = dataLabelInfo[i].news; + dataLabel.set(labelProperties[i]); + } + await context.sync(); + }); + } + + async function styleDataLabelSubstrings() { + // This function styles substrings within data label text using font formatting. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.load("points"); + await context.sync(); + + series.points.load("items"); + await context.sync(); + + // Style a substring in the first data label. + let searchString = "sports"; + let dataLabel = series.points.getItemAt(dataLabelInfo[0].index).dataLabel.load("text"); + await context.sync(); + let substringStart = dataLabel.text.indexOf(searchString); + let subLabel = dataLabel.getSubstring(substringStart, searchString.length); + subLabel.font.size = 13; + subLabel.font.bold = true; + + // Style a substring in the second data label. + searchString = "'Titanic'"; + dataLabel = series.points.getItemAt(dataLabelInfo[1].index).dataLabel.load("text"); + await context.sync(); + + substringStart = dataLabel.text.indexOf(searchString); + subLabel = dataLabel.getSubstring(substringStart, searchString.length); + subLabel.font.name = "Calibri"; + subLabel.font.size = 13; + subLabel.font.italic = true; + subLabel.font.color = "blue"; + await context.sync(); + }); + } + + async function changeLabelShapesToRoundRectangle() { + // This function changes the geometric shape of data labels to round rectangles. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.load("*"); + await context.sync(); + + series.points.load("*"); + await context.sync(); + + // Set both data labels to round rectangle shape. + let dataLabel = series.points.getItemAt(dataLabelInfo[0].index).dataLabel; + dataLabel.geometricShapeType = Excel.GeometricShapeType.roundRectangle; + + dataLabel = series.points.getItemAt(dataLabelInfo[1].index).dataLabel; + dataLabel.geometricShapeType = Excel.GeometricShapeType.roundRectangle; + await context.sync(); + }); + } + + async function changeLabelShapesToAssorted() { + // This function changes data labels to different geometric shapes with custom formatting. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + + // Set first data label to snip1Rectangle shape. + let dataLabel = series.points.getItemAt(dataLabelInfo[0].index).dataLabel; + dataLabel.geometricShapeType = Excel.GeometricShapeType.snip1Rectangle; + + // Set second data label to snip2DiagonalRectangle shape with light green fill. + dataLabel = series.points.getItemAt(dataLabelInfo[1].index).dataLabel; + dataLabel.geometricShapeType = Excel.GeometricShapeType.snip2DiagonalRectangle; + dataLabel.format.fill.setSolidColor("90EE90"); + await context.sync(); + }); + } + + /** Create sample data and a line chart for the data labels demo. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject(sheetName).delete(); + const sheet = context.workbook.worksheets.add(sheetName); + + // Add sample data to the worksheet. + const dataRange = sheet.getRange("A1:B32"); + dataRange.values = sampleData; + + sheet.activate(); + await context.sync(); + + // Create a line chart with markers. + const chart = sheet.charts.add(Excel.ChartType.lineMarkers, dataRange); + + // Position and format the chart. + chart.setPosition("D4", "Q25"); + chart.legend.visible = false; + chart.title.text = "Product price"; + chart.title.format.font.size = 20; + chart.axes.valueAxis.minimum = 80; + + await context.sync(); + }); + } + + /** 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); + } + } + + // Save chart data labels as an object for use throughout the sample. + const dataLabelInfo = [ + { + index: 11, + date: "7/12/2023", + news: "The city holds a sports event." + }, + { + index: 20, + date: "7/21/2023", + news: "The movie 'Titanic' returns to the cinema." + } + ]; + + // Sample data for the chart. + const sampleData = [ + ["Date", "Price"], + ["7/1/2023", 100], + ["7/2/2023", 96.71], + ["7/3/2023", 103.24], + ["7/4/2023", 109.09], + ["7/5/2023", 113.68], + ["7/6/2023", 118.68], + ["7/7/2023", 123.2], + ["7/8/2023", 135.05], + ["7/9/2023", 138.68], + ["7/10/2023", 129.63], + ["7/11/2023", 130.85], + ["7/12/2023", 135.71], + ["7/13/2023", 124.83], + ["7/14/2023", 118.94], + ["7/15/2023", 119.63], + ["7/16/2023", 127.2], + ["7/17/2023", 113.98], + ["7/18/2023", 110.32], + ["7/19/2023", 119.3], + ["7/20/2023", 120.36], + ["7/21/2023", 111.88], + ["7/22/2023", 118.88], + ["7/23/2023", 124.37], + ["7/24/2023", 119.53], + ["7/25/2023", 133.42], + ["7/26/2023", 125.67], + ["7/27/2023", 135.82], + ["7/28/2023", 137.87], + ["7/29/2023", 138.9], + ["7/30/2023", 139.36], + ["7/31/2023", 138.75] + ]; + language: typescript +template: + content: |- +
+

This sample shows how to create data labels for charts and adjust the font and appearance of those labels.

+
+
+

Set up

+ +
+
+

Add data labels to the chart

+ +
+
+

Style data labels

+ +
+
+ +
+
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-data-source.yaml b/samples/excel/10-chart/chart-data-source.yaml new file mode 100644 index 000000000..59e74e3f5 --- /dev/null +++ b/samples/excel/10-chart/chart-data-source.yaml @@ -0,0 +1,119 @@ +order: 14 +id: excel-chart-data-source +name: Chart series data source +description: This sample shows how to get information about the data source of a chart series. +host: EXCEL +api_set: + ExcelApi: '1.15' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("log-chart-series-source").addEventListener("click", () => tryCatch(logChartSeriesSource)); + + async function logChartSeriesSource() { + // This function retrieves the data source information of a chart series in the Sample worksheet. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Get the first chart series from the first chart on the worksheet. + const seriesCollection = sheet.charts.getItemAt(0).series; + const series = seriesCollection.getItemAt(0); + + // Get the series data source string and type values. + const dataSourceString = series.getDimensionDataSourceString("Values"); + const dataSourceType = series.getDimensionDataSourceType("Values"); + + series.load("name"); + await context.sync(); + + // Log the data source information to the console. + console.log(series.name + " data source string: " + dataSourceString.value); + console.log(series.name + " data source type: " + dataSourceType.value); + }); + } + + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + // Create an a table named SalesTable on the Sample worksheet. + let expensesTable = sheet.tables.add("A1:E1", true); + expensesTable.name = "SalesTable"; + + expensesTable.getHeaderRowRange().values = [["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"]]; + expensesTable.rows.add(null, [ + ["Frames", 5000, 7000, 6544, 4377], + ["Saddles", 400, 323, 276, 651], + ["Brake levers", 12000, 8766, 8456, 9812], + ["Chains", 1550, 1088, 692, 853], + ["Mirrors", 225, 600, 923, 544], + ["Spokes", 6005, 7634, 4589, 8765] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + sheet.activate(); + + // Create a line chart based on data from SalesTable. + let dataRange = sheet.getRange("A1:E7"); + let chart = sheet.charts.add("Line", dataRange, Excel.ChartSeriesBy.rows); + + // Position and style the chart. + chart.setPosition("A15", "E30"); + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to get information about the data source of a chart series.

+
+
+

Set up

+

Add a product table and line chart to a sample worksheet.

+ +
+
+

Try it out

+

Log information to the console about the data source of the chart series Frames.

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-data-table.yaml b/samples/excel/10-chart/chart-data-table.yaml new file mode 100644 index 000000000..423e060b2 --- /dev/null +++ b/samples/excel/10-chart/chart-data-table.yaml @@ -0,0 +1,157 @@ +order: 3 +id: excel-chart-data-table +name: Chart data table +description: Add a data table to a chart and then format that data table. +host: EXCEL +api_set: + ExcelApi: '1.14' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-column-clustered-chart").addEventListener("click", () => tryCatch(createColumnClusteredChart)); + document.getElementById("add-chart-data-table").addEventListener("click", () => tryCatch(addChartDataTable)); + document.getElementById("format-chart-data-table").addEventListener("click", () => tryCatch(formatChartDataTable)); + + async function createColumnClusteredChart() { + // This function creates a clustered column chart based on data from a table on + // this worksheet and then sets name, position, and format for the chart. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Create a clustered column chart with data from "SalesTable". + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + const chart = sheet.charts.add("ColumnClustered", dataRange, "Auto"); + + // Set name, position, and format for the chart. + chart.name = "SalesChart"; + chart.title.text = "Quarterly sales chart"; + chart.setPosition("A9", "L20"); + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + + const points = chart.series.getItemAt(0).points; + points.getItemAt(0).format.fill.setSolidColor("pink"); + points.getItemAt(1).format.fill.setSolidColor("indigo"); + + await context.sync(); + }); + } + + async function addChartDataTable() { + // This function adds a data table to a chart that already exists on the worksheet. + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the data table object for the chart and set it to visible. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load("visible"); + chartDataTable.visible = true; + await context.sync(); + }); + } + + async function formatChartDataTable() { + // This function adjusts the display and format of a chart data table that already exists on the worksheet. + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + let expensesTable = sheet.tables.add("A1:E1", true); + expensesTable.name = "SalesTable"; + expensesTable.getHeaderRowRange().values = [["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"]]; + + expensesTable.rows.add(null, [ + ["Frames", 5000, 7000, 6544, 4377], + ["Saddles", 400, 323, 276, 651], + ["Brake levers", 12000, 8766, 8456, 9812], + ["Chains", 1550, 1088, 692, 853], + ["Mirrors", 225, 600, 923, 544], + ["Spokes", 6005, 7634, 4589, 8765] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to add a data table to a chart and then format that data table.

+
+
+

Set up

+ +

+ +
+
+

Try it out

+ +

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-formatting.yaml b/samples/excel/10-chart/chart-formatting.yaml index b852a2e29..79a031e34 100644 --- a/samples/excel/10-chart/chart-formatting.yaml +++ b/samples/excel/10-chart/chart-formatting.yaml @@ -1,4 +1,4 @@ -order: 6 +order: 7 id: excel-chart-formatting name: Formatting description: Formats labels and lines of a slope chart. @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#format-chart").click(() => tryCatch(formatChart)); - $("#show-datalabels").click(() => tryCatch(dataLabels)); - $("#change-color").click(() => tryCatch(changeColor)); - $("#clear").click(() => tryCatch(clearChart)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("format-chart").addEventListener("click", () => tryCatch(formatChart)); + document.getElementById("show-datalabels").addEventListener("click", () => tryCatch(dataLabels)); + document.getElementById("change-color").addEventListener("click", () => tryCatch(changeColor)); + document.getElementById("clear").addEventListener("click", () => tryCatch(clearChart)); async function formatChart() { await Excel.run(async (context) => { @@ -60,7 +60,7 @@ script: pointsLoaded = series.points.count; } - for (var j = 0; j < pointsLoaded; j++) { + for (let j = 0; j < pointsLoaded; j++) { // the colors assume "Format chart" has been pressed series.points.getItemAt(j).markerBackgroundColor = "#404040"; series.points.getItemAt(j).markerForegroundColor = "#404040"; @@ -84,7 +84,7 @@ script: await context.sync(); // color everything grey before highlighting spokes - for (var i = 0; i < chart.series.count; i++) { + for (let i = 0; i < chart.series.count; i++) { chart.series.getItemAt(i).format.line.color = "#636363"; chart.series.getItemAt(i).dataLabels.format.font.color = "#636363"; } @@ -106,7 +106,7 @@ script: charts.load("count"); await context.sync(); - for (var i = 0; i < charts.count; i++) { + for (let i = 0; i < charts.count; i++) { charts.getItemAt(0).delete(); } await context.sync(); @@ -171,18 +171,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to format different aspects of a chart.

- -
+

Set up

- -
+

Try it out

+
+
+

Try it out

+ +
+
+ +
+
+ +
+
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-legend.yaml b/samples/excel/10-chart/chart-legend.yaml index bd95dae97..5e2cabac5 100644 --- a/samples/excel/10-chart/chart-legend.yaml +++ b/samples/excel/10-chart/chart-legend.yaml @@ -1,4 +1,4 @@ -order: 7 +order: 8 id: excel-chart-legend name: Legend description: Formats the legend's font. @@ -6,9 +6,9 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#format-legend-font").click(() => tryCatch(formatLegendFont)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("format-legend-font").addEventListener("click", () => tryCatch(formatLegendFont)); async function formatLegendFont() { await Excel.run(async (context) => { @@ -100,18 +100,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to format the legend font in a chart.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -131,15 +129,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-point.yaml b/samples/excel/10-chart/chart-point.yaml index 6370a490c..627984a03 100644 --- a/samples/excel/10-chart/chart-point.yaml +++ b/samples/excel/10-chart/chart-point.yaml @@ -1,4 +1,4 @@ -order: 8 +order: 9 id: excel-chart-point name: Points description: Sets the color of a point on the chart. @@ -6,9 +6,9 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: |+ - $("#setup").click(() => tryCatch(setup)); - $("#set-chart-point-color").click(() => tryCatch(setChartPointColor)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-chart-point-color").addEventListener("click", () => tryCatch(setChartPointColor)); async function setChartPointColor() { await Excel.run(async (context) => { @@ -79,33 +79,27 @@ script: console.error(error); } } - - - language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to set chart point color.

- -
+

Set up

- -
+

Try it out

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -117,15 +111,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-series-markers.yaml b/samples/excel/10-chart/chart-series-markers.yaml index 2aec1f275..6d319a862 100644 --- a/samples/excel/10-chart/chart-series-markers.yaml +++ b/samples/excel/10-chart/chart-series-markers.yaml @@ -1,4 +1,4 @@ -order: 10 +order: 11 id: excel-chart-series-markers name: Series markers description: Sets the chart series marker properties. @@ -6,9 +6,9 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#set-markers").click(() => tryCatch(setMarkers)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-markers").addEventListener("click", () => tryCatch(setMarkers)); async function setMarkers() { await Excel.run(async (context) => { @@ -81,18 +81,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to set chart series marker properties.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -114,13 +112,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-series-plotorder.yaml b/samples/excel/10-chart/chart-series-plotorder.yaml index c8c7a14d1..69ce579ef 100644 --- a/samples/excel/10-chart/chart-series-plotorder.yaml +++ b/samples/excel/10-chart/chart-series-plotorder.yaml @@ -1,4 +1,4 @@ -order: 11 +order: 12 id: excel-chart-series-plotorder name: Series plot order description: Orders the plotting of series in a chart. @@ -6,9 +6,9 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#order-series-plot").click(() => tryCatch(addSeries)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("order-series-plot").addEventListener("click", () => tryCatch(addSeries)); async function addSeries() { await Excel.run(async (context) => { @@ -91,19 +91,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to change the plot order of series in a chart.

- -
+

Set up

- -
+

Try it out

- -
+

Try it out

- -
+
@@ -140,15 +137,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-title-format.yaml b/samples/excel/10-chart/chart-title-format.yaml index 3dfee0e3a..b080b8b5f 100644 --- a/samples/excel/10-chart/chart-title-format.yaml +++ b/samples/excel/10-chart/chart-title-format.yaml @@ -1,4 +1,4 @@ -order: 12 +order: 13 id: excel-chart-title-format name: Title format description: Adjust a chart title's format. @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#change-title-format").click(() => tryCatch(changeTitleFormat)); - $("#change-title-substring").click(() => tryCatch(changeTitleSubstring)); - $("#change-title-orientation").click(() => tryCatch(changeTitleOrientation)); - $("#add-title-shadow").click(() => tryCatch(addTitleShadow)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("change-title-format").addEventListener("click", () => tryCatch(changeTitleFormat)); + document.getElementById("change-title-substring").addEventListener("click", () => tryCatch(changeTitleSubstring)); + document.getElementById("change-title-orientation").addEventListener("click", () => tryCatch(changeTitleOrientation)); + document.getElementById("add-title-shadow").addEventListener("click", () => tryCatch(addTitleShadow)); async function changeTitleFormat() { await Excel.run(async (context) => { @@ -106,19 +106,17 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to adjust format a chart's title.

- -
+

Set up

- -
+

Try it out

- language: html style: content: |- @@ -148,15 +145,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/10-chart/chart-trendlines.yaml b/samples/excel/10-chart/chart-trendlines.yaml index c9af58528..ee4b19ffe 100644 --- a/samples/excel/10-chart/chart-trendlines.yaml +++ b/samples/excel/10-chart/chart-trendlines.yaml @@ -1,17 +1,17 @@ -order: 13 +order: 14 id: excel-chart-trendlines name: Trendlines -description: 'Adds, gets, and formats trendlines in a chart.' +description: Adds, gets, and formats trendlines in a chart. host: EXCEL api_set: ExcelApi: '1.7' script: - content: |+ - $("#setup").click(() => tryCatch(setup)); - $("#add-trendline").click(() => tryCatch(addTrendline)); - $("#get-trendline").click(() => tryCatch(getTrendline)); - $("#get-trendline-color").click(() => tryCatch(getTrendlineColor)); - $("#set-trendline-color").click(() => tryCatch(setTrendlineColor)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-trendline").addEventListener("click", () => tryCatch(addTrendline)); + document.getElementById("get-trendline").addEventListener("click", () => tryCatch(getTrendline)); + document.getElementById("get-trendline-color").addEventListener("click", () => tryCatch(getTrendlineColor)); + document.getElementById("set-trendline-color").addEventListener("click", () => tryCatch(setTrendlineColor)); async function addTrendline() { await Excel.run(async (context) => { @@ -134,42 +134,35 @@ script: console.error(error); } } - - - language: typescript template: content: |- -
+

This sample shows how to add, get, and format trendlines in a chart.

- -
+

Set up

- -
+

Try it out

- -
+
- -
+
-
+
@@ -188,15 +181,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/10-chart/create-doughnut-chart.yaml b/samples/excel/10-chart/create-doughnut-chart.yaml index b7d8c3815..a9df8e856 100644 --- a/samples/excel/10-chart/create-doughnut-chart.yaml +++ b/samples/excel/10-chart/create-doughnut-chart.yaml @@ -1,4 +1,4 @@ -order: 5 +order: 6 id: excel-chart-create-doughnut-chart name: Doughnut chart description: Creates a doughnut chart and adjusts its size. @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#create-doughnut-chart").click(() => tryCatch(createChart)); - $("#add-series").click(() => tryCatch(addSeries)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-doughnut-chart").addEventListener("click", () => tryCatch(createChart)); + document.getElementById("add-series").addEventListener("click", () => tryCatch(addSeries)); async function createChart() { Excel.run(async (context) => { @@ -103,18 +103,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to create a doughnut chart.

- -
+

Set up

- -
+

Try it out

-
+

Try it out

To better view the comment changes, open the Comments pane by selecting Show Comments from the Review tab.

-
+

Try it out

To better view the comment changes, open the Comments pane by selecting Show Comments from the Review tab.

@@ -72,7 +72,7 @@ template: Mention someone in a comment

-

Change the email and name fields in the addCommentWithMention method to test the notification functionality.

+

Change the email and name fields in the addCommentWithMention function to test the notification functionality.

language: html style: @@ -88,15 +88,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/12-comment/comment-replies.yaml b/samples/excel/12-comments-and-notes/comment-replies.yaml similarity index 82% rename from samples/excel/12-comment/comment-replies.yaml rename to samples/excel/12-comments-and-notes/comment-replies.yaml index acade0f0a..ae02603bd 100644 --- a/samples/excel/12-comment/comment-replies.yaml +++ b/samples/excel/12-comments-and-notes/comment-replies.yaml @@ -1,18 +1,18 @@ order: 3 id: excel-comment-replies name: Comment replies -description: 'Adds, edits, and removes comment replies.' +description: Adds, edits, and removes comment replies. host: EXCEL api_set: ExcelApi: '1.10' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#add-first-comment-reply").click(() => tryCatch(addFirstCommentReply)); - $("#add-second-comment-reply").click(() => tryCatch(addSecondCommentReply)); - $("#get-comment-reply-metadata").click(() => tryCatch(getCommentReplyMetadata)); - $("#edit-comment-reply").click(() => tryCatch(editCommentReply)); - $("#delete-comment-reply").click(() => tryCatch(deleteCommentReply)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-first-comment-reply").addEventListener("click", () => tryCatch(addFirstCommentReply)); + document.getElementById("add-second-comment-reply").addEventListener("click", () => tryCatch(addSecondCommentReply)); + document.getElementById("get-comment-reply-metadata").addEventListener("click", () => tryCatch(getCommentReplyMetadata)); + document.getElementById("edit-comment-reply").addEventListener("click", () => tryCatch(editCommentReply)); + document.getElementById("delete-comment-reply").addEventListener("click", () => tryCatch(deleteCommentReply)); async function addFirstCommentReply() { await Excel.run(async (context) => { @@ -103,16 +103,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to add, edit, and remove comment replies.

-
+

Setup

-
+

Try it out

To better view the comment changes, open the Comments pane by selecting Show Comments from the Review tab.

-
+

Try it out

To better view the comment changes, open the Comments pane by selecting Show Comments from the Review tab.

@@ -99,15 +99,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/12-comments-and-notes/excel-note-basics.yaml b/samples/excel/12-comments-and-notes/excel-note-basics.yaml new file mode 100644 index 000000000..582c5d52c --- /dev/null +++ b/samples/excel/12-comments-and-notes/excel-note-basics.yaml @@ -0,0 +1,162 @@ +order: 5 +id: excel-note-basics +name: Notes +description: Adds, edits, and removes notes. +host: EXCEL +api_set: + ExcelApi: '1.18' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-note-to-selected-cell").addEventListener("click", () => tryCatch(addNoteToSelectedCell)); + document.getElementById("add-note-to-cell").addEventListener("click", () => tryCatch(addNoteToCell)); + document.getElementById("change-note-visibility").addEventListener("click", () => tryCatch(changeNoteVisibility)); + document.getElementById("edit-note-content").addEventListener("click", () => tryCatch(editNoteContent)); + document.getElementById("edit-note-size").addEventListener("click", () => tryCatch(editNoteSize)); + document.getElementById("delete-note").addEventListener("click", () => tryCatch(deleteNote)); + + async function addNoteToSelectedCell() { + // This function adds a note to the selected cell. + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); + } + + async function addNoteToCell() { + // This function adds a note to cell A2. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + + // Note that an InvalidArgument error is thrown if multiple cells are passed to `notes.add`. + sheet.notes.add("A2", "The second note."); + await context.sync(); + }); + } + + async function changeNoteVisibility() { + // This function sets the note on cell A1 to visible. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); + } + + async function editNoteContent() { + // This function changes the content in the first note. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); + } + + async function editNoteSize() { + // This function changes the height and width of the first note. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); + } + + async function deleteNote() { + // This function deletes the note from cell A2. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItem("A2"); + note.delete(); + + await context.sync(); + }); + } + + /** Set up Sample worksheet. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Notes").delete(); + const sheet = context.workbook.worksheets.add("Notes"); + + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +

+

This sample shows how to work with notes: Add notes, edit content, size, and visibility, and remove notes.

+
+
+

Setup

+ +
+
+

Try it out

+ +

+ +

+ +

+ +

+ +

+ +

+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml b/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml index 07bcbf4c2..7e207e842 100644 --- a/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml +++ b/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.6' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#apply-conditional-formats-default-priority").click(() => tryCatch(applyConditionalFormatsWithDefaultPriority)); - $("#apply-conditional-formats-explicit-priority").click(() => tryCatch(applyPrioritizedConditionalFormats)); - $("#apply-conditional-formats-stop-if-true").click(() => tryCatch(applyPrioritizedConditionalFormatsWithStopOnTrue)); - $("#remove-conditional-format").click(() => tryCatch(removeConditionalFormat)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("apply-conditional-formats-default-priority").addEventListener("click", () => tryCatch(applyConditionalFormatsWithDefaultPriority)); + document.getElementById("apply-conditional-formats-explicit-priority").addEventListener("click", () => tryCatch(applyPrioritizedConditionalFormats)); + document.getElementById("apply-conditional-formats-stop-if-true").addEventListener("click", () => tryCatch(applyPrioritizedConditionalFormatsWithStopOnTrue)); + document.getElementById("remove-conditional-format").addEventListener("click", () => tryCatch(removeConditionalFormat)); async function applyConditionalFormatsWithDefaultPriority() { @@ -178,20 +178,18 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to use priorities to work with conditional formatting of ranges when more than one conditional format applies to some cells.

- -
+

Set up

- -
+

Try it out

- -
+

Try it out

- -
+

XML part display

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -145,15 +142,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml b/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml index c42b996bd..0ffaf7ac0 100644 --- a/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml +++ b/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml @@ -7,14 +7,14 @@ host: EXCEL api_set: ExcelApi: '1.5' script: - content: | - $("#create-custom-xml-part").click(() => tryCatch(createCustomXmlPart)); - $("#test-for-unique-namespace").click(() => tryCatch(testForUniqueNamespace)); - $("#delete-all-custom-xml-parts").click(() => tryCatch(deleteAllCustomXmlParts)); + content: |- + document.getElementById("create-custom-xml-part").addEventListener("click", () => tryCatch(createCustomXmlPart)); + document.getElementById("test-for-unique-namespace").addEventListener("click", () => tryCatch(testForUniqueNamespace)); + document.getElementById("delete-all-custom-xml-parts").addEventListener("click", () => tryCatch(deleteAllCustomXmlParts)); async function createCustomXmlPart() { await Excel.run(async (context) => { - $("#display-xml").text(""); + document.getElementById("display-xml").textContent = ""; // You must have the xmlns attribute to populate the // CustomXml.namespaceUri property. @@ -26,7 +26,7 @@ script: // Make it a bit more readable. const readableXml = xmlBlob.value.replace(/>\n<"); - $("#display-xml").text(readableXml); + document.getElementById("display-xml").textContent = readableXml; await context.sync(); }); @@ -34,7 +34,7 @@ script: async function testForUniqueNamespace() { await Excel.run(async (context) => { - $("#display-xml").text(""); + document.getElementById("display-xml").textContent = ""; const contosoNamespace = "http://schemas.contoso.com/review/1.0"; const customXmlParts = context.workbook.customXmlParts; const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); @@ -51,8 +51,8 @@ script: // Make it a bit more readable. const readableXml = xmlBlob.value.replace(/>\n<"); - $("#display-xml").text(`The only XML part in the namespace ${contosoNamespace} is: - ${readableXml}`); + document.getElementById("display-xml").textContent = `The only XML part in the namespace ${contosoNamespace} is: + ${readableXml}`; } else { console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); @@ -64,7 +64,7 @@ script: async function deleteAllCustomXmlParts() { await Excel.run(async (context) => { - $("#display-xml").text(""); + document.getElementById("display-xml").textContent = ""; const customXmlParts = context.workbook.customXmlParts; customXmlParts.load("items"); @@ -90,12 +90,11 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to determine if there is just one XML part for a specified namespace.

- -
+

Try it out

Press the "Create XML part" button to create and display Contoso's Reviewer metadata. Press it more than once if you want to set up an error situation.

- -
+

XML part display

- language: html style: content: |- @@ -131,15 +128,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/20-data-types/data-types-basic-types.yaml b/samples/excel/20-data-types/data-types-basic-types.yaml new file mode 100644 index 000000000..523da4b44 --- /dev/null +++ b/samples/excel/20-data-types/data-types-basic-types.yaml @@ -0,0 +1,362 @@ +order: 8 +id: excel-data-types-basic-types +name: Basic types with metadata +description: This sample shows how to work with metadata on basic types. +host: EXCEL +api_set: + ExcelApi: '1.19' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-basic-types-with-metadata").addEventListener("click", () => tryCatch(setBasicTypesWithMetadata)); + document.getElementById("set-referenced-values").addEventListener("click", () => tryCatch(setReferencedValues)); + document.getElementById("set-circular-reference-values").addEventListener("click", () => tryCatch(setCircularReferenceValues)); + document.getElementById("print-to-console").addEventListener("click", () => tryCatch(printToConsole)); + + const sheetName = "Sample"; + + /** Add basic types with metadata to the worksheet. */ + async function setBasicTypesWithMetadata() { + await Excel.run(async (context) => { + // Get the worksheet and target range. + const sheet = context.workbook.worksheets.getItem(sheetName); + const dataRange = sheet.getRange("A1:A4"); + + // Write a variety of basic types with metadata to the range. + dataRange.valuesAsJson = [ + [doubleWithFormatAndMetadata], + [doubleWithMetadata], + [stringWithMetadata], + [booleanWithMetadata] + ]; + + dataRange.format.autofitColumns(); + await context.sync(); + }); + } + + /** Set basic types with metadata that reference other basic types in the worksheet. */ + async function setReferencedValues() { + await Excel.run(async (context) => { + // Get the worksheet and target range. + const sheet = context.workbook.worksheets.getItem(sheetName); + const targetRange = sheet.getRange("A5"); + + // Write a string with metadata that references other values. + targetRange.valuesAsJson = [ + [stringWithReferencedValues] + ]; + targetRange.format.autofitColumns(); + + await context.sync(); + }); + } + + /** Set basic types with metadata that contain circular references. */ + async function setCircularReferenceValues() { + await Excel.run(async (context) => { + // Get the worksheet and target range. + const sheet = context.workbook.worksheets.getItem(sheetName); + const targetRange = sheet.getRange("A6"); + + // Write a string with metadata that contains circular references. + targetRange.valuesAsJson = [ + [stringWithCircularReferences] + ]; + targetRange.format.autofitColumns(); + + await context.sync(); + }); + } + + /** Get and log information about the basic types in the worksheet. */ + async function printToConsole() { + await Excel.run(async (context) => { + // Get the worksheet and target range. + const sheet = context.workbook.worksheets.getItem(sheetName); + const dataRange = sheet.getRange("A1:A6"); + + // Load the data type property of the range. + dataRange.load("valuesAsJson"); + await context.sync(); + + const dataValues = dataRange.valuesAsJson; + + // Print information about the data types to the console. + console.log("Basic types as an array:", dataValues); + }); + } + + /** Set up Sample worksheet. */ + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet and activate it. + context.workbook.worksheets.getItemOrNullObject(sheetName).delete(); + const sheet = context.workbook.worksheets.add(sheetName); + sheet.activate(); + + await context.sync(); + }); + } + + /** 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); + } + } + + /** Basic string value with metadata. */ + const basicStringValue: Excel.StringCellValue = { + type: Excel.CellValueType.string, + basicType: Excel.CellValueType.string, + basicValue: "This is a basic string value" + }; + + /** Basic double value with metadata. */ + const basicDoubleValue: Excel.DoubleCellValue = { + type: Excel.CellValueType.double, + basicType: Excel.CellValueType.double, + basicValue: 10 + }; + + /** Basic boolean value with metadata. */ + const basicBooleanValue: Excel.BooleanCellValue = { + type: Excel.CellValueType.boolean, + basicType: Excel.CellValueType.boolean, + basicValue: true + }; + + /** Web image cell value. */ + const imageCellValue: Excel.WebImageCellValue = { + type: "WebImage", + basicType: "Error", + basicValue: "#VALUE!", + address: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/microsoft-logo.png?raw=true", + }; + + /** Basic view layout with icon for card and compact views. */ + const basicViewLayoutWithIcon: Excel.BasicViewLayouts = { + card: { + title: "This is the title", + sections: [ + { + layout: "List", + properties: ["stringProperty", "booleanProperty", "doubleProperty"], + collapsed: false, + collapsible: true + } + ], + subTitle: { + property: "stringProperty" + }, + mainImage: { + property: "imageProperty" + } + }, + compact: { + icon: Excel.EntityCompactLayoutIcons.animalDog + } + }; + + /** Simple view layout without icon. */ + const basicViewLayoutSimple: Excel.BasicViewLayouts = { + card: { + title: "This is the title", + subTitle: { + property: "stringProperty" + } + } + }; + + /** Cell value provider attributes for data source attribution. */ + const cellValueProvider: Excel.CellValueProviderAttributes = { + description: "Microsoft Bing", + logoSourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/microsoft-logo.png?raw=true", + logoTargetAddress: "http://microsoft.com/" + }; + + /** Double value with formatting and metadata. */ + const doubleWithFormatAndMetadata: Excel.DoubleCellValue = { + type: Excel.CellValueType.double, + basicType: Excel.CellValueType.double, + basicValue: 300, + numberFormat: "$0.00", + properties: { + stringProperty: basicStringValue, + booleanProperty: basicBooleanValue, + doubleProperty: basicDoubleValue, + imageProperty: imageCellValue + }, + layouts: basicViewLayoutWithIcon, + provider: cellValueProvider + }; + + /** Double value with metadata but no special formatting. */ + const doubleWithMetadata: Excel.DoubleCellValue = { + type: Excel.CellValueType.double, + basicType: Excel.CellValueType.double, + basicValue: 123.45, + properties: { + stringProperty: basicStringValue, + booleanProperty: basicBooleanValue, + doubleProperty: basicDoubleValue, + imageProperty: imageCellValue + }, + layouts: basicViewLayoutSimple, + provider: cellValueProvider + }; + + /** String value with metadata. */ + const stringWithMetadata: Excel.StringCellValue = { + type: Excel.CellValueType.string, + basicType: Excel.CellValueType.string, + basicValue: "String with metadata", + properties: { + stringProperty: basicStringValue, + booleanProperty: basicBooleanValue, + doubleProperty: basicDoubleValue, + imageProperty: imageCellValue + }, + layouts: basicViewLayoutWithIcon, + provider: cellValueProvider + }; + + /** Boolean value with metadata. */ + const booleanWithMetadata: Excel.BooleanCellValue = { + type: Excel.CellValueType.boolean, + basicType: Excel.CellValueType.boolean, + basicValue: true, + properties: { + stringProperty: basicStringValue, + booleanProperty: basicBooleanValue, + doubleProperty: basicDoubleValue, + imageProperty: imageCellValue + }, + layouts: basicViewLayoutSimple, + provider: cellValueProvider + }; + + /** String with metadata that references other values. */ + const stringWithReferencedValues = { + type: Excel.CellValueType.string, + basicType: Excel.CellValueType.string, + basicValue: "String with referenced values", + properties: { + stringProperty: { + type: Excel.CellValueType.reference, + reference: 0 + }, + booleanProperty: { + type: Excel.CellValueType.reference, + reference: 1 + }, + doubleWithFormatProperty: { + type: Excel.CellValueType.reference, + reference: 2 + }, + doubleProperty: { + type: Excel.CellValueType.reference, + reference: 3 + } + }, + referencedValues: [stringWithMetadata, booleanWithMetadata, doubleWithFormatAndMetadata, doubleWithMetadata], + layouts: { + compact: { + icon: Excel.EntityCompactLayoutIcons.apple + } + } + }; + + /** String with metadata that contains circular references. */ + const stringWithCircularReferences = { + type: Excel.CellValueType.string, + basicType: Excel.CellValueType.string, + basicValue: "String with circular references", + properties: { + doubleProperty: { + type: Excel.CellValueType.double, + basicType: Excel.CellValueType.double, + basicValue: 10, + properties: { + stringProperty: basicStringValue, + doubleProperty: basicDoubleValue, + booleanProperty: basicBooleanValue, + rootProperty: { + type: Excel.CellValueType.reference, + reference: 0 + } + }, + referencedValues: [ + { + type: Excel.ReferenceValueType.root + } + ] + } + }, + layouts: { + compact: { + icon: Excel.EntityCompactLayoutIcons.animalTurtle + } + } + }; + language: typescript +template: + content: |- +
+

This sample shows how to create basic types with metadata and then work with those basic types.

+
+
+

Set up

+ +
+
+

Try it out

+

Add basic types to the worksheet. Select the icon in each cell to see a data type card with metadata.

+ +
+
+

Add a basic type with referenced values. Open the data type card to see other values in the worksheet that this basic type references—it references cells A1, A2, A3, and A4.

+ +
+
+

Add a basic type with circular references. Open the data type card and select the doubleProperty to see the circular references.

+ +
+
+

Print information about each of your basic types to the console.

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/20-data-types/data-types-entity-attribution.yaml b/samples/excel/20-data-types/data-types-entity-attribution.yaml new file mode 100644 index 000000000..497c603ec --- /dev/null +++ b/samples/excel/20-data-types/data-types-entity-attribution.yaml @@ -0,0 +1,228 @@ +order: 6 +id: excel-data-types-entity-attribution +name: 'Data types: Entity value attribution properties' +description: This sample shows how to set data provider attributions on entity values in the card layout. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-entities-to-table").addEventListener("click", () => tryCatch(addEntitiesToTable)); + + async function addEntitiesToTable() { + // This function retrieves data for each of the existing products in the table, + // creates entity values for each of those products, and adds the entities + // to the table. + await Excel.run(async (context) => { + const productsTable = context.workbook.tables.getItem("ProductsTable"); + + // Add a new column to the table for the entity values. + productsTable.columns.getItemOrNullObject("Product").delete(); + const productColumn = productsTable.columns.add(0, null, "Product"); + + // Get product data from the table. + const dataRange = productsTable.getDataBodyRange(); + dataRange.load("values"); + + await context.sync(); + + // Set up the entities by mapping the product names to + // the sample JSON product data. + const entities = dataRange.values.map((rowValues) => { + // Get products and product properties. + const product = getProduct(rowValues[1]); + + // Create entities by combining Products Table data and JSON data. + return [makeProductEntity(rowValues[1], rowValues[2], product)]; + }); + + // Add the complete entities to the Products Table. + productColumn.getDataBodyRange().valuesAsJson = entities; + + productColumn.getRange().format.autofitColumns(); + await context.sync(); + }); + } + + // Create entities with card layout and data provider fields. + function makeProductEntity(productID: number, productName: string, product?: any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { /* Excel.EntityPropertyType */ + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + } + }, + layouts: { /* Excel.EntityViewLayouts */ + card: { /* Excel.EntityCardLayout */ + title: { property: "Product Name" }, + sections: [ /* Excel.CardLayoutSection */ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + } + ] + } + }, + provider: { + description: product.providerName, // Name of the data provider. Displays as a tooltip when hovering over the logo. Also displays as a fallback if the source address for the image is broken. + logoSourceAddress: product.sourceAddress, // Source URL of the logo to display. + logoTargetAddress: product.targetAddress // Destination URL that the logo navigates to when clicked. + } + }; + + return entity; + } + + // Get products and product properties. + function getProduct(productID: number): any { + return products.find((p) => p.productID == productID); + } + + /** Set up Sample worksheet. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const productsTable = sheet.tables.add("A1:C1", true /*hasHeaders*/); + productsTable.name = "ProductsTable"; + + productsTable.getHeaderRowRange().values = [["Product", "ProductID", "ProductName"]]; + + productsTable.rows.add( + null /*add at the end*/, + products.map((p) => [null, p.productID, p.productName]) + ); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + + await context.sync(); + }); + } + + /** 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); + } + } + + /** Sample JSON product data. */ + const products = [ + { + productID: 1, + productName: "Chai", + quantityPerUnit: "10 boxes x 20 bags", + unitPrice: 18, + providerName: "Microsoft", + sourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/microsoft-logo.png?raw=true", + targetAddress: "http://microsoft.com/" + }, + { + productID: 2, + productName: "Chang", + quantityPerUnit: "24 - 12 oz bottles", + unitPrice: 19, + providerName: "MSN", + sourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/msn-logo.png?raw=true", + targetAddress: "http://msn.com/" + }, + { + productID: 3, + productName: "Aniseed Syrup", + quantityPerUnit: "12 - 550 ml bottles", + unitPrice: 10, + providerName: "Xbox", + sourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/xbox-logo.png?raw=true", + targetAddress: "http://xbox.com/" + }, + { + productID: 4, + productName: "Chef Anton's Cajun Seasoning", + quantityPerUnit: "48 - 6 oz jars", + unitPrice: 22, + providerName: "Microsoft", + sourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/microsoft-logo.png?raw=true", + targetAddress: "http://microsoft.com/" + }, + { + productID: 5, + productName: "Chef Anton's Gumbo Mix", + quantityPerUnit: "36 boxes", + unitPrice: 21.35, + providerName: "MSN", + sourceAddress: "https://github.com/OfficeDev/office-js-snippets/blob/main/.github/images/msn-logo.png?raw=true", + targetAddress: "http://msn.com/" + }, + ]; + language: typescript +template: + content: |- +
+

This sample shows how to set data provider attributions on entity values in the card layout. The data is aggregated from three different data providers, and three attributions are displayed.

+
+
+

Set up

+ +
+
+

Try it out

+ +

To see the entity value's data attribution, click the icon to the left of the title in the Product column after selecting Add entity values.

+

The data attribution appears as a logo in the bottom left corner of the entity card. Hover over the logo to see the name of the data provider. Click on the logo to visit the data provider's URL.

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/20-data-types/data-types-entity-icons.yaml b/samples/excel/20-data-types/data-types-entity-icons.yaml new file mode 100644 index 000000000..b9bac49e6 --- /dev/null +++ b/samples/excel/20-data-types/data-types-entity-icons.yaml @@ -0,0 +1,114 @@ +order: 5 +id: excel-data-types-icons +name: 'Data types: Create entity icons' +description: Display all the icons available for entity data types. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-icons").addEventListener("click", () => tryCatch(createIcons)); + + // Retrieve the entity card icons enum. + const iconNames = Excel.EntityCompactLayoutIcons; + let icons; + + function createEntitiesWithIcons(icons): Excel.EntityCellValue[][] { + /* This method creates an entity data type for each + * icon in the `EntityCompactLayoutIcons` enum, + * and then displays the icon name with its icon. + */ + let entities = []; + icons.forEach(function(iconName, index, array) { + let icon = iconNames[iconName]; + entities.push([ + { + type: "Entity", + text: iconName, + properties: {}, + layouts: { + compact: { + icon + } + } + } + ]); + }); + return entities; + } + + async function createIcons() { + await Excel.run(async (context) => { + /* This method populates Column A in the worksheet + * with all of the entities and icons created by the + * `createEntitiesWithIcons` method. + */ + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const rangeString = "A1:A" + Object.keys(iconNames).length; + const range = sheet.getRange(rangeString ); + + range.valuesAsJson = createEntitiesWithIcons(Object.keys(iconNames)); + + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to display all the icons available for entity data types, along with the name of each icon.

+

After creating the icons, select an icon to open the entity card for that data type. The entity cards in this sample display only the icon names.

+
+
+

Set up

+ +
+
+

Run sample

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/20-data-types/data-types-entity-values.yaml b/samples/excel/20-data-types/data-types-entity-values.yaml new file mode 100644 index 000000000..577b39f18 --- /dev/null +++ b/samples/excel/20-data-types/data-types-entity-values.yaml @@ -0,0 +1,601 @@ +order: 3 +id: excel-data-types-entity-values +name: 'Data types: Create entity cards from data in a table' +description: This sample shows how to create entity cards for each row in a table. An entity is a container for data types, similar to an object in object-oriented programming. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("addEntitiesToTable").addEventListener("click", () => tryCatch(addEntitiesToTable)); + + async function addEntitiesToTable() { + // This function retrieves data for each of the existing products in the table, + // creates entity values for each of those products, and adds the entities + // to the table. + await Excel.run(async (context) => { + const productsTable = context.workbook.tables.getItem("ProductsTable"); + + // Add a new column to the table for the entity values. + productsTable.columns.getItemOrNullObject("Product").delete(); + const productColumn = productsTable.columns.add(0, null, "Product"); + + // Get product data from the table. + const dataRange = productsTable.getDataBodyRange(); + dataRange.load("values"); + + await context.sync(); + + // Set up the entities by mapping the product names to + // the sample JSON product data. + const entities = dataRange.values.map((rowValues) => { + // Get products and product properties. + const product = getProduct(rowValues[1]); + + // Get product categories and category properties. + const category = product ? getCategory(product.categoryID) : null; + + // Get product suppliers and supplier properties. + const supplier = product ? getSupplier(product.supplierID) : null; + + // Create entities by combining product, category, and supplier properties. + return [makeProductEntity(rowValues[1], rowValues[2], product, category, supplier)]; + }); + + // Add the complete entities to the Products Table. + productColumn.getDataBodyRange().valuesAsJson = entities; + + productColumn.getRange().format.autofitColumns(); + await context.sync(); + }); + } + + // Create entities from product properties. + function makeProductEntity( + productID: number, + productName: string, + product?: any, + category?: any, + supplier?: any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + }, + Discontinued: { + type: Excel.CellValueType.boolean, + basicValue: product.discontinued || false + } + }, + layouts: { + compact: { + icon: Excel.EntityCompactLayoutIcons.shoppingBag + }, + card: { + title: { property: "Product Name" }, + sections: [ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + }, + { + layout: "List", + title: "Additional information", + collapsed: true, + properties: ["Discontinued"] + } + ] + } + } + }; + + // Add image property to the entity and then add it to the card layout. + if (product.productImage) { + entity.properties["Image"] = { + type: Excel.CellValueType.webImage, + address: product.productImage || "" + }; + entity.layouts.card.mainImage = { property: "Image" }; + } + + // Add a nested entity for the product category. + if (category) { + entity.properties["Category"] = { + type: Excel.CellValueType.entity, + text: category.categoryName, + properties: { + "Category ID": { + type: Excel.CellValueType.double, + basicValue: category.categoryID, + propertyMetadata: { + // Exclude the category ID property from the card view and auto complete. + excludeFrom: { + cardView: true, + autoComplete: true + } + } + }, + "Category Name": { + type: Excel.CellValueType.string, + basicValue: category.categoryName || "" + }, + "Description": { + type: Excel.CellValueType.string, + basicValue: category.description || "" + } + }, + layouts: { + compact: { + icon: Excel.EntityCompactLayoutIcons.branch + }, + } + }; + + // Add nested product category to the card layout. + entity.layouts.card.sections[0].properties.push("Category"); + } + + // Add a nested entity for the supplier. + if (supplier) { + entity.properties["Supplier"] = { + type: Excel.CellValueType.entity, + text: supplier.companyName, + properties: { + "Supplier ID": { + type: Excel.CellValueType.double, + basicValue: supplier.supplierID, + }, + "Company Name": { + type: Excel.CellValueType.string, + basicValue: supplier.companyName || "" + }, + "Contact Name": { + type: Excel.CellValueType.string, + basicValue: supplier.contactName || "" + }, + "Contact Title": { + type: Excel.CellValueType.string, + basicValue: supplier.contactTitle || "" + }, + }, + layouts: { + compact: { + icon: Excel.EntityCompactLayoutIcons.boxMultiple + }, + card: { + title: { property: "Company Name" }, + sections: [ + { + layout: "List", + properties: [ + "Supplier ID", + "Company Name", + "Contact Name", + "Contact Title" + ] + }, + ] + } + } + }; + + // Add nested product supplier to the card layout. + entity.layouts.card.sections[2].properties.push("Supplier"); + } + return entity; + } + + // Get products and product properties. + function getProduct(productID: number): any { + return products.find((p) => p.productID == productID); + } + + // Get product categories and category properties. + function getCategory(categoryID: number): any { + return categories.find((c) => c.categoryID == categoryID); + } + + // Get product suppliers and supplier properties. + function getSupplier(supplierID: number): any { + return suppliers.find((s) => s.supplierID == supplierID); + } + + /** Set up Sample worksheet. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const productsTable = sheet.tables.add("A1:C1", true /*hasHeaders*/); + productsTable.name = "ProductsTable"; + + productsTable.getHeaderRowRange().values = [["Product", "ProductID", "ProductName"]]; + + productsTable.rows.add( + null /*add at the end*/, + products.map((p) => [null, p.productID, p.productName]) + ); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + + await context.sync(); + }); + } + + /** 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); + } + } + + /** Sample JSON product data. */ + const products = [ + { + productID: 1, + productName: "Chai", + supplierID: 1, + categoryID: 1, + quantityPerUnit: "10 boxes x 20 bags", + unitPrice: 18, + discontinued: false, + productImage: "" + }, + { + productID: 2, + productName: "Chang", + supplierID: 1, + categoryID: 1, + quantityPerUnit: "24 - 12 oz bottles", + unitPrice: 19, + discontinued: false, + productImage: "" + }, + { + productID: 3, + productName: "Aniseed Syrup", + supplierID: 1, + categoryID: 2, + quantityPerUnit: "12 - 550 ml bottles", + unitPrice: 10, + discontinued: false, + productImage: "" + }, + { + productID: 4, + productName: "Chef Anton's Cajun Seasoning", + supplierID: 2, + categoryID: 2, + quantityPerUnit: "48 - 6 oz jars", + unitPrice: 22, + discontinued: false, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/chili-peppers.jpg?raw=true" + }, + { + productID: 5, + productName: "Chef Anton's Gumbo Mix", + supplierID: 2, + categoryID: 2, + quantityPerUnit: "36 boxes", + unitPrice: 21.35, + discontinued: true, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/crustacean.jpg?raw=true" + }, + { + productID: 6, + productName: "Grandma's Boysenberry Spread", + supplierID: 3, + categoryID: 2, + quantityPerUnit: "12 - 8 oz jars", + unitPrice: 25, + discontinued: false, + productImage: "" + }, + { + productID: 7, + productName: "Uncle Bob's Organic Dried Pears", + supplierID: 3, + categoryID: 7, + quantityPerUnit: "12 - 1 lb pkgs.", + unitPrice: 30, + discontinued: false, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/fruit.jpg?raw=true" + }, + { + productID: 8, + productName: "Northwoods Cranberry Sauce", + supplierID: 3, + categoryID: 2, + quantityPerUnit: "12 - 12 oz jars", + unitPrice: 40, + discontinued: false, + productImage: "" + }, + { + productID: 9, + productName: "Mishi Kobe Niku", + supplierID: 4, + categoryID: 6, + quantityPerUnit: "18 - 500 g pkgs.", + unitPrice: 97, + discontinued: true, + productImage: "" + }, + { + productID: 10, + productName: "Ikura", + supplierID: 4, + categoryID: 8, + quantityPerUnit: "12 - 200 ml jars", + unitPrice: 31, + discontinued: false, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/dried-legume.jpg?raw=true" + }, + { + productID: 11, + productName: "Queso Cabrales", + supplierID: 5, + categoryID: 4, + quantityPerUnit: "1 kg pkg.", + unitPrice: 21, + discontinued: false, + productImage: "" + }, + { + productID: 12, + productName: "Queso Manchego La Pastora", + supplierID: 5, + categoryID: 4, + quantityPerUnit: "10 - 500 g pkgs.", + unitPrice: 38, + discontinued: false, + productImage: "" + }, + { + productID: 13, + productName: "Konbu", + supplierID: 6, + categoryID: 8, + quantityPerUnit: "2 kg box", + unitPrice: 6, + discontinued: false, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/green-leaf.jpg?raw=true" + }, + { + productID: 14, + productName: "Tofu", + supplierID: 6, + categoryID: 7, + quantityPerUnit: "40 - 100 g pkgs.", + unitPrice: 23.25, + discontinued: false, + productImage: "" + }, + { + productID: 15, + productName: "Genen Shouyu", + supplierID: 6, + categoryID: 2, + quantityPerUnit: "24 - 250 ml bottles", + unitPrice: 15.5, + discontinued: false, + productImage: "" + }, + { + productID: 16, + productName: "Pavlova", + supplierID: 7, + categoryID: 3, + quantityPerUnit: "32 - 500 g boxes", + unitPrice: 17.45, + discontinued: false, + productImage: "" + }, + { + productID: 17, + productName: "Alice Mutton", + supplierID: 7, + categoryID: 6, + quantityPerUnit: "20 - 1 kg tins", + unitPrice: 39, + discontinued: true, + productImage: "" + }, + { + productID: 18, + productName: "Carnarvon Tigers", + supplierID: 7, + categoryID: 8, + quantityPerUnit: "16 kg pkg.", + unitPrice: 62.5, + discontinued: false, + productImage: "https://github.com/OfficeDev/office-js-snippets/blob/prod/.github/images/crustacean.jpg?raw=true" + }, + { + productID: 19, + productName: "Teatime Chocolate Biscuits", + supplierID: 8, + categoryID: 3, + quantityPerUnit: "10 boxes x 12 pieces", + unitPrice: 9.2, + discontinued: false, + productImage: "" + }, + { + productID: 20, + productName: "Sir Rodney's Marmalade", + supplierID: 8, + categoryID: 3, + quantityPerUnit: "30 gift boxes", + unitPrice: 81, + discontinued: false, + productImage: "" + } + ]; + + const categories = [ + { + categoryID: 1, + categoryName: "Beverages", + description: "Soft drinks, coffees, teas, beers, and ales" + }, + { + categoryID: 2, + categoryName: "Condiments", + description: "Sweet and savory sauces, relishes, spreads, and seasonings" + }, + { + categoryID: 3, + categoryName: "Confections", + description: "Desserts, candies, and sweet breads" + }, + { + categoryID: 4, + categoryName: "Dairy Products", + description: "Cheeses" + }, + { + categoryID: 5, + categoryName: "Grains/Cereals", + description: "Breads, crackers, pasta, and cereal" + }, + { + categoryID: 6, + categoryName: "Meat/Poultry", + description: "Prepared meats" + }, + { + categoryID: 7, + categoryName: "Produce", + description: "Dried fruit and bean curd" + }, + { + categoryID: 8, + categoryName: "Seafood", + description: "Seaweed and fish" + } + ]; + + const suppliers = [ + { + "supplierID": 1, + "companyName": "Exotic Liquids", + "contactName": "Charlotte Cooper", + "contactTitle": "Purchasing Manager", + }, + { + "supplierID": 2, + "companyName": "New Orleans Cajun Delights", + "contactName": "Shelley Burke", + "contactTitle": "Order Administrator", + }, + { + "supplierID": 3, + "companyName": "Grandma Kelly's Homestead", + "contactName": "Regina Murphy", + "contactTitle": "Sales Representative", + }, + { + "supplierID": 4, + "companyName": "Tokyo Traders", + "contactName": "Yoshi Nagase", + "contactTitle": "Marketing Manager", + "address": "9-8 Sekimai Musashino-shi", + }, + { + "supplierID": 5, + "companyName": "Cooperativa de Quesos 'Las Cabras'", + "contactName": "Antonio del Valle Saavedra", + "contactTitle": "Export Administrator", + }, + { + "supplierID": 6, + "companyName": "Mayumi's", + "contactName": "Mayumi Ohno", + "contactTitle": "Marketing Representative", + }, + { + "supplierID": 7, + "companyName": "Pavlova, Ltd.", + "contactName": "Ian Devling", + "contactTitle": "Marketing Manager", + }, + { + "supplierID": 8, + "companyName": "Specialty Biscuits, Ltd.", + "contactName": "Peter Wilson", + "contactTitle": "Sales Representative", + } + ]; + language: typescript +template: + content: |- +
+

This sample shows how to create entity values for each row in a table. An entity value is a container for data types, similar to an object in object-oriented programming.

+

In particular, this sample highlights the card layout options of an entity value, including the title, an image, collapsible sections, and nested entity values.

+
+
+

Set up

+ +
+
+

Try it out

+ +

To see the entity value, click the icon to the left of the title in the Product column after selecting Add entity values.

+

Note: In Excel on Mac, nested icons (such as the icons that display inside an entity card) always display as the default icon, even when another icon is selected with the API. This is a known bug.

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/20-data-types/data-types-error-values.yaml b/samples/excel/20-data-types/data-types-error-values.yaml new file mode 100644 index 000000000..26fe44110 --- /dev/null +++ b/samples/excel/20-data-types/data-types-error-values.yaml @@ -0,0 +1,113 @@ +order: 4 +id: excel-data-types-error-values +name: 'Data types: Set and change error values' +description: This sample shows how to set a cell value to an error data type, and then update the value of cells that contain an error data type. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-busy-error").addEventListener("click", () => tryCatch(setBusyError)); + document.getElementById("change-busy-error").addEventListener("click", () => tryCatch(changeBusyError)); + + async function setBusyError() { + // This function sets the value of cell A1 to a #BUSY! error using data types. + await Excel.run(async (context) => { + // Retrieve the Sample worksheet and cell A1 on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const range = sheet.getRange("A1"); + + // Get the error data type and set its type to `busy`. + const error: Excel.ErrorCellValue = { + type: Excel.CellValueType.error, + errorType: Excel.ErrorCellValueType.busy + }; + + // Set cell A1 as the busy error. + range.valuesAsJson = [[error]]; + await context.sync(); + }); + } + + async function changeBusyError() { + // This function checks if the used range contains a #BUSY! error, and then updates all the cells in the range that contain the error. + await Excel.run(async (context) => { + // Retrieve the Sample worksheet and the used range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const usedRange = sheet.getUsedRange(); + + // Load the `valuesAsJson` property for comparison. + usedRange.load("valuesAsJson"); + await context.sync(); + + // Check if the used range contains a #BUSY! error. + if (usedRange.valuesAsJson[0][0]["errorType"] == Excel.ErrorCellValueType.busy) { + // If the used range contains a #BUSY! error, load and change those values. + usedRange.load("values"); + await context.sync(); + usedRange.values = [["Process unavailable."]]; + } + + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to set the value of cell A1 to the #BUSY! error data type. The sample then checks to see if the worksheet contains a #BUSY! error, and then updates all cells that contain a #BUSY! error.

+
+
+

Set up

+ +

Try it out

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/20-data-types/data-types-formatted-number.yaml b/samples/excel/20-data-types/data-types-formatted-number.yaml new file mode 100644 index 000000000..e072889de --- /dev/null +++ b/samples/excel/20-data-types/data-types-formatted-number.yaml @@ -0,0 +1,151 @@ +order: 1 +id: excel-data-types-doubles +name: 'Data types: Formatted numbers' +description: This sample shows how to set and get formatted numbers using double data types. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-double-as-date").addEventListener("click", () => tryCatch(setDoubleAsDate)); + document.getElementById("set-double-as-currency").addEventListener("click", () => tryCatch(setDoubleAsCurrency)); + document.getElementById("get-double").addEventListener("click", () => tryCatch(getDouble)); + + async function setDoubleAsDate() { + // This function creates a double data type, + // and sets the format of this data type as a date. + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const dateRange = sheet.getRange("A1"); + + // Write a number formatted as a date to cell A1. + dateRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 32889.0, + numberFormat: "m/d/yyyy" + } + ] + ]; + await context.sync(); + }); + } + + async function setDoubleAsCurrency() { + // This function creates a double data type, + // and sets the format of this data type as a currency. + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const currencyRange = sheet.getRange("A2"); + + // Write a number formatted as currency to cell A2. + currencyRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 12.34, + numberFormat: "$* #,##0.00" + } + ] + ]; + + await context.sync(); + }); + } + + async function getDouble() { + // This function prints information about data types + // in cells A1 and A2 to the console. + await Excel.run(async (context) => { + // Get the Sample worksheet and two ranges on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const currencyRange = sheet.getRange("A2"); + const dateRange = sheet.getRange("A1"); + + // Load the data type property of the ranges. + currencyRange.load("valuesAsJson"); + dateRange.load("valuesAsJson"); + await context.sync(); + + const currencyValues = currencyRange.valuesAsJson[0][0]; + const dateValues = dateRange.valuesAsJson[0][0]; + + // Print information about the data types to the console. + console.log("Date"); + console.log(" Type: " + dateValues.type); + console.log(" Basic value: " + dateValues.basicValue); + console.log(" Basic type: " + dateValues.basicType); + console.log(" Number format: " + (dateValues as Excel.DoubleCellValue).numberFormat); + + console.log("Currency"); + console.log(" Type: " + currencyValues.type); + console.log(" Basic value: " + currencyValues.basicValue); + console.log(" Basic type: " + currencyValues.basicType); + console.log(" Number format: " + (currencyValues as Excel.DoubleCellValue).numberFormat); + }); + } + + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to work with double data types to create formatted numbers.

+
+
+

Set up

+ +

Try it out

+ + + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/20-data-types/data-types-references.yaml b/samples/excel/20-data-types/data-types-references.yaml new file mode 100644 index 000000000..e139b4da9 --- /dev/null +++ b/samples/excel/20-data-types/data-types-references.yaml @@ -0,0 +1,339 @@ +order: 7 +id: excel-data-types-references +name: 'Data types: Entity values with references' +description: This sample shows how to create entity values with references to other entity values. An entity value is a container for data, and this container can reference (or contain) other entities within the original entity. One entity can contain multiple additional entities. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-entities-to-table").addEventListener("click", () => tryCatch(addEntitiesToTable)); + + async function addEntitiesToTable() { + // This function creates entity values with references to other entity values. + // It retrieves data for each of the employees in the table on the worksheet, + // creates entity values for each of those employees, and adds the entities + // to the table. Each employee entity references (or contains) other + // employee entities. In this scenario, the purpose of one employee + // referencing another is to show a managerial hierarchy. + await Excel.run(async (context) => { + const employeesTable = context.workbook.tables.getItem("EmployeesTable"); + + // Refresh the table column with the entity values. + employeesTable.columns.getItemOrNullObject("Employee").delete(); + const employeeColumn = employeesTable.columns.add(0, null, "Employee"); + + // Get employee data from the table. + const dataRange = employeesTable.getDataBodyRange(); + dataRange.load("values"); + await context.sync(); + + // Create the entities by mapping the employee IDs in table to the sample + // JSON employee data. + const entities = dataRange.values.map((rowValues) => { + // Get employee properties. + const employee = getEmployee(rowValues[1] /* Employee ID */); + + // Collect all the references that are needed to make the employee entity. + const references = collectReferences(employee); + + // Create employee entity from employee properties. + const employeeEntity = makeEmployeeEntity( + rowValues[2], /* Last name */ + rowValues[3], /* First name */ + employee, + references + ); + + // Collect reference values for the employee entity. + const referencedValues: any[] = [{ type: "Root" }]; + references.slice(1).forEach((id) => { + const referencedEmployee = getEmployee(id); + referencedValues.push( + makeEmployeeEntity(referencedEmployee.lastName, referencedEmployee.firstName, referencedEmployee, references) + ); + }); + employeeEntity.referencedValues = referencedValues; + + return [employeeEntity]; + }); + + // Add the complete entities to the Employees Table. + employeeColumn.getDataBodyRange().valuesAsJson = entities; + employeeColumn.getRange().format.autofitColumns(); + await context.sync(); + }); + } + + // Helper function to collect all the references for the employee entity. + // A reference means one entity contains another entity. + function collectReferences(employee) { + const references: number[] = []; + collectManagerReferences(employee, references); + return references; + } + + // Helper function to collect manager and direct report references for each employee entity. + function collectManagerReferences(employee, references: number[]) { + // Confirm references haven't already been collected for this employee. + if (references.indexOf(employee.employeeID) >= 0) { + return; + } + + // Record the reference for the employee. + ensureReferenceExist(references, employee.employeeID); + + // Record the reference for the manager, if the employee has a manager. + if (employee.reportsTo != null) { + // Get the manager. + const manager = getEmployee(employee.reportsTo); + // Collect references for the manager. + collectManagerReferences(manager, references); + } + + // Collect references for each of the direct reports of the employee, if any. + const directReports = employee.directReports || getDirectReports(employee.employeeID); + if (directReports.length > 0) { + directReports.forEach((direct) => collectManagerReferences(direct, references)); + } + } + + // Helper function to check whether a specific reference ID exists in a list of IDs. + // If the ID doesn't exist, add it to the list. + function ensureReferenceExist(list: number[], id: number) { + if (list.indexOf(id) < 0) { + list.push(id); + } + } + + // Create entities from employee properties. + function makeEmployeeEntity(lastName: string, firstName: string, employee: any, references: number[]): Excel.EntityCellValue { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: `${firstName} ${lastName}`, + properties: { + "Employee ID": { + type: Excel.CellValueType.string, + basicValue: employee.employeeID.toString() + }, + "Last Name": { + type: Excel.CellValueType.string, + basicValue: lastName + }, + "First Name": { + type: Excel.CellValueType.string, + basicValue: firstName + }, + Name: { + type: Excel.CellValueType.string, + basicValue: `${firstName} ${lastName}` + }, + Title: { + type: Excel.CellValueType.string, + basicValue: employee.title + } + }, + layouts: { + card: { + title: { property: "Name" }, + sections: [ + { + layout: "List", + properties: ["Employee ID", "First Name", "Last Name", "Title"] + } + ] + } + } + }; + + // Add manager reference, if the employee has a manager. + if (employee.reportsTo != null) { + entity.properties["Manager"] = { + type: "Reference", + reference: references.indexOf(employee.reportsTo) + }; + entity.layouts.card.sections[0].properties.push("Manager"); + } + + // Add references for direct reports, if any. + if (employee.directReports.length > 0) { + entity.properties["Direct Reports"] = { + type: Excel.CellValueType.array, + elements: employee.directReports.map((direct) => { + return [ + { + type: "Reference", + reference: references.indexOf(direct.employeeID) + } + ]; + }), + }; + entity.layouts.card.sections[0].properties.push("Direct Reports"); + } + + return entity; + } + + // Get employee properties. + function getEmployee(employeeID: number): any { + // Find the employee in the sample data. + const employee = employees.find((e) => e.employeeID === employeeID); + + // Add direct reports for the employee. + employee["directReports"] = getDirectReports(employeeID); + return employee; + } + + // Get direct reports of employee. + function getDirectReports(employeeID: number): any { + return employees.filter((e) => e.reportsTo === employeeID); + } + + /** Set up Sample worksheet with a table of employee data. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const employeesTable = sheet.tables.add("A1:D1", true /* hasHeaders */); + employeesTable.name = "EmployeesTable"; + + employeesTable.getHeaderRowRange().values = [["Employee", "EmployeeID", "LastName", "FirstName"]]; + + employeesTable.rows.add( + null /* Add at the end. */, + employees.map((e) => [null, e.employeeID, e.lastName, e.firstName]) + ); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + sheet.activate(); + + await context.sync(); + }); + } + + /** 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); + } + } + + /** Sample JSON employee data. */ + const employees = [ + { + employeeID: 1, + lastName: "Davolio", + firstName: "Nancy", + title: "Vice President, Sales", + reportsTo: null + }, + { + employeeID: 2, + lastName: "Fuller", + firstName: "Andrew", + title: "Sales Representative", + reportsTo: 1 + }, + { + employeeID: 3, + lastName: "Leverling", + firstName: "Janet", + title: "Sales Representative", + reportsTo: 4 + }, + { + employeeID: 4, + lastName: "Peacock", + firstName: "Margaret", + title: "Sales Manager", + reportsTo: 1 + }, + { + employeeID: 5, + lastName: "Buchanan", + firstName: "Steven", + title: "Sales Representative", + reportsTo: 4 + }, + { + employeeID: 6, + lastName: "Suyama", + firstName: "Michael", + title: "Sales Representative", + reportsTo: 4 + }, + { + employeeID: 7, + lastName: "King", + firstName: "Robert", + title: "Sales Representative", + reportsTo: 4 + }, + { + employeeID: 8, + lastName: "Callahan", + firstName: "Laura", + title: "Inside Sales Coordinator", + reportsTo: 1 + }, + { + employeeID: 9, + lastName: "Dodsworth", + firstName: "Anne", + title: "Sales Representative", + reportsTo: 4 + } + ]; + language: typescript +template: + content: |- +
+

This sample shows how to create entity values with references to other entity values. An entity value is a container for data, and this container can reference (or contain) other entities within the original entity. One entity can contain multiple additional entities.

+
+
+

Set up

+ +
+
+

Try it out

+

To see referenced entities within an entity, take the following steps.

+
    +
  1. Select Add entity values to add entity values to the table. +

  2. +
  3. Open the Andrew Fuller entity card by selecting the icon to the left of this name in the Employee column.
  4. +
  5. In the Andrew Fuller entity card, select the Manager field. This opens the referenced entity for Nancy Davolio.
  6. +
  7. The referenced Nancy Davolio entity itself contains multiple referenced entities in the Direct Reports field. Select the Direct Reports field to explore the referenced entities for all the employees that report to Nancy Davolio.
  8. +
  9. To navigate back to the original Andrew Fuller entity, select the Back arrow in the top left corner of the entity card.
  10. +
+

You can also use the Extract to grid button in the card modal window, to the right of the Manager or Direct Reports fields, to add the referenced entities to the table in new columns.

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/20-data-types/data-types-web-image.yaml b/samples/excel/20-data-types/data-types-web-image.yaml new file mode 100644 index 000000000..d42de34d6 --- /dev/null +++ b/samples/excel/20-data-types/data-types-web-image.yaml @@ -0,0 +1,189 @@ +order: 2 +id: excel-data-types-web-image +name: 'Data types: Web images' +description: This sample shows how to set and get web images in a worksheet using data types. +host: EXCEL +api_set: + ExcelApi: '1.16' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("insert-image").addEventListener("click", () => tryCatch(insertImage)); + document.getElementById("retrieve-image-info").addEventListener("click", () => tryCatch(retrieveImageInfo)); + document.getElementById("open-image").addEventListener("click", () => tryCatch(openImage)); + document.getElementById("clear-form").addEventListener("click", () => tryCatch(clearForm)); + + async function insertImage() { + // This function inserts a web image into the currently selected cell. + await Excel.run(async (context) => { + // Retrieve image data from the task pane and then clear the input fields. + const imageUrl = (document.getElementById("url") as HTMLInputElement).value; + const imageAltText = (document.getElementById("alt-text") as HTMLInputElement).value; + clearForm(); + + // Load the active cell. + const activeCell = context.workbook.getActiveCell(); + activeCell.load(); + await context.sync(); + + if (!imageUrl) { + console.log("Please enter an image URL."); + return; + } + + // Create a web image object and assign the image details. + const webImage: Excel.WebImageCellValue = { + type: "WebImage", /* The string equivalent of `Excel.CellValueType.webImage`. */ + address: imageUrl, + altText: imageAltText + }; + + // Insert web image into the active cell. + activeCell.valuesAsJson = [[webImage]]; + + await context.sync(); + }); + } + + async function retrieveImageInfo() { + // This function retrieves image data from a selected cell and displays it in the existing input fields in the task pane. + await Excel.run(async (context) => { + // Load the active cell information. + const activeCell = context.workbook.getActiveCell(); + activeCell.load("valuesAsJson"); + await context.sync(); + + // Get image data from the active cell. + const values = activeCell.valuesAsJson; + const webImageData = values[0][0] as Excel.WebImageCellValue; + const webImageUrl = webImageData.address; + const webImageAltText = webImageData.altText; + + if (!webImageUrl) { + console.log("The selected cell is missing an image URL. Make sure to select a cell that contains an image."); + return; + } + + // Assign image data to corresponding input fields in the task pane. + (document.getElementById("url") as HTMLInputElement).value = webImageUrl; + (document.getElementById("alt-text") as HTMLInputElement).value = webImageAltText; + }); + } + + async function openImage() { + // This function retrieves the image URL from the selected cell and opens that image in a new browser tab. + await Excel.run(async (context) => { + // Load the active cell information. + const activeCell = context.workbook.getActiveCell(); + activeCell.load("valuesAsJson"); + await context.sync(); + + // Get image URL from the active cell. + const values = activeCell.valuesAsJson; + const webImageData = values[0][0] as Excel.WebImageCellValue; + const webImageUrl = webImageData.address; + + if (!webImageUrl) { + console.log("The selected cell is missing an image URL. Select a cell that contains an image."); + return; + } + + // Open the image URL in a new browser tab. + const tab = window.open(webImageData.address, "_blank"); + }); + } + + async function clearForm() { + // Clear the input fields in the task pane. + (document.getElementById("url") as HTMLInputElement).value = ""; + (document.getElementById("alt-text") as HTMLInputElement).value = ""; + } + + async function setup() { + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to work with the web image data type. Insert an image into the selected cell and then + retrieve information about that image.

+
+
+

Set up

+

Add a new worksheet and then enter the URL and alt text for an image of your choice.

+ + +
+ + +
+
+

Try it out

+

Select the cell you want to insert the web image into, and then select the Insert image button.

+ +

Select the cell containing the web image that you want to view the details of, and then select the Retrieve image details button. The image details will display here in the task pane, in the preceding Image URL and Alt text fields.

+ +

Select the cell with the image you want to view and then select the Open image in browser button. The image will open in a new web browser tab.

+ +

Clear the Image URL and Alt text fields in the task pane.

+ +
+ 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; + } + + label { + display: inline-block; + margin-bottom: 5px; + margin-left: 20px; + min-width: 80px; + } + + input { + display: inline-block; + padding: 5px; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/22-data-validation/data-validation.yaml b/samples/excel/22-data-validation/data-validation.yaml index cabcc1092..d808941a2 100644 --- a/samples/excel/22-data-validation/data-validation.yaml +++ b/samples/excel/22-data-validation/data-validation.yaml @@ -1,16 +1,16 @@ order: 1 id: excel-data-validation name: Data validation -description: 'Sets data validation rules on ranges, prompts users to enter valid data, and displays messages when invalid data is entered.' +description: Sets data validation rules on ranges, prompts users to enter valid data, and displays messages when invalid data is entered. host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#positive-number").click(() => tryCatch(addPositiveNumberRequirement)); - $("#require-approved-location").click(() => tryCatch(requireApprovedName)); - $("#comment-redundancy").click(() => tryCatch(warnAboutCommentRedundancy)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("positive-number").addEventListener("click", () => tryCatch(addPositiveNumberRequirement)); + document.getElementById("require-approved-location").addEventListener("click", () => tryCatch(requireApprovedName)); + document.getElementById("comment-redundancy").addEventListener("click", () => tryCatch(warnAboutCommentRedundancy)); async function addPositiveNumberRequirement() { await Excel.run(async (context) => { @@ -137,19 +137,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to apply data validation to cells.

- -
+

Set up

- -
+

Try it out

Press Require approved name and then click on a cell in the Baby Name column and use the drop down to enter an approved value.

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -127,15 +128,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/26-document/get-file-in-slices-async.yaml b/samples/excel/26-document/get-file-in-slices-async.yaml index 28c0c4e7f..9c1cff8ca 100644 --- a/samples/excel/26-document/get-file-in-slices-async.yaml +++ b/samples/excel/26-document/get-file-in-slices-async.yaml @@ -1,15 +1,15 @@ order: 1 id: excel-document-get-file-in-slices-async name: Get file using slicing -description: Uses slicing to get the byte array and base64-encoded string that represent the current document. +description: Uses slicing to get the byte array and Base64-encoded string that represent the current document. host: EXCEL api_set: ExcelApi: '1.4' script: content: |- - $("#setup").click(() => tryCatch(setup)); - $("#get-file").click(() => tryCatch(getCurrentFile)); - $("#new-workbook-from-file").click(() => tryCatch(newWorkbookFromFile)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("get-file").addEventListener("click", () => tryCatch(getCurrentFile)); + document.getElementById("new-workbook-from-file").addEventListener("click", () => tryCatch(newWorkbookFromFile)); function getCurrentFile() { const sliceSize = 4096; /*Bytes*/ @@ -35,9 +35,11 @@ script: console.log("Received the full contents of the file."); let base64string = base64js.fromByteArray(byteArray); - $('#file-contents').val(base64string).show(); + const fileContentsElement = document.getElementById("file-contents") as HTMLTextAreaElement; + fileContentsElement.value = base64string; + fileContentsElement.style.display = "block"; - console.log("The base64-encoded string that represents the current document has been written to the text box. To validate the string, use the \"Create workbook from string\" button."); + console.log("The Base64-encoded string that represents the current document has been written to the text box. To validate the string, use the \"Create workbook from string\" button."); } } @@ -82,7 +84,9 @@ script: } async function newWorkbookFromFile() { - await Excel.createWorkbook($('#file-contents').text()).catch(function (error) { + const fileContentsElement = document.getElementById("file-contents"); + const fileContentsText = fileContentsElement.textContent; + await Excel.createWorkbook(fileContentsText).catch(function (error) { console.error(error); }); } @@ -147,35 +151,32 @@ script: } declare namespace base64js { - /** Takes a byte array and returns a base64 string + /** Takes a byte array and returns a Base64 string * Imported from https://www.npmjs.com/package/base64-js package. */ function fromByteArray(array: number[]): string; } language: typescript template: - content: | -
-

This sample shows how to get the base64-encoded string that represents the current document. It uses the getFileAsync() method to read the file in slices and then joins all slices back together to form the complete file.

+ content: |- +
+

This sample shows how to get the Base64-encoded string that represents the current document. It uses the getFileAsync() method to read the file in slices and then joins all slices back together to form the complete file.

- -
+

Set up

- -
+

Try it out


- +
- -
+

Create a new workbook

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -204,15 +205,10 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - core-js@2.4.1/client/core.min.js - @types/core-js + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css - jquery@3.1.1 - @types/jquery@3.3.1 https://unpkg.com/base64-js@1.2.1/base64js.min.js diff --git a/samples/excel/26-document/properties.yaml b/samples/excel/26-document/properties.yaml index 3e34550fb..e6de99c1a 100644 --- a/samples/excel/26-document/properties.yaml +++ b/samples/excel/26-document/properties.yaml @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#set-doc-properties").click(() => tryCatch(setDocProperties)); - $("#get-doc-properties").click(() => tryCatch(getDocProperties)); - $("#set-custom-doc-properties").click(() => tryCatch(setCustomDocProperties)); - $("#get-custom-doc-properties").click(() => tryCatch(getCustomDocProperties)); - $("#get-count-custom-doc-properties").click(() => tryCatch(getCountCustomDocProperties)); + content: |- + document.getElementById("set-doc-properties").addEventListener("click", () => tryCatch(setDocProperties)); + document.getElementById("get-doc-properties").addEventListener("click", () => tryCatch(getDocProperties)); + document.getElementById("set-custom-doc-properties").addEventListener("click", () => tryCatch(setCustomDocProperties)); + document.getElementById("get-custom-doc-properties").addEventListener("click", () => tryCatch(getCustomDocProperties)); + document.getElementById("get-count-custom-doc-properties").addEventListener("click", () => tryCatch(getCountCustomDocProperties)); async function setDocProperties() { await Excel.run(async (context) => { @@ -52,7 +52,7 @@ script: // Write the document properties to the console. // To learn how to view document properties in the UI, - // see https://support.office.com/article/View-or-change-the-properties-for-an-Office-file-21D604C2-481E-4379-8E54-1DD4622C6B75 + // see https://support.microsoft.com/office/21D604C2-481E-4379-8E54-1DD4622C6B75 console.log("Author: " + docProperties.author); console.log("Last author : " + docProperties.lastAuthor); console.log("Revision number: " + docProperties.revisionNumber); @@ -91,7 +91,7 @@ script: // Write the custom document properties to the console. // To learn how to view document properties in the UI, - // see https://support.office.com/article/View-or-change-the-properties-for-an-Office-file-21D604C2-481E-4379-8E54-1DD4622C6B75 + // see https://support.microsoft.com/office/21D604C2-481E-4379-8E54-1DD4622C6B75 console.log("Custom key : " + customProperty.key); console.log("Custom value : " + customProperty.value); @@ -123,45 +123,39 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to set and get document properties.

- -
+

Try it out

- -
+
- -
+
- -
+
- -
+
- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -173,15 +167,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/data-change-event-details.yaml b/samples/excel/30-events/data-change-event-details.yaml index 2fb735c4f..83fb96270 100644 --- a/samples/excel/30-events/data-change-event-details.yaml +++ b/samples/excel/30-events/data-change-event-details.yaml @@ -1,14 +1,14 @@ -order: 5 +order: 6 id: excel-data-change-event-details -name: Data change event details +name: Data changed event details description: Uses the onChanged event of a table to determine the specifics of changes. host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#register-handler").click(() => tryCatch(registerChangeEventHandler)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-handler").addEventListener("click", () => tryCatch(registerChangeEventHandler)); async function registerChangeEventHandler() { await Excel.run(async (context) => { @@ -70,17 +70,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to use table changed events.

- -
+

Setup

-
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -102,15 +101,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/data-changed.yaml b/samples/excel/30-events/data-changed.yaml index cb790701b..4418efaff 100644 --- a/samples/excel/30-events/data-changed.yaml +++ b/samples/excel/30-events/data-changed.yaml @@ -1,15 +1,15 @@ -order: 4 +order: 5 id: excel-events-data-changed -name: Data change event +name: Data changed event description: Registers an event handler that runs when data is changed. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#register-data-changed-handler").click(() => tryCatch(registerDataChangedHandler)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-data-changed-handler").addEventListener("click", () => tryCatch(registerDataChangedHandler)); async function registerDataChangedHandler() { await Excel.run(async (context) => { @@ -75,18 +75,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to register and use a handler for the data-changed event.

- -
+

Set up

- -
+

Try it out

- -
+

Try it out

- -
+

Try it out

Click the button to register handlers for the pie chart's activated and deactivated events. Then click the chart to activate it. Watch the console. Finally, click the cylinder chart to deactivate the pie chart.

- -
+

Try it out

Click the button to register and use handlers for the worksheet's ChartCollection events.

-
+

Try it out

In addition to hovering over a cell, you can view comment changes in the Comments pane by selecting Show Comments from the Review tab.

-
+
language: html style: content: |- @@ -167,15 +167,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/30-events/events-disable-events.yaml b/samples/excel/30-events/events-disable-events.yaml index 9524450c3..80390cd6a 100644 --- a/samples/excel/30-events/events-disable-events.yaml +++ b/samples/excel/30-events/events-disable-events.yaml @@ -1,4 +1,4 @@ -order: 6 +order: 7 id: excel-events-disable-events name: Enable and disable events description: Toggles event firing on and off. @@ -6,11 +6,11 @@ host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#toggleEvents").click(() => tryCatch(toggleEvents)); - $("#setup").click(() => tryCatch(setup)); - $("#refreshData").click(() => tryCatch(addOrRefreshData)); - $("#registerSumChangedHandlers").click(() => tryCatch(registerSumChangedHandlers)); + content: |- + document.getElementById("toggleEvents").addEventListener("click", () => tryCatch(toggleEvents)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("refreshData").addEventListener("click", () => tryCatch(addOrRefreshData)); + document.getElementById("registerSumChangedHandlers").addEventListener("click", () => tryCatch(registerSumChangedHandlers)); async function toggleEvents() { await Excel.run(async (context) => { @@ -38,7 +38,7 @@ script: await context.sync(); // add an event handler to each cell in the sum range - for (var i = 0; i < sumRange.columnCount; i++) { + for (let i = 0; i < sumRange.columnCount; i++) { let sumBinding = context.workbook.bindings.add(sumRange.getCell(0,i), Excel.BindingType.range, "SumBinding" + i); sumBinding.onDataChanged.add(onSumChanged); } @@ -87,8 +87,8 @@ script: await context.sync(); // fill the range with random numbers - for (var i = 0; i < dataRange.rowCount; i++) { - for (var j = 0; j < dataRange.columnCount; j++) { + for (let i = 0; i < dataRange.rowCount; i++) { + for (let j = 0; j < dataRange.columnCount; j++) { dataRange.getCell(i, j).values = [[Math.round(Math.random() * 100)]]; } } @@ -108,7 +108,7 @@ script: sumRange.load(["columnCount"]); await context.sync(); - for (var i = 0; i < sumRange.columnCount; i++) { + for (let i = 0; i < sumRange.columnCount; i++) { const formulaCell = sumRange.getCell(0, i); const startAddressCell = dataRange.getCell(0, i); const endAddressCell = dataRange.getCell(dataRange.rowCount - 1, i); @@ -136,10 +136,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to turn events on and off.

-
+

Setup

-
+

Try it out

The handlers update the "Grand Total" cell when events are fired (and enabled). Try editing the cells or refreshing the data with events enabled and disabled.

+

Register the formula changed event handler to this worksheet.

+ +

Trigger a change to the formula in cell D1. Watch the console to see details about the change event.

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/events-table-changed.yaml b/samples/excel/30-events/events-table-changed.yaml index bbbe20fc2..e5dfb7b9f 100644 --- a/samples/excel/30-events/events-table-changed.yaml +++ b/samples/excel/30-events/events-table-changed.yaml @@ -1,4 +1,4 @@ -order: 10 +order: 12 id: excel-events-table-changed name: Table events description: Registers event handlers that run when a table is changed or selected. @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: |+ - $("#setup").click(() => tryCatch(setup)); - $("#register-on-changed-handler").click(() => tryCatch(registerOnChangedHandler)); - $("#change-data").click(() => tryCatch(changeData)); - $("#register-on-selection-changed-handler").click(() => tryCatch(registerOnSelectionChangedHandler)); - $("#change-selection").click(() => tryCatch(changeSelection)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-on-changed-handler").addEventListener("click", () => tryCatch(registerOnChangedHandler)); + document.getElementById("change-data").addEventListener("click", () => tryCatch(changeData)); + document.getElementById("register-on-selection-changed-handler").addEventListener("click", () => tryCatch(registerOnSelectionChangedHandler)); + document.getElementById("change-selection").addEventListener("click", () => tryCatch(changeSelection)); async function registerOnChangedHandler() { await Excel.run(async (context) => { @@ -104,54 +104,44 @@ script: console.error(error); } } - - - language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to register and use event handlers for table onChanged and onSelectionChanged events.

- -
+

Set up

- -
+

Try it out

- -
+

Changing data in a table triggers the data changed event. You can change the data manually or programmatically.

- -
+
- -
+

Changing a range selection in a table triggers the table onSelectionChanged event. You can change selection manually or programmatically.

- - language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -163,15 +153,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/events-tablecollection-changed.yaml b/samples/excel/30-events/events-tablecollection-changed.yaml index 18423e54d..4e1d575b3 100644 --- a/samples/excel/30-events/events-tablecollection-changed.yaml +++ b/samples/excel/30-events/events-tablecollection-changed.yaml @@ -1,4 +1,4 @@ -order: 9 +order: 10 id: excel-events-tablecollection-changed name: Table collection events description: Registers an event handler that runs when a table collection is changed. @@ -6,10 +6,10 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: |+ - $("#setup").click(() => tryCatch(setup)); - $("#register-on-changed-handler").click(() => tryCatch(registerOnChangedHandler)); - $("#change-data").click(() => tryCatch(changeData)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-on-changed-handler").addEventListener("click", () => tryCatch(registerOnChangedHandler)); + document.getElementById("change-data").addEventListener("click", () => tryCatch(changeData)); async function registerOnChangedHandler() { await Excel.run(async (context) => { @@ -111,40 +111,33 @@ script: console.error(error); } } - - - language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to register and use an event handler for table collection onChanged event.

- -
+

Set up

- -
+

Try it out

- -
+

Changing data in tables triggers the data changed event. You can change the data manually or programmatically.

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -156,15 +149,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/events-workbook-activated.yaml b/samples/excel/30-events/events-workbook-activated.yaml new file mode 100644 index 000000000..40f11633c --- /dev/null +++ b/samples/excel/30-events/events-workbook-activated.yaml @@ -0,0 +1,73 @@ +order: 13 +id: excel-events-workbook-activated +name: Workbook activated event +description: This sample shows how to register a workbook activated event handler. +host: EXCEL +api_set: + ExcelAPI: '1.13' +script: + content: |- + document.getElementById("register-event-handler").addEventListener("click", () => tryCatch(registerEventHandler)); + + async function workbookActivated(event: Excel.WorkbookActivatedEventArgs) { + await Excel.run(async (context) => { + // Callback function for when the workbook is activated. + console.log("The workbook was activated."); + }); + } + + async function registerEventHandler() { + await Excel.run(async (context) => { + const workbook = context.workbook; + + // Register the workbook activated event handler. + workbook.onActivated.add(workbookActivated); + + await context.sync(); + console.log("Added event handler for workbook activated."); + }); + } + + /** 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: |- +
+

This sample shows how to register a workbook activated event handler.

+

Once the event handler is registered, a notification prints to the console when the workbook is activated. Try + switching to another application and then switching back to Excel to see the console notification.

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml b/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml index 06010812d..166a02278 100644 --- a/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml +++ b/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml @@ -1,23 +1,23 @@ -order: 11 +order: 14 id: excel-events-workbook-and-worksheet-collection name: Workbook and worksheet collection events -description: 'Registers event handlers that run when a worksheet is added, activated, or deactivated, or when the settings of a workbook are changed.' +description: Registers event handlers that run when a worksheet is added, activated, or deactivated, or when the settings of a workbook are changed. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.7' script: content: |- - $("#register-on-add-handler").click(() => tryCatch(registerOnAddHandler)); - $("#add-worksheet").click(() => tryCatch(addWorksheet)); + document.getElementById("register-on-add-handler").addEventListener("click", () => tryCatch(registerOnAddHandler)); + document.getElementById("add-worksheet").addEventListener("click", () => tryCatch(addWorksheet)); - $("#register-on-activate-handler").click(() => tryCatch(registerOnActivateHandler)); - $("#register-on-deactivate-handler").click(() => tryCatch(registerOnDeactivateHandler)); - $("#delete-worksheet").click(() => tryCatch(deleteWorksheet)); + document.getElementById("register-on-activate-handler").addEventListener("click", () => tryCatch(registerOnActivateHandler)); + document.getElementById("register-on-deactivate-handler").addEventListener("click", () => tryCatch(registerOnDeactivateHandler)); + document.getElementById("delete-worksheet").addEventListener("click", () => tryCatch(deleteWorksheet)); - $("#create-setting").click(() => tryCatch(createSetting)); - $("#change-setting").click(() => tryCatch(changeSetting)); - $("#register-settings-changed-handler").click(() => tryCatch(registerSettingsChangedHandler)); + document.getElementById("create-setting").addEventListener("click", () => tryCatch(createSetting)); + document.getElementById("change-setting").addEventListener("click", () => tryCatch(changeSetting)); + document.getElementById("register-settings-changed-handler").addEventListener("click", () => tryCatch(registerSettingsChangedHandler)); async function registerOnAddHandler() { await Excel.run(async (context) => { @@ -142,7 +142,7 @@ script: async function changeSetting() { - // The settings.add function is also how you change a + // The settings.add method is also how you change a // setting. There is no settings.setItem or setting.set // method. For example: // await Excel.run(async (context) => { @@ -171,15 +171,13 @@ script: language: typescript template: content: |- -
+

This sample shows how to register and use handlers for when a worksheet is added, activated, or deactivated, or when the settings of a workbook are changed.

- -
+

Try it out

-

Added

-
+
@@ -187,7 +185,6 @@ template: Add worksheet
-

Activated/Deactivated

-

Settings

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -224,15 +220,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/30-events/events-worksheet-protection.yaml b/samples/excel/30-events/events-worksheet-protection.yaml new file mode 100644 index 000000000..8b83fc7cc --- /dev/null +++ b/samples/excel/30-events/events-worksheet-protection.yaml @@ -0,0 +1,105 @@ +order: 16 +id: excel-events-worksheet-protection +name: Worksheet protection events +description: Registers an event handler to listen for worksheet protection status changes. +host: EXCEL +api_set: + ExcelAPI: '1.14' +script: + content: |- + document.getElementById("register-event").addEventListener("click", () => tryCatch(registerEvent)); + document.getElementById("change-protection").addEventListener("click", () => tryCatch(changeProtection)); + + async function registerEvent() { + // This function registers an event handler for the onProtectionChanged event of a worksheet. + await Excel.run(async (context) => { + // Set "Sample" as the active worksheet. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + + // Register the onProtectionChanged event handler. + sheet.onProtectionChanged.add(checkProtection); + await context.sync(); + console.log("Added a worksheet protection change event handler."); + }); + } + + async function checkProtection(event: Excel.WorksheetProtectionChangedEventArgs) { + // This function is an event handler that returns the protection status of a worksheet + // and information about the changed worksheet. + await Excel.run(async (context) => { + const protectionStatus = event.isProtected; + const worksheetId = event.worksheetId; + const source = event.source; + console.log("Protection status changed. Protection status is now: " + protectionStatus + "."); + console.log(" ID of changed worksheet: " + worksheetId + "."); + console.log(" Source of change event: " + source + "."); + }); + } + + async function changeProtection() { + // This function toggles the protection status of a worksheet between "protected" and "unprotected". + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + sheet.activate(); + + // Load the protected property of the WorksheetProtection object. + sheet.load("protection/protected"); + await context.sync(); + + // Enable worksheet protection if it's disabled, or disable worksheet protection if it's enabled. + if (sheet.protection.protected) { + sheet.protection.unprotect(); + } else { + sheet.protection.protect(); + } + }); + } + + /** 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: |- +
+

This sample shows how to register a worksheet protection change event handler. Once the event handler is registered, you can enable and disable worksheet protection for the current worksheet. When worksheet protection is enabled, the current worksheet can't be edited.

+
+
+

Try it out

+ +

+

Toggle worksheet protection and then try editing a cell on the worksheet.

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/30-events/events-worksheet.yaml b/samples/excel/30-events/events-worksheet.yaml index cc075a288..77b2aee9b 100644 --- a/samples/excel/30-events/events-worksheet.yaml +++ b/samples/excel/30-events/events-worksheet.yaml @@ -1,21 +1,23 @@ -order: 12 +order: 15 id: excel-events-worksheet name: Worksheet events -description: 'Registers event handlers that run when data is changed in worksheet, the selected range changes in a worksheet, or the worksheet is recalculated.' +description: Registers event handlers that run when data is changed in worksheet, the selected range changes in a worksheet, or the worksheet is recalculated. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.7' script: content: |- - $("#setup").click(() => tryCatch(setup)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#register-on-selection-changed-handler").click(() => tryCatch(registerSelectionChangedHandler)); - $("#select-range").click(() => tryCatch(selectRange)); + document.getElementById("register-on-selection-changed-handler").addEventListener("click", () => tryCatch(registerSelectionChangedHandler)); + document.getElementById("select-range").addEventListener("click", () => tryCatch(selectRange)); - $("#register-on-changed-handler").click(() => tryCatch(registerOnChangedHandler)); - $("#register-onCalculated-handler").click(() => tryCatch(registerOnCalculatedHandler)); - $("#recalculate").click(() => tryCatch(recalculate)); + document.getElementById("register-on-changed-handler").addEventListener("click", () => tryCatch(registerOnChangedHandler)); + document.getElementById("register-onCalculated-handler").addEventListener("click", () => tryCatch(registerOnCalculatedHandler)); + document.getElementById("recalculate").addEventListener("click", () => tryCatch(recalculate)); + + document.getElementById("delete-data").addEventListener("click", () => tryCatch(deleteData)); async function registerSelectionChangedHandler() { await Excel.run(async (context) => { @@ -96,15 +98,41 @@ script: }); } - async function onChange(event) { + async function deleteData() { + // This function deletes data from a range and sets the delete shift direction to "up". await Excel.run(async (context) => { - console.log( - "Handler for worksheet onChanged event has been triggered. Data changed address : " + - event.address - ); + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("A5:F5"); + range.delete(Excel.DeleteShiftDirection.up); }); } + async function onChange(event: Excel.WorksheetChangedEventArgs) { + // This function is an event handler that returns the address, trigger source, + // and insert or delete shift directions of the change. + await Excel.run(async (context) => { + // Return the address where change occurred. + console.log(`Handler for worksheet onChanged event has been triggered.`); + console.log(` Data changed address: ` + event.address); + + // Return the source of the event that triggered the change. + console.log(` Data change trigger source: ` + event.triggerSource); + + // Note:insertShiftDirection and deleteShiftDirection are exclusive and both enums can't have a value at the same time. + // If one has a value, then the other will return undefined. + + // If the insert shift direction is defined, return it. + if (event.changeDirectionState.insertShiftDirection) { + console.log(` Cells inserted shift direction: ` + event.changeDirectionState.insertShiftDirection); + } + + // If the delete shift direction is defined, return it. + if (event.changeDirectionState.deleteShiftDirection) { + console.log(` Cells deleted shift direction: ` + event.changeDirectionState.deleteShiftDirection); + } + }); + } + async function setup() { await Excel.run(async (context) => { context.workbook.worksheets.getItemOrNullObject("Sample").delete(); @@ -141,21 +169,18 @@ script: language: typescript template: content: |- -
+

This sample shows how to register and use an event handler for the worksheet onSelectionChanged event.

- -
+

Set up

- -
+

Try it out

- -

Selection Changed

+

Selection Changed

@@ -172,10 +197,15 @@ template: +

Detect insert and delete shift directions

+

Use the "Insert" and "Delete" buttons in the Excel UI to trigger the onChanged event. Or, use the following "Delete" button to see the properties returned by the event when a table row is removed.

+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -187,15 +217,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/30-events/selection-changed-events.yaml b/samples/excel/30-events/selection-changed-events.yaml index 3a3a96e4c..cce99d599 100644 --- a/samples/excel/30-events/selection-changed-events.yaml +++ b/samples/excel/30-events/selection-changed-events.yaml @@ -1,15 +1,15 @@ -order: 7 +order: 9 id: excel-selection-changed-events -name: Selection change events +name: Selection changed events description: Registers handlers all the different `onSelectionChanged` events and displays how each event reports the selected addresses. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#register-event-handlers").click(() => tryCatch(registerEventHandlers)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); async function registerEventHandlers() { await Excel.run(async (context) => { @@ -101,12 +101,11 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to register and use event handlers for table onChanged and onSelectionChanged events.

- -
+

Set up

- -
+

Try it out

- -
+

The console will log the addresses reported by the different onSelectionChanged events. Change the cell or cells selected in the worksheet to see the results. Try selecting single cells, multiple cells, and multiple discontiguous cells.

- - language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -146,15 +141,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/34-named-item/create-and-remove-named-item.yaml b/samples/excel/34-named-item/create-and-remove-named-item.yaml index c152eb15d..05d26ce65 100644 --- a/samples/excel/34-named-item/create-and-remove-named-item.yaml +++ b/samples/excel/34-named-item/create-and-remove-named-item.yaml @@ -1,19 +1,19 @@ order: 1 id: excel-named-item-create-and-remove-named-item -name: 'Create, access, and remove' -description: 'Creates, accesses, and removes named items in a worksheet.' +name: Create, access, and remove +description: Creates, accesses, and removes named items in a worksheet. host: EXCEL api_set: ExcelApi: '1.4' script: content: |- - $("#setup").click(() => tryCatch(setup)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#add-name-to-total").click(() => tryCatch(addNameToTotal)); - $("#add-name-to-header").click(() => tryCatch(addNameToHeader)); - $("#format-named-range").click(() => tryCatch(formatRangeByName)); - $("#remove-name").click(() => tryCatch(removeName)); - $("#list-named-items").click(() => tryCatch(listNamedItems)); + document.getElementById("add-name-to-total").addEventListener("click", () => tryCatch(addNameToTotal)); + document.getElementById("add-name-to-header").addEventListener("click", () => tryCatch(addNameToHeader)); + document.getElementById("format-named-range").addEventListener("click", () => tryCatch(formatRangeByName)); + document.getElementById("remove-name").addEventListener("click", () => tryCatch(removeName)); + document.getElementById("list-named-items").addEventListener("click", () => tryCatch(listNamedItems)); async function addNameToTotal() { await Excel.run(async (context) => { @@ -78,13 +78,15 @@ script: async function listNamedItems() { await Excel.run(async (context) => { + // Log all the named items in the active worksheet. const namedItems = context.workbook.worksheets.getActiveWorksheet().names.load(); await context.sync(); console.log("This worksheet contains " + namedItems.items.length + " named items."); for (let i = 0; i < namedItems.items.length; i++) { - console.log(JSON.stringify(namedItems.items[i])) + "\n"; + const namedItem : Excel.NamedItem = namedItems.items[i]; + console.log(JSON.stringify(namedItem)) + "\n"; } await context.sync(); @@ -180,12 +182,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to create, access, and delete named items.

- -
+

Setup

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -124,13 +123,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/38-pivottable/pivottable-calculations.yaml b/samples/excel/38-pivottable/pivottable-calculations.yaml index 0efe9bded..602a9788e 100644 --- a/samples/excel/38-pivottable/pivottable-calculations.yaml +++ b/samples/excel/38-pivottable/pivottable-calculations.yaml @@ -8,11 +8,11 @@ api_set: ExcelApi: '1.8' script: content: |- - $("#setup").click(() => tryCatch(setup)); - $("#deletePivot").click(() => tryCatch(deletePivot)); - $("#showPercentages").click(() => tryCatch(showPercentages)); - $("#showDifferenceFrom").click(() => tryCatch(showDifferenceFrom)); - $("#showSums").click(() => tryCatch(showSums)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("deletePivot").addEventListener("click", () => tryCatch(deletePivot)); + document.getElementById("showPercentages").addEventListener("click", () => tryCatch(showPercentages)); + document.getElementById("showDifferenceFrom").addEventListener("click", () => tryCatch(showDifferenceFrom)); + document.getElementById("showSums").addEventListener("click", () => tryCatch(showSums)); async function showPercentages() { await Excel.run(async (context) => { @@ -24,7 +24,7 @@ script: wholesaleDataHierarchy.load("showAs"); await context.sync(); - // show the crates of each fruit type sold at the farm as a percentage of the column's total + // Show the crates of each fruit type sold at the farm as a percentage of the column's total. let farmShowAs = farmDataHierarchy.showAs; farmShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); @@ -48,8 +48,8 @@ script: wholesaleDataHierarchy.load("showAs"); await context.sync(); - // show the difference between crate sales of the "A Farms" and the other farms - // this difference is both aggregated and shown for individual fruit types (where applicable) + // Show the difference between crate sales of the "A Farms" and the other farms. + // This difference is both aggregated and shown for individual fruit types (where applicable). let farmShowAs = farmDataHierarchy.showAs; farmShowAs.calculation = Excel.ShowAsCalculation.differenceFrom; farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm"); @@ -75,7 +75,7 @@ script: wholesaleDataHierarchy.load("showAs"); await context.sync(); - // show the sum totals crates of each fruit type sold at the farm (the default behavior) + // Show the sum totals crates of each fruit type sold at the farm (the default behavior). let farmShowAs = farmDataHierarchy.showAs; farmShowAs.calculation = Excel.ShowAsCalculation.none; farmDataHierarchy.showAs = farmShowAs; @@ -89,13 +89,13 @@ script: async function setup() { await Excel.run(async (context) => { - // create the worksheets + // Create the worksheets. context.workbook.worksheets.getItemOrNullObject("Data").delete(); const dataSheet = context.workbook.worksheets.add("Data"); context.workbook.worksheets.getItemOrNullObject("Pivot").delete(); const pivotSheet = context.workbook.worksheets.add("Pivot"); - // create farm data + // Create farm data. const data = [["Farm", "Type", "Classification", "Crates Sold at Farm", "Crates Sold Wholesale"], ["A Farms", "Lime", "Organic", 300, 2000], ["A Farms", "Lemon", "Organic", 250, 1800], @@ -123,7 +123,7 @@ script: range.format.autofitColumns(); pivotSheet.activate(); - // create the PivotTable + // Create the PivotTable. context.workbook.worksheets.getActiveWorksheet() .pivotTables.add("Farm Sales", "Data!A1:E21", "A2"); const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); @@ -152,22 +152,20 @@ script: // 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: |- -
+

This sample shows how to change the calculations of PivotTable data hierarchies.

- -
+

Set up

- -
+

Try it out

- -
+

Clean up

-
+

Try it out

-
+

Create the PivotTable

- -
+

Adjust the PivotTable

- -
+

Adjust formatting

- -
+

Delete the PivotTable

- -
+

Try it out

- -
+

Change functions

- -
+

Filtering

After pressing the "Enable filter" button, manually select the classification filter for the PivotTable - -

+

Data Manipulation

- -
+

Clean up

- -
+

Try it out

- -
+
@@ -181,15 +182,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/38-pivottable/pivottable-pivotfilters.yaml b/samples/excel/38-pivottable/pivottable-pivotfilters.yaml index d824dc378..1d2bcef68 100644 --- a/samples/excel/38-pivottable/pivottable-pivotfilters.yaml +++ b/samples/excel/38-pivottable/pivottable-pivotfilters.yaml @@ -1,4 +1,4 @@ -order: 6 +order: 5 id: excel-pivottables-pivotfilters name: PivotFilters description: Applies PivotFilters to a PivotTable. @@ -6,15 +6,15 @@ host: EXCEL api_set: ExcelAPI: '1.12' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#manual-filter").click(() => tryCatch(manualFilter)); - $("#date-filter").click(() => tryCatch(dateFilter)); - $("#value-filter").click(() => tryCatch(valueFilter)); - $("#label-filter").click(() => tryCatch(labelFilter)); - $("#clear-filters").click(() => tryCatch(clearFilters)); - $("#log-filters").click(() => tryCatch(logFilters)); - $("#get-crate-total").click(() => tryCatch(getCrateTotal)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("manual-filter").addEventListener("click", () => tryCatch(manualFilter)); + document.getElementById("date-filter").addEventListener("click", () => tryCatch(dateFilter)); + document.getElementById("value-filter").addEventListener("click", () => tryCatch(valueFilter)); + document.getElementById("label-filter").addEventListener("click", () => tryCatch(labelFilter)); + document.getElementById("clear-filters").addEventListener("click", () => tryCatch(clearFilters)); + document.getElementById("log-filters").addEventListener("click", () => tryCatch(logFilters)); + document.getElementById("get-crate-total").addEventListener("click", () => tryCatch(getCrateTotal)); async function manualFilter() { await Excel.run(async (context) => { @@ -253,22 +253,19 @@ script: language: typescript template: content: |- -
+

This sample shows how to filter PivotTables with the different PivotFilters.

- -
+

Set up

- -
+

Try it out

- -
+

Filters

Manual filter

-

PivotTable Status

+

+
+

Try it out

+ + + + +
+

Header and total settings

+ +
+

Empty cell settings

+ +
+

PivotTable refresh formatting settings

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/38-pivottable/pivottable-refresh.yaml b/samples/excel/38-pivottable/pivottable-refresh.yaml new file mode 100644 index 000000000..e2975ff72 --- /dev/null +++ b/samples/excel/38-pivottable/pivottable-refresh.yaml @@ -0,0 +1,133 @@ +order: 8 +id: excel-pivottable-refresh +name: Refresh +description: Refreshes a PivotTable based on table row additions. +host: EXCEL +api_set: + ExcelApi: '1.8' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("refresh-pivottable").addEventListener("click", () => tryCatch(refreshPivotTable)); + document.getElementById("add-table-row").addEventListener("click", () => tryCatch(addTableRow)); + + async function refreshPivotTable() { + // This function refreshes the "Farm Sales" PivotTable, + // which updates the PivotTable with changes made to the source table. + await Excel.run(async (context) => { + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + pivotTable.refresh(); + await context.sync(); + }); + } + + async function addTableRow() { + // This function adds a row to the PivotTable's source table. + await Excel.run(async (context) => { + const dataTable = context.workbook.tables.getItem("DataTable"); + dataTable.rows.add(null, [["G Farms", "Mango", "Organic", 200, 1000]]); + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const data = [ + ["Farm", "Type", "Classification", "Crates Sold at Farm", "Crates Sold Wholesale"], + ["A Farms", "Lime", "Organic", 300, 2000], + ["A Farms", "Lemon", "Organic", 250, 1800], + ["A Farms", "Orange", "Organic", 200, 2200], + ["B Farms", "Lime", "Conventional", 80, 1000], + ["B Farms", "Lemon", "Conventional", 75, 1230], + ["B Farms", "Orange", "Conventional", 25, 800], + ["B Farms", "Orange", "Organic", 20, 500], + ["B Farms", "Lemon", "Organic", 10, 770], + ["B Farms", "Kiwi", "Conventional", 30, 300], + ["B Farms", "Lime", "Organic", 50, 400], + ["C Farms", "Apple", "Organic", 275, 220], + ["C Farms", "Kiwi", "Organic", 200, 120], + ["D Farms", "Apple", "Conventional", 100, 3000], + ["D Farms", "Apple", "Organic", 80, 2800], + ["E Farms", "Lime", "Conventional", 160, 2700], + ["E Farms", "Orange", "Conventional", 180, 2000], + ["E Farms", "Apple", "Conventional", 245, 2200], + ["E Farms", "Kiwi", "Conventional", 200, 1500], + ["F Farms", "Kiwi", "Organic", 100, 150], + ["F Farms", "Lemon", "Conventional", 150, 270] + ]; + + const range = sheet.getRange("A1:E21"); + range.values = data; + const table = sheet.tables.add(range, true); + table.name = "DataTable"; + range.format.autofitColumns(); + + const rangeToPlacePivot = sheet.getRange("G1"); + + // Make the source of the PivotTable a Table so added rows are picked up by the refresh operation. + const pivotTable = sheet.pivotTables.add("Farm Sales", table, rangeToPlacePivot); + + pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Farm")); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold at Farm")); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold Wholesale")); + + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to refresh a PivotTable.

+
+
+

Setup

+ +
+
+

Try it out

+

Add a row to the table, then refresh the PivotTable. Note that the PivotTable doesn't automatically refresh.

+ +

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/38-pivottable/pivottable-slicer.yaml b/samples/excel/38-pivottable/pivottable-slicer.yaml index 36ca4db7b..15c781177 100644 --- a/samples/excel/38-pivottable/pivottable-slicer.yaml +++ b/samples/excel/38-pivottable/pivottable-slicer.yaml @@ -1,4 +1,4 @@ -order: 5 +order: 9 id: excel-pivottable-slicer name: Slicer description: Adds a slicer to a PivotTable. @@ -6,15 +6,15 @@ host: EXCEL api_set: ExcelApi: '1.10' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#add-pivot-table").click(() => tryCatch(addPivotTable)); - $("#add-slicer").click(() => tryCatch(addSlicer)); - $("#format-slicer").click(() => tryCatch(formatSlicer)); - $("#apply-style").click(() => tryCatch(applyStyle)); - $("#add-filters").click(() => tryCatch(addFilters)); - $("#remove-filters").click(() => tryCatch(removeFilters)); - $("#remove-slicer").click(() => tryCatch(removeSlicer)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-pivot-table").addEventListener("click", () => tryCatch(addPivotTable)); + document.getElementById("add-slicer").addEventListener("click", () => tryCatch(addSlicer)); + document.getElementById("format-slicer").addEventListener("click", () => tryCatch(formatSlicer)); + document.getElementById("apply-style").addEventListener("click", () => tryCatch(applyStyle)); + document.getElementById("add-filters").addEventListener("click", () => tryCatch(addFilters)); + document.getElementById("remove-filters").addEventListener("click", () => tryCatch(removeFilters)); + document.getElementById("remove-slicer").addEventListener("click", () => tryCatch(removeSlicer)); async function addSlicer() { await Excel.run(async (context) => { @@ -142,21 +142,20 @@ script: language: typescript template: content: |- -
+

This sample shows how to work with a slicer on a PivotTable.

- -
+

Setup

-
+

Try it out

Add the slicer, then try out the formatting and filtering options.

Clean up

@@ -188,7 +187,7 @@ template:
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -200,15 +199,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/38-pivottable/pivottable-source-data.yaml b/samples/excel/38-pivottable/pivottable-source-data.yaml new file mode 100644 index 000000000..75014fedb --- /dev/null +++ b/samples/excel/38-pivottable/pivottable-source-data.yaml @@ -0,0 +1,127 @@ +order: 7 +id: excel-pivottable-data-source +name: PivotTable data source +description: Gets information about the data source of a PivotTable. +host: EXCEL +api_set: + ExcelApi: '1.15' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("get-pivottable-data-source").addEventListener("click", () => tryCatch(getPivotTableDataSource)); + + async function getPivotTableDataSource() { + // This function logs information about the data source of a PivotTable. + await Excel.run(async (context) => { + const worksheet = context.workbook.worksheets.getItem("TotalPivot"); + const pivotTable = worksheet.pivotTables.getItem("All Farm Sales"); + + // Retrieve the type and string representation of the data source of the PivotTable. + const pivotTableDataSourceType = pivotTable.getDataSourceType(); + const pivotTableDataSourceString = pivotTable.getDataSourceString(); + await context.sync(); + + // Log the data source information. + console.log("Data source: " + pivotTableDataSourceString.value); + console.log("Source type: " + pivotTableDataSourceType.value); + }); + } + + async function setup() { + await Excel.run(async (context) => { + // Create the worksheets. + context.workbook.worksheets.getItemOrNullObject("Data").delete(); + const dataSheet = context.workbook.worksheets.add("Data"); + context.workbook.worksheets.getItemOrNullObject("TotalPivot").delete(); + const totalPivot = context.workbook.worksheets.add("TotalPivot"); + + // Create farm data. + const data = [ + ["Farm", "Type", "Classification", "Crates Sold at Farm", "Crates Sold Wholesale"], + ["A Farms", "Lime", "Organic", 300, 2000], + ["A Farms", "Lemon", "Organic", 250, 1800], + ["A Farms", "Orange", "Organic", 200, 2200], + ["B Farms", "Lime", "Conventional", 80, 1000], + ["B Farms", "Lemon", "Conventional", 75, 1230], + ["B Farms", "Orange", "Conventional", 25, 800], + ["B Farms", "Orange", "Organic", 20, 500], + ["B Farms", "Lemon", "Organic", 10, 770], + ["B Farms", "Kiwi", "Conventional", 30, 300], + ["B Farms", "Lime", "Organic", 50, 400], + ["C Farms", "Apple", "Organic", 275, 220], + ["C Farms", "Kiwi", "Organic", 200, 120], + ["D Farms", "Apple", "Conventional", 100, 3000], + ["D Farms", "Apple", "Organic", 80, 2800], + ["E Farms", "Lime", "Conventional", 160, 2700], + ["E Farms", "Orange", "Conventional", 180, 2000], + ["E Farms", "Apple", "Conventional", 245, 2200], + ["E Farms", "Kiwi", "Conventional", 200, 1500], + ["F Farms", "Kiwi", "Organic", 100, 150], + ["F Farms", "Lemon", "Conventional", 150, 270] + ]; + + const range = dataSheet.getRange("A1:E21"); + range.values = data; + range.format.autofitColumns(); + + // Create the PivotTable. + const pivotTable = totalPivot.pivotTables.add("All Farm Sales", "Data!A1:E21", "TotalPivot!A2"); + pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Farm")); + pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Type")); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold Wholesale")); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold at Farm")); + + // Switch to the worksheet with a PivotTable. + totalPivot.activate(); + + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to get information about the data source of a PivotTable. It returns the type and string representation of the data source.

+

Note: This sample works in Excel on Windows and Excel on the web. It doesn't work in Excel on Mac; this is a known issue.

+
+
+

Set up

+ +
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/cell-properties.yaml b/samples/excel/42-range/cell-properties.yaml index e923d3f2d..acf10f685 100644 --- a/samples/excel/42-range/cell-properties.yaml +++ b/samples/excel/42-range/cell-properties.yaml @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#set-cell-properties").click(() => tryCatch(setCellProperties)); - $("#get-cell-properties").click(() => tryCatch(getCellProperties)); - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("set-cell-properties").addEventListener("click", () => tryCatch(setCellProperties)); + document.getElementById("get-cell-properties").addEventListener("click", () => tryCatch(getCellProperties)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); async function setCellProperties() { await Excel.run(async (context) => { @@ -145,18 +145,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to format a range.

- -
+

Set up

- -
+

Try it out

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -171,15 +169,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/formatting.yaml b/samples/excel/42-range/formatting.yaml index a8abfa954..3e526ce4a 100644 --- a/samples/excel/42-range/formatting.yaml +++ b/samples/excel/42-range/formatting.yaml @@ -7,11 +7,11 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#set-font-and-fill-color").click(() => tryCatch(setFontAndFillColor)); - $("#set-number-format").click(() => tryCatch(setNumberFormat)); + document.getElementById("set-font-and-fill-color").addEventListener("click", () => tryCatch(setFontAndFillColor)); + document.getElementById("set-number-format").addEventListener("click", () => tryCatch(setNumberFormat)); async function setFontAndFillColor() { await Excel.run(async (context) => { @@ -75,19 +75,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to format a range.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -110,15 +108,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/insert-delete-clear-range.yaml b/samples/excel/42-range/insert-delete-clear-range.yaml index cd6db23fd..a762879be 100644 --- a/samples/excel/42-range/insert-delete-clear-range.yaml +++ b/samples/excel/42-range/insert-delete-clear-range.yaml @@ -1,18 +1,18 @@ order: 8 id: excel-range-insert-delete-and-clear-range -name: 'Insert, delete, and clear' -description: 'Inserts, deletes, and clears a range.' +name: Insert, delete, and clear +description: Inserts, deletes, and clears a range. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#insert-range").click(() => tryCatch(insertRange)); - $("#delete-range").click(() => tryCatch(deleteRange)); - $("#clear-range").click(() => tryCatch(clearRange)); + document.getElementById("insert-range").addEventListener("click", () => tryCatch(insertRange)); + document.getElementById("delete-range").addEventListener("click", () => tryCatch(deleteRange)); + document.getElementById("clear-range").addEventListener("click", () => tryCatch(clearRange)); async function insertRange() { await Excel.run(async (context) => { @@ -85,19 +85,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to insert, delete and clear the contents of a range.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -123,15 +121,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/42-range/outline.yaml b/samples/excel/42-range/outline.yaml index 02f043b4a..f3c53898c 100644 --- a/samples/excel/42-range/outline.yaml +++ b/samples/excel/42-range/outline.yaml @@ -6,14 +6,14 @@ host: EXCEL api_set: ExcelApi: '1.10' script: - content: | - $("#setup-data").click(() => tryCatch(setupData)); - $("#setup-totals").click(() => tryCatch(setupTotals)); - $("#group-rows").click(() => tryCatch(groupRows)); - $("#group-columns").click(() => tryCatch(groupColumns)); - $("#collapse-outline").click(() => tryCatch(collapseOutline)); - $("#expand-outline").click(() => tryCatch(expandOutline)); - $("#ungroup").click(() => tryCatch(ungroup)); + content: |- + document.getElementById("setup-data").addEventListener("click", () => tryCatch(setupData)); + document.getElementById("setup-totals").addEventListener("click", () => tryCatch(setupTotals)); + document.getElementById("group-rows").addEventListener("click", () => tryCatch(groupRows)); + document.getElementById("group-columns").addEventListener("click", () => tryCatch(groupColumns)); + document.getElementById("collapse-outline").addEventListener("click", () => tryCatch(collapseOutline)); + document.getElementById("expand-outline").addEventListener("click", () => tryCatch(expandOutline)); + document.getElementById("ungroup").addEventListener("click", () => tryCatch(ungroup)); async function groupRows() { Excel.run(async (context) => { @@ -171,11 +171,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to group and ungroup rows and columns for an outline.

- -
+

Set up

- -
+

Try it out

+
+

Set up

+
-
+

Try it out

- - - - -
+ + + + + +
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -163,15 +201,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-areas.yaml b/samples/excel/42-range/range-areas.yaml index cfbff6ec9..23f24ddf6 100644 --- a/samples/excel/42-range/range-areas.yaml +++ b/samples/excel/42-range/range-areas.yaml @@ -1,18 +1,18 @@ order: 3 id: excel-range-areas name: Discontiguous ranges (RangeAreas) and special cells -description: 'Creates and uses RangeAreas, which are sets of ranges that need not be contiguous, through user selection and programmatic selection of special cells.' +description: Creates and uses RangeAreas, which are sets of ranges that need not be contiguous, through user selection and programmatic selection of special cells. host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#reset").click(() => tryCatch(reset)); - $("#color-selected-ranges").click(() => tryCatch(colorSelectedRanges)); - $("#color-specified-ranges").click(() => tryCatch(colorSpecifiedRanges)); - $("#color-all-formula-ranges").click(() => tryCatch(colorAllFormulaRanges)); - $("#color-all-logical-text-ranges").click(() => tryCatch(colorAllLogicalAndTextRanges)); - $("#read-properties-specified-ranges").click(() => tryCatch(readPropertiesOfSpecifiedRanges)); + content: |- + document.getElementById("reset").addEventListener("click", () => tryCatch(reset)); + document.getElementById("color-selected-ranges").addEventListener("click", () => tryCatch(colorSelectedRanges)); + document.getElementById("color-specified-ranges").addEventListener("click", () => tryCatch(colorSpecifiedRanges)); + document.getElementById("color-all-formula-ranges").addEventListener("click", () => tryCatch(colorAllFormulaRanges)); + document.getElementById("color-all-logical-text-ranges").addEventListener("click", () => tryCatch(colorAllLogicalAndTextRanges)); + document.getElementById("read-properties-specified-ranges").addEventListener("click", () => tryCatch(readPropertiesOfSpecifiedRanges)); async function colorSelectedRanges() { await Excel.run(async (context) => { @@ -123,12 +123,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to apply actions simultaneously to multiple, discontiguous ranges. Some of these ranges are found using the Range object's getSpecialCells method.

- -
+

Set up

- -
+

Try it out

+
+
+

Try it out

+ +
+ +
+ +
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-copyfrom.yaml b/samples/excel/42-range/range-copyfrom.yaml index 0db6cc1ac..c48034c2c 100644 --- a/samples/excel/42-range/range-copyfrom.yaml +++ b/samples/excel/42-range/range-copyfrom.yaml @@ -6,16 +6,16 @@ host: EXCEL api_set: ExcelApi: '1.10' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#copyAll").click(() => tryCatch(copyAll)); - $("#copyFormula").click(() => tryCatch(copyFormula)); - $("#copyFormulaResult").click(() => tryCatch(copyFormulaResult)); - $("#copySingleAcrossRange").click(() => tryCatch(copySingleAcrossRange)); - $("#copyOnlyFormat").click(() => tryCatch(copyOnlyFormat)); - $("#skipBlanks").click(() => tryCatch(skipBlanks)); - $("#transpose").click(() => tryCatch(transpose)); - $("#move").click(() => tryCatch(move)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("copyAll").addEventListener("click", () => tryCatch(copyAll)); + document.getElementById("copyFormula").addEventListener("click", () => tryCatch(copyFormula)); + document.getElementById("copyFormulaResult").addEventListener("click", () => tryCatch(copyFormulaResult)); + document.getElementById("copySingleAcrossRange").addEventListener("click", () => tryCatch(copySingleAcrossRange)); + document.getElementById("copyOnlyFormat").addEventListener("click", () => tryCatch(copyOnlyFormat)); + document.getElementById("skipBlanks").addEventListener("click", () => tryCatch(skipBlanks)); + document.getElementById("transpose").addEventListener("click", () => tryCatch(transpose)); + document.getElementById("move").addEventListener("click", () => tryCatch(move)); async function copyAll() { await Excel.run(async (context) => { @@ -154,16 +154,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to copy data and formatting from one range (A1:E1) to another.

-
+

Setup

-
+

Try it out

+
+
+

Try it out

+

Cell D3 has dependents across worksheets.

+ + + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-direct-dependents.yaml b/samples/excel/42-range/range-direct-dependents.yaml new file mode 100644 index 000000000..a4843dd2b --- /dev/null +++ b/samples/excel/42-range/range-direct-dependents.yaml @@ -0,0 +1,161 @@ +order: 21 +id: excel-direct-dependents +name: Direct dependents +description: This sample shows how to find and highlight the direct dependents of the currently selected cell. Dependent cells contain formulas that refer to other cells. +host: EXCEL +api_set: + ExcelAPI: '1.13' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("select-D3").addEventListener("click", () => tryCatch(selectD3)); + document.getElementById("select-E4").addEventListener("click", () => tryCatch(selectE4)); + document.getElementById("get-direct-dependents").addEventListener("click", () => tryCatch(getDirectDependents)); + + /** Select a cell with direct dependents on the same worksheet. */ + async function selectD3() { + await Excel.run(async (context) => { + // Activate the sample worksheet. + const sheet = context.workbook.worksheets.getItem("Sample2019Data"); + sheet.activate(); + + // Select cell D3. + const range = sheet.getRange("D3"); + range.select(); + await context.sync(); + }); + } + + /** Select a cell with direct dependents across worksheets. */ + async function selectE4() { + await Excel.run(async (context) => { + // Activate the sample worksheet. + const sheet = context.workbook.worksheets.getItem("Sample2019Data"); + sheet.activate(); + + // Select cell E4. + const range = sheet.getRange("E4"); + range.select(); + await context.sync(); + }); + } + + async function getDirectDependents() { + await Excel.run(async (context) => { + // Direct dependents are cells that contain formulas that refer to other cells. + let range = context.workbook.getActiveCell(); + let directDependents = range.getDirectDependents(); + range.load("address"); + directDependents.areas.load("address"); + await context.sync(); + + console.log(`Direct dependent cells of ${range.address}:`); + + // Use the direct dependents API to loop through direct dependents of the active cell. + for (let i = 0; i < directDependents.areas.items.length; i++) { + // Highlight and print the address of each dependent cell. + directDependents.areas.items[i].format.fill.color = "Yellow"; + console.log(` ${directDependents.areas.items[i].address}`); + } + await context.sync(); + }); + } + + /** Create two sample tables on different worksheets with methods that span the tables. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample2019Data").delete(); + context.workbook.worksheets.getItemOrNullObject("Sample2020Data").delete(); + + // Set up the first sample table. + const sheet1 = context.workbook.worksheets.add("Sample2019Data"); + const data1 = [ + ["Product", "Qty", "Unit Price", "Total Price 2019"], + ["Almonds", 2, 7.5, "=C3 * D3"], + ["Coffee", 1, 34.5, "=C4 * D4"], + ["Chocolate", 5, 9.56, "=C5 * D5"] + ]; + + const range1 = sheet1.getRange("B2:E5"); + range1.values = data1; + range1.format.autofitColumns(); + + // Set up the second sample table. + const sheet2 = context.workbook.worksheets.add("Sample2020Data"); + const data2 = [ + ["Product", "Qty", "Unit Price", "Total Price 2020", "Average Annual Price"], + ["Almonds", 2, 8.0, "=C3 * D3", "=Sample2019Data!E3 + E3 / 2"], + ["Coffee", 1, 36.5, "=C4 * D4", "=Sample2019Data!E4 + E4 / 2"], + ["Chocolate", 5, 11.2, "=C5 * D5", "=Sample2019Data!E5 + E5 / 2"] + ]; + const range2 = sheet2.getRange("B2:F5"); + range2.values = data2; + range2.format.autofitColumns(); + + // Style the tables. + const header1 = range1.getRow(0); + header1.format.fill.color = "#4472C4"; + header1.format.font.color = "white"; + const header2 = range2.getRow(0); + header2.format.fill.color = "#4472C4"; + header2.format.font.color = "white"; + sheet2.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to find and highlight the dependents of the currently selected cell. Dependent cells contain formulas that refer to other cells.

+
+
+

Set up

+ +
+
+

Try it out

+

Cells in the 'E' column have direct dependents on the same worksheet. Cells in the 'F' column have direct dependents on another worksheet.

+ +
+ +
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-find.yaml b/samples/excel/42-range/range-find.yaml index 9ad3fa386..a72156601 100644 --- a/samples/excel/42-range/range-find.yaml +++ b/samples/excel/42-range/range-find.yaml @@ -7,12 +7,12 @@ api_set: ExcelApi: '1.9' script: content: |- - $("#setup").click(() => tryCatch(setup)); - $("#findText").click(() => tryCatch(findText)); - $("#findTextWithNullCheck").click(() => tryCatch(findTextWithNullCheck)); - $("#toggleComplete").click(() => tryCatch(toggleComplete)); - $("#toggleCase").click(() => tryCatch(toggleCase)); - $("#toggleDirection").click(() => tryCatch(toggleDirection)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("findText").addEventListener("click", () => tryCatch(findText)); + document.getElementById("findTextWithNullCheck").addEventListener("click", () => tryCatch(findTextWithNullCheck)); + document.getElementById("toggleComplete").addEventListener("click", () => tryCatch(toggleComplete)); + document.getElementById("toggleCase").addEventListener("click", () => tryCatch(toggleCase)); + document.getElementById("toggleDirection").addEventListener("click", () => tryCatch(toggleDirection)); let isCompleteMatchToggle = false; let isMatchCaseToggle = false; @@ -26,7 +26,8 @@ script: // NOTE: If no match is found, an ItemNotFound error // is thrown when Range.find is evaluated. - const foundRange = searchRange.find($("#searchText").text(), { + const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value; + const foundRange = searchRange.find(searchText, { completeMatch: isCompleteMatchToggle, matchCase: isMatchCaseToggle, searchDirection: searchDirectionToggle @@ -45,7 +46,8 @@ script: const sheet = context.workbook.worksheets.getItem("Sample"); const table = sheet.tables.getItem("ExpensesTable"); const searchRange = table.getRange(); - const foundRange = searchRange.findOrNullObject($("#searchText").text(), { + const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value; + const foundRange = searchRange.findOrNullObject(searchText, { completeMatch: isCompleteMatchToggle, matchCase: isMatchCaseToggle, searchDirection: searchDirectionToggle @@ -113,16 +115,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to find a cell with a matching string value within a range.

-
+

Setup

-
+

Try it out

Enter text to search for in the box below and press Find text or Find text with null check to display the found text's address in the console.

@@ -159,13 +161,7 @@ style: language: css libraries: |- https://appsforoffice.microsoft.com/lib/1/hosted/office.js - @types/office-js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - 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 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-get-range-edge.yaml b/samples/excel/42-range/range-get-range-edge.yaml new file mode 100644 index 000000000..9d5a21ffe --- /dev/null +++ b/samples/excel/42-range/range-get-range-edge.yaml @@ -0,0 +1,225 @@ +order: 20 +id: excel-range-get-range-edge +name: Select used range edge +description: This sample shows how to select the edges of the used range, based on the currently selected range. +host: EXCEL +api_set: + ExcelAPI: '1.13' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("select-E9").addEventListener("click", () => tryCatch(selectE9)); + document.getElementById("select-D8-E9").addEventListener("click", () => tryCatch(selectD8E9)); + document.getElementById("get-range-edge-left").addEventListener("click", () => tryCatch(getRangeEdgeLeft)); + document.getElementById("get-range-edge-up").addEventListener("click", () => tryCatch(getRangeEdgeUp)); + document.getElementById("get-extended-range-right").addEventListener("click", () => tryCatch(getExtendedRangeRight)); + document.getElementById("get-extended-range-down").addEventListener("click", () => tryCatch(getExtendedRangeDown)); + + async function getRangeEdgeLeft() { + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get the left-most cell of the current used range. + // This method acts like the Ctrl+Arrow key keyboard shortcut while a range is selected. + const rangeEdge = range.getRangeEdge( + "Left", // Specify the direction as a string. + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + + // Select the edge of the range. + rangeEdge.select(); + + await context.sync(); + }); + } + + async function getRangeEdgeUp() { + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Specify the direction with the `KeyboardDirection` enum. + const direction = Excel.KeyboardDirection.up; + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get the top-most cell of the current used range. + // This method acts like the Ctrl+Arrow key keyboard shortcut while a range is selected. + const rangeEdge = range.getRangeEdge( + direction, + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + rangeEdge.select(); + + await context.sync(); + }); + } + + async function getExtendedRangeRight() { + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get all the cells from the currently selected range to the right-most edge of the used range. + // This method acts like the Ctrl+Shift+Arrow key keyboard shortcut while a range is selected. + const extendedRange = range.getExtendedRange( + "Right", // Specify the direction as a string. + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + extendedRange.select(); + + await context.sync(); + }); + } + + async function getExtendedRangeDown() { + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Specify the direction with the `KeyboardDirection` enum. + const direction = Excel.KeyboardDirection.down; + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get all the cells from the currently selected range to the bottom-most edge of the used range. + // This method acts like the Ctrl+Shift+Arrow key keyboard shortcut while a range is selected. + const extendedRange = range.getExtendedRange( + direction, + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + extendedRange.select(); + + await context.sync(); + }); + } + + /** Select a range with one cell. */ + async function selectE9() { + await Excel.run(async (context) => { + // Get the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Select cell E9. + const range = sheet.getRange("E9"); + range.select(); + await context.sync(); + }); + } + + /** Select a range with multiple cells. */ + async function selectD8E9() { + await Excel.run(async (context) => { + // Get the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Select range D8:E9. + const range = sheet.getRange("D8:E9"); + range.select(); + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const expensesTable = sheet.tables.add("C5:F5", true /*hasHeaders*/); + expensesTable.name = "ExpensesTable"; + + expensesTable.getHeaderRowRange().values = [["Date", "Merchant", "Category", "Amount"]]; + + expensesTable.rows.add(null /*add at the end*/, [ + ["1/1/2017", "The Phone Company", "Communications", "$120"], + ["1/2/2017", "Northwind Electric Cars", "Transportation", "$142"], + ["1/5/2017", "Best For You Organics Company", "Groceries", "$27"], + ["1/10/2017", "Coho Vineyard", "Restaurant", "$33"], + ["1/11/2017", "Bellows College", "Education", "$350"], + ["1/15/2017", "Trey Research", "Other", "$135"], + ["1/15/2017", "Best For You Organics Company", "Groceries", "$97"] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + + await context.sync(); + }); + } + + /** 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: |- +

+

This sample shows how to select the edges of the used range, based on the currently selected range.

+
+
+

Set up

+ +
+
+

Try it out

+ + +
+

The first type of range edge selection selects the cell at the furthest edge of the current used range, in the directions up or left. This action matches the result of using the Ctrl+Arrow key keyboard shortcut while a range is selected.

+ + +
+

The second type of range edge selection selects all the cells from the currently selected range to the furthest edge of the used range, in the directions right or down. This action matches the result of using the Ctrl+Shift+Arrow key keyboard shortcut while a range is selected.

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/42-range/range-hyperlink.yaml b/samples/excel/42-range/range-hyperlink.yaml index 1f7f91207..1b83b866e 100644 --- a/samples/excel/42-range/range-hyperlink.yaml +++ b/samples/excel/42-range/range-hyperlink.yaml @@ -1,19 +1,19 @@ order: 7 id: excel-range-hyperlink name: Hyperlinks -description: 'Creates, updates, and clears hyperlinks in a range.' +description: Creates, updates, and clears hyperlinks in a range. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#create-url-hyperlinks").click(() => tryCatch(createUrlHyperlinks)); - $("#create-document-hyperlinks").click(() => tryCatch(createDocumentHyperlinks)); - $("#update-hyperlinks").click(() => tryCatch(updateHyperlinks)); - $("#clear-hyperlinks").click(() => tryCatch(clearHyperlinks)); + document.getElementById("create-url-hyperlinks").addEventListener("click", () => tryCatch(createUrlHyperlinks)); + document.getElementById("create-document-hyperlinks").addEventListener("click", () => tryCatch(createDocumentHyperlinks)); + document.getElementById("update-hyperlinks").addEventListener("click", () => tryCatch(updateHyperlinks)); + document.getElementById("clear-hyperlinks").addEventListener("click", () => tryCatch(clearHyperlinks)); async function createUrlHyperlinks() { await Excel.run(async (context) => { @@ -112,7 +112,7 @@ script: let cellRange = productsRange.getCell(i, 0); // Clear the hyperlink. - // This eliminates the hyperlink but does not update text format. + // This removes the hyperlink but does not update text format. cellRange.clear(Excel.ClearApplyTo.hyperlinks); // Update text format. @@ -273,18 +273,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to create, update, and clear a hyperlink for a range.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -313,15 +311,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/42-range/range-merged-ranges.yaml b/samples/excel/42-range/range-merged-ranges.yaml new file mode 100644 index 000000000..d6e4d7fe7 --- /dev/null +++ b/samples/excel/42-range/range-merged-ranges.yaml @@ -0,0 +1,131 @@ +order: 19 +id: excel-merged-ranges +name: Merged ranges +description: This sample shows how to create and find merged ranges in a worksheet. +host: EXCEL +api_set: + ExcelAPI: '1.13' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("create-merged-range").addEventListener("click", () => tryCatch(createMergedRange)); + document.getElementById("get-merged-range").addEventListener("click", () => tryCatch(getMergedRange)); + + async function createMergedRange() { + await Excel.run(async (context) => { + // Retrieve the worksheet and the table in that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const tableRange = sheet.getRange("B2:E6"); + + // Create a merged range in the first row of the table. + const chartTitle = tableRange.getRow(0); + chartTitle.merge(true); + + // Format the merged range. + chartTitle.format.horizontalAlignment = "Center"; + + await context.sync(); + }); + } + + async function getMergedRange() { + await Excel.run(async (context) => { + // Retrieve the worksheet and the table in that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const tableRange = sheet.getRange("B2:E6"); + + // Retrieve the merged range within the table and load its details. + const mergedAreas = tableRange.getMergedAreasOrNullObject(); + mergedAreas.load("address"); + mergedAreas.load("cellCount"); + + // Select the merged range. + const range = mergedAreas.areas.getItemAt(0); + range.select(); + await context.sync(); + + // Print out the details of the `mergedAreas` range object. + console.log(`Address of the merged range: ${mergedAreas.address}`); + console.log(`Number of cells in the merged range: ${mergedAreas.cellCount}`); + + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + // Create a table. + const data = [ + ["Product chart", "", "", ""], + ["Product", "Qty", "Unit Price", "Total Price"], + ["Almonds", 2, 7.5, "=C4 * D4"], + ["Coffee", 1, 34.5, "=C5 * D5"], + ["Chocolate", 5, 9.56, "=C6 * D6"] + ]; + + const tableRange = sheet.getRange("B2:E6"); + tableRange.values = data; + tableRange.format.autofitColumns(); + + // Add a header row to the table. + const header = tableRange.getRow(1); + header.format.fill.color = "#4472C4"; + header.format.font.color = "white"; + + sheet.activate(); + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to create and find merged ranges in a worksheet.

+
+
+

Set up

+ +
+
+

Try it out

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-relationships.yaml b/samples/excel/42-range/range-relationships.yaml index bb5b531bc..9f6343134 100644 --- a/samples/excel/42-range/range-relationships.yaml +++ b/samples/excel/42-range/range-relationships.yaml @@ -1,19 +1,19 @@ order: 10 id: excel-range-range-relationships name: Range relationships -description: 'Shows relationships between ranges, such as bounding rectangles and intersections.' +description: Shows relationships between ranges, such as bounding rectangles and intersections. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#bounding-rect").click(() => tryCatch(boundingRect)); - $("#intersection").click(() => tryCatch(intersection)); - $("#offset-range").click(() => tryCatch(offsetRange)); - $("#resized-range").click(() => tryCatch(resizedRange)); - $("#create-sales-contest-charts").click(() => tryCatch(createContestCharts)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("bounding-rect").addEventListener("click", () => tryCatch(boundingRect)); + document.getElementById("intersection").addEventListener("click", () => tryCatch(intersection)); + document.getElementById("offset-range").addEventListener("click", () => tryCatch(offsetRange)); + document.getElementById("resized-range").addEventListener("click", () => tryCatch(resizedRange)); + document.getElementById("create-sales-contest-charts").addEventListener("click", () => tryCatch(createContestCharts)); async function boundingRect() { await Excel.run(async (context) => { @@ -99,7 +99,7 @@ script: await context.sync(); if (asianContestRange.isNullObject) { - // See the declaration of this method for how to + // See the declaration of this function for how to // test this code path. reportMissingData("Asian"); } else { @@ -113,7 +113,7 @@ script: } if (europeanContestRange.isNullObject) { - // See the declaration of this method for how to + // See the declaration of this function for how to // test this code path. reportMissingData("European"); } else { @@ -147,7 +147,7 @@ script: } function reportMissingData(continent: string) { - // To test this method, + // To test this function, // (1) Press "Create Table" // (2) Delete data from the rows for one continent, // INCLUDING THE "Sales Team" COLUMN VALUES. @@ -204,18 +204,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to do various operations on ranges, for example, getting the bounding rect of two ranges.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -248,15 +246,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/42-range/range-remove-duplicates.yaml b/samples/excel/42-range/range-remove-duplicates.yaml index 1d61d4180..b3227be4f 100644 --- a/samples/excel/42-range/range-remove-duplicates.yaml +++ b/samples/excel/42-range/range-remove-duplicates.yaml @@ -6,11 +6,11 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#delete-name").click(() => tryCatch(deleteName)); - $("#delete-distributor").click(() => tryCatch(deleteDistributor)); + document.getElementById("delete-name").addEventListener("click", () => tryCatch(deleteName)); + document.getElementById("delete-distributor").addEventListener("click", () => tryCatch(deleteDistributor)); async function deleteName() { await Excel.run(async (context) => { @@ -83,19 +83,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to remove rows with duplicate column values from a range.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -119,15 +117,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/range-text-orientation.yaml b/samples/excel/42-range/range-text-orientation.yaml index 7211ee30b..60ef84009 100644 --- a/samples/excel/42-range/range-text-orientation.yaml +++ b/samples/excel/42-range/range-text-orientation.yaml @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#set-text-orientation").click(() => tryCatch(setTextOrientation)); - $("#get-text-orientation").click(() => tryCatch(getTextOrientation)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-text-orientation").addEventListener("click", () => tryCatch(setTextOrientation)); + document.getElementById("get-text-orientation").addEventListener("click", () => tryCatch(getTextOrientation)); async function setTextOrientation() { await Excel.run(async (context) => { @@ -75,19 +75,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to set and get the text orientation within a range.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -113,15 +111,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/selected-range.yaml b/samples/excel/42-range/selected-range.yaml index 4c14a5798..cc469f680 100644 --- a/samples/excel/42-range/selected-range.yaml +++ b/samples/excel/42-range/selected-range.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#get-selection").click(() => tryCatch(getSelection)); - $("#set-selection").click(() => tryCatch(setSelection)); + content: |- + document.getElementById("get-selection").addEventListener("click", () => tryCatch(getSelection)); + document.getElementById("set-selection").addEventListener("click", () => tryCatch(setSelection)); async function getSelection() { await Excel.run(async (context) => { @@ -45,12 +45,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to get and set the currently selected range.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -73,15 +72,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/set-get-values.yaml b/samples/excel/42-range/set-get-values.yaml index b9c1d91fc..373aa4107 100644 --- a/samples/excel/42-range/set-get-values.yaml +++ b/samples/excel/42-range/set-get-values.yaml @@ -7,17 +7,17 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - - $("#set-value").click(() => tryCatch(setValue)); - $("#set-values").click(() => tryCatch(setValues)); - $("#set-formula").click(() => tryCatch(setFormula)); - $("#set-formulas").click(() => tryCatch(setFormulas)); - $("#set-formulas-r1c1").click(() => tryCatch(setFormulasR1C1)); - $("#get-values").click(() => tryCatch(getValues)); - $("#get-texts").click(() => tryCatch(getTexts)); - $("#get-formulas").click(() => tryCatch(getFormulas)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + document.getElementById("set-value").addEventListener("click", () => tryCatch(setValue)); + document.getElementById("set-values").addEventListener("click", () => tryCatch(setValues)); + document.getElementById("set-formula").addEventListener("click", () => tryCatch(setFormula)); + document.getElementById("set-formulas").addEventListener("click", () => tryCatch(setFormulas)); + document.getElementById("set-formulas-r1c1").addEventListener("click", () => tryCatch(setFormulasR1C1)); + document.getElementById("get-values").addEventListener("click", () => tryCatch(getValues)); + document.getElementById("get-texts").addEventListener("click", () => tryCatch(getTexts)); + document.getElementById("get-formulas").addEventListener("click", () => tryCatch(getFormulas)); async function setValue() { await Excel.run(async (context) => { @@ -173,21 +173,18 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to set and get values and formulas for a range.

- -
+

Set up

- -
+

Try it out

- @@ -203,9 +200,7 @@ template: -
- @@ -218,7 +213,7 @@ template:
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -230,15 +225,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/42-range/style.yaml b/samples/excel/42-range/style.yaml index 2ad8bcd6c..8ae288cd7 100644 --- a/samples/excel/42-range/style.yaml +++ b/samples/excel/42-range/style.yaml @@ -1,20 +1,20 @@ order: 14 id: excel-range-style name: Style -description: 'Creates a custom style, applies a custom and built-in styles to a range, gets style properties, and deletes the custom style.' +description: Creates a custom style, applies a custom and built-in styles to a range, gets style properties, and deletes the custom style. author: siewmoi host: EXCEL api_set: ExcelApi: '1.7' script: - content: |+ - $("#setup").click(() => tryCatch(setup)); - $("#add-new-style").click(() => tryCatch(addNewStyle)); - $("#apply-new-style").click(() => tryCatch(applyNewStyle)); - $("#apply-built-in-style").click(() => tryCatch(applyBuiltInStyle)); - $("#get-style-font").click(() => tryCatch(getStyleFontProperties)); - $("#get-style-alignment").click(() => tryCatch(getStyleAlignmentProperties)); - $("#delete-new-style").click(() => tryCatch(deleteNewStyle)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-new-style").addEventListener("click", () => tryCatch(addNewStyle)); + document.getElementById("apply-new-style").addEventListener("click", () => tryCatch(applyNewStyle)); + document.getElementById("apply-built-in-style").addEventListener("click", () => tryCatch(applyBuiltInStyle)); + document.getElementById("get-style-font").addEventListener("click", () => tryCatch(getStyleFontProperties)); + document.getElementById("get-style-alignment").addEventListener("click", () => tryCatch(getStyleAlignmentProperties)); + document.getElementById("delete-new-style").addEventListener("click", () => tryCatch(deleteNewStyle)); async function addNewStyle() { await Excel.run(async (context) => { @@ -151,56 +151,46 @@ script: console.error(error); } } - - - language: typescript template: - content: | -
+ content: |- +

This sample shows how to add, apply, get and delete styles.

- -
+

Set up

- -
+

Try it out

Add new style will throw an error if the style has already been added.

- -
+
- -
+
- -
+
- -
+
- -
+

Clean up

Delete new style throws an error if the style doesn't exist (that is, hasn't been added). Deleting the style also causes the other buttons using the style to fail.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -135,15 +133,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/44-shape/shape-create-and-delete.yaml b/samples/excel/44-shape/shape-create-and-delete.yaml index 3469e9ea7..4a07c2b60 100644 --- a/samples/excel/44-shape/shape-create-and-delete.yaml +++ b/samples/excel/44-shape/shape-create-and-delete.yaml @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#createHexagon").click(() => tryCatch(createHexagon)); - $("#createTriangle").click(() => tryCatch(createTriangle)); - $("#createSmileyFace").click(() => tryCatch(createSmileyFace)); - $("#removeAll").click(() => tryCatch(removeAll)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("createHexagon").addEventListener("click", () => tryCatch(createHexagon)); + document.getElementById("createTriangle").addEventListener("click", () => tryCatch(createTriangle)); + document.getElementById("createSmileyFace").addEventListener("click", () => tryCatch(createSmileyFace)); + document.getElementById("removeAll").addEventListener("click", () => tryCatch(removeAll)); async function createHexagon() { await Excel.run(async (context) => { @@ -90,16 +90,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to create different shapes, then delele them.

-
+

Setup

-
+

Try it out

+
+
+

Try it out

+

Add a shape to the workbook. This button adds a shape that covers the existing chart title with a new shape that contains text.

+ +
+
+

Group the new chart title together with the existing chart.

+ +
+
+

Get the active shape and display it as an image in this task pane. Make sure the chart is selected.

+ +
+
+

Image of the active shape:

+
+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/44-shape/shape-groups.yaml b/samples/excel/44-shape/shape-groups.yaml index b6d60f218..27d563fc6 100644 --- a/samples/excel/44-shape/shape-groups.yaml +++ b/samples/excel/44-shape/shape-groups.yaml @@ -6,12 +6,12 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#createShapes").click(() => tryCatch(createShapes)); - $("#groupShapes").click(() => tryCatch(groupShapes)); - $("#moveGroup").click(() => tryCatch(moveGroup)); - $("#ungroupShapes").click(() => tryCatch(ungroupShapes)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("createShapes").addEventListener("click", () => tryCatch(createShapes)); + document.getElementById("groupShapes").addEventListener("click", () => tryCatch(groupShapes)); + document.getElementById("moveGroup").addEventListener("click", () => tryCatch(moveGroup)); + document.getElementById("ungroupShapes").addEventListener("click", () => tryCatch(ungroupShapes)); async function groupShapes() { await Excel.run(async (context) => { @@ -105,10 +105,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to group and upgroup shapes in a worksheet.

-
+

Setup

-
+

Try it out

-
+

Try it out

Select an image file (JPEG or PNG).

@@ -127,15 +127,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/44-shape/shape-lines.yaml b/samples/excel/44-shape/shape-lines.yaml index 8fd8207fe..521fcaa91 100644 --- a/samples/excel/44-shape/shape-lines.yaml +++ b/samples/excel/44-shape/shape-lines.yaml @@ -7,17 +7,17 @@ api_set: ExcelApi: '1.9' script: content: |- - $("#setup").click(() => tryCatch(setup)); - $("#createShapes").click(() => tryCatch(createShapes)); - $("#addStraightLine").click(() => tryCatch(addStraightLine)); - $("#addCurvedLine").click(() => tryCatch(addCurvedLine)); - $("#arrowLine").click(() => tryCatch(arrowLine)); - $("#diamondLine").click(() => tryCatch(diamondLine)); - $("#connectStraightLine").click(() => tryCatch(connectStraightLine)); - $("#disconnectStraightLine").click(() => tryCatch(disconnectStraightLine)); - $("#connectCurvedLine").click(() => tryCatch(connectCurvedLine)); - $("#disconnectCurvedLine").click(() => tryCatch(disconnectCurvedLine)); - $("#deleteLines").click(() => tryCatch(deleteLines)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("createShapes").addEventListener("click", () => tryCatch(createShapes)); + document.getElementById("addStraightLine").addEventListener("click", () => tryCatch(addStraightLine)); + document.getElementById("addCurvedLine").addEventListener("click", () => tryCatch(addCurvedLine)); + document.getElementById("arrowLine").addEventListener("click", () => tryCatch(arrowLine)); + document.getElementById("diamondLine").addEventListener("click", () => tryCatch(diamondLine)); + document.getElementById("connectStraightLine").addEventListener("click", () => tryCatch(connectStraightLine)); + document.getElementById("disconnectStraightLine").addEventListener("click", () => tryCatch(disconnectStraightLine)); + document.getElementById("connectCurvedLine").addEventListener("click", () => tryCatch(connectCurvedLine)); + document.getElementById("disconnectCurvedLine").addEventListener("click", () => tryCatch(disconnectCurvedLine)); + document.getElementById("deleteLines").addEventListener("click", () => tryCatch(deleteLines)); async function addStraightLine() { await Excel.run(async (context) => { @@ -161,10 +161,10 @@ script: language: typescript template: content: |- -

+

This sample shows how to create and modify line shapes.

-
+

Setup

-
+

Try it out

-
+

Try it out

-
+

Try it out

- -
+

Try it out

Press the following buttons in order, so rows and columns of appropriate sizes are added.

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -165,15 +163,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/convert-range-to-table.yaml b/samples/excel/46-table/convert-range-to-table.yaml index 1e7924e1b..41472f1c0 100644 --- a/samples/excel/46-table/convert-range-to-table.yaml +++ b/samples/excel/46-table/convert-range-to-table.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#convert-range-to-table").click(() => tryCatch(convertRangeToTable)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("convert-range-to-table").addEventListener("click", () => tryCatch(convertRangeToTable)); async function convertRangeToTable() { await Excel.run(async (context) => { @@ -59,19 +59,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to convert a range to a table.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -91,15 +89,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/create-table.yaml b/samples/excel/46-table/create-table.yaml index ab0340392..fefc4246e 100644 --- a/samples/excel/46-table/create-table.yaml +++ b/samples/excel/46-table/create-table.yaml @@ -7,8 +7,8 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#create-table").click(() => tryCatch(createTable)); + content: |- + document.getElementById("create-table").addEventListener("click", () => tryCatch(createTable)); async function createTable() { await Excel.run(async (context) => { @@ -51,12 +51,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to create a table.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -76,15 +75,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/filter-data.yaml b/samples/excel/46-table/filter-data.yaml index 229a37783..6ed0d3812 100644 --- a/samples/excel/46-table/filter-data.yaml +++ b/samples/excel/46-table/filter-data.yaml @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#filter-table").click(() => tryCatch(filterTable)); - $("#clear-filters").click(() => tryCatch(clearFilters)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("filter-table").addEventListener("click", () => tryCatch(filterTable)); + document.getElementById("clear-filters").addEventListener("click", () => tryCatch(clearFilters)); async function filterTable() { await Excel.run(async (context) => { @@ -87,19 +87,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to filter the data in a table using different filter types.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -122,15 +120,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/formatting.yaml b/samples/excel/46-table/formatting.yaml index a40833fc5..7fdd568d8 100644 --- a/samples/excel/46-table/formatting.yaml +++ b/samples/excel/46-table/formatting.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#format-table").click(() => tryCatch(formatTable)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("format-table").addEventListener("click", () => tryCatch(formatTable)); async function formatTable() { await Excel.run(async (context) => { @@ -66,19 +66,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to format the different components of a table.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -98,15 +96,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/get-data-from-table.yaml b/samples/excel/46-table/get-data-from-table.yaml index 3b48ea6df..04533610a 100644 --- a/samples/excel/46-table/get-data-from-table.yaml +++ b/samples/excel/46-table/get-data-from-table.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#get-data-from-table").click(() => tryCatch(getData)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("get-data-from-table").addEventListener("click", () => tryCatch(getData)); async function getData() { await Excel.run(async (context) => { @@ -79,29 +79,25 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to get data from a table and write it to the sheet.

- -
+

Set up

- -
+

Try it out

- - language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -113,15 +109,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml b/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml index c719c7902..64d67cb9e 100644 --- a/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml +++ b/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml @@ -7,11 +7,11 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: |+ - $("#create-table").click(() => tryCatch(createTable)); - $("#filter-table").click(() => tryCatch(filterTable)); - $("#get-range").click(() => tryCatch(getRange)); - $("#get-visible-range").click(() => tryCatch(getVisibleRange)); + content: |- + document.getElementById("create-table").addEventListener("click", () => tryCatch(createTable)); + document.getElementById("filter-table").addEventListener("click", () => tryCatch(filterTable)); + document.getElementById("get-range").addEventListener("click", () => tryCatch(getRange)); + document.getElementById("get-visible-range").addEventListener("click", () => tryCatch(getVisibleRange)); async function getVisibleRange() { await Excel.run(async (context) => { @@ -94,15 +94,13 @@ script: console.error(error); } } - language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to filter the data in a table using different filter types.

- -
+

Set up

- -
+

Try it out

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -136,15 +132,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/import-json-data.yaml b/samples/excel/46-table/import-json-data.yaml index 937fa71bb..3c6f80d16 100644 --- a/samples/excel/46-table/import-json-data.yaml +++ b/samples/excel/46-table/import-json-data.yaml @@ -7,8 +7,8 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#import-json-data").click(() => tryCatch(importJsonData)); + content: |- + document.getElementById("import-json-data").addEventListener("click", () => tryCatch(importJsonData)); async function importJsonData() { await Excel.run(async (context) => { @@ -113,21 +113,19 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to import json data into a new table.

- -
+

Try it out

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -139,15 +137,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/resize-table.yaml b/samples/excel/46-table/resize-table.yaml new file mode 100644 index 000000000..5b41656d6 --- /dev/null +++ b/samples/excel/46-table/resize-table.yaml @@ -0,0 +1,100 @@ +order: 10 +id: excel-table-resize +name: Resize a table +description: This sample shows how to resize a table. +host: EXCEL +api_set: + ExcelAPI: '1.13' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("resize-table").addEventListener("click", () => tryCatch(resizeTable)); + + async function resizeTable() { + await Excel.run(async (context) => { + // Retrieve the worksheet and a table on that worksheet. + const sheet = context.workbook.worksheets.getItem("Sample"); + const expensesTable = sheet.tables.getItem("ExpensesTable"); + + // Resize the table. + expensesTable.resize("A1:D20"); + + await context.sync(); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const expensesTable = sheet.tables.add("A1:D1", true /*hasHeaders*/); + expensesTable.name = "ExpensesTable"; + + expensesTable.getHeaderRowRange().values = [["Date", "Merchant", "Category", "Amount"]]; + + expensesTable.rows.add(null /*add at the end*/, [ + ["1/1/2017", "The Phone Company", "Communications", "$120"], + ["1/2/2017", "Northwind Electric Cars", "Transportation", "$142"], + ["1/5/2017", "Best For You Organics Company", "Groceries", "$27"], + ["1/10/2017", "Coho Vineyard", "Restaurant", "$33"], + ["1/11/2017", "Bellows College", "Education", "$350"], + ["1/15/2017", "Trey Research", "Other", "$135"], + ["1/15/2017", "Best For You Organics Company", "Groceries", "$97"] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + + await context.sync(); + }); + } + + /** 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: |- +
+

This sample shows how to resize a table.

+
+
+

Set up

+ +
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/46-table/sort-data.yaml b/samples/excel/46-table/sort-data.yaml index 255f6015c..85780b33f 100644 --- a/samples/excel/46-table/sort-data.yaml +++ b/samples/excel/46-table/sort-data.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#sort-table").click(() => tryCatch(sortTable)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("sort-table").addEventListener("click", () => tryCatch(sortTable)); async function sortTable() { await Excel.run(async (context) => { @@ -73,19 +73,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to sort the data in a table.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -105,15 +103,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/create-get-change-delete-settings.yaml b/samples/excel/50-workbook/create-get-change-delete-settings.yaml index bb393f18b..43fd23536 100644 --- a/samples/excel/50-workbook/create-get-change-delete-settings.yaml +++ b/samples/excel/50-workbook/create-get-change-delete-settings.yaml @@ -1,16 +1,16 @@ order: 2 id: excel-settings-create-get-change-delete-settings name: Add-in settings -description: 'Creates, gets, changes, and deletes settings that are unique to the specific workbook and add-in combination.' +description: Creates, gets, changes, and deletes settings that are unique to the specific workbook and add-in combination. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#create-setting").click(() => tryCatch(createSetting)); - $("#change-setting").click(() => tryCatch(changeSetting)); - $("#delete-setting").click(() => tryCatch(deleteSetting)); + content: |- + document.getElementById("create-setting").addEventListener("click", () => tryCatch(createSetting)); + document.getElementById("change-setting").addEventListener("click", () => tryCatch(changeSetting)); + document.getElementById("delete-setting").addEventListener("click", () => tryCatch(deleteSetting)); async function createSetting() { await Excel.run(async (context) => { @@ -48,7 +48,7 @@ script: await Excel.run(async (context) => { const settings = context.workbook.settings; - // The settings.add function is also how you change a + // The settings.add method is also how you change a // setting. There is no settings.setItem or setting.set // method. settings.add("NeedsReview", false); @@ -74,11 +74,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to create, get, change, and delete settings in the workbook.

- -
+

Try it out

Press the button to create and display a setting.

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -107,15 +106,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/50-workbook/create-workbook.yaml b/samples/excel/50-workbook/create-workbook.yaml index 289d412d0..6516a6b05 100644 --- a/samples/excel/50-workbook/create-workbook.yaml +++ b/samples/excel/50-workbook/create-workbook.yaml @@ -1,15 +1,15 @@ order: 4 id: excel-workbook-create-workbook name: Create workbook -description: 'Creates a new, empty workbook and creates a new workbook by copying an existing one.' +description: Creates a new, empty workbook and creates a new workbook by copying an existing one. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#create-new-blank-workbook").click(() => tryCatch(createBlankWorkbook)); - $("#file").change(() => tryCatch(createWorkbookFromExisting)); + content: |- + document.getElementById("create-new-blank-workbook").addEventListener("click", () => tryCatch(createBlankWorkbook)); + document.getElementById("file").addEventListener("change", () => tryCatch(createWorkbookFromExisting)); async function createBlankWorkbook() { await Excel.run(async (context) => { @@ -18,21 +18,21 @@ script: } async function createWorkbookFromExisting() { - const myFile = document.getElementById("file"); + const myFile = document.getElementById("file") as HTMLInputElement; const reader = new FileReader(); reader.onload = ((event) => { Excel.run(context => { - // strip off the metadata before the base64-encoded string + // Remove the metadata before the Base64-encoded string. const startIndex = reader.result.toString().indexOf("base64,"); - const mybase64 = reader.result.toString().substr(startIndex + 7); + const myBase64 = reader.result.toString().substr(startIndex + 7); - Excel.createWorkbook(mybase64); + Excel.createWorkbook(myBase64); return context.sync(); }); }); - // read in the file as a data URL so we can parse the base64-encoded string + // Read in the file as a data URL so we can parse the Base64-encoded string. reader.readAsDataURL(myFile.files[0]); } @@ -48,11 +48,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to create a new, empty workbook and how to create a new workbook by copying an existing one.

- -
+

Try it out

Create empty workbook

-
+

Try it out

-
+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -131,15 +131,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/culture-info.yaml b/samples/excel/50-workbook/culture-info.yaml index b7aaaa803..602c6e658 100644 --- a/samples/excel/50-workbook/culture-info.yaml +++ b/samples/excel/50-workbook/culture-info.yaml @@ -6,11 +6,11 @@ host: EXCEL api_set: ExcelApi: '1.11' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#display-culture-info").click(() => tryCatch(displayCultureInfo)); - $("#write-decimal").click(() => tryCatch(writeDecimal)); - $("#write-big-number").click(() => tryCatch(writeBigNumber)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("display-culture-info").addEventListener("click", () => tryCatch(displayCultureInfo)); + document.getElementById("write-decimal").addEventListener("click", () => tryCatch(writeDecimal)); + document.getElementById("write-big-number").addEventListener("click", () => tryCatch(writeBigNumber)); async function displayCultureInfo() { await Excel.run(async (context) => { @@ -108,18 +108,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to apply the cultural settings APIs to help normalize data.

- -
+

Setup

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -145,15 +143,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/data-protection.yaml b/samples/excel/50-workbook/data-protection.yaml index 07123e44a..3597277aa 100644 --- a/samples/excel/50-workbook/data-protection.yaml +++ b/samples/excel/50-workbook/data-protection.yaml @@ -6,16 +6,16 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#protect-data-in-worksheet").click(() => tryCatch(protectDataInWorksheet)); - $("#unprotect-data-in-worksheet").click(() => tryCatch(unprotectDataInWorksheet)); - $("#protect-workbook-structure").click(() => tryCatch(protectWorkbookStructure)); - $("#unprotect-workbook-structure").click(() => tryCatch(unprotectWorkbookStructure)); - $("#password-protect-data-in-worksheet").click(() => tryCatch(passwordProtectDataInWorksheet)); - $("#password-unprotect-data-in-worksheet").click(() => tryCatch(passwordUnprotectDataInWorksheet)); - $("#password-protect-workbook-structure").click(() => tryCatch(passwordProtectWorkbookStructure)); - $("#password-unprotect-workbook-structure").click(() => tryCatch(passwordUnprotectWorkbookStructure)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("protect-data-in-worksheet").addEventListener("click", () => tryCatch(protectDataInWorksheet)); + document.getElementById("unprotect-data-in-worksheet").addEventListener("click", () => tryCatch(unprotectDataInWorksheet)); + document.getElementById("protect-workbook-structure").addEventListener("click", () => tryCatch(protectWorkbookStructure)); + document.getElementById("unprotect-workbook-structure").addEventListener("click", () => tryCatch(unprotectWorkbookStructure)); + document.getElementById("password-protect-data-in-worksheet").addEventListener("click", () => tryCatch(passwordProtectDataInWorksheet)); + document.getElementById("password-unprotect-data-in-worksheet").addEventListener("click", () => tryCatch(passwordUnprotectDataInWorksheet)); + document.getElementById("password-protect-workbook-structure").addEventListener("click", () => tryCatch(passwordProtectWorkbookStructure)); + document.getElementById("password-unprotect-workbook-structure").addEventListener("click", () => tryCatch(passwordUnprotectWorkbookStructure)); async function protectDataInWorksheet() { await Excel.run(async (context) => { @@ -175,18 +175,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to protect a worksheet's data and the workbook's structure.

- -
+

Set up

- -
+

Try it out

Protect without password

@@ -251,15 +249,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/workbook-built-in-functions.yaml b/samples/excel/50-workbook/workbook-built-in-functions.yaml new file mode 100644 index 000000000..407a00492 --- /dev/null +++ b/samples/excel/50-workbook/workbook-built-in-functions.yaml @@ -0,0 +1,120 @@ +order: 10 +id: excel-workbook-built-in-function +name: Use built-in Excel functions +description: Use the VLOOKUP and SUM built-in Excel functions. +host: EXCEL +api_set: + ExcelAPI: '1.2' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("call-vlookup").addEventListener("click", () => tryCatch(callVlookup)); + document.getElementById("nest-functions").addEventListener("click", () => tryCatch(nestFunctions)); + + async function callVlookup() { + await Excel.run(async (context) => { + // This function uses VLOOKUP to find data in the "Wrench" row on the worksheet. + let range = context.workbook.worksheets.getItem("Sample").getRange("A1:D4"); + + // Get the value in the second column in the "Wrench" row. + let unitSoldInNov = context.workbook.functions.vlookup("Wrench", range, 2, false); + unitSoldInNov.load("value"); + + await context.sync(); + console.log(" Number of wrenches sold in November = " + unitSoldInNov.value); + }); + } + + async function nestFunctions() { + await Excel.run(async (context) => { + // This function uses VLOOKUP to find data in the "Wrench" row + // on the worksheet, and then it uses SUM to combine the values. + let range = context.workbook.worksheets.getItem("Sample").getRange("A1:D4"); + + // Get the values in the second, third, and fourth columns in the "Wrench" row, + // and combine those values with SUM. + let sumOfTwoLookups = context.workbook.functions.sum( + context.workbook.functions.vlookup("Wrench", range, 2, false), + context.workbook.functions.vlookup("Wrench", range, 3, false), + context.workbook.functions.vlookup("Wrench", range, 4, false) + ); + sumOfTwoLookups.load("value"); + + await context.sync(); + console.log(" Number of wrenches sold in November, December, and January = " + sumOfTwoLookups.value); + }); + } + + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const expensesTable = sheet.tables.add("A1:D1", true /*hasHeaders*/); + expensesTable.getHeaderRowRange().values = [["Product", "November", "December", "January"]]; + + expensesTable.rows.add(null /*add at the end*/, [ + ["Hammer", "23", "18", "17"], + ["Wrench", "12", "11", "14"], + ["Saw", "5", "15", "19"] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + sheet.getRange("A1").select(); + sheet.activate(); + + await context.sync(); + }); + } + + /** 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: |- +

+

This sample shows how to use and nest the built-in Excel functions VLOOKUP and SUM. The sample uses VLOOKUP to return data, and then it uses SUM to combine data returned by VLOOKUP.

+
+
+

Setup

+ +

Try it out

+

Use VLOOKUP to return the number of wrenches sold in November.

+ +

Use VLOOKUP to find the number of wrenches sold in November, December, and January, and then use SUM to combine the three values.

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/workbook-calculation.yaml b/samples/excel/50-workbook/workbook-calculation.yaml index 8a5c101cc..83e0dfb71 100644 --- a/samples/excel/50-workbook/workbook-calculation.yaml +++ b/samples/excel/50-workbook/workbook-calculation.yaml @@ -6,8 +6,14 @@ host: EXCEL api_set: ExcelApi: '1.11' script: - content: | - $("#setup").click(() => tryCatch(setup)); $("#register-onCalculated-handler").click(() => tryCatch(registerOnCalculatedHandler)); $("#recalculate-single").click(() => tryCatch(recalculateSingle)); $("#recalculate-column").click(() => tryCatch(recalculateColumn)); $("#manual-calculations").click(() => tryCatch(switchToManualCalculations)); $("#automatic-calculations").click(() => tryCatch(switchToAutomaticCalculations)); $("#force-calculation").click(() => tryCatch(forceCalculation)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("register-onCalculated-handler").addEventListener("click", () => tryCatch(registerOnCalculatedHandler)); + document.getElementById("recalculate-single").addEventListener("click", () => tryCatch(recalculateSingle)); + document.getElementById("recalculate-column").addEventListener("click", () => tryCatch(recalculateColumn)); + document.getElementById("manual-calculations").addEventListener("click", () => tryCatch(switchToManualCalculations)); + document.getElementById("automatic-calculations").addEventListener("click", () => tryCatch(switchToAutomaticCalculations)); + document.getElementById("force-calculation").addEventListener("click", () => tryCatch(forceCalculation)); async function registerOnCalculatedHandler() { await Excel.run(async (context) => { let sheet = context.workbook.worksheets.getItem("Sample"); @@ -128,20 +134,18 @@ script: language: typescript template: content: |- -
+

This sample shows how to use the calculation APIs.

- -
+

Set up

-
+

Try it out

-

Calculation events

-

Manual calculations

Try switching to manual calculation, then editing the workbook.

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -180,15 +183,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/workbook-get-active-cell.yaml b/samples/excel/50-workbook/workbook-get-active-cell.yaml index 6b56e6c76..a0d0c7f07 100644 --- a/samples/excel/50-workbook/workbook-get-active-cell.yaml +++ b/samples/excel/50-workbook/workbook-get-active-cell.yaml @@ -6,8 +6,8 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#get-active-cell").click(() => tryCatch(run)); + content: |- + document.getElementById("get-active-cell").addEventListener("click", () => tryCatch(run)); async function run() { await Excel.run(async (context) => { @@ -34,12 +34,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to get the active cell of the entire workbook.

- -
+

Try it out

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/50-workbook/workbook-save-and-close.yaml b/samples/excel/50-workbook/workbook-save-and-close.yaml index c93326fad..bccaac16a 100644 --- a/samples/excel/50-workbook/workbook-save-and-close.yaml +++ b/samples/excel/50-workbook/workbook-save-and-close.yaml @@ -6,11 +6,11 @@ host: EXCEL api_set: ExcelAPI: '1.11' script: - content: | - $("#saveWithPrompt").click(() => tryCatch(saveWithPrompt)); - $("#saveWithoutPrompt").click(() => tryCatch(saveWithoutPrompt)); - $("#closeWithSave").click(() => tryCatch(closeWithSave)); - $("#closeWithoutSave").click(() => tryCatch(closeWithoutSave)); + content: |- + document.getElementById("saveWithPrompt").addEventListener("click", () => tryCatch(saveWithPrompt)); + document.getElementById("saveWithoutPrompt").addEventListener("click", () => tryCatch(saveWithoutPrompt)); + document.getElementById("closeWithSave").addEventListener("click", () => tryCatch(closeWithSave)); + document.getElementById("closeWithoutSave").addEventListener("click", () => tryCatch(closeWithoutSave)); async function saveWithPrompt() { await Excel.run(async (context) => { @@ -48,11 +48,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to save a workbook, both with and without a prompt to the user, and how to close the workbook.

- -
+

Try it out

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -118,15 +116,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml b/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml index 904c01b51..4f31e4fcf 100644 --- a/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml +++ b/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml @@ -1,17 +1,17 @@ order: 2 id: excel-worksheet-add-delete-rename-move-worksheet -name: 'Add, delete, rename, and move worksheet' -description: 'Adds, deletes, renames, and moves a worksheet.' +name: Add, delete, rename, and move worksheet +description: Adds, deletes, renames, and moves a worksheet. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#add-worksheet").click(() => tryCatch(addWorksheet)); - $("#delete-worksheet").click(() => tryCatch(deleteWorksheet)); - $("#rename-worksheet").click(() => tryCatch(renameWorksheet)); - $("#move-worksheet").click(() => tryCatch(moveWorksheet)); + content: |- + document.getElementById("add-worksheet").addEventListener("click", () => tryCatch(addWorksheet)); + document.getElementById("delete-worksheet").addEventListener("click", () => tryCatch(deleteWorksheet)); + document.getElementById("rename-worksheet").addEventListener("click", () => tryCatch(renameWorksheet)); + document.getElementById("move-worksheet").addEventListener("click", () => tryCatch(moveWorksheet)); async function addWorksheet() { await Excel.run(async (context) => { @@ -103,12 +103,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to add, delete, rename and change the position of a worksheet.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -137,15 +136,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/54-worksheet/gridlines.yaml b/samples/excel/54-worksheet/gridlines.yaml index ed691a166..b82a15470 100644 --- a/samples/excel/54-worksheet/gridlines.yaml +++ b/samples/excel/54-worksheet/gridlines.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.8' script: - content: | - $("#hide-gridlines").click(() => tryCatch(hideGridlines)); - $("#show-gridlines").click(() => tryCatch(showGridlines)); + content: |- + document.getElementById("hide-gridlines").addEventListener("click", () => tryCatch(hideGridlines)); + document.getElementById("show-gridlines").addEventListener("click", () => tryCatch(showGridlines)); async function hideGridlines() { await Excel.run(async (context) => { @@ -41,12 +41,11 @@ script: } language: typescript template: - content: |+ -
+ content: |- +

This sample shows how to hide and show gridlines within a worksheet.

- -
+

Try it out

- language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -72,15 +70,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/list-worksheets.yaml b/samples/excel/54-worksheet/list-worksheets.yaml index 50e56f674..6bda99375 100644 --- a/samples/excel/54-worksheet/list-worksheets.yaml +++ b/samples/excel/54-worksheet/list-worksheets.yaml @@ -7,8 +7,8 @@ host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#list-worksheets").click(() => tryCatch(listWorksheets)); + content: |- + document.getElementById("list-worksheets").addEventListener("click", () => tryCatch(listWorksheets)); async function listWorksheets() { await Excel.run(async (context) => { @@ -40,12 +40,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to list the names of the worksheets in the workbook.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -65,15 +64,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml b/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml index da01e093a..b1eb24c61 100644 --- a/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml +++ b/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.5' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#compare-current-and-previous-year").click(() => tryCatch(compareCurrentWithPreviousTax)); - $("#compare-first-and-last-year").click(() => tryCatch(compareFirstWithMostRecentTaxRate)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("compare-current-and-previous-year").addEventListener("click", () => tryCatch(compareCurrentWithPreviousTax)); + document.getElementById("compare-first-and-last-year").addEventListener("click", () => tryCatch(compareFirstWithMostRecentTaxRate)); async function setup() { await Excel.run(async (context) => { @@ -119,19 +119,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to get a reference to a sheet using its relative worksheet position.

- -
+

Set up

- -
+

Try it out

Select any of the three worksheets for 2015, 1016, or 2017 and press the button to compare the tax due on the current sheet with the previous sheet.

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -156,15 +154,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/tab-color.yaml b/samples/excel/54-worksheet/tab-color.yaml index 7e2656a1f..eee99f9b4 100644 --- a/samples/excel/54-worksheet/tab-color.yaml +++ b/samples/excel/54-worksheet/tab-color.yaml @@ -7,11 +7,11 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#set-tab-color-to-hex-color").click(() => tryCatch(setTabColorToHexColor)); - $("#set-tab-color-to-named-color").click(() => tryCatch(setTabColorToNamedColor)); - $("#set-tab-color-to-default-color").click(() => tryCatch(setTabColorToDefaultColor)); - $("#get-tab-color").click(() => tryCatch(getTabColor)); + content: |- + document.getElementById("set-tab-color-to-hex-color").addEventListener("click", () => tryCatch(setTabColorToHexColor)); + document.getElementById("set-tab-color-to-named-color").addEventListener("click", () => tryCatch(setTabColorToNamedColor)); + document.getElementById("set-tab-color-to-default-color").addEventListener("click", () => tryCatch(setTabColorToDefaultColor)); + document.getElementById("get-tab-color").addEventListener("click", () => tryCatch(getTabColor)); async function setTabColorToHexColor() { await Excel.run(async (context) => { @@ -65,11 +65,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to set and get the tab color of a worksheet.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -101,15 +100,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/worksheet-auto-filter.yaml b/samples/excel/54-worksheet/worksheet-auto-filter.yaml index bb4178d93..1450908f8 100644 --- a/samples/excel/54-worksheet/worksheet-auto-filter.yaml +++ b/samples/excel/54-worksheet/worksheet-auto-filter.yaml @@ -6,20 +6,47 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#add-auto-filter").click(() => tryCatch(addAutoFilter)); - $("#randomize-data").click(() => tryCatch(randomizeData)); - $("#refresh-auto-filter").click(() => tryCatch(refreshAutoFilter)); - $("#remove-auto-filter").click(() => tryCatch(removeAutoFilter)); - - async function addAutoFilter() { + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-percent-auto-filter").addEventListener("click", () => tryCatch(addPercentAutoFilter)); + document.getElementById("add-custom-auto-filter").addEventListener("click", () => tryCatch(addCustomAutoFilter)); + document.getElementById("randomize-data").addEventListener("click", () => tryCatch(randomizeData)); + document.getElementById("refresh-auto-filter").addEventListener("click", () => tryCatch(refreshAutoFilter)); + document.getElementById("clear-single-auto-filter").addEventListener("click", () => tryCatch(clearSingleAutoFilter)); + document.getElementById("remove-all-auto-filters").addEventListener("click", () => tryCatch(removeAllAutoFilters)); + + async function addPercentAutoFilter() { + // This function adds a percentage AutoFilter to the active worksheet + // and applies the filter to a column of the used range. + await Excel.run(async (context) => { + // Retrieve the active worksheet and the used range on that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const farmData = sheet.getUsedRange(); + + // Add a filter that will only show the rows with the top 50% of values in column 3. + sheet.autoFilter.apply(farmData, 3, { + criterion1: "50", + filterOn: Excel.FilterOn.topPercent + }); + + await context.sync(); + }); + } + + async function addCustomAutoFilter() { + // This function adds a custom AutoFilter to the active worksheet + // and applies the filter to a column of the used range. await Excel.run(async (context) => { + // Retrieve the active worksheet and the used range on that worksheet. const sheet = context.workbook.worksheets.getActiveWorksheet(); const farmData = sheet.getUsedRange(); - // This filter will only show the rows with the top 25% of values in column 3. - sheet.autoFilter.apply(farmData, 3, { criterion1: "25", filterOn: Excel.FilterOn.topPercent }); + // Add a filter that will only show the rows with values that end with the letter "e" in column 1. + sheet.autoFilter.apply(farmData, 1, { + criterion1: "=*e", + filterOn: Excel.FilterOn.custom + }); + await context.sync(); }); } @@ -40,16 +67,36 @@ script: } async function refreshAutoFilter() { + // This function refreshes the AutoFilter to ensure that changes are captured. await Excel.run(async (context) => { + // Retrieve the active worksheet. const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Reapply the filter to capture changes. sheet.autoFilter.reapply(); await context.sync(); }); } - async function removeAutoFilter() { + async function clearSingleAutoFilter() { + // This function clears the AutoFilter setting from one column. await Excel.run(async (context) => { + // Retrieve the active worksheet. const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Clear the filter from only column 3. + sheet.autoFilter.clearColumnCriteria(3); + await context.sync(); + }); + } + + async function removeAllAutoFilters() { + // This function removes all AutoFilters from the active worksheet. + await Excel.run(async (context) => { + // Retrieve the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Remove all filters. sheet.autoFilter.remove(); await context.sync(); }); @@ -83,11 +130,13 @@ script: ["F Farms", "Kiwi", "Organic", 150], ["F Farms", "Lemon", "Conventional", 270] ]; + const range = dataSheet.getRange("A1:D21"); range.values = data; dataSheet.getRange("A1:D1").format.font.bold = true; range.format.autofitColumns(); dataSheet.activate(); + await context.sync(); }); } @@ -104,38 +153,46 @@ script: language: typescript template: content: |- -
-

This sample shows how to work with an AutoFilter on a worksheet.

+
+

This sample shows how to work with an AutoFilter on a worksheet.

- -
-

Setup

-
-
-

Try it out

- -

- +

+ +

+

When the data in the worksheet or table changes, the AutoFilter needs to be refreshed by your add-in.

+ +

+ +

+ -

-

When the data in the worksheet or table changes, the AutoFilter needs to be refreshed by your add-in.

- -

-

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -147,15 +204,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/worksheet-copy.yaml b/samples/excel/54-worksheet/worksheet-copy.yaml index bd11af31b..5a3cc6818 100644 --- a/samples/excel/54-worksheet/worksheet-copy.yaml +++ b/samples/excel/54-worksheet/worksheet-copy.yaml @@ -6,9 +6,9 @@ host: EXCEL api_set: ExcelApi: '1.7' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#copy-worksheet").click(() => tryCatch(run)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("copy-worksheet").addEventListener("click", () => tryCatch(run)); async function run() { await Excel.run(async (context) => { @@ -66,18 +66,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to copy a worksheet.

- -
+

Set up

- -
+

Try it out

-
+

Try it out

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -171,15 +169,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/54-worksheet/worksheet-page-layout.yaml b/samples/excel/54-worksheet/worksheet-page-layout.yaml index 64c36ead9..f94c050d7 100644 --- a/samples/excel/54-worksheet/worksheet-page-layout.yaml +++ b/samples/excel/54-worksheet/worksheet-page-layout.yaml @@ -6,15 +6,15 @@ host: EXCEL api_set: ExcelApi: '1.9' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#setPageBreaks").click(() => tryCatch(setPageBreaks)); - $("#center").click(() => tryCatch(center)); - $("#setBlackAndWhite").click(() => tryCatch(setBlackAndWhite)); - $("#setPrintTitleRow").click(() => tryCatch(setPrintTitleRow)); - $("#setPrintArea").click(() => tryCatch(setPrintArea)); - $("#changeOrientation").click(() => tryCatch(changeOrientation)); - $("#setZoom").click(() => tryCatch(setZoom)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("setPageBreaks").addEventListener("click", () => tryCatch(setPageBreaks)); + document.getElementById("center").addEventListener("click", () => tryCatch(center)); + document.getElementById("setBlackAndWhite").addEventListener("click", () => tryCatch(setBlackAndWhite)); + document.getElementById("setPrintTitleRow").addEventListener("click", () => tryCatch(setPrintTitleRow)); + document.getElementById("setPrintArea").addEventListener("click", () => tryCatch(setPrintArea)); + document.getElementById("changeOrientation").addEventListener("click", () => tryCatch(changeOrientation)); + document.getElementById("setZoom").addEventListener("click", () => tryCatch(setZoom)); async function setPageBreaks() { await Excel.run(async (context) => { @@ -145,16 +145,16 @@ script: language: typescript template: content: |- -
+

This sample shows how to change page layout and other settings for printing a worksheet.

-
+

Setup

-
+

Try it out

In Excel, choose View > Page Layout, then observe the page layout changes as you press the following buttons.

@@ -202,15 +202,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/54-worksheet/worksheet-range-cell.yaml b/samples/excel/54-worksheet/worksheet-range-cell.yaml index 176fe8714..5e6e7340d 100644 --- a/samples/excel/54-worksheet/worksheet-range-cell.yaml +++ b/samples/excel/54-worksheet/worksheet-range-cell.yaml @@ -1,19 +1,19 @@ order: 7 id: excel-worksheet-worksheet-range-cell name: Get range or cell -description: 'Gets the used range, the entire range of a worksheet, the specified range, and the specified cell.' +description: Gets the used range, the entire range of a worksheet, the specified range, and the specified cell. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - $("#get-used-range").click(() => tryCatch(getUsedRange)); - $("#get-entire-range").click(() => tryCatch(getEntireRange)); - $("#get-range").click(() => tryCatch(getRange)); - $("#get-cell").click(() => tryCatch(getCell)); + document.getElementById("get-used-range").addEventListener("click", () => tryCatch(getUsedRange)); + document.getElementById("get-entire-range").addEventListener("click", () => tryCatch(getEntireRange)); + document.getElementById("get-range").addEventListener("click", () => tryCatch(getRange)); + document.getElementById("get-cell").addEventListener("click", () => tryCatch(getCell)); async function getUsedRange() { await Excel.run(async (context) => { @@ -101,19 +101,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to get a range or a cell in a worksheet.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -142,15 +140,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/54-worksheet/worksheet-visibility.yaml b/samples/excel/54-worksheet/worksheet-visibility.yaml index 2dafa0639..15dd5af96 100644 --- a/samples/excel/54-worksheet/worksheet-visibility.yaml +++ b/samples/excel/54-worksheet/worksheet-visibility.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#hide-worksheet").click(() => tryCatch(hideWorksheet)); - $("#unhide-worksheet").click(() => tryCatch(unhideWorksheet)); + content: |- + document.getElementById("hide-worksheet").addEventListener("click", () => tryCatch(hideWorksheet)); + document.getElementById("unhide-worksheet").addEventListener("click", () => tryCatch(unhideWorksheet)); async function hideWorksheet() { await Excel.run(async (context) => { @@ -82,19 +82,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to change the visbility of a worksheet.

- -
+

Set up

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -117,15 +115,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml b/samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml deleted file mode 100644 index c6000cd21..000000000 --- a/samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml +++ /dev/null @@ -1,84 +0,0 @@ -order: 1 -id: excel-workbook-insert-external-worksheets -name: Insert external worksheets -description: Inserts worksheets from another workbook into the current workbook. -host: EXCEL -api_set: - ExcelAPI: '1.13' -script: - content: | - $("#file").change(() => tryCatch(insertSheets)); - - async function insertSheets() { - const myFile = document.getElementById("file"); - const reader = new FileReader(); - - reader.onload = (event) => { - Excel.run((context) => { - // strip off the metadata before the base64-encoded string - const startIndex = reader.result.toString().indexOf("base64,"); - const workbookContents = reader.result.toString().substr(startIndex + 7); - - const sheets = context.workbook.worksheets; - sheets.addFromBase64( - workbookContents, - null, // get all the worksheets - Excel.WorksheetPositionType.end // insert them after the current workbook's worksheets - ); - return context.sync(); - }); - }; - - // read in the file as a data URL so we can parse the base64-encoded string - reader.readAsDataURL(myFile.files[0]); - } - - /** 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: |- -
-

This sample shows how to copy the worksheets from an existing workbook into the current workbook.

-
- -
-

Try it out

-

Select an Excel workbook to copy its worksheets into the current workbook.

-
- -
-
- 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/beta/hosted/office.js - @types/office-js-preview - - 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 \ No newline at end of file diff --git a/samples/excel/90-scenarios/currency-converter.yaml b/samples/excel/90-scenarios/currency-converter.yaml index 7e57e9818..70f09cc0f 100644 --- a/samples/excel/90-scenarios/currency-converter.yaml +++ b/samples/excel/90-scenarios/currency-converter.yaml @@ -7,7 +7,7 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | + content: |- /* * Copyright (c) Riwut Libinuko. All rights reserved. Licensed under the MIT license. */ @@ -17,8 +17,8 @@ script: let tableSetup: Record = {}; - $("#convert").click(() => tryCatch(convert)); - $("#setup").click(() => tryCatch(setupSample)); + document.getElementById("convert").addEventListener("click", () => tryCatch(convert)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setupSample)); /** Main converting function **/ async function convert() { @@ -141,26 +141,23 @@ script: } language: typescript template: - content: | -
+ content: |- +

Simple Currency Converter

- -
+

Simple currency converter shows how to read data from a transaction table, and uses currency converter API to calculate the amount in base currency.

The code also performs table validation and identify if the table has predefined headers. You can try to to rearrange the the column, and see by yourself!

- -
+

Set up

- -
+

Try it out

The currency conversion is provided by exchangeratesapi.io which uses exchange rate data published by the European Central Bank. Click "Convert"

@@ -183,12 +180,8 @@ style: 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 - moment@2.18.1 - moment-msdate@0.2.2 \ No newline at end of file + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css + moment@2.18.1 + moment-msdate@0.2.2 diff --git a/samples/excel/90-scenarios/multiple-property-set.yaml b/samples/excel/90-scenarios/multiple-property-set.yaml index fc6a4c6b6..56c6c6e30 100644 --- a/samples/excel/90-scenarios/multiple-property-set.yaml +++ b/samples/excel/90-scenarios/multiple-property-set.yaml @@ -7,10 +7,10 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#set-multiple-properties-with-object").click(() => tryCatch(setMultiplePropertiesWithObject)); - $("#copy-properties-from-range").click(() => tryCatch(copyPropertiesFromRange)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("set-multiple-properties-with-object").addEventListener("click", () => tryCatch(setMultiplePropertiesWithObject)); + document.getElementById("copy-properties-from-range").addEventListener("click", () => tryCatch(copyPropertiesFromRange)); async function setMultiplePropertiesWithObject() { await Excel.run(async (context) => { @@ -94,19 +94,17 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to format a range.

- -
+

Set up

- -
+

Try it out

- -
+
+

Performance settings

+ +

+ +

+ +

+

Try it out

-

- +

+

language: html @@ -115,15 +182,12 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - core-js@2.4.1/client/core.min.js - @types/core-js + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/@microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js + https://unpkg.com/@microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts \ No newline at end of file diff --git a/samples/excel/90-scenarios/report-generation.yaml b/samples/excel/90-scenarios/report-generation.yaml index 2add48209..749d8b54e 100644 --- a/samples/excel/90-scenarios/report-generation.yaml +++ b/samples/excel/90-scenarios/report-generation.yaml @@ -1,14 +1,14 @@ order: 2 id: excel-scenarios-report-generation name: Report generation -description: 'Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data.' +description: Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data. author: OfficeDev host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#create-report").click(() => tryCatch(createReport)); + content: |- + document.getElementById("create-report").addEventListener("click", () => tryCatch(createReport)); /** Load sample data into a new worksheet and create a chart */ async function createReport() { @@ -120,11 +120,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to load sample data into the worksheet, and then create a chart.

- -
+

Try it out

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -135,18 +127,13 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - core-js@2.4.1/client/core.min.js - @types/core-js + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css - jquery@3.1.1 - @types/jquery@3.3.1 - moment@2.18.1 - moment-msdate@0.2.2 \ No newline at end of file + moment@2.18.1 + moment-msdate@0.2.2 diff --git a/samples/excel/99-just-for-fun/color-wheel.yaml b/samples/excel/99-just-for-fun/color-wheel.yaml index b63475a5b..2e6b62749 100644 --- a/samples/excel/99-just-for-fun/color-wheel.yaml +++ b/samples/excel/99-just-for-fun/color-wheel.yaml @@ -7,9 +7,9 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#wheel").click(wheelGo); - $("#stop").click(wheelStop); + content: |- + document.getElementById("wheel").addEventListener("click", wheelGo); + document.getElementById("stop").addEventListener("click", wheelStop); let isStopped: boolean @@ -52,7 +52,7 @@ script: theWheel.legend.visible = false; let points = theWheel.series.getItemAt(0).points; - for (var i = 0; i < numberOfSlices; i++) { + for (let i = 0; i < numberOfSlices; i++) { points.getItemAt(i).format.fill.setSolidColor("black") } @@ -86,13 +86,13 @@ script: } async function loopThroughColors(points: Excel.ChartPointsCollection, max, colorGenerator: (i: number) => string) { - for (var i = 0; i < max; i++) { + for (let i = 0; i < max; i++) { if (isStopped) { return; } - var X = i % numberOfSlices; + let X = i % numberOfSlices; await pause(pauseLength); - var color = colorGenerator(i); + let color = colorGenerator(i); points.getItemAt(X).format.fill.setSolidColor(color); await points.context.sync(); } @@ -111,8 +111,10 @@ script: } language: typescript template: - content: |+ -

Spin the rainbow wheel

+ content: |- +
+

Spin the rainbow wheel

+

- language: html style: - content: | + content: |- h2:not(:first-child) { margin-top: 35px; } @@ -142,15 +143,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/99-just-for-fun/gradient.yaml b/samples/excel/99-just-for-fun/gradient.yaml index d4720d92e..619402144 100644 --- a/samples/excel/99-just-for-fun/gradient.yaml +++ b/samples/excel/99-just-for-fun/gradient.yaml @@ -8,15 +8,14 @@ api_set: ExcelApi: '1.4' script: content: |- - initializeColorPickers(); + // Set up the click handler. + document.getElementById("draw-gradient").addEventListener("click", drawGradient); + document.getElementById("random").addEventListener("click", randomizeColors); - // Set up the click handler: - const $drawButton = $("#draw-gradient").click(drawGradient); - $("#random").click(randomizeColors); - - /** Click-handler for drawing the gradient */ + /** Click-handler for drawing the gradient. */ async function drawGradient() { - $drawButton.prop("disabled", true); + const drawButton = document.getElementById("draw-gradient") as HTMLButtonElement; + drawButton.disabled = true; try { await Excel.run(drawGradientHelper); @@ -24,10 +23,10 @@ script: console.log(error); } - $drawButton.prop("disabled", false); + drawButton.disabled = false; } - /** Helper function to do the actual gradient-drawing */ + /** Helper function to do the actual gradient-drawing. */ async function drawGradientHelper(context: Excel.RequestContext) { context.workbook.worksheets.getItemOrNullObject("Gradient").delete(); const sheet = context.workbook.worksheets.add("Gradient"); @@ -40,9 +39,21 @@ script: } }); - let originalSize = parseInt($("#size").val() as string); + let originalSize = parseInt((document.getElementById("size") as HTMLInputElement).value); const colors2D = createColorArray(originalSize); + // Retrieve color values from elements. + const topLeftColor = (document.getElementById("top-left") as HTMLInputElement).value; + const topRightColor = (document.getElementById("top-right") as HTMLInputElement).value; + const bottomLeftColor = (document.getElementById("bottom-left") as HTMLInputElement).value; + const bottomRightColor = (document.getElementById("bottom-right") as HTMLInputElement).value; + + // Convert HEX colors to RGB using TinyColor. + const topLeftRgb = tinycolor(topLeftColor).toRgb(); + const topRightRgb = tinycolor(topRightColor).toRgb(); + const bottomLeftRgb = tinycolor(bottomLeftColor).toRgb(); + const bottomRightRgb = tinycolor(bottomRightColor).toRgb(); + if (Office.context.requirements.isSetSupported("ExcelApi", "1.9")) { // ExcelApi 1.9 introduced the setCellProperties APIs to efficiently set different properties // across a range without needing to iterate cell-by-cell. @@ -73,21 +84,33 @@ script: } function createColorArray(size: number): string[][] { - // Create a 2D in-memory array to hold the colors + // Create a 2D in-memory array to hold the colors. let colors2D = Array(size); for (let row = 0; row < size; row++) { colors2D[row] = Array(size); } + // Get the color values from the color pickers. + const topLeftColor = (document.getElementById("top-left") as HTMLInputElement).value; + const topRightColor = (document.getElementById("top-right") as HTMLInputElement).value; + const bottomLeftColor = (document.getElementById("bottom-left") as HTMLInputElement).value; + const bottomRightColor = (document.getElementById("bottom-right") as HTMLInputElement).value; + + // Convert HEX to RGB using TinyColor. + const topLeftRgb = tinycolor(topLeftColor).toRgb(); + const topRightRgb = tinycolor(topRightColor).toRgb(); + const bottomLeftRgb = tinycolor(bottomLeftColor).toRgb(); + const bottomRightRgb = tinycolor(bottomRightColor).toRgb(); + const topColors = getColorsArray( - $("#top-left").spectrum("get").toRgb(), - $("#top-right").spectrum("get").toRgb(), + topLeftRgb, + topRightRgb, size ); const bottomColors = getColorsArray( - $("#bottom-left").spectrum("get").toRgb(), - $("#bottom-right").spectrum("get").toRgb(), + bottomLeftRgb, + bottomRightRgb, size ); @@ -101,9 +124,9 @@ script: return colors2D; } - /** Helper function to get an array of colors */ - function getColorsArray(color1: ColorFormats.RGB, color2: ColorFormats.RGB, count: number) { - const result = new Array(count); + /** Helper function to get an array of colors. */ + function getColorsArray(color1, color2, count: number) { + const result = new Array(count); for (let i = 0; i < count; i++) { const fraction = i / (count - 1); result[i] = { @@ -115,58 +138,55 @@ script: return result; } - function initializeColorPickers() { - $("#color-table input[type='text']").spectrum({ - preferredFormat: "rgb", - showInput: true - }); - } - function randomizeColors() { - $("#color-table input[type='text']").each((index, element) => { - $(element).spectrum("set", tinycolor.random().toHexString()); + // Select all color input elements. + const colorInputs = document.querySelectorAll("#color-table input[type='color']"); + + // Iterate through each color input and set a random color. + colorInputs.forEach((input) => { + const randomColor = tinycolor.random().toHexString(); + (input as HTMLInputElement).value = randomColor; }); } language: typescript template: content: |- -

Color configuration

- -
-
Top left
- - - - - - - - - -
-
- Bottom right +
+

Color configuration

+
+
+
+
Top left
+ + + + + + + + + +
+
+ Bottom right +
-
- - - -

Size - (width x height) -

- - - - -
-
- Uses the Spectrum color picker, and the TinyColor libraries. + +

Size + (width x height) +

+ + +
+
+ Uses the TinyColor library. +
-
+
language: html style: content: |- @@ -208,19 +228,10 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css - tinycolor2@1.4.1/tinycolor.js + https://unpkg.com/tinycolor2@1.4.1/tinycolor.js @types/tinycolor2 - spectrum-colorpicker@1.8.0/spectrum.js - spectrum-colorpicker@1.8.0/spectrum.css - @types/spectrum diff --git a/samples/excel/99-just-for-fun/path-finder-game.yaml b/samples/excel/99-just-for-fun/path-finder-game.yaml index b63a27b27..812b2fdfd 100644 --- a/samples/excel/99-just-for-fun/path-finder-game.yaml +++ b/samples/excel/99-just-for-fun/path-finder-game.yaml @@ -7,12 +7,11 @@ host: EXCEL api_set: ExcelApi: '1.4' script: - content: | - $("#setup").click(setup); - $("#repeat").click(repeat); - - const $pruneTheGrid = $("#step-by-step").click(pruneTheGrid); - const $allAtOnce = $("#all-at-once").click(allAtOnce); + content: |- + document.getElementById("setup").addEventListener("click", setup); + document.getElementById("repeat").addEventListener("click", repeat); + document.getElementById("step-by-step").addEventListener("click", pruneTheGrid); + document.getElementById("all-at-once").addEventListener("click", allAtOnce); const GRID_ROW_COUNT = 25; const GRID_COLUMN_COUNT = 30; @@ -20,7 +19,7 @@ script: let matrixPrevious: string[][] function setup() { - const density = parseInt($("#density").val() as string) / 100; + const density = parseInt((document.getElementById("density") as HTMLInputElement).value) / 100; const symbol = "\u25cf"; const matrix = new Array(GRID_ROW_COUNT); @@ -32,7 +31,7 @@ script: } matrixPrevious = matrix; - $("#repeat").show(); + document.getElementById("repeat").style.display = "block"; setupHelper(matrix); } @@ -71,7 +70,8 @@ script: } async function pruneTheGrid() { - $pruneTheGrid.attr("disabled", "true"); + const pruneTheGrid = document.getElementById("step-by-step") as HTMLButtonElement; + pruneTheGrid.disabled = true; await tryCatch(() => Excel.run(async (context) => { const grid = context.workbook.worksheets @@ -84,11 +84,12 @@ script: await context.sync(); })); - $pruneTheGrid.removeAttr("disabled"); + pruneTheGrid.disabled = false; } async function allAtOnce() { - $allAtOnce.attr("disabled", "true"); + const allAtOnce = document.getElementById("all-at-once") as HTMLButtonElement; + allAtOnce.disabled = true; let counter = 0; await tryCatch(() => Excel.run(async (context) => { @@ -111,7 +112,7 @@ script: })); console.log("Count of iterations: " + counter); - $allAtOnce.removeAttr("disabled"); + allAtOnce.disabled = false; } @@ -174,13 +175,12 @@ script: } language: typescript template: - content: | -
+ content: |- +

Check whether there is a path from left to right, moving forward one cell at a time (and only straight or diagonally).

-

Set up

-
+
Circle density (%)

-

Find the path:

-
+

- @@ -221,15 +219,9 @@ style: margin-bottom: 0; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/99-just-for-fun/patterns.yaml b/samples/excel/99-just-for-fun/patterns.yaml index 282e7cbaf..76399f6c7 100644 --- a/samples/excel/99-just-for-fun/patterns.yaml +++ b/samples/excel/99-just-for-fun/patterns.yaml @@ -8,9 +8,9 @@ api_set: ExcelApi: '1.4' script: content: |- - $("#squares").click(() => tryCatch(drawSquares)); - $("#spiral").click(() => tryCatch(drawSpiral)); - $("#decoration").click(() => tryCatch(drawDecoration)); + document.getElementById("squares").addEventListener("click", () => tryCatch(drawSquares)); + document.getElementById("spiral").addEventListener("click", () => tryCatch(drawSpiral)); + document.getElementById("decoration").addEventListener("click", () => tryCatch(drawDecoration)); async function drawSquares() { await Excel.run(async (context) => { @@ -20,9 +20,9 @@ script: sheet.activate(); formatBackground(sheet); - const size = parseInt($("#size").val() as string); + const size = parseInt((document.getElementById("size") as HTMLInputElement).value); - for (var i = 0; i < size; i++) { + for (let i = 0; i < size; i++) { const width = size * 2 - 2 * i; const colors = [ rgb(30 + Math.floor(225 / size * i), 0, 0), @@ -45,7 +45,7 @@ script: sheet.activate(); formatBackground(sheet); - const size = Math.floor(parseInt($("#size").val() as string) / 2); + const size = Math.floor(parseInt((document.getElementById("size") as HTMLInputElement).value) / 2); for (let i = 0; i < size - 1; i++) { @@ -106,15 +106,15 @@ script: sheet.activate(); formatBackground(sheet); - const size = Math.floor(parseInt($("#size").val() as string) / 2); + const size = Math.floor(parseInt((document.getElementById("size") as HTMLInputElement).value) / 2); - for (var i = 0; i < size; i++) { + for (let i = 0; i < size; i++) { const range1 = sheet.getCell(2 * i + 1, 2 * i + 1).getResizedRange(size - i, size - i); const range2 = sheet.getCell(2 * i + 1, 3 * size - i).getResizedRange(size - i, size - i); const range3 = sheet.getCell(3 * size - i, 2 * i + 1).getResizedRange(size - i, size - i); const range4 = sheet.getCell(3 * size - i, 3 * size - i).getResizedRange(size - i, size - i); - var colorFactor = 255 - Math.floor(200 / size * i) + let colorFactor = 255 - Math.floor(200 / size * i) range1.format.fill.color = rgb(colorFactor, 255 - colorFactor, 0); range2.format.fill.color = rgb(colorFactor, 255 - colorFactor, 0); range3.format.fill.color = rgb(colorFactor, 255 - colorFactor, 0); @@ -155,31 +155,27 @@ script: language: typescript template: content: |- -

Draw colorful patterns

- -
+

Draw colorful patterns

+
Choose size:
- -
+


-

-
language: html style: - content: | + content: |- h2:not(:first-child) { margin-top: 35px; } @@ -188,15 +184,9 @@ style: width: 100%; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/excel/99-just-for-fun/tetrominos.yaml b/samples/excel/99-just-for-fun/tetrominos.yaml index 19ee7a37f..57441e125 100644 --- a/samples/excel/99-just-for-fun/tetrominos.yaml +++ b/samples/excel/99-just-for-fun/tetrominos.yaml @@ -8,24 +8,23 @@ api_set: ExcelApi: '1.9' script: content: |- - $("#run").click(() => { - $("#setup").hide(); + document.getElementById("run").addEventListener("click", () => { + document.getElementById("setup").style.display = "none"; tryCatch(run); }); - - $("#selectedFile").change(() => tryCatch(readImageFromFile)); - $("#focusButton").click(() => tryCatch(focus)); + document.getElementById("selectedFile").addEventListener("change", () => tryCatch(readImageFromFile)); + document.getElementById("focusButton").addEventListener("click", () => tryCatch(focus)); let backgroundPicture = getDefaultBackgroundPicture(); function readImageFromFile() { - const myFile = document.getElementById("selectedFile"); + const myFile = document.getElementById("selectedFile") as HTMLInputElement; const reader = new FileReader(); reader.onload = (event) => { const startIndex = reader.result.toString().indexOf("base64,"); - const mybase64 = reader.result.toString().substr(startIndex + 7); - backgroundPicture = mybase64; + const myBase64 = reader.result.toString().substr(startIndex + 7); + backgroundPicture = myBase64; }; // Read in the image file as a data URL. @@ -33,7 +32,7 @@ script: } function focus() { - $("#container").focus(); + document.getElementById("container").focus(); } async function run() { @@ -171,9 +170,9 @@ script: this.pieceY = 0; this.pieceX = NUM_COLS / 2 - 2; this.rows = []; - for (var i = 0; i < NUM_ROWS; i++) { + for (let i = 0; i < NUM_ROWS; i++) { this.rows[i] = []; - for (var j = 0; j < NUM_COLS; j++) { + for (let j = 0; j < NUM_COLS; j++) { this.rows[i][j] = 0; } } @@ -187,9 +186,9 @@ script: this.pieceY = 0; this.pieceX = NUM_COLS / 2 - 2; this.rows = []; - for (var i = 0; i < NUM_ROWS; i++) { + for (let i = 0; i < NUM_ROWS; i++) { this.rows[i] = []; - for (var j = 0; j < NUM_COLS; j++) { + for (let j = 0; j < NUM_COLS; j++) { this.rows[i][j] = 0; } } @@ -621,10 +620,12 @@ script: } } - await run($("#container")[0], $("#sessionPane")[0]); + const container = document.getElementById("container"); + const sessionPane = document.getElementById("sessionPane"); + await run(container, sessionPane); - $("#container").focus(); - $("#focus").show(); + container.focus(); + document.getElementById("focus").style.display = "block"; }); } @@ -633,7 +634,7 @@ script: try { await callback(); } catch (error) { - $("#setup").show(); + document.getElementById("setup").style.display = "block"; // Note: In a production add-in, you'd want to notify the user through your add-in's UI. console.error(error); } @@ -646,28 +647,27 @@ script: template: content: |-
-
+

This sample lets you repeatedly stack tetrominos, which are represented by Shapes. Select a background image (or leave blank for the default) and Start!. The controls will then be displayed.

- -
+

Select Background Image

-
+

-

language: html style: @@ -784,17 +784,11 @@ style: border: 1px solid black; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js diff --git a/samples/excel/default.yaml b/samples/excel/default.yaml index 10ea5b1db..c303f62eb 100644 --- a/samples/excel/default.yaml +++ b/samples/excel/default.yaml @@ -6,8 +6,8 @@ host: EXCEL api_set: ExcelApi: '1.1' script: - content: | - $("#run").click(() => tryCatch(run)); + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); async function run() { await Excel.run(async (context) => { @@ -31,7 +31,7 @@ script: } language: typescript template: - content: | + content: |- @@ -49,15 +49,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/onenote/default.yaml b/samples/onenote/default.yaml index 57fbd0e52..16f59bda5 100644 --- a/samples/onenote/default.yaml +++ b/samples/onenote/default.yaml @@ -6,8 +6,8 @@ host: ONENOTE api_set: OneNoteApi: '1.1' script: - content: | - $("#run").click(() => tryCatch(run)); + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); async function run() { await OneNote.run(async (context) => { @@ -29,7 +29,7 @@ script: } language: typescript template: - content: | + content: |- @@ -47,15 +47,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/10-roaming-settings/roaming-settings.yaml b/samples/outlook/10-roaming-settings/roaming-settings.yaml index c86dc2430..a24b5e596 100644 --- a/samples/outlook/10-roaming-settings/roaming-settings.yaml +++ b/samples/outlook/10-roaming-settings/roaming-settings.yaml @@ -1,29 +1,30 @@ id: outlook-roaming-settings-roaming-settings name: Use add-in settings -description: 'Gets, sets, and saves add-in roaming settings' +description: Gets, sets, saves, and removes add-in roaming settings. host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); - $("#set").click(set); - $("#save").click(save); + content: |- + document.getElementById("get").addEventListener("click", get); + document.getElementById("set").addEventListener("click", set); + document.getElementById("save").addEventListener("click", save); + document.getElementById("remove").addEventListener("click", remove); function get() { - var settingName = $("#settingName").val(); - var settingValue = Office.context.roamingSettings.get(settingName); - $("#settingValue").val(settingValue); + const settingName = (document.getElementById("settingName") as HTMLInputElement).value; + const settingValue = Office.context.roamingSettings.get(settingName); + (document.getElementById("settingValue") as HTMLInputElement).value = settingValue; console.log(`The value of setting "${settingName}" is "${settingValue}".`); } - + function set() { - var settingName = $("#settingName").val(); - var settingValue = $("#settingValue").val(); + const settingName = (document.getElementById("settingName") as HTMLInputElement).value; + const settingValue = (document.getElementById("settingValue") as HTMLInputElement).value; Office.context.roamingSettings.set(settingName, settingValue); console.log(`Setting "${settingName}" set to value "${settingValue}".`); } - + function save() { // Save settings in the mailbox to make it available in future sessions. Office.context.roamingSettings.saveAsync(function(result) { @@ -34,14 +35,20 @@ script: } }); } + + function remove() { + // Remove the specified setting from the mailbox. + const settingName = (document.getElementById("settingName") as HTMLInputElement).value; + Office.context.roamingSettings.remove(settingName); + console.log(`The "${settingName}" setting has been removed.`); + } language: typescript template: - content: | -
+ content: |- +

This sample shows how to set, save, and get add-in properties that can be accessed the next time the add-in is opened.

- -
+

Try it out

@@ -60,6 +67,9 @@ template: +
language: html style: @@ -75,15 +85,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/15-item-custom-properties/load-set-get-save.yaml b/samples/outlook/15-item-custom-properties/load-set-get-save.yaml index c24b37bdc..cd2502b98 100644 --- a/samples/outlook/15-item-custom-properties/load-set-get-save.yaml +++ b/samples/outlook/15-item-custom-properties/load-set-get-save.yaml @@ -1,97 +1,114 @@ id: outlook-item-custom-properties-load-set-get-save name: Work with item custom properties -description: 'Gets the custom properties that the add-in placed on the current item, sets a new one, gets it, removes it, and saves all custom properties back to the item.' +description: Gets the custom properties that the add-in placed on the current item, sets a new one, gets it, removes it, and saves all custom properties back to the item. host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - var customProps; + content: |- + let customProps; + + document.getElementById("load").addEventListener("click", load); + document.getElementById("get").addEventListener("click", get); + document.getElementById("get-all").addEventListener("click", getAll); + document.getElementById("set").addEventListener("click", set); + document.getElementById("remove").addEventListener("click", remove); + document.getElementById("save").addEventListener("click", save); - $("#load").click(load); - $("#get").click(get); - $("#set").click(set); - $("#remove").click(remove); - $("#save").click(save); - function load() { - Office.context.mailbox.item.loadCustomPropertiesAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log("Loaded following custom properties:"); - customProps = result.value; - var dataKey = Object.keys(customProps)[0]; - var data = customProps[dataKey]; - for (var propertyName in data) - { - var propertyValue = data[propertyName]; - console.log(`${propertyName}: ${propertyValue}`); - } - } - else { + Office.context.mailbox.item.loadCustomPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); + return; } + + customProps = result.value; + console.log("Loaded the CustomProperties object."); }); } function get() { - var propertyName = $("#propertyName").val(); - var propertyValue = customProps.get(propertyName); - $("#propertyValue").val(propertyValue); + const propertyName = (document.getElementById("get-property-name") as HTMLInputElement).value; + const propertyValue = customProps.get(propertyName); console.log(`The value of custom property "${propertyName}" is "${propertyValue}".`); } + function getAll() { + let allCustomProps; + if (Office.context.requirements.isSetSupported("Mailbox", "1.9")) { + allCustomProps = customProps.getAll(); + } else { + allCustomProps = customProps["rawData"]; + } + + console.log(allCustomProps); + } + function set() { - var propertyName = $("#propertyName").val(); - var propertyValue = $("#propertyValue").val(); + const propertyName = (document.getElementById("set-property-name") as HTMLInputElement).value; + const propertyValue = (document.getElementById("property-value") as HTMLInputElement).value; customProps.set(propertyName, propertyValue); console.log(`Custom property "${propertyName}" set to value "${propertyValue}".`); } function remove() { - var propertyName = $("#propertyName").val(); + const propertyName = (document.getElementById("remove-property-name") as HTMLInputElement).value; customProps.remove(propertyName); console.log(`Custom property "${propertyName}" removed.`); } function save() { - customProps.saveAsync(function(result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { + customProps.saveAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { console.error(`saveAsync failed with message ${result.error.message}`); - } else { - console.log(`Custom properties saved with status: ${result.status}`); + return; } + + console.log(`Custom properties saved with status: ${result.status}`); }); } language: typescript template: - content: | -
-

This sample shows how to set, save, and get add-in's per-item properties that can be accessed the next time the add-in is opened for the same item.

+ content: |- +
+

This sample shows how to set, save, and get the custom per-item properties of an add-in.

- -
-

Try it out

-
- - +
+

Try it out

+

First load the CustomProperties object of the mail item.

+ +
+ +
-
- - +
+ +
- - - - +
+ + +
+ -
@@ -109,15 +126,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/20-item-body/add-inline-base64-image.yaml b/samples/outlook/20-item-body/add-inline-base64-image.yaml new file mode 100644 index 000000000..e97523983 --- /dev/null +++ b/samples/outlook/20-item-body/add-inline-base64-image.yaml @@ -0,0 +1,100 @@ +order: 3 +id: outlook-item-body-add-inline-base64-image +name: Add inline Base64-encoded image to message or appointment body (Compose) +description: Add an inline Base64-encoded image to the body of a message or appointment being composed. +host: OUTLOOK +api_set: + Mailbox: '1.8' +script: + content: |- + document.getElementById("prepend-image").addEventListener("click", prependImage); + document.getElementById("append-image").addEventListener("click", appendImage); + + const base64String = + "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAnUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAN0S+bUAAAAMdFJOUwAQIDBAUI+fr7/P7yEupu8AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF8SURBVGhD7dfLdoMwDEVR6Cspzf9/b20QYOthS5Zn0Z2kVdY6O2WULrFYLBaLxd5ur4mDZD14b8ogWS/dtxV+dmx9ysA2QUj9TQRWv5D7HyKwuIW9n0vc8tkpHP0W4BOg3wQ8wtlvA+PC1e8Ao8Ld7wFjQtHvAiNC2e8DdqHqKwCrUPc1gE1AfRVgEXBfB+gF0lcCWoH2tYBOYPpqQCNwfT3QF9i+AegJfN8CtAWhbwJagtS3AbIg9o2AJMh9M5C+SVGBvx6zAfmT0r+Bv8JMwP4kyFPir+cswF5KL3WLv14zAFBCLf56Tw9cparFX4upgaJUtPhrOS1QlY5W+vWTXrGgBFB/b72ev3/0igUdQPppP/nfowfKUUEFcP207y/yxKmgAYQ+PywoAFOfCH3A2MdCFzD3kdADBvq10AGG+pXQBgb7pdAEhvuF0AIc/VtoAK7+JciAs38KIuDugyAC/v4hiMCE/i7IwLRBsh68N2WQjMVisVgs9i5bln8LGScNcCrONQAAAABJRU5ErkJggg=="; + + function prependImage() { + // Insert the Base64-encoded image to the beginning of the body. + Office.context.mailbox.item.addFileAttachmentFromBase64Async(base64String, "sample.png", { isInline: true }, (attachmentResult) => { + if (attachmentResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to attach file: ${attachmentResult.error.message}`); + return; + } + + Office.context.mailbox.item.body.prependAsync('', { coercionType: Office.CoercionType.Html }, (prependResult) => { + if (prependResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to prepend image to body: ${attachmentResult.error.message}`); + return; + } + + console.log("Inline Base64-encoded image added to the beginning of the body."); + }) + }); + } + + function appendImage() { + // Get the current body of the message or appointment. + Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, (bodyResult) => { + if (bodyResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to get body: ${bodyResult.error.message}`); + return; + } + + // Add the Base64-encoded image to the end of the body. + const options = { isInline: true, asyncContext: bodyResult.value }; + Office.context.mailbox.item.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => { + if (attachResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to attach file: ${attachResult.error.message}`); + return; + } + + let body = attachResult.asyncContext; + body += ''; + + Office.context.mailbox.item.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => { + if (setResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to set body: ${setResult.error.message}`); + return; + } + + console.log("Inline Base64-encoded image added to the end of the body."); + }); + }); + }); + } + language: typescript +template: + content: |- +
+

This sample adds an inline Base64-encoded image to the body of the message or appointment being composed.

+

Required mode: Compose

+
+
+

Try it out

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/20-item-body/append-text-on-send.yaml b/samples/outlook/20-item-body/append-text-on-send.yaml new file mode 100644 index 000000000..b283f7abd --- /dev/null +++ b/samples/outlook/20-item-body/append-text-on-send.yaml @@ -0,0 +1,72 @@ +order: 5 +id: outlook-item-body-append-text-on-send +name: Append text to item body on send +description: Appends text to the end of the message or appointment's body once it's sent. +host: OUTLOOK +api_set: + Mailbox: '1.9' +script: + content: |- + document.getElementById("append-on-send").addEventListener("click", appendOnSend); + + function appendOnSend() { + // This snippet appends text to the end of the message or appointment's body once it's sent. + const text = (document.getElementById("text-field") as HTMLInputElement).value; + + // It's recommended to call getTypeAsync and pass its returned value to the options.coercionType parameter of the appendOnSendAsync call. + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.appendOnSendAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" will be appended to the body once the message or appointment is sent. Send the mail item to test this feature.`); + }); + }); + } + language: typescript +template: + content: |- +
+

This sample appends text to the end of the message or appointment's body once it's sent.

+

Required mode: Compose

+
+
+

Try it out

+

Important: To use appendOnSendAsync, you must set AppendOnSend as an extended permission in the ExtendedPermissions manifest element. To learn more about append-on-send and its configuration, see Implement append-on-send in your Outlook add-in.

+
+ + +
+
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/20-item-body/get-body-format.yaml b/samples/outlook/20-item-body/get-body-format.yaml new file mode 100644 index 000000000..b077f1147 --- /dev/null +++ b/samples/outlook/20-item-body/get-body-format.yaml @@ -0,0 +1,55 @@ +order: 4 +id: outlook-item-body-get-body-format +name: Get the item's body format +description: Gets a message or appointment's body format (plain text or HTML). +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("get-body-format").addEventListener("click", getBodyFormat); + + function getBodyFormat() { + // Get the mail item's body format (plain text or HTML) and log it to the console. + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log("Body format: " + asyncResult.value); + }); + } + language: typescript +template: + content: |- +
+

This sample gets the message or appointment's body format (plain text or HTML).

+

Required mode: Compose

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/20-item-body/get-selected-data.yaml b/samples/outlook/20-item-body/get-selected-data.yaml index d2721dd2c..90a1a202e 100644 --- a/samples/outlook/20-item-body/get-selected-data.yaml +++ b/samples/outlook/20-item-body/get-selected-data.yaml @@ -6,14 +6,14 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get-selected-data").click(getSelectedData); + content: |- + document.getElementById("get-selected-data").addEventListener("click", getSelectedData); function getSelectedData() { Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var text = asyncResult.value.data; - var prop = asyncResult.value.sourceProperty; + const text = asyncResult.value.data; + const prop = asyncResult.value.sourceProperty; console.log("Selected text in " + prop + ": " + text); } else { console.error(asyncResult.error); @@ -23,12 +23,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get the selected text in the item body or subject/title.

Required mode: Compose

- -
+

Try it out

Select text in the item body or subject then push the Get selected text 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/20-item-body/prepend-text-to-item-body.yaml b/samples/outlook/20-item-body/prepend-text-to-item-body.yaml new file mode 100644 index 000000000..e9b2a5b1c --- /dev/null +++ b/samples/outlook/20-item-body/prepend-text-to-item-body.yaml @@ -0,0 +1,74 @@ +order: 6 +id: outlook-item-body-prepend-text-to-item-body +name: Prepend text to item body +description: Adds text to the beginning of the message or appointment's body. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("prepend").addEventListener("click", prependText); + + function prependText() { + /* This snippet adds text to the beginning of the message or appointment's body. + + When prepending a link in HTML markup to the body, you can disable the online link preview by setting the anchor tag's id attribute to "LPNoLP". For example, 'Click here!'. + */ + const text = (document.getElementById("text-field") as HTMLInputElement).value; + + // It's recommended to call getTypeAsync and pass its returned value to the options.coercionType parameter of the prependAsync call. + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.prependAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" prepended to the body.`); + }); + }); + } + language: typescript +template: + content: |- +
+

This sample adds text to the beginning of the message or appointment's body.

+

Required mode: Compose

+
+
+

Try it out

+
+ + +
+
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/20-item-body/replace-selected-text.yaml b/samples/outlook/20-item-body/replace-selected-text.yaml new file mode 100644 index 000000000..425dcee0b --- /dev/null +++ b/samples/outlook/20-item-body/replace-selected-text.yaml @@ -0,0 +1,78 @@ +order: 2 +id: outlook-item-body-replace-selected-text +name: Replace selected text in item body +description: Replaces selected text in a message or appointment's body with specified text. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("replace-selection").addEventListener("click", replaceSelection); + + function replaceSelection() { + /* This snippet replaces selected text in a message or appointment's body with specified text. + + If you want to use a link in HTML markup as a value of the setSelectedDataAsync call's data parameter, you can disable online link preview by setting the anchor tag's id attribute to "LPNoLP". For example, 'Click here!'. + */ + const text = (document.getElementById("text-field") as HTMLInputElement).value; + + // It's recommended to call getTypeAsync and pass its returned value to the options.coercionType parameter of the prependAsync call. + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.setSelectedDataAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`Replaced selected text with "${text}".`); + }); + }); + } + language: typescript +template: + content: |- +
+

This sample replaces selected text in a message or appointment's body with specified text.

+

Required mode: Compose

+
+
+

Try it out

+
    +
  1. Select text in the item's body.
  2. +
    +
  3. Enter text to replace the selected text.
  4. +
+
+ +
+
+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/25-item-save-and-close/close-async.yaml b/samples/outlook/25-item-save-and-close/close-async.yaml new file mode 100644 index 000000000..59b23949a --- /dev/null +++ b/samples/outlook/25-item-save-and-close/close-async.yaml @@ -0,0 +1,57 @@ +order: 2 +id: outlook-close-async +name: Close the current message and discard changes (Message Compose) +description: Closes the current message and discards any unsaved changes when specified. +host: OUTLOOK +api_set: + Mailbox: '1.14' +script: + content: |- + document.getElementById("close-async").addEventListener("click", closeAsync); + + function closeAsync() { + // This snippet closes the current message being composed and discards any unsaved changes when the optional property, discardItem, is set to true. + // The API call works on a new message being composed, a reply, or an existing draft. + // When discardItem is set to false or isn't defined on a new message with unsaved changes, the user is prompted to save a draft, discard the changes, or cancel the close operation. + Office.context.mailbox.item.closeAsync( + { discardItem: true }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to close the current message being composed and discard any unsaved changes.

+

Required mode: Message Compose

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/25-item-save-and-close/close.yaml b/samples/outlook/25-item-save-and-close/close.yaml index 54e6b9e3f..ffc78cc69 100644 --- a/samples/outlook/25-item-save-and-close/close.yaml +++ b/samples/outlook/25-item-save-and-close/close.yaml @@ -1,3 +1,4 @@ +order: 1 id: outlook-item-save-and-close-close name: Close the item description: Closes the item (compose mode) @@ -5,20 +6,19 @@ host: OUTLOOK api_set: Mailbox: '1.3' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.mailbox.item.close(); } language: typescript template: - content: | -
+ content: |- +

This sample shows how to close the item in compose mode.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -38,15 +38,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/25-item-save-and-close/save.yaml b/samples/outlook/25-item-save-and-close/save.yaml index 77d79ce17..b6c26f24b 100644 --- a/samples/outlook/25-item-save-and-close/save.yaml +++ b/samples/outlook/25-item-save-and-close/save.yaml @@ -1,3 +1,4 @@ +order: 3 id: outlook-item-save-and-close-save name: Save the item description: Saves the item (compose mode) @@ -5,8 +6,8 @@ host: OUTLOOK api_set: Mailbox: '1.3' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.mailbox.item.saveAsync(function (result) { @@ -20,12 +21,11 @@ script: } language: typescript template: - content: | -
+ content: |- +

This sample shows how to save the item in compose mode.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -45,15 +45,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml b/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml new file mode 100644 index 000000000..1f967c9d6 --- /dev/null +++ b/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml @@ -0,0 +1,124 @@ +order: 15 +id: outlook-recipients-and-attendees-get-all-attendees +name: Get all attendees +description: Gets all appointment attendees and organizes them by their response. +host: OUTLOOK +api_set: + Mailbox: '1.7' +script: + content: |- + document.getElementById("get-attendees").addEventListener("click", getAttendees); + + function getAttendees() { + // This snippet gets an appointment's required and optional attendees and groups them by their response. + const appointment = Office.context.mailbox.item; + let attendees; + if (Object.keys(appointment.organizer).length === 0) { + // Get attendees as the meeting organizer. + appointment.requiredAttendees.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.log(result.error.message); + return; + } + + attendees = result.value; + appointment.optionalAttendees.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.log(result.error.message); + return; + } + + attendees = attendees.concat(result.value); + + // Organize attendees by their meeting response and print this to the console. + organizeByResponse(attendees); + }); + }); + } else { + // Get attendees as a meeting attendee. + attendees = appointment.requiredAttendees; + attendees = attendees.concat(appointment.optionalAttendees); + + // Organize attendees by their meeting response and print this to the console. + organizeByResponse(attendees); + } + } + + function organizeByResponse(attendees) { + const accepted = []; + const declined = []; + const noResponse = []; + const tentative = []; + attendees.forEach(attendee => { + switch (attendee.appointmentResponse) { + case Office.MailboxEnums.ResponseType.Accepted: + accepted.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Declined: + declined.push(attendee); + break; + case Office.MailboxEnums.ResponseType.None: + noResponse.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Tentative: + tentative.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Organizer: + console.log(`Organizer: ${attendee.displayName}, ${attendee.emailAddress}`); + break; + } + }); + + // List attendees by their response. + console.log("Accepted: "); + printAttendees(accepted); + console.log("Declined: "); + printAttendees(declined); + console.log("Tentative: "); + printAttendees(tentative); + console.log("No response: "); + printAttendees(noResponse); + } + + function printAttendees(attendees) { + if (attendees.length === 0) { + console.log("None"); + } else { + attendees.forEach(attendee => { + console.log(` ${attendee.displayName}, ${attendee.emailAddress}`); + }); + } + } + language: typescript +template: + content: |- +
+

This sample shows how to get all appointment attendees and organize them by their response.

+

Required mode: Appointment Organizer, Appointment Read

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml b/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml index 03898b0c9..a0982310c 100644 --- a/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml +++ b/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml @@ -6,25 +6,24 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get-cc").click(getCc); + content: |- + document.getElementById("get-cc").addEventListener("click", getCc); function getCc() { - var msgCc = Office.context.mailbox.item.cc; + const msgCc = Office.context.mailbox.item.cc; console.log("Message copied to:"); - for (var i = 0; i < msgCc.length; i++) { + for (let i = 0; i < msgCc.length; i++) { console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); } } language: typescript template: content: |- -
+

This sample shows how to get the Cc line recipients of the email.

Required mode: Message Read

- -
+

Try it out

language: html @@ -44,15 +78,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/35-notifications/add-getall-remove.yaml b/samples/outlook/35-notifications/add-getall-remove.yaml index 813f4a12a..a864ce4d1 100644 --- a/samples/outlook/35-notifications/add-getall-remove.yaml +++ b/samples/outlook/35-notifications/add-getall-remove.yaml @@ -1,73 +1,110 @@ id: outlook-notifications-add-getall-remove name: Work with notification messages -description: 'Adds different kinds of notification messages, gets all, and replaces and removes an individual notification message.' +description: Adds different kinds of notification messages, gets all notifications, and replaces and removes an individual notification message. host: OUTLOOK api_set: - Mailbox: '1.3' + Mailbox: '1.10' script: - content: | - $("#addProgress").click(addProgress); - $("#addInformational").click(addInformational); - $("#addInformationalPersisted").click(addInformationalPersisted); - $("#addError").click(addError); - $("#getAll").click(getAll); - $("#replace").click(replace); - $("#remove").click(remove); + content: |- + document.getElementById("addProgress").addEventListener("click", addProgress); + document.getElementById("addInformational").addEventListener("click", addInformational); + document.getElementById("addInformationalPersisted").addEventListener("click", addInformationalPersisted); + document.getElementById("addInsight").addEventListener("click", addInsight); + document.getElementById("addError").addEventListener("click", addError); + document.getElementById("getAll").addEventListener("click", getAll); + document.getElementById("replace").addEventListener("click", replace); + document.getElementById("remove").addEventListener("click", remove); function addProgress() { - var id = $("#notificationId").val(); - var details = + // Adds a progress indicator to the mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; + const details = { - type: "progressIndicator", + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, message: "Progress indicator with id = " + id }; Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult); } function addInformational() { - var id = $("#notificationId").val(); - var details = + // Adds an informational notification to the mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; + const details = { - type: "informationalMessage", + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", + icon: "PG.Icon.16", persistent: false }; Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult); } function addInformationalPersisted() { - var id = $("#notificationId").val(); - var details = + // Adds a persistent information notification to the mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; + const details = { - type: "informationalMessage", + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, message: "Persistent informational notification message with id = " + id, - icon: "icon1", + icon: "PG.Icon.16", persistent: true }; Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult); } + function addInsight() { + // Adds an informational message with actions to the mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; + + const itemId = Office.context.mailbox.item.itemId; + const details = { + type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage, + message: "This is an insight notification with id = " + id, + icon: "PG.Icon.16", + actions: [ + { + actionText: "Open insight", + actionType: Office.MailboxEnums.ActionType.ShowTaskPane, + // Identify whether the current mail item is in read or compose mode to set the appropriate commandId value. + commandId: (itemId == undefined ? "PG.HelpCommand.Compose" : "PG.HelpCommand.Read"), + contextData: { a: "aValue", b: "bValue" } + } + ] + }; + + Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult); + } + function addError() { - var id = $("#notificationId").val(); - var details = + // Adds an error notification to the mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; + const details = { - type: "errorMessage", + type: Office.MailboxEnums.ItemNotificationMessageType.ErrorMessage, message: "Error notification message with id = " + id }; Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult); } function getAll() { - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); + // Gets all the notification messages and their keys for the current mail item. + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); } function replace() { - var id = $("#notificationId").val(); + // Replaces a notification message of a given key with another message. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; Office.context.mailbox.item.notificationMessages.replaceAsync( id, { - type: "informationalMessage", + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, message: "Notification message with id = " + id + " has been replaced with an informational message.", icon: "icon2", persistent: false @@ -76,46 +113,67 @@ script: } function remove() { - var id = $("#notificationId").val(); + // Removes a notification message from the current mail item. + const id = (document.getElementById("notificationId") as HTMLInputElement).value; Office.context.mailbox.item.notificationMessages.removeAsync(id, handleResult); } function handleResult(result) { + // Helper method to display the result of an asynchronous call. console.log(result); } language: typescript template: - content: | -
+ content: |- +

This sample shows how to add different kinds of notification messages, get all, replace, and remove an individual notification message.

- -
-

Try it out

+
+

Try it out

- +
+

Add a notification

+

To add a notification, enter a unique ID for the notification in the text field, then select one of the notification types below.

+

Note:

+
    +
  • You can add a maximum of five notifications per mail item.
  • +
  • You can only add one insight notification to a mail item.
  • +
  • In Outlook on the web and in new Outlook on Windows, you can only add an insight notification to an item in compose mode.
  • +
+
+
+
+ +
+

Get all notifications

+

Replace a notification

+

To replace a notification with an informational message, enter the ID of the notification you want to replace in the text field, then select Replace notification.

+

Remove a notification

+

To remove a notification, enter the ID of the notification you want to remove in the text field, then select Remove notification.

language: html @@ -132,15 +190,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/40-attachments/attachments-compose.yaml b/samples/outlook/40-attachments/attachments-compose.yaml index 1ba54c00e..6d26d5131 100644 --- a/samples/outlook/40-attachments/attachments-compose.yaml +++ b/samples/outlook/40-attachments/attachments-compose.yaml @@ -1,125 +1,146 @@ id: outlook-attachments-attachments-compose name: Manipulate attachments (Item Compose) -description: 'Adds, gets, and removes attachments from a message or an appointment in Compose mode.' +description: Adds, gets, and removes attachments from a message or an appointment in Compose mode. host: OUTLOOK api_set: - Mailbox: '1.1' + Mailbox: '1.8' script: - content: | - $("#add").click(add); - $("#addItemAttachment").click(addItemAttachment); - $("#addBase64").click(addBase64); - $("#get").click(get); - $("#remove").click(remove); + content: |- + document.getElementById("add").addEventListener("click", add); + document.getElementById("addBase64").addEventListener("click", addBase64); + document.getElementById("get").addEventListener("click", get); + document.getElementById("remove").addEventListener("click", remove); function add() { - var attachmentUrl = $("#attachmentUrl").val(); - Office.context.mailbox.item.addFileAttachmentAsync( - attachmentUrl, - getFileName(attachmentUrl), - { "asyncContext" : { var1: 1, var2: true } }, - function(result) { console.log(result); }); - } - - function addItemAttachment() { - var attachmentItemId = $("#attachmentItemId").val(); - Office.context.mailbox.item.addItemAttachmentAsync( - attachmentItemId, - "My attachment", - { "asyncContext" : { var3: 3, var4: false } }, - function(result) { console.log(result); }); + const attachmentUrl = (document.getElementById("attachmentUrl") as HTMLInputElement).value; + Office.context.mailbox.item.addFileAttachmentAsync( + attachmentUrl, + getFileName(attachmentUrl), + { isInline: false }, + (result) => { + console.log(result); + } + ); } function addBase64() { - base64String = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - base64String, - "logo.png", - { isInline: false }, - function(result) { console.log(result); }); + const base64String = + "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + base64String, + "logo.png", + { isInline: false }, + (result) => { + console.log(result); + } + ); } function get() { - Office.context.mailbox.item.getAttachmentsAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(result.error.message); - } else { - if (result.value.length > 0) { - for (var i = 0; i < result.value.length; i++) { - var attachment = result.value[i]; - console.log(`${attachment.id}. Name: ${attachment.name}, size: ${attachment.size}, isInline: ${attachment.isInline}`); - } - } - else { - console.log("No attachments on this message."); - } + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + if (result.value.length > 0) { + for (let i = 0; i < result.value.length; i++) { + const attachment = result.value[i]; + let attachmentType; + switch (attachment.attachmentType) { + case Office.MailboxEnums.AttachmentType.Cloud: + attachmentType = "Attachment is stored in a cloud location"; + break; + case Office.MailboxEnums.AttachmentType.File: + attachmentType = "Attachment is a file"; + break; + case Office.MailboxEnums.AttachmentType.Item: + attachmentType = "Attachment is an Exchange item"; + break; } - }); + console.log( + "ID: " + + attachment.id + + "\n" + + "Type: " + + attachmentType + + "\n" + + "Name: " + + attachment.name + + "\n" + + "Size: " + + attachment.size + + "\n" + + "isInline: " + + attachment.isInline + ); + } + } else { + console.log("No attachments on this message."); + } + }); } function remove() { - Office.context.mailbox.item.removeAttachmentAsync( - $("#attachmentId").val(), - { asyncContext : null }, - function(result) - { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`${result.error.message}`); - } else { - console.log(`Attachment removed successfully.`); - } - } - ); + Office.context.mailbox.item.removeAttachmentAsync( + (document.getElementById("attachmentId") as HTMLInputElement).value, + (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(`Attachment removed successfully.`); + } + ); } function getFileName(url) { - var lastIndex = url.lastIndexOf('/'); - if (lastIndex >= 0) { - return url.substring(lastIndex + 1); - } - return url; + const lastIndex = url.lastIndexOf("/"); + if (lastIndex >= 0) { + return url.substring(lastIndex + 1); + } + return url; } language: typescript template: - content: | -
-

This sample shows how to add, get, and remove attachments from a message or an appointment in Compose mode.

-

Required mode: Item Compose

+ content: |- +
+

This sample shows how to add, get, and remove attachments from a message or an appointment in Compose mode.

+

Required mode: Item Compose

- -
-

Try it out

-
- - +
+

Try it out

+
+

ADD

+ +
+ +
- -
- - -
- - - -
- - +
+

REMOVE

+
+ +
-
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -131,15 +152,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/40-attachments/get-attachment-content.yaml b/samples/outlook/40-attachments/get-attachment-content.yaml index 6ecee8e46..b4c3f5fde 100644 --- a/samples/outlook/40-attachments/get-attachment-content.yaml +++ b/samples/outlook/40-attachments/get-attachment-content.yaml @@ -1,66 +1,94 @@ id: outlook-attachments-get-attachment-content name: Get attachment content -description: Gets the attachment content. +description: Gets the attachment content in read or compose mode. host: OUTLOOK api_set: Mailbox: '1.8' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("attachment-content-compose").addEventListener("click", getAttachmentContentCompose); + document.getElementById("attachment-content-read").addEventListener("click", getAttachmentContentRead); - function run() { - var item = Office.context.mailbox.item; - var options = {asyncContext: {currentItem: item}}; - item.getAttachmentsAsync(options, callback); + function getAttachmentContentCompose() { + // Gets the attachments of the current message or appointment in compose mode. The getAttachmentsAsync call can only be used in compose mode. + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.log(result.error.message); + return; + } - function callback(result) { - if (result.value.length > 0) { - for (i = 0 ; i < result.value.length ; i++) { - result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); - } - } + if (result.value.length <= 0) { + console.log("Mail item has no attachments."); + return; } - function handleAttachmentsCallback(result) { - // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file. - switch (result.value.format) { - case Office.MailboxEnums.AttachmentContentFormat.Base64: - // Handle file attachment. - console.log(result.value.content); - break; - case Office.MailboxEnums.AttachmentContentFormat.Eml: - // Handle email item attachment. - console.log("Attachment is a message."); - break; - case Office.MailboxEnums.AttachmentContentFormat.ICalendar: - // Handle .icalender attachment. - console.log("Attachment is a calendar item."); - break; - case Office.MailboxEnums.AttachmentContentFormat.Url: - // Handle cloud attachment. - console.log("Attachment is a cloud attachment."); - break; - default: - // Handle attachment formats that are not supported. - } + for (let i = 0; i < result.value.length; i++) { + // Log the attachment type and its contents to the console. + Office.context.mailbox.item.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); } + }); + } + + function getAttachmentContentRead() { + // Gets the attachments of the current message or appointment in read mode. The item.attachments call can only be used in read mode. + const item = Office.context.mailbox.item; + const attachments = item.attachments; + if (attachments.length <= 0) { + console.log("Mail item has no attachments."); + return; + } + + for (let i = 0; i < attachments.length; i++) { + // Log the attachment type and its contents to the console. + item.getAttachmentContentAsync(attachments[i].id, handleAttachmentsCallback); + } + } + + function handleAttachmentsCallback(result) { + // Identifies whether the attachment is a Base64-encoded string, .eml file, .icalendar file, or a URL. + switch (result.value.format) { + case Office.MailboxEnums.AttachmentContentFormat.Base64: + // Handle file attachment. + console.log("Attachment is a Base64-encoded string."); + break; + case Office.MailboxEnums.AttachmentContentFormat.Eml: + // Handle email item attachment. + console.log("Attachment is a message."); + break; + case Office.MailboxEnums.AttachmentContentFormat.ICalendar: + // Handle .icalender attachment. + console.log("Attachment is a calendar item."); + break; + case Office.MailboxEnums.AttachmentContentFormat.Url: + // Handle cloud attachment. + console.log("Attachment is a cloud attachment."); + break; + default: + // Handle attachment formats that aren't supported. + } + + console.log(result.value.content); } language: typescript template: - content: | -
-

This sample shows how to get the attachment content from a message or an appointment.

+ content: |- +
+

This sample gets the attachment content from a message or an appointment in read or compose mode.

+

Required mode: Compose or Read

- -
-

Try it out

- +
+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -68,19 +96,12 @@ style: section.samples .ms-Button, section.setup .ms-Button { display: block; margin-bottom: 5px; - margin-left: 20px; min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/40-attachments/get-attachments-read.yaml b/samples/outlook/40-attachments/get-attachments-read.yaml index 7b9fd8efc..1177cb2b2 100644 --- a/samples/outlook/40-attachments/get-attachments-read.yaml +++ b/samples/outlook/40-attachments/get-attachments-read.yaml @@ -5,22 +5,33 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { - var attachments = Office.context.mailbox.item.attachments; - console.log(attachments); + const item = Office.context.mailbox.item; + + if (item.attachments.length > 0) { + for (let i = 0; i < item.attachments.length; i++) { + const attachment = item.attachments[i]; + console.log(`${i+1}. Name: ${attachment.name}`); + console.log(`ID: ${attachment.id}`); + console.log(`Type: ${attachment.attachmentType}`); + console.log(`Inline content: ${attachment.isInline}`); + console.log(`Size: ${attachment.size}`); + } + } else { + console.log("This mail item doesn't contain any attachments."); + } } language: typescript template: - content: | -
+ content: |- +

This sample shows how to get the attachments of a message or an appointment in Read mode.

Required mode: Item Read

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -40,15 +51,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/45-categories/work-with-categories.yaml b/samples/outlook/45-categories/work-with-categories.yaml index c28c5abda..c547ef97a 100644 --- a/samples/outlook/45-categories/work-with-categories.yaml +++ b/samples/outlook/45-categories/work-with-categories.yaml @@ -1,20 +1,20 @@ order: 1 id: outlook-categories-work-with-categories name: Work with item categories -description: 'Gets, adds, and removes categories assigned to the item.' +description: Gets, adds, and removes categories assigned to the item. host: OUTLOOK api_set: Mailbox: '1.8' script: - content: | - $("#get-categories").click(getCategories); - $("#add-categories").click(addCategories); - $("#remove-categories").click(removeCategories); + content: |- + document.getElementById("get-categories").addEventListener("click", getCategories); + document.getElementById("add-categories").addEventListener("click", addCategories); + document.getElementById("remove-categories").addEventListener("click", removeCategories); function getCategories() { Office.context.mailbox.item.categories.getAsync(function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; + const categories = asyncResult.value; if (categories && categories.length > 0) { console.log("Categories assigned to this item:"); console.log(JSON.stringify(categories)); @@ -33,10 +33,10 @@ script: Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; + const masterCategories = asyncResult.value; if (masterCategories && masterCategories.length > 0) { // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; + const categoryToAdd = [masterCategories[0].displayName]; Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { console.log(`Successfully assigned category '${categoryToAdd}' to item.`); @@ -56,10 +56,10 @@ script: function removeCategories() { Office.context.mailbox.item.categories.getAsync(function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; + const categories = asyncResult.value; if (categories && categories.length > 0) { // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; + const categoryToRemove = [categories[0].displayName]; Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); @@ -78,11 +78,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to get, add, and remove categories assigned to the item.

- -
+

Try it out

-
+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -60,15 +60,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/55-display-items/display-new-appointment.yaml b/samples/outlook/55-display-items/display-new-appointment.yaml index 727832dd4..f562ea6c9 100644 --- a/samples/outlook/55-display-items/display-new-appointment.yaml +++ b/samples/outlook/55-display-items/display-new-appointment.yaml @@ -1,3 +1,4 @@ +order: 2 id: outlook-display-items-display-new-appointment name: Create a new appointment description: Opens a new appointment form with sample content and a few fields populated. @@ -5,13 +6,13 @@ host: OUTLOOK api_set: Mailbox: '1.9' script: - content: | - $("#run").click(run); - $("#run-async").click(runAsync); + content: |- + document.getElementById("run").addEventListener("click", run); + document.getElementById("run-async").addEventListener("click", runAsync); function run() { - var start = new Date(); - var end = new Date(); + const start = new Date(); + const end = new Date(); end.setHours(start.getHours() + 1); Office.context.mailbox.displayNewAppointmentForm({ @@ -27,8 +28,8 @@ script: } function runAsync() { - var start = new Date(); - var end = new Date(); + const start = new Date(); + const end = new Date(); end.setHours(start.getHours() + 1); // The async version is only available starting with requirement set 1.9, @@ -52,12 +53,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to display a new appointment and populate attendees, location, body, and a few other properties.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -80,15 +80,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/55-display-items/display-new-message.yaml b/samples/outlook/55-display-items/display-new-message.yaml index fe126b5b7..0302dc756 100644 --- a/samples/outlook/55-display-items/display-new-message.yaml +++ b/samples/outlook/55-display-items/display-new-message.yaml @@ -1,13 +1,14 @@ +order: 1 id: outlook-display-items-display-new-message name: Create a new message -description: 'Opens a new message form with a sample content, recipients, and an inline image attachment' +description: Opens a new message form with a sample content, recipients, and an inline image attachment host: OUTLOOK api_set: Mailbox: '1.9' script: - content: | - $("#run").click(run); - $("#run-async").click(runAsync); + content: |- + document.getElementById("run").addEventListener("click", run); + document.getElementById("run-async").addEventListener("click", runAsync); function run() { Office.context.mailbox.displayNewMessageForm({ @@ -19,7 +20,7 @@ script: { type: "file", name: "image.png", - url: "http://www.cutestpaw.com/wp-content/uploads/2011/11/Cute-Black-Dogs-s.jpg", + url: "https://i.imgur.com/9S36xvA.jpg", isInline: true } ] @@ -39,24 +40,23 @@ script: { type: "file", name: "image.png", - url: "http://www.cutestpaw.com/wp-content/uploads/2011/11/Cute-Black-Dogs-s.jpg", + url: "https://i.imgur.com/9S36xvA.jpg", isInline: true } ] }, - function(asyncResult) { + (asyncResult) => { console.log(JSON.stringify(asyncResult)); } ); } language: typescript template: - content: | -
+ content: |- +

This sample shows how to display a new message, populate recipients, subject, and body, and add an inline image attachment.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -79,15 +79,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/55-display-items/display-reply-forms.yaml b/samples/outlook/55-display-items/display-reply-forms.yaml index fbf9ff7d9..3759106b0 100644 --- a/samples/outlook/55-display-items/display-reply-forms.yaml +++ b/samples/outlook/55-display-items/display-reply-forms.yaml @@ -1,3 +1,4 @@ +order: 5 id: outlook-display-items-display-reply-forms name: Create replies description: Opens reply and reply-all message forms with sample reply content. @@ -5,11 +6,11 @@ host: OUTLOOK api_set: Mailbox: '1.9' script: - content: | - $("#display-reply-form").click(displayReplyForm); - $("#display-reply-form-async").click(displayReplyFormAsync); - $("#display-reply-all-form").click(displayReplyAllForm); - $("#display-reply-all-form-async").click(displayReplyAllFormAsync); + content: |- + document.getElementById("display-reply-form").addEventListener("click", displayReplyForm); + document.getElementById("display-reply-form-async").addEventListener("click", displayReplyFormAsync); + document.getElementById("display-reply-all-form").addEventListener("click", displayReplyAllForm); + document.getElementById("display-reply-all-form-async").addEventListener("click", displayReplyAllFormAsync); // The async version is only available starting with requirement set 1.9. function displayReplyForm() { @@ -38,11 +39,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to create reply or reply-all messages and populate the body of the reply.

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -72,15 +72,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/55-display-items/display-reply-with-attachments.yaml b/samples/outlook/55-display-items/display-reply-with-attachments.yaml index ff2d97913..bb2dbd573 100644 --- a/samples/outlook/55-display-items/display-reply-with-attachments.yaml +++ b/samples/outlook/55-display-items/display-reply-with-attachments.yaml @@ -1,61 +1,191 @@ +order: 6 id: outlook-display-items-display-reply-with-attachments -name: 'Create a reply, with attachments' -description: Opens a reply message forms and adds sample attachments. +name: Create a reply with attachments +description: Opens a reply or reply-all message form and adds sample attachments. host: OUTLOOK api_set: Mailbox: '1.9' script: - content: | - $("#run").click(run); - $("#run-async").click(runAsync); + content: |- + document.getElementById("reply").addEventListener("click", reply); + document.getElementById("reply-async").addEventListener("click", replyAsync); + document.getElementById("reply-all").addEventListener("click", replyAll); + document.getElementById("reply-all-async").addEventListener("click", replyAllAsync); + + function reply() { + // Define attachments. + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; - function run() { + // Create the reply with attachments. Office.context.mailbox.item.displayReplyForm({ - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ], - options: { asyncContext: null }, - callback: function(result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { console.error(`Action failed with message ${result.error.message}`); + return; } + + console.log("Created a reply with attachments."); } }); } - function runAsync() { - // The async version is only available starting with requirement set 1.9, - // and provides a callback when the new appointment form has been created. + function replyAll() { + // Define attachments. + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + // Create the reply with attachments. + Office.context.mailbox.item.displayReplyAllForm({ + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); + } + }); + } + + function replyAsync() { + // Define attachments. + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + // The async version was introduced in requirement set 1.9. + // It provides a callback when the new appointment form has been created. Office.context.mailbox.item.displayReplyFormAsync( { - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ] + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

", + attachments: [base64Attachment, fileAttachment, itemAttachment] }, - function(asyncResult) { - console.log(JSON.stringify(asyncResult)); + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created reply with attachments."); + } + ); + } + + function replyAllAsync() { + // Define attachments. + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + // The async version was introduced in requirement set 1.9. + // It provides a callback when the new appointment form has been created. + Office.context.mailbox.item.displayReplyAllFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); } ); } language: typescript template: content: |- -
+

This sample shows how to create a reply message and add an inline image attachment and an item attachment.

+

Required mode: Compose

- -
+

Try it out

- + + + -
language: html style: @@ -71,15 +201,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/60-sensitivity-label/sensitivity-label.yaml b/samples/outlook/60-sensitivity-label/sensitivity-label.yaml new file mode 100644 index 000000000..6bda2298e --- /dev/null +++ b/samples/outlook/60-sensitivity-label/sensitivity-label.yaml @@ -0,0 +1,94 @@ +order: 2 +id: outlook-sensitivity-labels-sensitivity-label +name: Work with sensitivity labels (Compose) +description: Gets and sets the sensitivity label on a message or appointment in compose mode. +host: OUTLOOK +api_set: + Mailbox: '1.13' +script: + content: |- + document.getElementById("get-sensitivity-label").addEventListener("click", getCurrentSensitivityLabel); + document.getElementById("set-sensitivity-label").addEventListener("click", setSensitivityLabel); + + function getCurrentSensitivityLabel() { + // This snippet gets the current mail item's sensitivity label. + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.mailbox.item.sensitivityLabel.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + + function setSensitivityLabel() { + // This snippet sets the sensitivity label on the current mail item. + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.sensitivityLabelsCatalog.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const catalog = asyncResult.value; + if (catalog.length > 0) { + var id = catalog[0].id; + Office.context.mailbox.item.sensitivityLabel.setAsync(id, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.status); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + else { + console.log("Catalog list is empty"); + } + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get and set the sensitivity label on a message or appointment being composed. To learn more about the sensitivity label API, see Manage the sensitivity label of your message or appointment in compose mode.

+

Required mode: Compose

+
+
+

Try it out

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml b/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml new file mode 100644 index 000000000..4467e3f77 --- /dev/null +++ b/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml @@ -0,0 +1,77 @@ +order: 1 +id: outlook-sensitivity-labels-sensitivity-labels-catalog +name: Work with the sensitivity labels catalog +description: Determines if sensitivity labels are enabled on the mailbox and retrieves all available labels from the catalog. +host: OUTLOOK +api_set: + Mailbox: '1.13' +script: + content: |- + document.getElementById("get-sensitivity-labels-enabled").addEventListener("click", getSensitivityLabelsCatalogIsEnabled); + document.getElementById("get-sensitivity-labels-catalog").addEventListener("click", getSensitivityLabelsCatalog); + + function getSensitivityLabelsCatalogIsEnabled() { + // This snippet determines if the sensitivity labels catalog is enabled on the current mailbox. + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + + function getSensitivityLabelsCatalog() { + // This snippet gets all available sensitivity labels from the catalog. + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.sensitivityLabelsCatalog.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const catalog = asyncResult.value; + console.log("Sensitivity Labels Catalog:"); + console.log(JSON.stringify(catalog)); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to determine if sensitivity labels are enabled on the mailbox and retrieves all available labels from the catalog. To learn more about the sensitivity label API, see Manage the sensitivity label of your message or appointment in compose mode.

+

Required mode: Compose

+
+
+

Try it out

+ + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml b/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml index d19d0927b..2a937c32d 100644 --- a/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml +++ b/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml @@ -1,131 +1,46 @@ id: outlook-delegates-and-shared-folders-get-shared-properties -name: Perform an operation as delegate -description: 'Gets shared properties for an item, checks delegate permissions and performs an operation as delegate.' +name: Identify a shared folder or shared mailbox context +description: Identifies whether the current mail item is in a shared folder or shared mailbox by getting its properties. host: OUTLOOK api_set: - Mailbox: '1.8' + Mailbox: '1.13' script: - content: | - $("#get").click(get); - $("#run-message").click(runOnMessage); - $("#run-appointment").click(runOnAppointment); + content: |- + document.getElementById("get").addEventListener("click", get); function get() { - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an item from a shared folder."); - return; - } - - Office.context.mailbox.item.getSharedPropertiesAsync(function(result) { - console.log(result.value); - }); - } - - function runOnMessage() { - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on a message from a shared folder."); - return; - } - - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/messages/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); - } - }); - } - - function runOnAppointment() { - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an appointment from a shared folder."); - return; - } - - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/events/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); }); } language: typescript template: - content: | -
-

This sample shows how to perform an operation as delegate.

+ content: |- +
+

This sample shows how to identify if the current mail item is in a shared folder or shared mailbox. This is done + by getting the item's shared properties.

+

Required mode: Compose, Read

+

Note: If you're testing this in Message Compose mode in Outlook on web or on Windows (new or classic), you + must meet certain conditions to call the getSharedPropertiesAsync method. To learn more, see Implement shared folders and shared mailbox scenarios in an Outlook add-in.

- -
-

Try it out on an item from a shared folder.

- - - +
+

Try it out on a message or appointment from a shared folder or shared mailbox.

+
language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -137,15 +52,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml b/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml new file mode 100644 index 000000000..efdf1f74d --- /dev/null +++ b/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml @@ -0,0 +1,69 @@ +id: outlook-mime-headers-get-internet-headers-message-read +name: Get internet headers +description: Gets internet headers on a message in Read mode. +host: OUTLOOK +api_set: + Mailbox: '1.8' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + Office.context.mailbox.item.getAllInternetHeadersAsync(function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Internet headers received successfully"); + if (asyncResult.value.match(/preferred-fruit:.*/gim)) { + console.log("Sender's preferred fruit: " + asyncResult.value.match(/preferred-fruit:.*/gim)[0].slice(17)); + } else { + console.log("Didn't receive header with sender's preferred fruit"); + } + if (asyncResult.value.match(/preferred-vegetable:.*/gim)) { + console.log( + "Sender's preferred vegetable: " + asyncResult.value.match(/preferred-vegetable:.*/gim)[0].slice(21) + ); + } else { + console.log("Didn't receive header with sender's preferred vegetable"); + } + } else { + console.log("Error getting internet headers: " + JSON.stringify(asyncResult.error)); + } + }); + } + + /* Sample output: + Sender's preferred fruit: orange + Sender's preferred vegetable: broccoli + */ + language: typescript +template: + content: |- +
+

This sample shows how to get internet headers on a message in Read mode.

+

Required mode: Message Read

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml b/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml new file mode 100644 index 000000000..78c540b7a --- /dev/null +++ b/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml @@ -0,0 +1,100 @@ +id: outlook-mime-headers-manage-custom-internet-headers-message-compose +name: Work with custom internet headers +description: Sets, gets, and removes custom internet headers on a message in Compose mode. +host: OUTLOOK +api_set: + Mailbox: '1.8' +script: + content: |- + document.getElementById("set-custom-headers").addEventListener("click", setCustomHeaders); + document.getElementById("get-selected-custom-headers").addEventListener("click", getSelectedCustomHeaders); + document.getElementById("remove-selected-custom-headers").addEventListener("click", removeSelectedCustomHeaders); + + // Set custom internet headers. + function setCustomHeaders() { + Office.context.mailbox.item.internetHeaders.setAsync( + { "preferred-fruit": "orange", "preferred-vegetable": "broccoli", "best-vegetable": "spinach" }, + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully set headers"); + } else { + console.log("Error setting headers: " + JSON.stringify(asyncResult.error)); + } + } + + ); + } + + // Get custom internet headers. + function getSelectedCustomHeaders() { + Office.context.mailbox.item.internetHeaders.getAsync( + ["preferred-fruit", "preferred-vegetable", "best-vegetable", "nonexistent-header"], + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Selected headers: " + JSON.stringify(asyncResult.value)); + } else { + console.log("Error getting selected headers: " + JSON.stringify(asyncResult.error)); + } + } + ); + } + + // Remove custom internet headers. + function removeSelectedCustomHeaders() { + Office.context.mailbox.item.internetHeaders.removeAsync( + ["best-vegetable", "nonexistent-header"], + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully removed selected headers"); + } else { + console.log("Error removing selected headers: " + JSON.stringify(asyncResult.error)); + } + } + ); + } + + /* Sample output: + Successfully set headers + Selected headers: {"best-vegetable":"spinach","preferred-fruit":"orange","preferred-vegetable":"broccoli"} + Successfully removed selected headers + Selected headers: {"preferred-fruit":"orange","preferred-vegetable":"broccoli"} + */ + language: typescript +template: + content: |- +
+

This sample shows how to set, get, and remove custom internet headers on a message in Compose mode.

+

Required mode: Message Compose

+
+
+

Try it out

+ + + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml b/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml deleted file mode 100644 index 609b69f79..000000000 --- a/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml +++ /dev/null @@ -1,101 +0,0 @@ -id: outlook-entities-and-regex-matches-basic-entities -name: Entities (Item Read) -description: Gets extracted entities. -host: OUTLOOK -api_set: - Mailbox: '1.1' -script: - content: | - $("#getEntities").click(getEntities); - $("#getEntitiesByType").click(getEntitiesByType); - - function getEntities() { - var entities = Office.context.mailbox.item.getEntities(); - var entityTypesFound = 0; - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } - if (entityTypesFound == 0) - { - console.log("No entities found on this item."); - } - } - - function getEntitiesByType() { - console.log(Office.context.mailbox.item.getEntitiesByType(Office.MailboxEnums.EntityType.Address)); - } - language: typescript -template: - content: | -
-

This sample shows how to get extracted entities.

-

Required mode: Item Read

-
- -
-

Try it out

- - -
- 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 diff --git a/samples/outlook/75-entities-and-regex-matches/contextual.yaml b/samples/outlook/75-entities-and-regex-matches/contextual.yaml deleted file mode 100644 index 3e30783aa..000000000 --- a/samples/outlook/75-entities-and-regex-matches/contextual.yaml +++ /dev/null @@ -1,83 +0,0 @@ -id: outlook-entities-and-regex-matches-contextual -name: 'Entities and Regex matches (Item Read, contextual)' -description: Gets extracted entities and regex matches when the add-in is opened as a contextual add-in. -host: OUTLOOK -api_set: - Mailbox: '1.1' -script: - content: | - $("#getFilteredEntitiesByName").click(getFilteredEntitiesByName); - $("#getRegExMatches").click(getRegExMatches); - $("#getRegExMatchesByName").click(getRegExMatchesByName); - - function getFilteredEntitiesByName() { - // This API would only work when you click on highlighted physical address that has the word "Way" in it. - console.log(Office.context.mailbox.item.getFilteredEntitiesByName("sampleFilterName")); - } - - function getRegExMatches() { - // This API would only work when you click on highlighted word "ScriptLab". - console.log(Office.context.mailbox.item.getRegExMatches()); - } - - function getRegExMatchesByName() { - // This API would only work when you click on highlighted word "ScriptLab". - console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); - } - - // This add-in declares extension point rules copied below. To see it activated contextually - // for address entity, try running it on an email that has "1 Microsoft Way, Redmond, WA 98052" in its content; - // for regex match, try running it on an email that has "ScriptLab" in its content. - // - // - // - // - // - // - // - language: typescript -template: - content: | -
-

This sample shows how to get extracted entities and regex matches.

-

Required mode: Item Read, contextual add-in

-
- -
-

Try it out while running this as a contextual add-in

- - - -
- 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 diff --git a/samples/outlook/75-entities-and-regex-matches/selected.yaml b/samples/outlook/75-entities-and-regex-matches/selected.yaml deleted file mode 100644 index 19a88dbd0..000000000 --- a/samples/outlook/75-entities-and-regex-matches/selected.yaml +++ /dev/null @@ -1,118 +0,0 @@ -id: outlook-entities-and-regex-matches-selected -name: 'Selected entities and Regex matches (Item Read, contextual)' -description: Gets selected entities and regex matches. -host: OUTLOOK -api_set: - Mailbox: '1.6' -script: - content: | - $("#getSelectedEntities").click(getSelectedEntities); - $("#getSelectedRegExMatches").click(getSelectedRegExMatches); - - function getSelectedEntities() { - var entities = Office.context.mailbox.item.getSelectedEntities(); - var entityTypesFound = 0; - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } - if (entityTypesFound == 0) - { - console.error("Open add-in by clicking on a highlighted entity, for this API to return something useful."); - } - } - - function getSelectedRegExMatches() { - var matches = Office.context.mailbox.item.getSelectedRegExMatches(); - if (matches) { - console.log(matches); - } - else { - console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); - } - } - - // This add-in declares extension point rules copied below. To see it activated contextually - // for address entity, try running it on an email that has "1 Microsoft Way, Redmond, WA 98052" in its content; - // for regex match, try running it on an email that has "ScriptLab" in its content. - // - // - // - // - // - // - // - language: typescript -template: - content: | -
-

This sample shows how to get selected entities and regex matches.

-

Required mode: Item Read

-
- -
-

Try it out while running this as a contextual add-in

- - -
- 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 diff --git a/samples/outlook/75-regex-matches/contextual.yaml b/samples/outlook/75-regex-matches/contextual.yaml new file mode 100644 index 000000000..c601055e2 --- /dev/null +++ b/samples/outlook/75-regex-matches/contextual.yaml @@ -0,0 +1,85 @@ +id: outlook-regex-matches-contextual +name: Get regex matches (Item Read, contextual) +description: Gets regex matches when the add-in is opened as a contextual add-in. +host: OUTLOOK +api_set: + Mailbox: '1.6' +script: + content: |- + document.getElementById("getRegExMatches").addEventListener("click", getRegExMatches); + document.getElementById("getRegExMatchesByName").addEventListener("click", getRegExMatchesByName); + document.getElementById("getSelectedRegExMatches").addEventListener("click", getSelectedRegExMatches); + + function getRegExMatches() { + // This API only works when you click on the highlighted word "ScriptLab". + console.log(Office.context.mailbox.item.getRegExMatches()); + } + + function getRegExMatchesByName() { + // This API only works when you click on the highlighted word "ScriptLab". + console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); + } + + function getSelectedRegExMatches() { + const matches = Office.context.mailbox.item.getSelectedRegExMatches(); + if (matches) { + console.log(matches); + } else { + console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); + } + } + + /* This add-in declares extension point manifest rules copied below. + For regex match, try running it on an email that has "ScriptLab" in its content. + Note: The following only applies when your add-in uses an XML manifest. Contextual add-ins aren't supported when a unified app manifest for Microsoft 365 (https://learn.microsoft.com/office/dev/add-ins/develop/unified-manifest-overview) is in use. + + + + + + */ + language: typescript +template: + content: |- +
+

This sample shows how to get regex matches.

+

Note: Contextual add-ins only support the use of an XML manifest. This feature isn't supported when your + add-in uses a + unified app manifest + for Microsoft 365.

+

Required mode: Item Read, contextual add-in

+
+
+

Tip: Try this out as a contextual add-in.

+ + + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/80-events/drag-drop-item.yaml b/samples/outlook/80-events/drag-drop-item.yaml new file mode 100644 index 000000000..8496c37ad --- /dev/null +++ b/samples/outlook/80-events/drag-drop-item.yaml @@ -0,0 +1,72 @@ +id: outlook-events-drag-drop-item +name: Drag and drop an item into the task pane +description: Handles the drag-and-drop event when a user drags and drops messages and file attachments into the add-in task pane. +host: OUTLOOK +api_set: + Mailbox: '1.5' +script: + content: | + Office.onReady(() => { + dragAndDropEventHandler(event); + }); + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } + language: typescript +template: + content: |- +
+

Drag and drop messages and file attachments into the add-in task pane.

+

To learn more about the drag-and-drop feature, see Drag and drop messages and + attachments into the task pane of an Outlook add-in.

+

Required mode: Compose or Read

+

Supported Outlook clients: Outlook on the web and the new Outlook on Windows

+
+
+

Try it out

+
    +
  1. Drag a message or file attachment from your mailbox to the task pane. As you drag the item across the task pane, the event name and the coordinates of your mouse pointer are displayed in the console.
  2. +
  3. Drop the message or file attachment into the task pane. The properties + of the dropped item are displayed in the console.
  4. +
+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml b/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml deleted file mode 100644 index ceb798d6e..000000000 --- a/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml +++ /dev/null @@ -1,66 +0,0 @@ -order: 5 -id: outlook-tokens-and-service-calls-basic-rest-cors -name: Get a message using REST -description: Gets a message using REST without any back-end code. -host: OUTLOOK -api_set: - Mailbox: '1.5' -script: - content: | - $("#run").click(run); - - function run() { - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) { - var ewsId = Office.context.mailbox.item.itemId; - var token = result.value; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + restId; - - var xhr = new XMLHttpRequest(); - xhr.open('GET', getMessageUrl); - xhr.setRequestHeader("Authorization", "Bearer " + token); - xhr.onload = function (e) { - console.log(this.response); - } - xhr.send(); - }); - } - language: typescript -template: - content: | -
-

This sample shows how to get a message using REST, without any back-end code.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml b/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml deleted file mode 100644 index c310ed7a5..000000000 --- a/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml +++ /dev/null @@ -1,62 +0,0 @@ -order: 1 -id: outlook-tokens-and-service-calls-ids-and-urls -name: Endpoint URLs and item IDs -description: 'Retrieves and displays REST and EWS endpoint URLs and item IDs, and converts item IDs for different protocols.' -host: OUTLOOK -api_set: - Mailbox: '1.5' -script: - content: | - $("#run").click(run); - - function run() { - console.log("EWS URL: " + Office.context.mailbox.ewsUrl); - var ewsId = Office.context.mailbox.item.itemId; - console.log("EWS item ID: " + Office.context.mailbox.item.itemId); - - console.log("REST URL: " + Office.context.mailbox.restUrl); - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - console.log("REST item ID: " + restId); - - var ewsId2 = Office.context.mailbox.convertToEwsId(restId, Office.MailboxEnums.RestVersion.v2_0); - console.log("EWS ID (from REST ID): " + ewsId2); - } - language: typescript -template: - content: | -
-

This sample shows how to retrieve REST and EWS endpoint URLs and item IDs, and convert item IDs for different protocols.

-
- -
-

Try it out

- -
- 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 diff --git a/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml b/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml deleted file mode 100644 index ad0ec35f9..000000000 --- a/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml +++ /dev/null @@ -1,59 +0,0 @@ -order: 8 -id: outlook-tokens-and-service-calls-item-id-compose -name: Get an item ID in compose mode -description: 'Gets an item ID in compose mode, to use in certain delegate scenarios.' -host: OUTLOOK -api_set: - Mailbox: '1.8' -script: - content: | - $("#run").click(run); - - function run() { - Office.context.mailbox.item.getItemIdAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`getItemIdAsync failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } - }); - } - language: typescript -template: - content: | -
-

This sample shows how to get an item ID in compose mode, to use in delegate scenarios where the item can't be saved due to insufficient delegate permissions.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml b/samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml deleted file mode 100644 index 06c761dc9..000000000 --- a/samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml +++ /dev/null @@ -1,70 +0,0 @@ -order: 6 -id: outlook-tokens-and-service-calls-make-ews-request-async -name: Get a message using EWS -description: Gets a message using EWS without any back-end code. -host: OUTLOOK -api_set: - Mailbox: '1.1' -script: - content: | - $("#run").click(run); - - function run() { - var ewsId = Office.context.mailbox.item.itemId; - var request = '' + - ' ' + - ' ' + - ' ' + - ' ' + - ' IdOnly' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ''; - - Office.context.mailbox.makeEwsRequestAsync(request, function (result) { - console.log(result); - }); - } - language: typescript -template: - content: | -
-

This sample shows how to get a message using EWS, without any back-end code.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml b/samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml deleted file mode 100644 index cec954b38..000000000 --- a/samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml +++ /dev/null @@ -1,59 +0,0 @@ -order: 4 -id: outlook-tokens-and-service-calls-user-callback-token -name: Get a callback token -description: Gets a callback token to use for calling outlook services from add-in's backend service. -host: OUTLOOK -api_set: - Mailbox: '1.1' -script: - content: | - $("#run").click(run); - - function run() { - Office.context.mailbox.getCallbackTokenAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Token retrieval failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } - }); - } - language: typescript -template: - content: | -
-

This sample shows how to get a callback token to use for calling outlook services from add-in's backend service.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml b/samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml deleted file mode 100644 index e974bfb1e..000000000 --- a/samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml +++ /dev/null @@ -1,59 +0,0 @@ -order: 3 -id: outlook-tokens-and-service-calls-user-identity-token -name: Get a user identity token -description: Gets a user identity token to use in authentication flows. -host: OUTLOOK -api_set: - Mailbox: '1.1' -script: - content: | - $("#run").click(run); - - function run() { - Office.context.mailbox.getUserIdentityTokenAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Token retrieval failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } - }); - } - language: typescript -template: - content: | -
-

This sample shows how to get a user identity token to use in authentication flows.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml new file mode 100644 index 000000000..e8c65bb22 --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml @@ -0,0 +1,78 @@ +order: 9 +id: outlook-tokens-and-service-calls-get-icaluid-as-attendee +name: Get an appointment's iCalUId as an attendee (Exchange on-premises only) +description: Uses Exchange Web Services (EWS) in an Exchange on-premises environment to get an appointment's iCalUId value where the user is an attendee. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + const ewsId = Office.context.mailbox.item.itemId; + const request = ` + + + + + AllProperties + + + + + + + `; + + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(getUID(result.value)); + }); + } + + function getUID(xmlResult) { + const parser = new DOMParser(); + const xmlText = parser.parseFromString(xmlResult, "text/xml"); + return xmlText.getElementsByTagName("t:UID")[0].childNodes[0].nodeValue; + } + language: typescript +template: + content: |- +
+

This sample uses Exchange Web Services (EWS) to get an appointment's iCalUId value if the user is an attendee.

+

Important: Exchange user identity and callback tokens are only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. Then, use Microsoft Graph to get the iCalUId property. +

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml new file mode 100644 index 000000000..2ac46bca0 --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml @@ -0,0 +1,82 @@ +order: 8 +id: outlook-tokens-and-service-calls-get-icaluid-as-organizer +name: Get an appointment's iCalUId as the organizer (Exchange on-premises only) +description: Uses Exchange Web Services (EWS) in an Exchange on-premises environment to get an appointment's iCalUId value where the user is the organizer. +host: OUTLOOK +api_set: + Mailbox: '1.3' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + Office.context.mailbox.item.saveAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + const ewsId = result.value; + const request = ` + + + + + AllProperties + + + + + + + `; + + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(getUID(result.value)); + }); + }); + } + + function getUID(xmlResult) { + const parser = new DOMParser(); + const xmlText = parser.parseFromString(xmlResult, "text/xml"); + return xmlText.getElementsByTagName("t:UID")[0].childNodes[0].nodeValue; + } + language: typescript +template: + content: |- +
+

This sample uses Exchange Web Services (EWS) to get an appointment's iCalUId value if the user is the organizer.

+

Important: Exchange user identity and callback tokens are only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. Then, use Microsoft Graph to get the iCalUId property. +

+
+ + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml new file mode 100644 index 000000000..d87c66aff --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml @@ -0,0 +1,61 @@ +order: 1 +id: outlook-tokens-and-service-calls-ids-and-urls +name: Endpoint URLs and item IDs in Exchange on-premises environments +description: Retrieves the Exchange Web Services (EWS) endpoint URL and item IDs and converts item IDs for different protocols. +host: OUTLOOK +api_set: + Mailbox: '1.5' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + // Get the EWS URL and EWS item ID. + console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + const ewsId = Office.context.mailbox.item.itemId; + console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + + // Convert the EWS item ID to a REST-formatted ID. + const restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); + console.log("REST item ID: " + restId); + + // Convert the REST-formatted ID back to an EWS-formatted ID. + const ewsId2 = Office.context.mailbox.convertToEwsId(restId, Office.MailboxEnums.RestVersion.v2_0); + console.log("EWS ID (from REST ID): " + ewsId2); + } + language: typescript +template: + content: |- +
+

This sample shows how to retrieve the EWS endpoint URL and item IDs, and convert item IDs for different protocols.

+

Important: Exchange user identity and callback tokens are only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. +

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml new file mode 100644 index 000000000..b56e7e86d --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml @@ -0,0 +1,67 @@ +order: 6 +id: outlook-tokens-and-service-calls-make-ews-request-async +name: Get a message using Exchange Web Services (EWS) in Exchange on-premises environments +description: Uses EWS in an Exchange on-premises environment to get a message without any backend code. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + const ewsId = Office.context.mailbox.item.itemId; + const request = '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' IdOnly' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ''; + + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { + console.log(result); + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get a message using EWS, without any backend code.

+

Important: This API is only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. Then, use Microsoft Graph to get the message. +

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml similarity index 58% rename from samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml rename to samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml index c9f6f9468..a9d4582cf 100644 --- a/samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml +++ b/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml @@ -1,16 +1,16 @@ order: 7 id: outlook-tokens-and-service-calls-send-message-using-make-ews-request-async -name: Send a message using EWS -description: Sends a message using EWS without any back-end code. +name: Send a message using Exchange Web Services (EWS) in Exchange on-premises environments +description: Uses EWS in an Exchange on-premises environment to send a message without any backend code. host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { - var request = ''+ + const request = ''+ ' '+ ' '+ ' '+ @@ -28,18 +28,21 @@ script: ' '+ ''; - Office.context.mailbox.makeEwsRequestAsync(request, function (result) { + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { console.log(result); }); } language: typescript template: - content: | -
+ content: |- +

This sample shows how to send a message using EWS, without any back-end code.

+

Important: This API is only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. Then, use Microsoft Graph to send the message. +

- -
+

Try it out

language: html style: - content: | + content: |- section.samples { margin-top: 20px; } @@ -59,15 +62,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml new file mode 100644 index 000000000..c60954ab4 --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml @@ -0,0 +1,58 @@ +order: 4 +id: outlook-tokens-and-service-calls-user-callback-token +name: Get a callback token in Exchange on-premises environments +description: Gets a callback token to call Outlook services from an add-in's backend service in an Exchange on-premises environment. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + Office.context.mailbox.getCallbackTokenAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Token retrieval failed with message: ${result.error.message}`); + return; + } + + console.log(result.value); + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get a callback token to call Outlook services from an add-in's backend service.

+

Important: Exchange user identity and callback tokens are only supported in Exchange on-premises environments. + Additionally, the Outlook REST v2.0 endpoint has been deprecated. Use + nested app authentication (NAA) + to get an access token instead. +

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml b/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml new file mode 100644 index 000000000..35efaf934 --- /dev/null +++ b/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml @@ -0,0 +1,57 @@ +order: 3 +id: outlook-tokens-and-service-calls-user-identity-token +name: Get a user identity token in Exchange on-premises environments +description: Gets a user identity token for authentication flows in an Exchange on-premises environment. +host: OUTLOOK +api_set: + Mailbox: '1.1' +script: + content: |- + document.getElementById("run").addEventListener("click", run); + + function run() { + Office.context.mailbox.getUserIdentityTokenAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Token retrieval failed with message: ${result.error.message}`) + return; + } + + console.log(result.value); + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get a user identity token to use in authentication flows.

+

Important: This API is only supported in Exchange on-premises environments. + In Exchange Online environments, use nested app authentication (NAA) + to get an access token. +

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/delay-message-delivery.yaml b/samples/outlook/90-other-item-apis/delay-message-delivery.yaml new file mode 100644 index 000000000..016265921 --- /dev/null +++ b/samples/outlook/90-other-item-apis/delay-message-delivery.yaml @@ -0,0 +1,115 @@ +order: 21 +id: outlook-delay-message-delivery +name: Get and set message delivery (Message Compose) +description: Gets and sets the delivery date and time of a message in compose mode. +host: OUTLOOK +api_set: + Mailbox: '1.13' +script: + content: |- + document.getElementById("get-date").addEventListener("click", getDeliveryDate); + document.getElementById("set-time-five-minutes").addEventListener("click", () => computeDelay("set-time-five-minutes")); + document.getElementById("set-time-fifteen-minutes").addEventListener("click", () => computeDelay("set-time-fifteen-minutes")); + document.getElementById("set-time-thirty-minutes").addEventListener("click", () => computeDelay("set-time-thirty-minutes")); + document.getElementById("set-time-sixty-minutes").addEventListener("click", () => computeDelay("set-time-sixty-minutes")); + document.getElementById("set-time-one-day").addEventListener("click", () => computeDelay("set-time-one-day")); + + let totalDelay = 0; + + function computeDelay(input) { + // This snippet identifies additional delivery delay time in minutes and adds it to the total delivery delay time of a message. + const element = document.getElementById(input) as HTMLInputElement | null; + if (element != null) { + const minutes = Number(element.value); + totalDelay += minutes; + setDeliveryDate(minutes); + } + } + + function getDeliveryDate() { + // This snippet gets the delivery date and time of a message. + Office.context.mailbox.item.delayDeliveryTime.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + const deliveryDate = asyncResult.value; + if (deliveryDate === 0) { + console.log("Your message will be delivered immediately when you select Send."); + } else { + const date = new Date(deliveryDate); + console.log(`Message delivery date and time: ${date.toString()}`); + } + }); + } + + function setDeliveryDate(minutes) { + // This snippet sets the delivery date and time of a message. + const currentTime = new Date().getTime(); + const milliseconds = totalDelay * 60000; + const timeDelay = new Date(currentTime + milliseconds); + Office.context.mailbox.item.delayDeliveryTime.setAsync(timeDelay, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + if (minutes === 1440) { + console.log(`Delayed delivery by an additional one day.`); + } else { + console.log(`Delayed delivery by an additional ${minutes} minutes.`); + } + }); + } + language: typescript +template: + content: |- +
+

This sample gets and sets the delivery date and time of a message in compose mode. To learn more about this API, see Manage the delivery date and time of a message.

+

Required mode: Compose

+
+
+

Try it out

+
+ +
+

Delay message delivery by:

+ + + + + +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml b/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml index 595c17a5a..6366043dc 100644 --- a/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml +++ b/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml @@ -1,15 +1,15 @@ -order: 12 +order: 13 id: outlook-other-item-apis-get-add-remove-enhancedlocation-appointment name: Manage the locations of an appointment -description: 'Gets, adds, and removes locations on an appointment (enhancedLocation API).' +description: Gets, adds, and removes locations on an appointment (enhancedLocation API). host: OUTLOOK api_set: Mailbox: '1.8' script: - content: | - $("#get").click(get); - $("#add").click(add); - $("#remove").click(remove); + content: |- + document.getElementById("get").addEventListener("click", get); + document.getElementById("add").addEventListener("click", add); + document.getElementById("remove").addEventListener("click", remove); function get() { Office.context.mailbox.item.enhancedLocation.getAsync((result) => { @@ -17,7 +17,7 @@ script: console.error(`Failed to get locations. Error message: ${result.error.message}`); return; } - var places = result.value; + const places = result.value; if (places && places.length > 0) { result.value.forEach(function(place) { console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); @@ -32,7 +32,7 @@ script: } function add() { - var locations = [ + const locations = [ { id: "Contoso", type: Office.MailboxEnums.LocationType.Custom @@ -52,7 +52,7 @@ script: } function remove() { - var locations = [ + const locations = [ { id: "Contoso", type: Office.MailboxEnums.LocationType.Custom @@ -73,11 +73,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get and set the location of an appointment.

Required modes: Appointment Organizer, Appointment Attendee

-
+

Try it out

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml b/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml index 9b49d4624..172ec5713 100644 --- a/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml +++ b/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml @@ -1,4 +1,4 @@ -order: 15 +order: 16 id: outlook-other-item-apis-get-date-time-created-read name: Get the creation date and time (Read) description: Gets the creation date and time of an item in Read mode. @@ -6,8 +6,8 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); + content: |- + document.getElementById("get").addEventListener("click", get); function get() { console.log(`Creation date and time: ${Office.context.mailbox.item.dateTimeCreated}`); @@ -15,11 +15,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get the creation date and time of an item in Read mode.

Required modes: Appointment Attendee, Message Read

-
+

Try it out

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-eml-format.yaml b/samples/outlook/90-other-item-apis/get-eml-format.yaml new file mode 100644 index 000000000..03c7207ed --- /dev/null +++ b/samples/outlook/90-other-item-apis/get-eml-format.yaml @@ -0,0 +1,54 @@ +order: 25 +id: outlook-get-eml-format +name: Get the Base64-encoded EML format of a message (Message Read) +description: Gets the Base64-encoded EML format of a message in read mode. +host: OUTLOOK +api_set: + Mailbox: '1.14' +script: + content: |- + document.getElementById("get-eml-format").addEventListener("click", getEmlFormat); + + function getEmlFormat() { + Office.context.mailbox.item.getAsFileAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Error encountered during processing: ${asyncResult.error.message}`); + return; + } + + console.log(asyncResult.value); + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get the Base64-encoded EML format of a message in read mode.

+

Required mode: Message Read

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-end-read.yaml b/samples/outlook/90-other-item-apis/get-end-read.yaml index 6064b48d8..2a94acc22 100644 --- a/samples/outlook/90-other-item-apis/get-end-read.yaml +++ b/samples/outlook/90-other-item-apis/get-end-read.yaml @@ -1,4 +1,4 @@ -order: 8 +order: 9 id: outlook-other-item-apis-get-end-read name: Get the end date and time (Read) description: Gets the end date and time of an item in Read mode. @@ -6,24 +6,35 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); + content: |- + document.getElementById("get-utc").addEventListener("click", getUtc); + document.getElementById("get-local").addEventListener("click", getLocal); + + function getUtc() { + const time = Office.context.mailbox.item.end; + console.log(`Appointment ends (UTC): ${time.toUTCString()}`); + } - function get() { - console.log(`Appointment ends: ${Office.context.mailbox.item.end}`); + function getLocal() { + const time = Office.context.mailbox.item.end; + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); } language: typescript template: content: |- -
+

This sample shows how to get the end date and time of an item in Read mode.

Required modes: Appointment Attendee, Message Read (meeting request)

-
+

Try it out

+
Get end date and time (UTC)
+ +
language: html style: @@ -39,15 +50,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-in-reply-to.yaml b/samples/outlook/90-other-item-apis/get-in-reply-to.yaml new file mode 100644 index 000000000..70f961e5e --- /dev/null +++ b/samples/outlook/90-other-item-apis/get-in-reply-to.yaml @@ -0,0 +1,54 @@ +order: 26 +id: outlook-get-in-reply-to +name: Get the ID of the message being replied to (Message Compose) +description: Retrieves the ID of the message being replied to by the current message. +host: OUTLOOK +api_set: + Mailbox: '1.14' +script: + content: |- + document.getElementById("get-in-reply-to").addEventListener("click", getInReplyTo); + + function getInReplyTo() { + // This snippet gets the ID of the message being replied to by the current message (PR_IN_REPLY_TO_ID). + // The API call is supported on messages being composed and isn't supported on read items. + const inReplyTo = Office.context.mailbox.item.inReplyTo; + if (inReplyTo) { + console.log("ID of the message being replied to: " + inReplyTo); + } else { + console.log("No InReplyTo property available for this message"); + } + } + language: typescript +template: + content: |- +
+

This sample shows how to get the ID of the message being replied to by the current message.

+

Required mode: Message Compose

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml b/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml index 1bc713903..aa5c12ad2 100644 --- a/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml +++ b/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml @@ -1,4 +1,4 @@ -order: 3 +order: 4 id: outlook-other-item-apis-get-internet-message-id-read name: Get the internet message ID (Message Read) description: Gets the internet message ID of a message in Read mode. @@ -6,8 +6,8 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); + content: |- + document.getElementById("get").addEventListener("click", get); function get() { console.log(`Internet message ID: ${Office.context.mailbox.item.internetMessageId}`); @@ -15,11 +15,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get the internet message ID of a message in Read mode.

Required mode: Message Read

-
+

Try it out

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-item-class-read.yaml b/samples/outlook/90-other-item-apis/get-item-class-read.yaml index 5b4c6aed7..fb319fb09 100644 --- a/samples/outlook/90-other-item-apis/get-item-class-read.yaml +++ b/samples/outlook/90-other-item-apis/get-item-class-read.yaml @@ -1,4 +1,4 @@ -order: 4 +order: 5 id: outlook-other-item-apis-get-item-class-read name: Get the item class (Read) description: Gets the item class of an item in Read mode. @@ -6,8 +6,8 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); + content: |- + document.getElementById("get").addEventListener("click", get); function get() { console.log(`Item class: ${Office.context.mailbox.item.itemClass}`); @@ -15,11 +15,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get the item class of an item in Read mode.

Required mode: Read

-
+

Try it out

- + +
language: html style: @@ -68,15 +87,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml b/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml index 2ee241201..0602dd47c 100644 --- a/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml +++ b/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml @@ -1,4 +1,4 @@ -order: 11 +order: 12 id: outlook-other-item-apis-get-set-location-appointment-organizer name: Get and set the location (Appointment Organizer) description: Gets and sets the location of an appointment in Compose mode. @@ -6,9 +6,9 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); - $("#set").click(set); + content: |- + document.getElementById("get").addEventListener("click", get); + document.getElementById("set").addEventListener("click", set); function get() { Office.context.mailbox.item.location.getAsync((result) => { @@ -21,7 +21,7 @@ script: } function set() { - var location = "my office"; + const location = "my office"; Office.context.mailbox.item.location.setAsync(location, (result) => { if (result.status !== Office.AsyncResultStatus.Succeeded) { console.error(`Action failed with message ${result.error.message}`); @@ -33,11 +33,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get and set the location of an appointment in Compose mode.

Required mode: Appointment Organizer

-
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml b/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml index 122238177..b956d94e0 100644 --- a/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml +++ b/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml @@ -1,4 +1,4 @@ -order: 7 +order: 8 id: outlook-other-item-apis-get-set-start-appointment-organizer name: Get and set the start date and time (Appointment Organizer) description: Gets and sets the start date and time of an appointment in Compose mode. @@ -6,22 +6,38 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); - $("#set").click(set); + content: |- + document.getElementById("get-utc").addEventListener("click", getUtc); + document.getElementById("get-local").addEventListener("click", getLocal); + document.getElementById("set").addEventListener("click", set); - function get() { + function getUtc() { Office.context.mailbox.item.start.getAsync((result) => { if (result.status !== Office.AsyncResultStatus.Succeeded) { console.error(`Action failed with message ${result.error.message}`); return; } - console.log(`Appointment starts: ${result.value}`); + + const time = result.value; + console.log(`Appointment starts (UTC): ${time.toUTCString()}`); + }); + } + + function getLocal() { + Office.context.mailbox.item.start.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + const time = result.value; + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); }); } function set() { - var start = new Date(); // Represents current date and time. + const start = new Date(); // Represents current date and time. start.setDate(start.getDate() + 2); // Add 2 days to current date. Office.context.mailbox.item.start.setAsync(start, (result) => { if (result.status !== Office.AsyncResultStatus.Succeeded) { @@ -34,18 +50,21 @@ script: language: typescript template: content: |- -
+

This sample shows how to get and set the start date and time of an appointment in Compose mode.

Required mode: Appointment Organizer

-
+

Try it out

- + +
language: html style: @@ -61,15 +80,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml b/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml index b305987cc..7a78c2b10 100644 --- a/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml +++ b/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml @@ -6,9 +6,9 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); - $("#set").click(set); + content: |- + document.getElementById("get").addEventListener("click", get); + document.getElementById("set").addEventListener("click", set); function get() { Office.context.mailbox.item.subject.getAsync((result) => { @@ -33,11 +33,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to set and get the subject of an item in Compose mode.

Required mode: Compose

-
+

Try it out

+ +
language: html style: @@ -39,15 +50,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/get-subject-read.yaml b/samples/outlook/90-other-item-apis/get-subject-read.yaml index 55bd28c6d..446e6fc0a 100644 --- a/samples/outlook/90-other-item-apis/get-subject-read.yaml +++ b/samples/outlook/90-other-item-apis/get-subject-read.yaml @@ -6,8 +6,8 @@ host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#get").click(get); + content: |- + document.getElementById("get").addEventListener("click", get); function get() { console.log(`Subject: ${Office.context.mailbox.item.subject}`); @@ -15,11 +15,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to get the subject of an item in Read mode.

Required mode: Read

-
+

Try it out

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/90-other-item-apis/send-async.yaml b/samples/outlook/90-other-item-apis/send-async.yaml new file mode 100644 index 000000000..84360408c --- /dev/null +++ b/samples/outlook/90-other-item-apis/send-async.yaml @@ -0,0 +1,53 @@ +order: 30 +id: outlook-send-async +name: Send the current message or appointment (Compose) +description: Sends the current message or appointment. +host: OUTLOOK +api_set: + Mailbox: '1.15' +script: + content: |- + document.getElementById("send-async").addEventListener("click", sendAsync); + + function sendAsync() { + // This snippet sends the current message or appointment being composed. + Office.context.mailbox.item.sendAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to programmatically send the current message or appointment being composed.

+

Required mode: Compose

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/99-preview-apis/session-data-apis.yaml b/samples/outlook/90-other-item-apis/session-data-apis.yaml similarity index 77% rename from samples/outlook/99-preview-apis/session-data-apis.yaml rename to samples/outlook/90-other-item-apis/session-data-apis.yaml index 758ba3cf7..1a38250ca 100644 --- a/samples/outlook/99-preview-apis/session-data-apis.yaml +++ b/samples/outlook/90-other-item-apis/session-data-apis.yaml @@ -1,16 +1,17 @@ -id: outlook-session-data-apis +order: 20 +id: outlook-other-item-apis-session-data-apis name: Work with session data APIs (Compose) -description: 'Set, get, get all, remove, and clear session data in Compose mode.' +description: Sets, gets, gets all, removes, and clears session data in Compose mode. host: OUTLOOK api_set: - Mailbox: preview + Mailbox: '1.11' script: - content: | - $("#setSessionData").click(setSessionData); - $("#getSessionData").click(getSessionData); - $("#getAllSessionData").click(getAllSessionData); - $("#removeSessionData").click(removeSessionData); - $("#clearSessionData").click(clearSessionData); + content: |- + document.getElementById("setSessionData").addEventListener("click", setSessionData); + document.getElementById("getSessionData").addEventListener("click", getSessionData); + document.getElementById("getAllSessionData").addEventListener("click", getAllSessionData); + document.getElementById("removeSessionData").addEventListener("click", removeSessionData); + document.getElementById("clearSessionData").addEventListener("click", clearSessionData); function setSessionData() { Office.context.mailbox.item.sessionData.setAsync( "Date", @@ -67,14 +68,14 @@ script: language: typescript template: content: |- -
+

This sample shows how to set, get, get all, remove, and clear session data in compose mode.

Required mode: Compose

-
+
@@ -105,12 +106,8 @@ style: min-width: 80px; } language: css -libraries: | - https://appsforoffice.microsoft.com/lib/beta/hosted/office.js - @types/office-js-preview - 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 \ No newline at end of file +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/20-item-body/set-selected-data.yaml b/samples/outlook/90-other-item-apis/set-selected-data.yaml similarity index 72% rename from samples/outlook/20-item-body/set-selected-data.yaml rename to samples/outlook/90-other-item-apis/set-selected-data.yaml index 4d8777681..8336180c8 100644 --- a/samples/outlook/20-item-body/set-selected-data.yaml +++ b/samples/outlook/90-other-item-apis/set-selected-data.yaml @@ -1,13 +1,13 @@ -order: 2 +order: 3 id: outlook-item-body-set-selected-data -name: Set selected text (Compose) +name: Replace selected text in item body or subject (Compose) description: Replaces the selected text in the item body or subject in Compose mode. host: OUTLOOK api_set: Mailbox: '1.1' script: - content: | - $("#set-selected-data").click(setSelectedData); + content: |- + document.getElementById("set-selected-data").addEventListener("click", setSelectedData); function setSelectedData() { Office.context.mailbox.item.setSelectedDataAsync("Replaced", function(asyncResult) { @@ -21,12 +21,11 @@ script: language: typescript template: content: |- -
+

This sample shows how to replace the selected text in the item body or subject/title.

Required mode: Compose

- -
+

Try it out

Select text in the item body or subject then push the Replace selected text button.

@@ -136,15 +135,9 @@ style: min-width: 80px; } language: css -libraries: | - https://appsforoffice.microsoft.com/lib/beta/hosted/office.js - @types/office-js-preview - - 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 +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/outlook/99-preview-apis/calendar-properties-apis.yaml b/samples/outlook/99-preview-apis/calendar-properties-apis.yaml deleted file mode 100644 index 22aff8892..000000000 --- a/samples/outlook/99-preview-apis/calendar-properties-apis.yaml +++ /dev/null @@ -1,106 +0,0 @@ -id: outlook-calendar-properties-apis -name: Work with calendar properties APIs (Compose) -description: Gets and sets isAllDayEvent and sensitivity properties of an appointment in Compose mode. -host: OUTLOOK -api_set: - Mailbox: preview -script: - content: | - $("#getIsAllDayEvent").click(getIsAllDayEvent); - $("#setIsAllDayEventTrue").click(setIsAllDayEventTrue); - $("#getSensitivity").click(getSensitivity); - $("#setSensitivityConfidential").click(setSensitivityConfidential); - - function getIsAllDayEvent() { - Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Is this an all-day event? " + asyncResult.value); - } else { - console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); - } - }); - } - - function setIsAllDayEventTrue() { - Office.context.mailbox.item.isAllDayEvent.setAsync(true, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); - } else { - console.log("Appointment set to all-day event."); - } - }); - } - - function getSensitivity() { - Office.context.mailbox.item.sensitivity.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Sensitivity: " + asyncResult.value); - } else { - console.log("Failed to get sensitivity: " + JSON.stringify(asyncResult.error)); - } - }); - } - - function setSensitivityConfidential() { - Office.context.mailbox.item.sensitivity.setAsync( - Office.MailboxEnums.AppointmentSensitivityType.Confidential, - function callback(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); - } else { - console.log("Successfully set appointment sensitivity."); - } - } - ); - } - language: typescript -template: - content: |- -
-

This sample shows how to get and set the isAllDayEvent and sensitivity properties of an appointment in compose mode. -

- Required mode: Appointment Organizer -

-

-
- -
- - - - -
- 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/beta/hosted/office.js - @types/office-js-preview - - 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 diff --git a/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml b/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml new file mode 100644 index 000000000..275967e00 --- /dev/null +++ b/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml @@ -0,0 +1,69 @@ +order: 1 +id: outlook-get-set-isalldayevent +name: Get and set the isAllDayEvent property (Appointment Organizer) +description: Gets and sets the isAllDayEvent property of an appointment being composed. +host: OUTLOOK +api_set: + Mailbox: preview +script: + content: |- + document.getElementById("getIsAllDayEvent").addEventListener("click", getIsAllDayEvent); + document.getElementById("setIsAllDayEventTrue").addEventListener("click", setIsAllDayEventTrue); + + function getIsAllDayEvent() { + Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Is this an all-day event? " + asyncResult.value); + } else { + console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); + } + }); + } + + function setIsAllDayEventTrue() { + Office.context.mailbox.item.isAllDayEvent.setAsync(true, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Appointment set to all-day event."); + } + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to get and set the isAllDayEvent property of an appointment being composed. +

+ Required mode: Appointment Organizer +

+

+
+
+ + +
+ 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/beta/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml b/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml new file mode 100644 index 000000000..3763ab1c4 --- /dev/null +++ b/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml @@ -0,0 +1,86 @@ +order: 3 +id: outlook-set-displayed-body-subject +name: Temporarily set the body or subject displayed in a message (Message Read) +description: Temporarily sets the content displayed in the body or subject of a message in read mode. +host: OUTLOOK +api_set: + Mailbox: preview +script: + content: |- + document.getElementById("set-body").addEventListener("click", setDisplayedBody); + document.getElementById("set-subject").addEventListener("click", setDisplayedSubject); + + function setDisplayedBody() { + // This snippet temporarily sets the content displayed in the body of a message in read mode. + // The set content will remain visible until the user switches to a different message in the Reading Pane or closes the window of the current message. + const bodyText = (document.getElementById("body-text-field") as HTMLInputElement).value; + Office.context.mailbox.item.display.body.setAsync(bodyText, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the body."); + }); + } + + function setDisplayedSubject() { + // This snippet temporarily sets the content displayed in the subject field of a message in read mode. + // The set content will remain visible until the user switches to a different message in the Reading Pane or closes the window of the current message. + const subjectText = (document.getElementById("subject-text-field") as HTMLInputElement).value; + Office.context.mailbox.item.display.subject.setAsync(subjectText, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the subject field."); + }); + } + language: typescript +template: + content: |- +
+

This sample shows how to temporarily set the content displayed in the body or subject of a + message in read mode.

+

Required mode: Message Read

+
+
+

Try it out

+
+ + +
+ +
+
+ + +
+ +
+ 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; + margin-top: 20px; + min-width: 80px; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/beta/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/default.yaml b/samples/outlook/default.yaml index 03b07809b..7ccf69f33 100644 --- a/samples/outlook/default.yaml +++ b/samples/outlook/default.yaml @@ -5,8 +5,8 @@ author: OfficeDev host: OUTLOOK api_set: null script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { const userProfile = Office.context.mailbox.userProfile; @@ -14,7 +14,7 @@ script: } language: typescript template: - content: | + content: |- @@ -32,15 +32,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/basic-api-call-js.yaml b/samples/powerpoint/basics/basic-api-call-js.yaml new file mode 100644 index 000000000..5f421f9bb --- /dev/null +++ b/samples/powerpoint/basics/basic-api-call-js.yaml @@ -0,0 +1,67 @@ +order: 2 +id: powerpoint-basics-basic-api-call-js +name: Basic API call (JavaScript) +description: Performs a basic PowerPoint API call using JavaScript. +host: POWERPOINT +api_set: + PowerPointApi: '1.4' +script: + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); + + function run() { + // This function gets the collection of shapes on the first slide, + // and adds a text box to the collection, while specifying its text, + // location, and size. Then it names the text box. + return PowerPoint.run(function(context) { + const shapes = context.presentation.slides.getItemAt(0).shapes; + const textbox = shapes.addTextBox("Hello!", { + left: 100, + top: 300, + height: 300, + width: 450 + }); + textbox.name = "Textbox"; + + return context.sync(); + }); + } + + /** 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: |- +
+ This sample executes a code snippet that adds a text box to the first slide in the presentation. +
+ + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/basic-api-call-ts.yaml b/samples/powerpoint/basics/basic-api-call-ts.yaml new file mode 100644 index 000000000..0761647c6 --- /dev/null +++ b/samples/powerpoint/basics/basic-api-call-ts.yaml @@ -0,0 +1,67 @@ +order: 1 +id: powerpoint-basics-basic-api-call-ts +name: Basic API call (TypeScript) +description: Performs a basic PowerPoint API call using TypeScript. +host: POWERPOINT +api_set: + PowerPointApi: '1.4' +script: + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); + + const run: Function = async () => { + // This function gets the collection of shapes on the first slide, + // and adds a text box to the collection, while specifying its text, + // location, and size. Then it names the text box. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 300, + height: 300, + width: 450 + }; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", shapeOptions); + + await context.sync(); + }); + } + + /** Default helper for invoking an action and handling errors. */ + const tryCatch: (callback: Function) => void = async (callback: Function) => { + 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: |- +
+ This sample executes a code snippet that adds a text box to the first slide in the presentation. +
+ + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/basic-common-api-call.yaml b/samples/powerpoint/basics/basic-common-api-call.yaml index edc6ba604..0f9d08860 100644 --- a/samples/powerpoint/basics/basic-common-api-call.yaml +++ b/samples/powerpoint/basics/basic-common-api-call.yaml @@ -1,14 +1,14 @@ -order: 1 +order: 3 id: powerpoint-basics-basic-common-api-call name: Basic API call (Office 2013) description: Executes a basic PowerPoint API call using the "common API" syntax (compatible with Office 2013). author: OfficeDev host: POWERPOINT api_set: - Selection: 1.1 + Selection: '1.1' script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, (asyncResult) => { @@ -21,7 +21,7 @@ script: } language: typescript template: - content: | + content: |- @@ -39,15 +39,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/insert-svg.yaml b/samples/powerpoint/basics/insert-svg.yaml deleted file mode 100644 index 45403aab4..000000000 --- a/samples/powerpoint/basics/insert-svg.yaml +++ /dev/null @@ -1,71 +0,0 @@ -order: 5 -id: powerpoint-basics-insert-svg -name: Insert SVG -description: Inserts an SVG image using an XML string. -author: OfficeDev -host: POWERPOINT -api_set: {} -script: - content: | - $('#insert').click(newImage); - - function newImage() { - Office.context.document.setSelectedDataAsync(getImageAsBase64String(), { - coercionType: Office.CoercionType.XmlSvg, - imageLeft: 50, - imageTop: 50, - imageWidth: 400 - }, - function (asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.error(asyncResult.error.message); - } - }); - } - - function getImageAsBase64String() { - // A production add-in code could get an image from an - // online source and pass it to a library function that - // converts to base 64. - var svg = " SVG Logo SVG "; - return svg; - } - language: typescript -template: - content: |- -
-

This sample shows how to insert an SVG image using an XML string as the source.

-
- -
-

Try it out

- -
- 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 \ No newline at end of file diff --git a/samples/powerpoint/default.yaml b/samples/powerpoint/default.yaml index 175564923..556474193 100644 --- a/samples/powerpoint/default.yaml +++ b/samples/powerpoint/default.yaml @@ -5,8 +5,8 @@ author: OfficeDev host: POWERPOINT api_set: {} script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, (asyncResult) => { @@ -19,7 +19,7 @@ script: } language: typescript template: - content: | + content: |- @@ -37,15 +37,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/create-presentation.yaml b/samples/powerpoint/document/create-presentation.yaml similarity index 68% rename from samples/powerpoint/basics/create-presentation.yaml rename to samples/powerpoint/document/create-presentation.yaml index 990e8bef9..fedd25925 100644 --- a/samples/powerpoint/basics/create-presentation.yaml +++ b/samples/powerpoint/document/create-presentation.yaml @@ -1,33 +1,32 @@ -order: 2 id: powerpoint-create-presentation name: Create presentation -description: 'Creates a new, empty presentation and creates a new presentation by copying an existing one.' +description: Creates a new, empty presentation and creates a new presentation by copying an existing one. author: OfficeDev host: POWERPOINT api_set: - PowerPoint: 1.1 + PowerPointApi: '1.1' script: - content: | - $("#create-new-blank-presentation").click(() => tryCatch(createBlankPresentation)); - $("#file").change(() => tryCatch(createPresentationFromExisting)); + content: |- + document.getElementById("create-new-blank-presentation").addEventListener("click", () => tryCatch(createBlankPresentation)); + document.getElementById("file").addEventListener("change", () => tryCatch(createPresentationFromExisting)); function createBlankPresentation() { PowerPoint.createPresentation(); } function createPresentationFromExisting() { - const myFile = document.getElementById("file"); + const myFile = document.getElementById("file") as HTMLInputElement; const reader = new FileReader(); reader.onload = (event) => { - // strip off the metadata before the base64-encoded string + // Remove the metadata before the Base64-encoded string. const startIndex = reader.result.toString().indexOf("base64,"); const copyBase64 = reader.result.toString().substr(startIndex + 7); PowerPoint.createPresentation(copyBase64); }; - // read in the file as a data URL so we can parse the base64-encoded string + // Read in the file as a data URL so we can parse the Base64-encoded string. reader.readAsDataURL(myFile.files[0]); } @@ -43,11 +42,10 @@ script: language: typescript template: content: |- -
+

This sample shows how to create a new, empty presentation and how to create a new presentation by copying an existing one.

- -
+

Try it out

Create empty presentation

+
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/basics/insert-image.yaml b/samples/powerpoint/images/insert-image.yaml similarity index 96% rename from samples/powerpoint/basics/insert-image.yaml rename to samples/powerpoint/images/insert-image.yaml index 8384b2407..a1debdc9e 100644 --- a/samples/powerpoint/basics/insert-image.yaml +++ b/samples/powerpoint/images/insert-image.yaml @@ -1,4 +1,4 @@ -order: 4 +order: 1 id: powerpoint-basics-insert-image name: Insert Image description: Inserts an image to the current slide. @@ -6,8 +6,8 @@ author: OfficeDev host: POWERPOINT api_set: {} script: - content: | - $('#insert').click(run); + content: |- + document.getElementById('insert').addEventListener("click", run); function run() { Office.context.document.setSelectedDataAsync(getImageAsBase64String(), { @@ -32,10 +32,9 @@ script: language: typescript template: content: |- -
+

Insert an image into the current slide.

- @@ -53,15 +52,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/images/insert-svg.yaml b/samples/powerpoint/images/insert-svg.yaml new file mode 100644 index 000000000..563929e69 --- /dev/null +++ b/samples/powerpoint/images/insert-svg.yaml @@ -0,0 +1,64 @@ +order: 2 +id: powerpoint-basics-insert-svg +name: Insert SVG +description: Inserts an SVG image using an XML string. +author: OfficeDev +host: POWERPOINT +api_set: {} +script: + content: |- + document.getElementById('insert').addEventListener("click", newImage); + + function newImage() { + Office.context.document.setSelectedDataAsync(getImageAsBase64String(), { + coercionType: Office.CoercionType.XmlSvg, + imageLeft: 50, + imageTop: 50, + imageWidth: 400 + }, + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(asyncResult.error.message); + } + }); + } + + function getImageAsBase64String() { + // A production add-in code could get an image from an + // online source and pass it to a library function that + // converts to base 64. + const svg = " SVG Logo SVG "; + return svg; + } + language: typescript +template: + content: |- +
+

This sample shows how to insert an SVG image using an XML string as the source.

+
+
+

Try it out

+ +
+ 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/scenarios/searches-wikipedia-api.yaml b/samples/powerpoint/scenarios/searches-wikipedia-api.yaml index 6930599d1..41e403296 100644 --- a/samples/powerpoint/scenarios/searches-wikipedia-api.yaml +++ b/samples/powerpoint/scenarios/searches-wikipedia-api.yaml @@ -6,120 +6,150 @@ author: cakriwut host: POWERPOINT api_set: {} script: - content: | + content: |- /* * Copyright (c) Riwut Libinuko. All rights reserved. Licensed under the MIT license. */ declare let moment: any; - $("#search").click(run); + + document.getElementById("search").addEventListener("click", run); async function run() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, {}, getSelectedText); } - /* Extract selected text and call SearchWiki */ + /* Extract selected text and call SearchWiki. */ function getSelectedText(result) { - $("#result").empty(); - $("#result").append('
    '); + const resultElement = document.getElementById("result"); + if (resultElement) { + resultElement.innerHTML = ""; + const listElement = document.createElement("ul"); + listElement.className = "ms-List"; + listElement.id = "ms-List"; // Ensure the list has an ID for later reference + resultElement.appendChild(listElement); + } + if (result.status === Office.AsyncResultStatus.Succeeded) { searchWiki(result.value); } else { console.error(result.error.message); - } + } } - /* Searching Wiki */ - + /* Searching Wiki. */ function searchWiki(pattern) { - let url = build_wiki_search_url(http://github.com/pattern); + const url = build_wiki_search_url(http://github.com/pattern); fetch(url) - .then((response) => { - return response.json(); - }) + .then((response) => response.json()) .then((data) => { - $.each(data.query.search, function(i, val) { - let date = moment(val.timestamp).format("YYYY-MM-DD hh:mm A"); - let listItem = build_list_item(val.title, val.pageid, val.snippet, date); - $(".ms-List").append(listItem); + data.query.search.forEach((val) => { + const date = moment(val.timestamp).format("YYYY-MM-DD hh:mm A"); + const listItem = build_list_item(val.title, val.pageid, val.snippet, date); + const listElement = document.getElementById("ms-List"); + if (listElement) { + const tempDiv = document.createElement("div"); + tempDiv.innerHTML = listItem; + const listItemNode = tempDiv.firstElementChild; + if (listItemNode) { + listElement.appendChild(listItemNode); + } + } }); + return data.query; }) - .then(function(data) { - $(".ms-ListItem").each(function(i, item) { - if ($(this).find(".listItem-link a").length === 0) { - getWikiLink($(this).data("pageid"), $(this)); + .then((data) => { + const listItems = document.querySelectorAll(".ms-ListItem"); + listItems.forEach((item) => { + const link = item.querySelector(".listItem-link a"); + if (!link || link.innerHTML.length === 0) { + const pageId = item instanceof HTMLElement ? item.dataset.pageid : undefined; + if (pageId) { + getWikiLink(pageId, item); + } } }); - }); + }) + .catch((error) => console.error("Error fetching Wikipedia data:", error)); } - // Search for Wiki Page link based on the given pageId - // Update itemHTML from the returned result - + // Search for Wiki Page link based on the given pageId. + // Update itemHTML from the returned result. function getWikiLink(pageid, itemHTML) { - let pageinfo = build_wiki_pageinfo(pageid); + const pageinfo = build_wiki_pageinfo(pageid); fetch(pageinfo) - .then((response) => { - return response.json(); - }) + .then((response) => response.json()) .then((data) => { - let itemUrl = data.query.pages[pageid].fullurl; - let images = data.query.pages[pageid].images; - let title = $(itemHTML) - .find(".listItem-link") - .html(); - $(itemHTML) - .find(".listItem-link") - .html('' + title + ""); - if (typeof images !== "undefined") { - $(itemHTML) - .find(".ms-ListItem-image") - .attr("data-image", images[0].title); + const itemUrl = data.query.pages[pageid].fullurl; + const images = data.query.pages[pageid].images; + const titleElement = itemHTML.querySelector(".listItem-link"); + const title = titleElement ? titleElement.innerHTML : ""; + + if (titleElement && itemUrl) { + titleElement.innerHTML = `${title}`; + } + + if (images && images.length > 0) { + const imageElement = itemHTML.querySelector(".ms-ListItem-image"); + if (imageElement) { + imageElement.setAttribute("data-image", images[0].title); + } } }) - .then((data) => { + .then(() => { getWikiImages(pageid, itemHTML); - }); + }) + .catch((error) => console.error("Error fetching Wiki link:", error)); } - // Search for Wiki image based on the given pageId, first image - // Update itemHTML from the returned result - + // Search for Wiki image based on the given pageId, first image. + // Update itemHTML from the returned result. function getWikiImages(pageid, itemHTML) { - let pageInfo = build_wiki_image_search(pageid); + const pageInfo = build_wiki_image_search(pageid); fetch(pageInfo) - .then((response) => { - return response.json(); - }) + .then((response) => response.json()) .then(async (data) => { - if (typeof data.query.pages[pageid].original !== "undefined") { - let img = data.query.pages[pageid].original.source; - $(itemHTML) - .find(".ms-ListItem-image") - .append(''); - return true; + const pageData = data.query.pages[pageid]; + if (pageData && pageData.original && pageData.original.source) { + const originalImage = pageData.original.source; + const imageElement = itemHTML.querySelector(".ms-ListItem-image"); + + if (originalImage && imageElement) { + const imgElement = document.createElement("img"); + imgElement.width = 70; // Set the width to 70px. + imgElement.src = originalImage; + imageElement.appendChild(imgElement); + return true; + } } else { - let img = $(itemHTML) - .find(".ms-ListItem-image") - .data("image"); - pageInfo = build_wiki_file_search(img); - let pageInfoResult = await fetch(pageInfo); - return pageInfoResult.json(); + const imageElement = itemHTML.querySelector(".ms-ListItem-image"); + const img = imageElement ? imageElement.dataset.image : undefined; + if (img) { + const pageInfoResult = await fetch(build_wiki_file_search(img)); + return pageInfoResult.json(); + } } }) .then((data) => { - if (typeof data.query !== "undefined") { - let key = Object.keys(data.query.pages)[0]; - if (data.query.pages[key].title !== "Undefined") { - let img = data.query.pages[key].thumbnail.source; - $(itemHTML) - .find(".ms-ListItem-image") - .append(''); + if (data && data.query) { + const key = Object.keys(data.query.pages)[0]; + const page = data.query.pages[key]; + if (page && page.thumbnail && page.thumbnail.source) { + const thumbnail = page.thumbnail.source; + const imageElement = itemHTML.querySelector(".ms-ListItem-image"); + + if (thumbnail && imageElement) { + const imgElement = document.createElement("img"); + imgElement.width = 70; // Set the width to 70px. + imgElement.src = thumbnail; + imageElement.appendChild(imgElement); + } } } - }); + }) + .catch((error) => console.error("Error fetching Wiki images:", error)); } /* Wikipedia API query */ @@ -131,65 +161,56 @@ script: /* Wikipedia Search Query pattern */ function build_wiki_search_url(http://github.com/pattern) { - let qry = "pageimages&list=search&srsearch="; + const qry = "pageimages&list=search&srsearch="; return wiki_base(qry + pattern); } /* Wikipedia Image Query pattern */ function build_wiki_image_search(pattern) { - let qry = "pageimages&piprop=original&pilicense=any&pageids="; + const qry = "pageimages&piprop=original&pilicense=any&pageids="; return wiki_base(qry + pattern); } /* Wikipedia File Query pattern */ function build_wiki_file_search(pattern) { - let qry = "pageimages|pageterms&pilicense=any&titles="; + const qry = "pageimages|pageterms&pilicense=any&titles="; return wiki_base(qry + pattern); } /* Wikipedia Page Info Query pattern */ function build_wiki_pageinfo(pattern) { - let qry = "info|images&inprop=url&pageids="; + const qry = "info|images&inprop=url&pageids="; return wiki_base(qry + pattern); } /* Render */ function build_list_item(title, pageid, summary, ts) { - return ( - '
  • ' + - '
    ' + - '' + - title + - "" + - "" + - summary + - "" + - '
    ' + - '
    ' + - '
    ' + - ' ' + - "
    " + - '
    ' + - ' ' + - "
    " + - "
    " + - "
  • " - ); + return ` +
  • +
    + ${title} + ${summary} +
    +
    +
    + +
    +
    + +
    +
    +
  • `; } language: typescript template: content: |- -
    +

    Search Wikipedia

    - -
    +

    This sample shows how to query external API (Wikipedia) with the text currently selected in the presentation.

    - -
    +

    Try it out

    Select any text in the presentation and press Search to see related Wikipedia entries.

    The search result will be provided by Wikipedia API.

    @@ -201,12 +222,11 @@ template:
    - -
    +

    Result

    -
    +
    language: html style: content: |- @@ -221,17 +241,11 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css - https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.js \ No newline at end of file + https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.js diff --git a/samples/powerpoint/shapes/add-modify-tables.yaml b/samples/powerpoint/shapes/add-modify-tables.yaml new file mode 100644 index 000000000..c9da7247f --- /dev/null +++ b/samples/powerpoint/shapes/add-modify-tables.yaml @@ -0,0 +1,417 @@ +order: 4 +id: powerpoint-shapes-add-modify-tables +name: Add and modify tables +description: Shows how to add and modify tables in a presentation. +host: POWERPOINT +api_set: + PowerPointApi: '1.8' +script: + content: | + document.getElementById("add-basic-table").addEventListener("click", () => tryCatch(addBasicTable)); + document.getElementById("table-width-height").addEventListener("click", () => tryCatch(tableWidthHeight)); + document + .getElementById("table-column-widths-row-heights") + .addEventListener("click", () => tryCatch(tableColumnWidthsRowHeights)); + document.getElementById("table-values").addEventListener("click", () => tryCatch(tableValues)); + document.getElementById("table-merge-areas").addEventListener("click", () => tryCatch(tableMergeAreas)); + document.getElementById("table-cell-fill-font").addEventListener("click", () => tryCatch(tableCellFillFont)); + document.getElementById("table-borders").addEventListener("click", () => tryCatch(tableBorders)); + document.getElementById("table-indent-margin").addEventListener("click", () => tryCatch(tableIndentMargin)); + document.getElementById("table-cell-alignment").addEventListener("click", () => tryCatch(tableCellAlignment)); + document.getElementById("table-text-runs").addEventListener("click", () => tryCatch(tableTextRuns)); + document.getElementById("table-from-shape").addEventListener("click", () => tryCatch(getTableFromShape)); + document.getElementById("update-table-values").addEventListener("click", () => tryCatch(updateTableValues)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function addBasicTable() { + // Adds a basic table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a simple table, specifying the row and column count. + shapes.addTable(3, 4); + await context.sync(); + }); + } + + async function tableWidthHeight() { + // Specifies the width and height of a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the width and height. + shapes.addTable(3, 4, { + width: 600, + height: 400 + }); + await context.sync(); + }); + } + + async function tableColumnWidthsRowHeights() { + // Specifies the column widths and row heights of a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); + } + + async function tableValues() { + // Specifies a table's values. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying cell values. + const shape = shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ] + }); + await context.sync(); + }); + } + + async function tableMergeAreas() { + // Specifies the merge areas of a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); + } + + async function tableCellFillFont() { + // Specifies the font formatting and fill colors of the cells in a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); + } + + async function tableBorders() { + // Specifies a table's borders. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); + } + + async function tableIndentMargin() { + // Specifying the indents for a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the indent level for cells. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }], + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }], + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }] + ] + }); + await context.sync(); + }); + } + + async function tableCellAlignment() { + // Specifies the horizontal and vertical alignments of the cells in a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying horizontal and vertical alignment. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify, + verticalAlignment: PowerPoint.TextVerticalAlignment.middle + } + }); + await context.sync(); + }); + } + + async function tableTextRuns() { + // Specifies the text runs of the cells in a table. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying text runs. + shapes.addTable(3, 4, { + specificCellProperties: [ + [ + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } } + ], + [ + { text: "Bold text", font: { bold: true } }, + { + textRuns: [ + { text: "Text runs with " }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.double } }, + { text: " and plain text" } + ] + }, + { text: "Italicized text", font: { italic: true } }, + { text: "Plain text" } + ], + [ + { text: "Bold text", font: { bold: true } }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.dotted } }, + { + font: { bold: true }, + textRuns: [ + { text: "Text runs with " }, + { text: "italicized text", font: { italic: true } }, + { text: " and (inherited) bold text" } + ] + }, + { text: "Italicized text", font: { italic: true } } + ] + ] + }); + await context.sync(); + }); + } + + async function getTableFromShape() { + // Gets the table from a shape. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + + if (shapeCount.value > 0) { + const shape = shapes.getItemAt(0); + shape.load("type"); + await context.sync(); + + // The shape type can indicate whether the shape is a table. + const isTable = shape.type === PowerPoint.ShapeType.table; + + if (isTable) { + // Get the Table object for the Shape which is a table. + const table = shape.getTable(); + table.load(); + await context.sync(); + + // Get the Table row and column count. + console.log("Table RowCount: " + table.rowCount + " and columnCount: " + table.columnCount); + } else console.log("Selected shape isn't table."); + } else console.log("No shape selected."); + }); + } + + async function updateTableValues() { + // Updates a table's values. + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table (which is a type of Shape). + const shape = shapes.addTable(4, 3); + let table = shape.getTable(); + table.load(); + await context.sync(); + + // Update values in the table. + for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) { + for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) { + const cell = table.getCellOrNullObject(rowIndex, columnIndex); + cell.text = generateRandomString(); + } + } + + await context.sync(); + }); + } + + function generateRandomString(length: number = 5): string { + // Generates a random string. + const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + let result = ""; + + while (result.length < length) { + const randomIndex = Math.floor(Math.random() * characters.length); + result += characters.charAt(randomIndex); + } + + return result; + } + + async function setup() { + await PowerPoint.run(async (context) => { + // Adds a new slide with some content. + const slideCountResult = context.presentation.slides.getCount(); + context.presentation.slides.add(); + await context.sync(); + + const newSlide = context.presentation.slides.getItemAt(slideCountResult.value); + newSlide.load("id"); + newSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon); + await context.sync(); + + console.log(`Added slide - ID: ${newSlide.id}`); + + // Switch to the new slide. + context.presentation.setSelectedSlides([newSlide.id]); + await context.sync(); + }); + } + + // 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: |- +
    +

    This sample shows how to add and modify tables.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + + + + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + 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 diff --git a/samples/powerpoint/shapes/binding-to-shapes.yaml b/samples/powerpoint/shapes/binding-to-shapes.yaml new file mode 100644 index 000000000..7eec3ed7b --- /dev/null +++ b/samples/powerpoint/shapes/binding-to-shapes.yaml @@ -0,0 +1,370 @@ +order: 5 +id: powerpoint-shapes-binding-to-shapes +name: Binding to shapes +description: Shows how to create binding references for images and work with z-order. +host: POWERPOINT +api_set: + PowerPointApi: '1.8' +script: + content: | + document + .getElementById("insert-image-and-create-binding") + .addEventListener("click", () => tryCatch(insertImageWithBinding)); + document.getElementById("replace-binding1").addEventListener("click", () => + tryCatch(() => { + replaceBinding(1); + }) + ); + document.getElementById("replace-binding2").addEventListener("click", () => + tryCatch(() => { + replaceBinding(2); + }) + ); + document.getElementById("replace-binding3").addEventListener("click", () => + tryCatch(() => { + replaceBinding(3); + }) + ); + document.getElementById("load-bindings").addEventListener("click", () => tryCatch(loadBindings)); + document.getElementById("bring-to-front").addEventListener("click", () => tryCatch(bringToFront)); + document.getElementById("bring-forward").addEventListener("click", () => tryCatch(bringForward)); + document.getElementById("send-backward").addEventListener("click", () => tryCatch(sendBackward)); + document.getElementById("send-to-back").addEventListener("click", () => tryCatch(sendToBack)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + const flowerImage = getImageAsBase64String(); + + const greenery1 = returnGreenery1AsBase64(); + + const greenery2 = returnGreenery2AsBase64(); + + const greenery3 = returnGreenery3AsBase64(); + + async function insertImageWithBinding() { + // Inserts an image with binding. + await PowerPoint.run(async (context) => { + const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value; + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, { + top: 100, + left: 30, + width: 200, + height: 200 + }); + + myShape.fill.setImage(flowerImage); + context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId); + await context.sync(); + + const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement; + + const option = new Option(`Binding ${bindingId}`, bindingId); + + // When a binding ID already exists, the binding is updated to refer to the new shape + // so select the existing item rather than add a new one. + const foundIndex = findDropdownItem(bindingsDropdown, option.text); + if (foundIndex < 0) { + bindingsDropdown.add(option); + bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1; + } else { + bindingsDropdown.selectedIndex = foundIndex; + } + }); + } + + async function replaceBinding(greenery) { + // Update image in binding with selected replacement image. + await PowerPoint.run(async (context) => { + if (greenery === 1) + context.presentation.bindings + .getItem((document.getElementById("bindings-dropdown") as HTMLSelectElement).value) + .getShape() + .fill.setImage(greenery1); + else if (greenery === 2) + context.presentation.bindings + .getItem((document.getElementById("bindings-dropdown") as HTMLSelectElement).value) + .getShape() + .fill.setImage(greenery2); + else + context.presentation.bindings + .getItem((document.getElementById("bindings-dropdown") as HTMLSelectElement).value) + .getShape() + .fill.setImage(greenery3); + + await context.sync(); + }); + } + + async function getShapeForBindingId(bindingId: string): Promise { + // Gets shape associated with binding ID. + return PowerPoint.run(async (context) => { + const binding = context.presentation.bindings.getItem(bindingId); + const shape = binding.getShape(); + return shape; + }); + } + + async function loadBindings() { + // Loads bindings. + await PowerPoint.run(async (context) => { + const bindings = context.presentation.bindings; + bindings.load("items"); + await context.sync(); + + const bindingCount = bindings.items.length; + if (bindingCount === 0) { + console.log(`There are no bindings.`); + } else if (bindingCount === 1) { + console.log("There's 1 binding."); + } else { + console.log(`There are ${bindingCount} bindings.`); + } + + bindings.items.forEach((binding) => { + getShapeForBindingId(binding.id).then((shape) => { + if (shape) { + console.log(`Binding ID: ${binding.id} refers to shape ID ${shape.id}`); + } else { + console.log(`Binding ID: ${binding.id} doesn't refers to shape.`); + } + }); + }); + + populateBindingsDropdown(bindings.items); + }); + } + + function findDropdownItem(dropdown: HTMLSelectElement, text: string): number { + // Finds dropdown items. + for (let index = 0; index < dropdown.options.length; ++index) { + if (dropdown.options[index].text === text) { + return index; + } + } + + return -1; + } + + async function populateBindingsDropdown(bindings: PowerPoint.Binding[]) { + // Populates bindings dropdown list. + const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement; + bindingsDropdown.options.length = 0; + bindings.forEach((binding) => { + const option = new Option(`Binding ${binding.id}`, binding.id); + bindingsDropdown.add(option); + }); + + bindingsDropdown.selectedIndex = 0; + } + + function bringToFront() { + // Brings the shape to the front. + changeZOrder(PowerPoint.ShapeZOrder.bringToFront); + } + + function bringForward() { + // Brings the shape forward. + changeZOrder(PowerPoint.ShapeZOrder.bringForward); + } + + function sendBackward() { + // Sends the shape backward. + changeZOrder(PowerPoint.ShapeZOrder.sendBackward); + } + + function sendToBack() { + // Sends the shape to the back. + changeZOrder(PowerPoint.ShapeZOrder.sendToBack); + } + + async function changeZOrder(operation: PowerPoint.ShapeZOrder) { + // Changes the z-order position of the selected shapes. + return PowerPoint.run(async (context) => { + const selectedShapes = context.presentation.getSelectedShapes(); + selectedShapes.load(); + await context.sync(); + + if (selectedShapes.items.length === 0) { + console.log("No shapes are selected."); + } else { + let direction = 1; // Start with bottom-most (lowest number). + + // Start with top-most when sending to back or bringing forward. + + switch (operation) { + case PowerPoint.ShapeZOrder.bringForward: + + case PowerPoint.ShapeZOrder.sendToBack: + direction = -1; // Reverse direction. + + break; + } + + // Change the z-order position for each of the selected shapes, + + // starting with the bottom-most when bringing to front or sending backward, + + // or top-most when sending to back or bringing forward, + + // so the selected shapes retain their relative z-order positions after they're changed. + + selectedShapes.items + .sort((a, b) => (a.zOrderPosition - b.zOrderPosition) * direction) + .forEach((shape) => { + try { + const originalZOrderPosition = shape.zOrderPosition; + shape.setZOrder(operation); + + console.log(`Changed z-order of shape ${shape.id}.`); + } catch (err) { + console.log(`Unable to change z-order of shape ${shape.id}. ${err.message}`); + } + }); + + await context.sync(); + } + }); + } + + function logSelectedShapesZOrder(selectedShapes: PowerPoint.ShapeScopedCollection) { + // Logs the z-order position of the selected shapes. + console.log(`Selected shapes:`); + + selectedShapes.items.forEach((shape, index) => { + console.log(` [${index}] shape ID ${shape.id}, z-order position: ${shape.zOrderPosition}`); + }); + } + + function getImageAsBase64String() { + // A production add-in code could get an image from an + + // online source and pass it to a library function that + + // converts to Base64. + + return "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCACqAP8DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD82GlbU7sxo7FCcktVyXQZ4oQ6FSHBKjlce59q1LDQ4tLtvtE0iraqN7seo9q5/wAReNJdSU29qPJtF4Vj99h/SuyTSXvbnXGyNvwrdW0l06TrI8UMfmXEsWNqDOP14xVPxF4sutblW2iYW9nGSIo1wD+J7/jTLuF/DugW+mvC0F3cqt1csTyysMxj6Y5/GudwXY54Ge1SnZClKVTToPT90C3J5+9705l89HfuD0HSkEDEBBu5q3a2mXA3HYT1IxU3HGm3sZ0do8hHAHfOM1KtpvO1V6dc/wCNaxsHjcLyB9OPaphp7xyEsu4Dp6GsXK2h6dPBykrmEYCh5UuT7dq6Dw5o0+r6jYWEEYknuZkhRCcAszADJ7dabBaSPJtSMsx4CoM11/gZV8Lao+sXkkVtLaQStBE0oWQzFSqHHXgtu/4DSjds644enRXNUdjP8fzQ6l4w1NrVpHsopPs9uCSxVEG0AZJwOOADgdqxIY5IYx8jbGPJx19qs+Za6eiPLdG5IxuSIEZ9wTTvPt5svBqcMhPH70GMke9FprUuMsHLRTILW2nvLlYrZZJpGOFjQEs3PQCq2pWn2W6kW5vbe2cH5l8ze/8A47mrniDVL6y0p9N0oSfYXVJby6iALSv/AHdwGQg9D3Ga4bp04p3tozy6tVXtDZHQiPSzGxOolJOcBIWIP41YsG02xSC5t9QjfUI5jhLiA+WqgfK3cE57HgY75rly5o8wii/kc7m2dTd2dzqd492Z7e8nmYu7ROAdx9vrVK7sZ7E7Z4ZIv9lxWMsgDA8j6Vq2fiS+tQAs3nxDrFOA6kenNWmmZt+RXk2lSCDtX2qFg4HGCAMiujtntvEiSQQ2UNnfY3ReW7ASHPKgHgcVnQ6Ve3M3lRWkzEHYMIQO/c8dj+VOxCakjE3tIzcH0wO9RlcN0xxXR3fhnU7edozZN5qgkiN0c4A68E56GsWeB0b94rRt1wwxmpZPL1IUdonPPIPOO9dT4hZbi20i4wGd7TaT05V2AI/DH5VzVnaSXd1FDErM7uFUL71veLZ4lv47OGQTQ2USwJIgwGIHzNjn+In8qadkwRz8rsGO77+ST9aaCSRupznvkHPY00A+mOKSJZNChYgq2fUZrsos2fhi1t1Tdc3c/nEtzsjC4HB6E5P4AVl6R4fwiX2ob7azyNqBf3kmPQenuce1SaneC/nFxLOcudir/dUdAo9AOK2WiBR6srlnMTpsXawA3dP5VXuQsUeQMsSeG5ycdf8A69Swkxq4Q70DZGR94UFjIcEZR+gbkj0pikVGh3jk+WeuGOSa7r4W3U//AAka29tFJMHhbfEmTkDnJHscVxqFhH+8G5Oi9jn0zXd/ClYxr0moXClLWGEq3zFSScAAfzrSnucs9jjPF+ty3Vy2nowS1hPzKh4dvU+uK5tSN65+7kZ+matapay2eo3MU8ZjkDklSPU1UPORXFKV3qd9j0Hx9NJqHi/U2ljWM70VUWPYFUIoUBewxisGKwxJhF3Z4wO/4Vv2zR+LrG21GaVdPlt4ltrp5dxWfYMLIpPViOCv+zmornxHa6VFLBpkW0uADcSDMn4E/dB9BWqTkrnTTnTjFK12TjwnfySxo9kbYuNwad1jGPU7iOK6K3+FGtR6FcazDHBf6dbD/SJrG5jmNuP7zqrZUdOcY5rgYr6TUJg0zvIx/ikYtiu9+GGvW3gjxbp+qXkzwadMWtL3ZjL28i7JBzwflbOPaok4rdnsYSjVr+9GKsv63M63tVvZIkt4HmmY7dqjO4/Sqmt63pehSS28hOq3agAJGw8mNvRm7ke351b8b350G0TTtJnkzcvMktwMAtEj7VUEdM4yea8+OnNKoA+TFY36s1xFWo26eGWnf/Ivah4zv76RtrraRkkiK3G1Vz29azWv5pB8zk/jTZ9NkttpILBum2r1p4W1a6RXh0u8lRwSpSBjux1xxzS5m9jw505qVqm/mZjXDseWOaQMT1NSyQNDK8ciNHIp2sjjBUjqCKif24NTzNgocquTQXU1uxMUjRn1Q4q7HdQXZ230HmA/8t4cLIvv6N+P51nRsB1rQ02xl1S6W2tYmlmYE7V7ADJJ9ABkk9qOZm0KcZ7kWt6DPojWzu6T2t1H5tvcxH5JVzg/Qgggg9CKy8YrtPGVwkmmaPotnBNLFo6Sie6KkrLNI+5yvoowoHrjPeuQCZPv71Tdjl5NdCPJpQcdDT2jwKYRg0r3Fytbk0Nw0ThgxVhyCDjFbmq3c3iSwNy91K91aoA8LyEq6D+JR2IzyPxrngcVd0u7azvYZgN2GwVboQeCPyJrRT6MThdXRnrhTkfpV631aeJBHIRPDn/VTDcv69Pwpuu6adF1m9sC6ubeVo9yHIODVNW/Gq1RipJnWaPcWjpKtm6Wl9cJ5bNMcIFP3grfw56d+KqTSW2hSSRva/bbjYU/f5Eac8OuOTx2Pf1rBDHtW1Y6jDfRLZX/AAg4inAy0Z/qvtVrUHKxDJ4jutxCLBCmSxSOJQCT+GafbeJ7uGUMSjEHdlkDA+hOaq6rp8unXj28oAZcfMDlXB5BHqCOlUSn5n1p6ozO1j1y18RGPzpmsr48ZXJQ4yOf7vb2qpqelz6fJ5UsW1nAKO46gngr2IPqK5aOQxSBk+Ug9R2rrNF1+11KCaz1czSfIFtHhG4wNkdf9nHYVafNoyufuUrTKu8SuDsySW6E+1WXsn8iRxsYoVJGPyFaUvhvVIrvyYrRJUZQ0TR4CzIeAQTVh9GvI9HEy2zosuSuwBjkcdATWsUTJnOrGJHSGXKpkklckdK6nTdeXwnbwoIUeW5TzJ9yA4X+EAdskZ+mKzdFSKHT5L29tnks4yVjwwXzZMcJ647nHQVjazfXNxqMktxEfMbapOeMBQOPypqXLtuYcjkz13xz8KbK4s/t9vdpqmniRYE1SxRgVbGQro3I4z1/A1wMfw60/TXebUNZtrlIlD/ZLcnzHP8Adb+771o+HPFWreLvEMelWd4+k6O433ZiON0S8tvI6+w9ar+K72C61S4eyjCRM+xDn+DoMn1rGMYzXO0ehXlHm9nDfucxq+tS6lIFCrDDH8scEYwiL6AVTgt5LqXO04qaS0eW5ZFHAPP9a3NO0tnCJGgz23cZ+lY1Jno4HCOs0M0zTnVtq4Vz0bsKo6xoOpWR8y4R5ou0q5K//Wr0HSNGMLB3QRpjLbhito+IdHSxlJkW6dP3ZjiGQW9M9K4tZSsj6yvQoU6FqkuW39bdTz7SXudc0mG1ubeRxbHdb3TEIkGfvh8jlWABBHII96W81LRtJ2pk6hKOWEZ2x/n1NGotPe+YsZcIxz5W4lVqongm5e0kuGjbailiAOeK0qThT31Z8/hqmNlTcaGke9tfv/yM+XxHe6nMkFrCsAZsLHap8zHtz1JpbiVtLnZbvUZ/tkR/1dvIX2tnpuBwCPbNTaXZXEsV0tvbOLjyj5ZiBL5JAI9uCasReFLaBFiu7r7PcDlgE3oB7Ed/WqjOU4+6jz52jLmnO789WM8XeNYPGGo2d7e2csl1DapbSztN+8uSpOJHIHLbSFz32isyO/0diA+mNgE8/aGyR6VNeeG4UZhHqNu2DgAqy59+lUn8PzqcRyQz88eXIOfpnFPXdoyfMacNzoDBS+ly4BOfLuiCR+INatr4iisbB7XQtujTMctcuA0sgP8ACJcZUewwOua4+ezuLN9ssTxPjOGGDUSXDIfmHFJSv0HGTj1NbUrnVred3u7m63THLSmYssn/AAIHBqr/AGrcuoWR1uEH8MyBv16/rUltqrCNowQ8T43wvyrfUf1pLzTI2tnvbMnykIEsDnLxZ6HPdc8Z7d6PQ1l3a07iNDaXUYMQe2m7qx3Ifx6j9apXWnzWpxIhUHo3UH6GkimKHngVrWOsvbr5bIl1bE/NDLyp9/Y/SmkpGbcepg7CCcc10PhnQRNIdS1AeTpNmVkmLsFaXuI0B+8zYxx06mtG7gNzYtNo5UxA/NGECyIRk8+o681yt3dXdy3+kySTEcfOxOKpRs9SJ8sV7jvch1W+l1TUbm8lwJbiVpGA9Sc1VBOacwwT6U0irPPJEY4/pUwILcdOxqsGNSRt71SHudJZ3UOuWyWN43lzx7mguNvHPVGA6g9j2rCuYfInMeQ+O6nINaGgSLHqMLkkFWAyPQ8VU1GE299PEU8rY5TaTnGD61o9VchKxVIAGcYNKMpwDtPTigqaTOMdvwqCjt9EvE1vQZLV5SL6xBe0zjMq5y8f1H3h+PrVXTtensJlZJWWTdkYOPw+lYugStHrFpJEzRyCRdjK2CDkd+1X9SnN3qt1K2Nryk4CgYwfYDP1xXQpOyZlboddDq+keKIY7LUo/sk6kCO5iHCjnII6c5Xn2qh4v8F3/hi4gtrww+RIplt7sS5jkUnHBGcHg8VzjuI5gvKjOVIPr6V6D8PvEGl3azaN4ntX1PRpU+VEcq8MoO4Mh7ZAYEd93tV2U/UXM4PXY5jw6n9ieFZbg7kn1HOW6ERKe31OfyrKuLhpU55wcg10vjSL7BDp+mIdyW9nDGCAMklQx/VjWXpmnMxCFR/vGsG+WKiephqEqzuluRaVEJmXzE6njI5xXTNd6fpUJme4W3ZRuEXVmwOoH4VFOkGgaXJeXBwVICqOrnsBXC38Op6vdLczwmIzqGi8z92rL22Z6j6Vytt7H0MqkMBFKOs2b8uv6p491AWSSm0sVBdwDhUQdWY9z2Aqee4EwisNOT9xH8qnHP1NMi01NGs00xVMeon59QkkPCN1WMeyjk+59q2fDxggUPaxh5Oisw4c+oHpS+HRbs5qNN4l/WMU9Hsur9DsPAvgqzjktzrF/HY+cMx+YGZpfZVUEn8q9Q8SHwV8OfDUN019Frmo3CEDRlheGZSR1kLDAQdMg546V43puoB9Uup5JpGjsUD3MyE75GJwkCEfd3HjPsT2rcj8DSajA+u+KrmPTLaQ/JD0Zh2AUcn6CvLqQjN+/qvxb8l2PZq4hxpOnTXLbd6WXltqzzmfVLi8nnS0iKCZuYLUHYOenqR9ai1jw1rUK+ZLBLEpQMMg8ivXvDdtLf3H2PwZooQL9/ULxA231IH3QPrWjrPinRfDUDx3+tX/AIq1ReGispAtvGwPIZ8YPPZQaipWqpqnCyt0Wv39F82fPrDU2m27P0/T/M+eP+Ee1FMm5dLTgMqTZDsD3C9SPwq/DZWFsFFzNLNzzsgYD9cVs6v4ugn1aa8h06CCaRt2HZpPw5xmqqeL5LqSZJI1kSVtwgX5Qhxj5R74rokpuO6+9/oRRk6crav5r8rFqDUdEl067sLuK4kgaFzaFjzbT8bWB/unBBX3z1FcrdeHZJ4TJbAXQB5ELDI/4D1rams5L4A2xHnf88CMOR7Dv+FY1zFc2sgYgxP6rxmqpTStGej9b/8ADmuISqS5kte1rfkc+9u0EwVg8bBsH1Fd94C0pZvFWjwwzR3aXNwlvcQSrszG52yKwPGNpPIPbNZ1vctrlylteeXvcFI53QFg3bLdfxNN1yCON0ZD5cicN6gitqk+SUez6iwkE41E97bM53VLNLPULqCKQTRRTPGkg6MoYgH8QKqBip4roPs6apEQxC3oICsTgSex9/esKeNoZHR1KspwVIwRWlmtThcVszX8PXcMWoW73IMkAbaybsDaeD+laOs3eiNdywjT7nTpFKqWEwnXgYLYIB5OD14zXLwSbDWlr0qTJY3Kkl5ItkhPUlTjP5Y/Ktea8bkRtB26MTUNA2wm4t5o7m13bPNj7H0ZTyv41jSweWeOV9a0dP1KayZjC/B6qeR6dPpVnU7JGgW7t8LbyHDJ2jb0+h5xRF8yM5xRz/Q+1OQ4OR0qWbaR0+aoWBX2qzlasy9p0xjuVIGW7AetX/E5Y6xOTycLkgY5Kgn9apaFbveajBbopd5XVFVepJOOKv8Aih0m129MSkRCQqgPHC8A/j1/Gr6CMgnd2pFQt0FLgenHTPpQpyeh96QF/QABq1tgE4kXAA9609SmU3k5A2hpXYZXoMn0qHwfABrKTyKxit1MrnbuwB0z7ZwKuTxNPENzrvBLZxkEmto3sTa+pmyuSeQAx5yewpRJhuG2M3IKirUNi8qygxnKHlv6VHE2JtkmCgAzkZPtjNMhndeILZdR8RNcMu5JbeCaMOedrRKQff6+1WrKwt7WHMjbokGSzHA+v0rnvDHizTNV02x0zWrz+yLvT0ZLbU2iaWOSLqIpFXkYOcMM8HBFY/jPxILiVtOtrqK5t0PM9tuKzegGQDj8K5pvmVz6XB4mlhqTcnr2Nq7u7XxZ4ihIUS6NpyhnViVEzdl/E/oDTfEtxer4lsfEN/Gb61ieA7Rwm1CMRD+6MDAHamRaemi6XY2ZXbcSr5sx77j2P0HFU5r/AP4SjWLHSDLLHZh/LXyFDM7euCQPasppq0VudEOSdCpi6+7+H+uxtaglr4k8Q6pqFu7nQp7mW4UyDbLKS24I30zz24rV0G1e/aedcQJGpxNIcKDjqTUV5pojt4LezgeCJhsVCc7QO2e56kmul8RQjwz8OBY28Jk1LVpFtkGMlh1bA/IfjWWIfIuVbnoZdB1aE8bV2irJfkc78OvEyaa8GnJYRXF1/aL3tzcygSL5SxbR8pOG2neRnu1djo2ha58UfFltZgvdsZPlYLhUU4ycdqwvCPw/ks72aIo0jtcJaKTwWwN0h/PAx6V9F6PpyeDtVs/CekuIdWvdo1K9i+/ECATEpHQheW+oHrXDVxKo0koayle3ot/kupx0KFR1E6/R2S899fTqzL8R6bo3hzw1badqF7cQaRIk3m21iFUTlDhVdhyckZIB/iA6A15b4cl8QeK1ki0bRNO0uwtkxNOLUlYxn7xJzjjjvXqOv2+i65rWqaprWppbaLp8gtdO06JwZp9vDMq9+c/N/jXouleJ5vAfhe1sbW1sNBstSHmxpfgLCgI+VpXPMkjYOF4A9K8ZRhSpNyhzSk0/e2T8l37766XdkdksJCo3zO6W99F8/Py1tornzVeaZpVqD9qa71dlGXaO1jiQZ643DJFcZ4i1Lw3DOq2NrdWYfakqMiYyP48884zkD0r2nxB8MGDy+LLvxnp8Qu3EK20BWQPycDYcLySeBWBrPhPwLqFvYWcUxfxNK7JLbxo8e8Yzu2tkKcD1x9K3o4qkm4pc1t7XVu/ZW8/v0Ilh7waUYxtbtfyvdLR/ccprej22jw24v4476wmjEsOo2Q8uVB1BA6H9KwNY0uKf7HdKUvrW6Rw5hGOUx83+ySCDt9QegrqJfBGoGwn0iBzNZ+TJdWUhOAhT/WRH0ODnHtXnnhzV9T8Pao9ggjWG7cQyx3CF1Xn7wHYjmtsPR5oyhf3t10v6pbPo7W722MMQ5U1FVI3t+XW3bzXcztZ0ZLWPzIn8y3YnbIOx9COxHpWfrge6062vt29yfJnbOcuBlSfqv8q7DVRbabq11a7lNjLIVzyfL9D+H9a5vV9Mn0/QboOSsT32yNCOpRTuYH0+cCu+hPmppvWL1TOfERVuaP8ASZzttdMu0/xDpWtqdi/iKza9gTzL6BR58ca8ug4349RwD7YNYCMd2K6fwswS7mkMsiAQSHcjYwwUkZ45HGCPQ16dNKS5WeLUlLc5Eo0UjK6lXU4KsMEH3q/rEYi0jSAciWRJZMHptL4X/wBBNaEFxZasZLzVTNJPD88gtwAZ1/u+i49fTtxWLrmrPrGoNcuqxKFWOKFPuxRqMKo+gqFoKp0RWifCkHqT1rX0i7jEjwXD4tplKv8ALn6H88VjK5wvTNWIX+cN6c1pHQzcrrUdf2b21y8MhBdOjdiKrC2lYqFjL7jgYFdXq0DXOk6ffL5Yl+aORsBi2DlSfQ4yPwrDub+RmYBgBjogC8fhWjVmZboms5k0KB5UO7UnXEbIciAHq2f72OBjpUhvk1lIoZyI7hQEW4/vjsH/AJZ9qyXkbHApIiwJ3HBPSlcViSWF4ZGjkGGHXNSWdtLd3ccECtNI5CqEGSSTXR6SllqthLJeQGe5tUwpVyu4YwMgdh61ah1I2/EFtb2gZtpEI+Zwc9WPPtjvVqOo1G6uT3trBpWjrYxuJL5mDXbRkFRj+DI9M5Pr+FULaSDzmwuAOcLz0rPubiWzkwcNhiSmT61fjt1MW8YTf8wBH3cf/XzWsXdg9FYsGF2jZ0BZT0GcsT/ntTL3TVKtJKWjdQADtwCen8qsy3GLGFvmjYNneOhPepxatLCHaYAHGN3P862Suc7djgNRCLeSiKGSGLcQiS8sB7+9aPgrS11fxLaQyLuhQmWTPTCjPP44qtqWoT311NPNK0skrtI7OckknJNdZ8NkaKx1m83hSypaqCuc7jk89uFH515sLSkjuqR5Xa5F4ivZJZtQlJYFeFK8YJNUfAB2eM9IO5lCzBtyDJGATWjrNrMNN1NyMgMuWA/2hWH4TvPsPifTJiokAnVSrAY+Y7e/1qW/3ibPVxWlOEV/L/me1+H9ObVr5Czf6PApYnPTuTVj4dyN4/8AibDfzpnTrKVbW0Qj5R3LfXH/AKFVW2vDpfgPxJcY2ypGbfHoS23/ABrU+Blquj2GkX7gqJ53mcnkFQdo/ka5J3lUl5XPo6LVOGGoR2k03+n5HrEFzYeHfiJqFzdRxeXp+pXDR28jhA8piUxrknAyf0BpvwS1JtZ+L8cl3J9p3MwM4yyksSZHGR3Yn8AK5f8AaZ05YksL/T4hcHXpImAAJeO5iO0Mvb5lfBH0r0z4JeH21PxjcXsQIlbT/tIQ/KwYwnccdvnB4rx6bpUsNOcvijFr5Xu/0/AmKf1mUZL4ea/q9fy/I67WvhH4e8VeONJjsYYDYTwvdWlw8ZD/AGaMkNITjjcQWI9xXo/izR9G+JHhPwleXnh2XWdGtb0WVpZ2cPmGZtwSNpGH3UGCS1TfD7StI8deF20+/v7vR9W0qxlgt7qyb948bxq+wf8AAgD+JFekfCjwJ4j8D6DoGj6AsN7FYXHnXd7czfu57dsHzB/tnrt6A59q8fE06tVKClZx6erld3ve/wCV/u6HVjHWXk7vre93fz01Wx4b4/8AhHo2s69rOl6homnalqFnKGtRHE9vZ2yfdWJZM/NKGHIAHHSvKZfhpZ+OfE2gWUegw+BPHMcTv9huLjIuAgIIyccsvzAV90fFxrnR/A+rTT248bzi8F9Y6bFAq/ZgpGwA8FnBBYH14r5c/aL0LSNP+K2ma7fq/iDxK8FuLGGIsscc+1ecDBLD344NfOZdhcbRrKNdu1rLXW/Lta9rXevTTdu7GpqvBR3ve3ra3VaLvftpfc+Y/CmteJPDPinV9FnsoZLaZJftUNyflgA+VpEODhsEr6HIzXB+NtCjdtK1K2wRJc+Q+Dkh1YYyfXBHNe//ALTnhG6+H2u3Wpb0kvdatV3wxdIF+8QfcsPyHvXBfB/TNI1vwtqyazPFJdQXcUtpArguWcFd7L1ABI+px6V+i05tUvbJX5Utuv8Aw6ZyVIe0XLKV72t6pPReux876zO39qXq7iR5r4yc/wAR7967CS3Pi/wFZP5yi7sUeAQyNgOi/N8v+1gkkd8Z7Vzni3Q20zXL2LPyrIdufrV6O5k8OaFZ+U8i3F22XUvlNgIxx7kHn2rupxhWwyb0vZr1PBtJ1owex54yNHcMjAgg966LQZthnYjcqwSBgSM42Gq/ii1jttelEY/dOA6E9gRkD8OR+FVb8/2bpa44muuFGeRH3Ptk8fnXbT91XZ5tVcsrFTS5/KulJK7G+VwwyCO9VL+1FreSxEHajcfTt+lS2a7Ru79jWv4pso1h0+4jGGlgHmHdncykjP5Y/KoS90cnzM5ndzzU8DY4znoSp71Cy4OMZ+lSWvLjPTFXE5XpodRp8lu+i6jFIWRCEkiJX+MHGCc8DBPY9q5qY/MSPWuriSOPwlcTZG+SVItuPTLEfoK5OVep7elbT0IjsM3fNk8injr60ix5/LrQfkIIPSsyjc8Mao2l6xBMpG0na4PdTweK3NT0a7tXvCbd2trd8GXgrg4KknseRXGwNhgSfy611eoatqGn/Yb0SSRx3VuFKbiA+04OfXoDzW8XoSpcrMpbxWZDuKgNyxAOPT8KuR3DKWfcCFBAHUf/AKq1bPTLfxjYNHp8Cw6uig/ZYwcXOOOB03d/f61iQW9y+Ioo2kkQfdKY5HXHtxVq63ByuaNldbYVjx+7AJfcOp6f/qrVtrMq1unKlgf3eMkDqPz61l2Gh3EtzEk4FpEWG+eUEAA5wcdxV/VdVjsgtnYxvNZtGEluMeW8rKc5Vuqr0474rZSsrswcXI88c5Nen/DRHuvCV+sTJDHDcDzccs7FflY+nAIry7qa734R6l5N5q2nsflurXeqHoXQ7gfrjNedS0kd1TXU6m8sv7Thu7MhUMylQ5OcsRwfzrzzwt4cu9Y8TLYROtvdQiSQNJ0VkUkD8wK9X0fMwuH8ob1ctz6Drg+9eb+CL9x45gmZ9rTtKGZueoJx+dZys5n0VanFUqMpf0tD1L4iQTQ+ANR1KK3kW21BoPtKiMj7Ld5Bkif0yQzKejKR6VveC4JbbwP4eULILq3tSZYgMhN7uyknsdmDjrzWZ8aVm1nwdZ6nDNJGbNgskaHaHU/xH1wcfTNZXwF+JVnaWGo+CNdnFvZahKt1pt4//LveAY2Mf7kgO054B2mijKMptT6qxtmcamDqU1H4Y2t6a/lf8D1H4kXEt78L9GvCSJtI1GObjqAe+f8AgIr6k8N+HUuJ7Hxh4UXypXgCXVlgM0e9fmOOhGTu/Ej0r540TSl8WeG9c8NzK0VxcRERRycFJl5Vfz/nV/4N/EzVPD+gxNFLLFfafKdNv7VmwVYf6tj/ALwBH1WvEqYX2laVNb7+vRr+vU9upWjzRqy2mlr0urrX1TsfRXwo8NWvg3xffWOuXNyNUTZLa3eCLZomA2qR1BwCMt3yPSvbdDtdW0TxNNFpul3usaGV8+NrZlzGrZzFhmGdrA/8BYelfK2neMLvxL4xsPFukx+bq1pCbO+0xx8t/bnkgAnG8dvXFe9+H/i3cRaKZ/C6I0akpMFJEtq/dJEblDn8DRFTqVIxcf3kU1bTWPppe2mq2e6tv52IouKUW7dtdLev9M9CkttL0BtT1aaG7a3ZFeDR5GykU4z8+ATwc529Ackda+TNR0bQPiV4umvtQ03VbrV/tP7maO4kTyCGPzIFIAK4zz6V1mneMXv764hvrW9M0xLOtrNINu45zgdCa6LwLbf8Kz0/XJZty2V/O9yqakweaEFRuUHryRnB5GTUzpte/Ui047a6LXa97/Jb7I0hT9ldb83n/Tf6nzr+0C114/8AFcGl2Uot7a0jCXGp3BzGgA5JP8ROOAO9cbNd6Hp1xoujaHagw23zS3Zwss20bnkduuCR07cVmfGHxTe6r4kuru13Pbo7Zgi6bM84rd8CfBm8k8Bah4p1meWzGoLtto4ZFLvbjltuQQu4kDPXg1qqP7pSm7JXfzt/WnQ7FTjFpv4tbLf1f9eh89a7af8ACV+KrmFJVt0XfLNM33YlHUn+grn/ABXfxanqrG0jKWceI4kIAIVRgZx37/jXQfEjU4raY6bptuLGxWQt5KtuZzngu55Y/X8MVxSgzSKM/M3AxXpYdKUIxS0R4WM5aDbe7/I2PEelWVvYabfzxNcXk0IKoX/dKAT94dST9RXn+pXM13fSzXB3SMeuMDAGAAOwAFet/EPTW0tbKxlws8NsgkA6biNx/mBXl08SPOATz6CrTcpteZxYqgqdGE+rSG2gZwNuMitnXSV0LRwxLKBMNuOnzCqum2gkOxc734UAVp+NopLG7j0q4t/IuLAENt6EMA2e+eT97PNdTVoM8eDcp2RxsqkcDp6U+1i3SxD1PXOMGnsAz4Awa0bKyWG1N/Pn7MjbRx99+yj+p7VMURPR6HS6jaRL4at9PRHGoRE3spHKyRkYA68FQCfcGuJmGc9q1dN1WRtW8+UjdK+WHbB4wB6YqDXbEWGo3EGCvlyFQCMcdv0rR+9qStNDO3Z75J9abnuB+dI3Gc9KTJOPSpETw5DjB5rZ1Mh9GsEl3LdxMyJg5zGeeR9c/nVXQ7L7dMVY7UjUyOcchVGT+lT3upLqmozSKqhHOFAGMDtWi2IerItEnuLLUrea3nMM8LiRHU4II54r07xXpkl3Y2OuafK9va6jEDPGj42XC5DjjoOn515pBAsLbxuJ7E16T4KvzqfhTxBp0kSyrBGt4oZ8bSp2tjHXhulbQV1Ziu4yTRwuZ7a4RSsiMnUlyTt9KJnV8xzyGOInIQZNaM4WeVgy7CnGCeT/AI1UZBcNwm5x1I659KmxtJnH7cc1oeHtWfQdbsr9TxDICwAzlTww/EE1p+MPC8/hnUSjoTayktDJjj3U+hHpXPOm0VxtcjN3Hoe86TElnrs0cEiPayqGhk6hkYZU/kf6V5DFu0rxLGMlWt7vB/B8V2Hw18bacmnvpniBri3gtcGz1aCIy/ZQTzFIowWRjyMcg5wCK5XxbJYf29qL6def2hC87tFcLG0akZ4YBufz6VM0rqaPT+sqrh405bxPcRJFPDNpV4S9vcRNGysMHkdfwx19q8R8XeFrzwnqTW9yjGPO6KbHyyrnqK9RhmfX9DsNQtCVkktt5JP8SkK4H4irPimwn8Y+BHRYy95aASqhHzcfeA+oz+VTVhyvmR9BCUMzwaTf7yC+86Pwd41vtFtLCTXbe6tmkVHtdahUvFLHgbBJj243dcDkcV1Gv6rd6f4wl8V6Tb/bLG905otZjtWjeOSQANHKoLD5hw2e2D6kVk/s6/EVW8LRadebJ/7OYRNDIA2YycodpHTqte4eItM8FeL9J+zahotk0LruDxxBGB9Qy9DXNUnOEo1Er22fX/gnTSw8cVQdOns90+j7rscd4f8AHHhG8u4bvwb4wsI3THm6TrDG0ulbuQx+R+c8hq9tXxUniaySN0j0rxIVEcWqWEqyO4x92RVJ8xSD357g8V8l/EP9nmwtrRNU8HOZriF97WVw4bcvXA6Z9CO9d/8ABz48aXHDFo97pmm+FPEMOV3TQeWj49Gxxnng81jWaxbi3G0ls72+456eHqYaDpYvWK2urr71sfTvjDVLnTfAdw+mGex1dFBge9n2JI3+0FG7aOvzHJ6V8/3fxF8Sa/Ottqk1hHFBgSYuiQeu4qAgxnsD+NbviS88U+MbZ2hja+tiuTc2jCSM/iucV49rvgzV9HKiSzuZbieQxqFUnkAfL9ea6Vg68/eqP79fzuWsXg6OkHb0/wCDdnZ3974b0qzmZ50nuZOFaONcg545Ocn8KW68dnR/B7Lt+yWskJhtLdGIVIydzMFHA3E/pXnNhqPhzRGm/tbUrLU9Ztz5n9nRXKxrCRxhmYgO2eqqcisfxX4lk8QTySXNzBawgArmaMKBjoAD9OlZyw7b5ZSv89EdFKvQjCVSnZJ9b+8/1t+Zwvii0/tbUDMvBc+g6/Wm6LoCaVqFpeah8tswZ4SwAR5ACVQ5PAJHWta91jRdAWUiRdZvAB5QhB8hDgfeY4LYyeAOveuYs5LjxDri3F7Pv/iaRuFjQenYCvTglBWifN4uMq0/bVtF26v5dEWPiRrD6vqf2mZi87QxF26FmKLk4rhY0Ms3K4HY4611mqaDrms6jLdW1m1xbs5CSxyIyBRnGTux0H6VSn02x0Mu1xPHfXSjKwWjh0B/2nHHHoufrWNOKWpOPqSr2hBbL5E2iZ8OWDa5OFD5MNkrjIeTHLY9FHPpnAqp4i1m4v8ATdHlbbKkKNbSbwCjAcqCPUAkZ9hWNqmpXOtXxmnI44SNBhEXrtUdhV7UoTB4cs89WmJH4CtW24s8aKUZKJmfbo4iWFlamQHILITj8M/zqrd38+pOhnlLhBhF6Ko9AOgFRlS8m0kKCcZPSnQwbmKg5J9KiNyajV9ENtPmvEznk4yBWp4nRU1bAz80aMc56lRVe1REljDqSxbkjpiuu1HSNP1zU7hGvns7m3RIUby/MiZggIBPBHp0NbW90xinKVkcBJCSeetPgtWchQpJPHArsbv4ez6SUl1C/t4oZBmOSINKsgOeVIGOx4JzxVWS+0/Tl8rTYZZJiuPtdzgFTnnYo6emTzSUQaZBdWsejaYINw+2Tcyg9Yk67eO571jNDsIKZIxnI4wall3MpwnfqetSRgoNm7r1K1e5GwsEzuPu4Uda7v4c7Xk1G38sDz7GYEgEkAKSTXJWtsWKoMjPP1rtvBKz6JPeagLdbi3iieKTeSMeYpUYI79/w5ropqxhNmFcRlAVVQGAwc/54rN3fZw2+QBc5I9T7VtS+WhkOC0+DyT296yQJvMUw7dxHG49PWlY1crnq1rpo8RyPbX0CXdu53OGGVBPcHt9aw/F/wALPDPhXw9f6rIb6UKNkKBxt3t93nGeOa1tC1w2t4rDb5ePmHrWH8bdca70WxgR5FiM54DfKRjv+NY1UuVs9aOsbsofDPS01n4c6vpjmMLfaigLL/rFMcRKEj+7l+PcGvNr6zm0+8mtbhDFPCxR1I6EV23wj1kQvf6eS25nS4QjoMZVv5rV74m+GLjVL6TWLKNWAiXz4wfnOP4sd+P5VyyjeKaNadp0bRWqbJfg3q5lW60uR8GFlubUdSzswQxgd87gfwNepxwnRLpy4CurkTW54KtjBBz3r5bWRkdZEZkdTuVlOCCO4r1vwt8cPtlqmneMVmvUVdkWrW4H2lBwAJP+eij1PzD1rWM4yhySOalUqYaqqsNuxoeJNIvvh74iXxR4dXfp7nMsI5VAT8yMB/Cex7V674U8TL4o8OrqejSeZacLPaucyW0ndWH909m71yenT2+qRPNoWq22rQthWjjYByPQo3P6VRtvDGu+CNej8V+DrSW21C2HmXWlvCXt54+SysvTBAPynjuMYrKFOVN2avE+iqYinUXt8LPll1TO+uru7s7uDzVkj3fMCucY781Y1K50DxLbmPWNLt7sgY8yYDeR7MMGnXn7Q/wxvLeJdYg1bRdTZMzWWnxLdRW7cgx7ywzg8jAPBHeuVuvH3w4v7ae70w+JLsQrveKHTFB9yxLlQK1q0aTVlJDw2dV37taDfyuTQ+EtF0qSR9A1nXfD0u4MDp186r7DGeQK9e+Fev6lo2nvdatr13qsds/mpPckBp5wCqY4yABgtzyVHcmvm7TfjZ4aNxJbw6dc6bk/ury+k81WHo4QZX2K59/WuxPj2e/0yN4QssEgIieFgUx6ccDmuZQcValL/L7j1MPisHVbq1IRi13Wv9eZm/FGDw9e6jcTtplsbkucsseM+pOK8h1CGNZGFvBHCVPGxMAj616DqDy6lM+baWR8hiFXn/8AVVzSPhjdazBNMyrE4DBXuPlB74OcY4H6VpSw1lY5MdmtGMXGilc8tSzlmgITceMkEdq3tW0BtC8KfZ5cQ319tkkXHzrB2HtuOPfArurnwjYeFxcz6lN52oWUkQhs0/1bFl3pIX6FQM8d+K898SanPqEk01wWmlZi2c9f/rVrU933VueZgcLLEp4rE/Ctk93/AMD8zjroxwriNdox933qlHMzSALn2p93MCxAznJPNSWNmZXjbIxuAO4dayhE48dieaVo6C2Fi013GCMjOSccVuePGNpHpunKAFgg8yRABw7HI569McVreHtOjju5by5Ux2FpGZmPQHHRc+pOB+NcfrN++rX89xLxJK5Ygds9vwraatG3c8uiuZufYxS2JB3z6+tXLa0LOhchAcVXCB5cKBgZxkZzWvBZr5aKrI7FN3PbntRGJi3dlrSdOe+1ezijj+VpgMZ7Dr+lRa7eBdUuGgJLyOzFscknkfkMV1uj2l14Yhh1CX5boDMMDRgh1Ixlsnjgkj8K5PWgTcmVFKsw3KGORn1AraUdB03a8jS8K+JM/wDEuv8AMlhPIhkSQnaMZ+Ye/J/OqXiqx/snVJIQhTIDo6j5WU9xWKJDGWVztYc5PTNdfftLrngu3v5ZAW0ub7OWbqY26AH60lqglLucugEZ6ZPrnpSRId5J4B5qVpPNBYIGHXcKuWFjJqJCQIX/ANonCg/WmkYNlvw/atd38UIGS2AFP5Cut8a3F1oU1vb+SRZpGsYNshaKZucvn17fhnvWCbi18OytDEGuL4/u5JopP3aL3C/3j1BPTHT1r0b4eeK7O8gutE1NS9pebBFLuyYHznI+tdKV42TMb2d5HnJSUp5qRyzRyPt+VTyfp+NaGh6VbyXG298uzVSVHPmOMd9o6Zq34uhl0bVL2xvt4mglKrgkKPf8q5q31mC3Z5lj3Sfd29zSWj1Ll5Hd6lod9ZADy3tJQBmTGUbPTHqPeqfijw62p+B7ouVkubZVnjK8k4+8PyzWZ4L/AOFh6VJDawBXsYhtW31RVmgCkg4AOfTt+lL4l+Let6LdX+kwaJo2kXEbsjyW8DuQSOqeYzAZHtXPKSktVY9GE5wVnqefeGtWbw5rNrenBjcmORPWNuGP9R9K9ivrp7eJwTHKpUhWiO4FSAQw9q8HkJdi7MWZuST3r1X4V6uPE1p/wj88wGowDdY7z/rlHWMe47e30rGm1fkKp1XRnzmReeFbLXMT20v2W5ckEbco59cdieaiT4P+I5wGt4becH+7MAceuDiuq1PSGspA5gKsOhC8jnmtnQdRazlCeYwQLn5jwB2FKVJX1PWXsKyvszxvWtDvvB+tfZroCG+g2v8Au2455HIr3/wT4ttL3R0u7aedopwVmiuJ2mMbcbo2yTx6Z7Y96534h+F38dWy31iVa+t0wFIA85fTPqK8n0XW9Q8Iaq01uPLmXMc1vMPlcd1Yf5xWPwO0thRcsJU56ep9H3WkaHefvv7NsvNUZH7hRn9KLjXW0qAi2tYUjUYVAoAI+grhvCfjTT9eQwJL9l1B2wtlcHAk/wBxumfQHmt6bTryNgk9pPESp2q6kbvp61r7JS1ie3Rzam1+8STOL8ReFNJ1i8luokbT3YbnWPpuPcKe1ZK/Dq8sW8201hI2UBwYgyt7dDXa3PhiV5OQy7wCit1/OoNX0a+051tY1bzBhSFwSpx3/Oj2HWx59fGYWpL4Vc51bPVbTmXxJfOobfmOQgg+uSSavaRpralqcG+6uJ9pBea7uGdVTHzE5PTFbFn8PdTmRbnUEeysV+VpWIXnGAAT1NcHqvxBbSNUkt9EtFt7FGKSx3yeY1yOhVwf4e+B+dDiofEcyxdOFnRhbz/yZ2nijX31jULm7j/1TMBER2jVQq8fQCuL1O5YNjcTk4IHrTofGmh3VuPPsbzTLgKMi0dZoXbudr4ZRntuNVp9W06cGSKa5nfIA3W4XA9Cd1CcO5risfPEe5BaGctsLudQMnBPAHT64rsPCmhW9rIb3WbiPTdKt32SPKeXb0C/xH2FT6Br2k2TBLTTGkuJB5Ye5YERnOchR1yM8Hjp6VT+LccmtazcPH0tGKpGOFAIBbA7AHNaXUVdaniSw86l3LT8yp4r8Xy39kujwxtDZRXEk8bOoVplONhOOoHOD/tVx1wCx+UYY9h602x1qe0ha2ntUvrc4AS4B3R4OfkYcrnn256VvW+t6QmHbw/Mr7VAD3pK57n7meee/FZqXO7syvyx5YoxLCwlcj5WJL7cgZwa9N0HwpD4ZSO71lP9JaPfBYSA5cnozeg77eCad4D1mB4dSksNKgsmhCtGwZpJGO8cF2zj8AOlZet6yBfs8szTeb2ZjlT35z2NdMbJXIjTUtZFbW7maWSO5lnLsTsYnjHJI/Dp+VZV5HDdzrERmV1z5hPfPFNtXlui5nYMByCDyPp2qK7jexmV413AgYkU8AigmbKV9pz2spjYMzE4yea7z4ZSJ9h1mKa3S5RUU+W6B++Oh471w0zq7szSdfmbsP8AOa7z4fr5fh/VLghgZdkZkx/Fk8fQjNaQWpzOV2ilKtgrySLp1obg7jllyGB9ugI/zmor/V5ryBoQIhGMsECBVTjGAAMUuoWUsbO8e0oM/PnsKzAsP2ZyrFm+8B3+tM0k7mVcQ4ZdimRSN2BnIPertjdyxyBixRlbIA7+lQsge3Mrtng+2TUulgJsZ/mz3Hakt9DCVj1n4rmPWfDvhbxDbILltSsxBcM/DG4i+U8em3bXk9rYSm9jjACYDbiecH0r2G/SbVvg7b3UNqS+maqiq+wfLviOVx6HbnOOormNE0AXt2ZUC20qqS3mnarduM1s43dzNS909CtJBNFEBwwkHAHJ9a4P46eCDdIviCzG6WJAl3Cq87B0k/DofbFbfw7mklQb5GfDgDcc4GK9A1JFmsY1kUOro6sGGQw9DWc0pI9JSbWp8ZyY4xyMU/Tr6fTdSgu7WV4Lm3bzY5U6qw5BqfVo1j1C7VFCqsrABRgAZqpaAEXJPJCcf99CvNe4N62Pp74Z6jafFjR5J1lSHX7NcX1llV84E4WaMHqCcBgOhOao6zoQ064nSRTDIpIZB0zXlPwcuJbPxXdzwSvBPFYTMksbFWQ5XkEcg19yeNdPtbv4Q6RqM9tDNqDxLuupIw0rfKOrnn9a9Kl+9hd7nK5ujUtHY+TZNYl0eUbshQAUVc/N/wDqrO1N9L8Wrm6gCXuMB0G1/wA+/wCNdr4itovM05vKTd9mU52jPQ1w+tRrFex7FCZTJ2jGeK55RT0Z79LEPl1VzGuvhhe3FwiaZcx3ssjAJEflkJJwAPXtViw+LXi/wJqM2nw6ot1DakQNbXgW5iyoAYAnPGc9DXo/hcC38O+Lp4h5U8OjTSRSpw0bbB8ynqDyeR615J8MbeK41QGWNJSJ48F1B65z1rBx9n8DtcyklXqqDR7J4G+MVx4vmsrfUvBdtE4mR5tWsi8aFAeQY2yOemVP4V13iTxlYaRLNdafo1vYzS/MfMkM8i577iB+grj5pXiudqOyDHRTisnxKxbT8kkkyKCT3G2t/aTtZs9Khl+HhLmlG/rsZniXxbeX80bTXctxHHyvnMTg+w7d642+mXUriOWWBJA5KksuWOK1NYAEJwMcKKwJSVWbBxwOn4VhbqzrxNW0eRLQ0YLTS42BWzj29i3r+NZ986zzhUARM4C47VctQDGBjjAqbQoIpbmAPGjgu2Qyg9hWnKjwpVpJWRr+C9GaEy6pdqYrW3GRkffbHygfjWRe3/2iaYXLNvclztGDzycV3/jljDouhxoSkcgO9V4DcDqO9cDqiK1+pKgn7O3JH+zVyVvdMISfJzdzImJmjfJHJHzA1nXZKT4DAgceowOldVY28RtrwmNCViyvyjg+orjr4fI//XTFQ0YTbep1/hOY2fhvUH5UzOkYyeGGcn8eP51mXUsN3qe5pdihsKq9Mf8A66u6ioTwlpRUBSyuWxxk/NyahtIkdLYsisdq8kZ7itHokgi/cLkSqpQ/KInyFzgEAf1qpCkk802QxAQ4VQTj6juauW/7yWLd83K9efWrMpMYiZDsbzByvB6VvFXOWo7GFaQxyX62tzGIkcYLnkgE8H+hr0y+0Gfw/wCHhpUqiC9cpLOv3SvB2qeOcLzj/ari9biQwK2xdzRAsccnOM5rvteuZruS0lnleaRrKAs8jFif3Sjkn2Aq4rRmMdZHK24UwPAB5ny7GB68+lZeoafHBAHdtvOEXBG72NadwAJoyBg7jVXxAM21pnnMhz+VKxo2Y5052syZQFUN8oz1H0p1raSQSYOdowMHp61r7FeJQyhgOgIzUrIotYjtHX0ppGMj0TT9Tt9O+DlxctOsUZ1NDOHcZAVMZC9z82K8K8Z+Kzq2rTLYXM0mnI37pm+Qt6kitD4hsV0Lw4gJCMs5KjoT5nWuG6Vz16jT5UOlFNcx/9k="; + } + + function returnGreenery1AsBase64() { + return "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"; + } + + function returnGreenery2AsBase64() { + return "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"; + } + + function returnGreenery3AsBase64() { + return "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"; + } + + async function setup() { + await PowerPoint.run(async (context) => { + // Adds a new slide with some content. + const slideCountResult = context.presentation.slides.getCount(); + context.presentation.slides.add(); + await context.sync(); + + const newSlide = context.presentation.slides.getItemAt(slideCountResult.value); + newSlide.load("id"); + newSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon); + await context.sync(); + + console.log(`Added slide - ID: ${newSlide.id}`); + + // Switch to the new slide. + context.presentation.setSelectedSlides([newSlide.id]); + await context.sync(); + }); + } + + // 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: |- +
    +

    This sample shows how to create binding references for images.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Insert image with binding

    +

    Try adding a few images. Enter an ID, then select the button. A binding with that ID will be created which refers + to the shape.

    +

    Binding ID: + +

    + +

    Show the bindings in the document

    +

    The console will show the bindings in the document.

    + +

    Update an image using its binding

    +

    Select a binding ID from the dropdown list then pick a replacement picture.

    +

    Choose the binding for the image you want to update:

    + +

    +

    Select the replacement image:

    + + + +

    +

    After adding a few images, try z-Order APIs

    +

    Click on or select the image you want to act on.

    + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + 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 diff --git a/samples/powerpoint/shapes/get-set-shapes.yaml b/samples/powerpoint/shapes/get-set-shapes.yaml new file mode 100644 index 000000000..521242f6e --- /dev/null +++ b/samples/powerpoint/shapes/get-set-shapes.yaml @@ -0,0 +1,227 @@ +order: 2 +id: powerpoint-shapes-get-set-shapes +name: Get, set, load, and save shapes +description: Get and set one or more selected shapes. Load and save one or more shapes. +host: POWERPOINT +api_set: + PowerPointApi: '1.5' +script: + content: | + document.getElementById("getSelectedShapes").addEventListener("click", () => tryCatch(getSelectedShapes)); + document.getElementById("setSelectedShapes").addEventListener("click", () => tryCatch(setSelectedShapes)); + document.getElementById("changeFill").addEventListener("click", () => tryCatch(changeFill)); + document.getElementById("saveShapeSelection").addEventListener("click", () => tryCatch(saveShapeSelection)); + document.getElementById("loadShapeSelection").addEventListener("click", () => tryCatch(loadShapeSelection)); + document.getElementById("createShapes").addEventListener("click", () => tryCatch(createShapes)); + document.getElementById("arrangeSelected").addEventListener("click", () => tryCatch(arrangeSelected)); + + async function getSelectedShapes() { + // Gets the shapes you selected on the slide and displays their IDs on the task pane. + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
    getSelectedShapes.getCount returned:" + shapeCount.value + "
    "; + finalTable += + "
    "; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
    IndexId
    " + index + "" + shape.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = ""; + outputSpan.innerHTML += finalTable; + }); + } + + async function setSelectedShapes() { + // Selects the first two shapes on slide 1. + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slide1 = context.presentation.slides.getItemAt(0); + slide1.load("shapes/items/type"); + await context.sync(); + + const shapes = slide1.shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape); + const shape1: PowerPoint.Shape = shapes[0]; + const shape2: PowerPoint.Shape = shapes[1]; + shape1.load("id"); + shape2.load("id"); + await context.sync(); + + console.log(`IDs: ${shape1.id}, ${shape2.id}`) + slide1.setSelectedShapes([shape1.id, shape2.id]); + await context.sync(); + }); + } + + async function changeFill() { + // Changes the selected shapes fill color to red. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); + } + + let savedSlideSelection = []; + let savedShapeSelection = []; + async function saveShapeSelection() { + // Saves which shapes are selected so that they can be reselected later. + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); + } + + async function loadShapeSelection() { + // Reselects shapes that were saved previously. + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); + await context.sync(); + slide1.setSelectedShapes(savedShapeSelection); + await context.sync(); + }); + } + + const slideWidth = 960; + const slideHeight = 540; + function getRandomBetween(a, b) { + return Math.random() * (b - a) + a; + } + + function generateRandomHexColor() { + return `#${Math.random() + .toString(16) + .substring(2, 8)}`; + } + + async function createShapes() { + // Creates random shapes on the selected slide. + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape( + PowerPoint.GeometricShapeType.rectangle + ); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = ""; + outputSpan.innerHTML += finalTable; + }); + } + + let currentLeft = 0; + let currentTop = 0; + async function arrangeSelected() { + // Arranges the selected shapes in a line from left to right. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); + } + + /** 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: |- +
    +

    This sample shows how to get selected shapes, and how to select and change specific shapes.

    +
    +
    +

    Try it out

    + +
    +
    +
    +
    +
    +
    + +
    + 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; + } + .content { + padding: 0 18px; + /* display: none; */ + overflow: hidden; + background-color: #f1f1f1; + max-height: 0; + transition: max-height 0.2s ease-out; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/powerpoint/shapes/get-shapes-by-type.yaml b/samples/powerpoint/shapes/get-shapes-by-type.yaml new file mode 100644 index 000000000..8e64c0bad --- /dev/null +++ b/samples/powerpoint/shapes/get-shapes-by-type.yaml @@ -0,0 +1,140 @@ +order: 3 +id: powerpoint-shapes-get-shapes-by-type +name: Select shapes by type +description: Gets shapes in a slide based on their type, such as GeometricShape or Line. +host: POWERPOINT +api_set: + PowerPointApi: '1.4' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("change-lines").addEventListener("click", () => tryCatch(changeLines)); + document.getElementById("change-geometric-shapes").addEventListener("click", () => tryCatch(changeGeometricShapes)); + + async function changeLines() { + // Changes the dash style of every line in the slide. + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the dash style for shapes of the type `line`. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.line) { + shape.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.dashDot; + } + }); + await context.sync(); + }); + } + + async function changeGeometricShapes() { + // Changes the transparency of every geometric shape in the slide. + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); + } + + async function setup() { + await PowerPoint.run(async (context) => { + // Create shapes of different types. + const shapes = context.presentation.slides.getItemAt(0).shapes; + + // Create geometric shapes. + shapes.addGeometricShape(PowerPoint.GeometricShapeType.diamond, { + left: 100, + top: 100, + height: 150, + width: 150 + }); + shapes.addGeometricShape(PowerPoint.GeometricShapeType.octagon, { + left: 400, + top: 300, + height: 150, + width: 150 + }); + + // Create lines. + shapes.addLine(PowerPoint.ConnectorType.elbow, { + left: 400, + top: 150, + height: 20, + width: 150 + }); + shapes.addLine(PowerPoint.ConnectorType.curve, { + left: 100, + top: 300, + height: 150, + width: 20 + }); + + await context.sync(); + }); + } + + /** 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: |- +
    +

    This sample shows how select and change shapes based on their types.

    +
    +
    +

    Setup

    +

    Create some shapes in a new, blank presentation.

    +

    + +

    +

    Try it out

    +

    + +

    + +

    +

    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/powerpoint/shapes/group-ungroup-shapes.yaml b/samples/powerpoint/shapes/group-ungroup-shapes.yaml new file mode 100644 index 000000000..4021254cc --- /dev/null +++ b/samples/powerpoint/shapes/group-ungroup-shapes.yaml @@ -0,0 +1,193 @@ +order: 6 +id: powerpoint-shapes-group-ungroup-shapes +name: Group and ungroup shapes +description: Shows how to create two shapes then group and ungroup them. +author: aafvstam +host: POWERPOINT +api_set: + PowerPointApi: '1.8' +script: + content: | + document.getElementById("group-shapes").addEventListener("click", () => tryCatch(groupShapes)); + document.getElementById("move-group").addEventListener("click", () => tryCatch(moveGroup)); + document.getElementById("ungroup-shapes").addEventListener("click", () => tryCatch(ungroupShapes)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function groupShapes() { + await PowerPoint.run(async (context) => { + // Groups the geometric shapes on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape); + if (shapesToGroup.length === 0) { + console.warn("No shapes on the current slide, so nothing to group."); + return; + } + + // Group the geometric shapes. + console.log(`Number of shapes to group: ${shapesToGroup.length}`); + const group = shapes.addGroup(shapesToGroup); + group.load("id"); + await context.sync(); + + console.log(`Grouped shapes. Group ID: ${group.id}`); + }); + } + + async function moveGroup() { + await PowerPoint.run(async (context) => { + // Move the first shape group to the top-left of the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); + if (shapeGroups.length === 0) { + console.warn("No shape groups on the current slide, so nothing to move."); + return; + } + + // Move the first grouped shapes. + const firstGroupId = shapeGroups[0].id; + const shapeGroupToMove = shapes.getItem(firstGroupId); + shapeGroupToMove.top = 0; + shapeGroupToMove.left = 0; + await context.sync(); + + console.log(`Moved shape group with group ID: ${firstGroupId}`); + }); + } + + async function ungroupShapes() { + await PowerPoint.run(async (context) => { + // Ungroups the first shape group on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); + if (shapeGroups.length === 0) { + console.warn("No shape groups on the current slide, so nothing to ungroup."); + return; + } + + // Ungroup the first grouped shapes. + const firstGroupId = shapeGroups[0].id; + const shapeGroupToUngroup = shapes.getItem(firstGroupId); + shapeGroupToUngroup.group.ungroup(); + await context.sync(); + + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); + }); + } + + async function setup() { + await PowerPoint.run(async (context) => { + // Adds a new slide with two shapes. + const slideCountResult = context.presentation.slides.getCount(); + context.presentation.slides.add(); + await context.sync(); + + const newSlide = context.presentation.slides.getItemAt(slideCountResult.value); + newSlide.load("id"); + + // Create two shapes. + const shape1 = newSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle); + shape1.left = 100; + shape1.top = 100; + shape1.width = 150; + shape1.height = 100; + shape1.fill.foregroundColor = "darkred"; + + const shape2 = newSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.ellipse); + shape2.left = 300; + shape2.top = 100; + shape2.width = 150; + shape2.height = 100; + shape2.fill.foregroundColor = "darkblue"; + + await context.sync(); + + console.log(`Added slide - ID: ${newSlide.id}`); + + // Switch to the new slide. + context.presentation.setSelectedSlides([newSlide.id]); + await context.sync(); + }); + } + + // 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: |- +
    +

    Shows how to group then ungroup shapes.

    +

    Code sample based on community contribution from Maarten van Stam.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + +
    + 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; + } + .content { + padding: 0 18px; + /* display: none; */ + overflow: hidden; + background-color: #f1f1f1; + max-height: 0; + transition: max-height 0.2s ease-out; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/shapes/shapes.yaml b/samples/powerpoint/shapes/shapes.yaml new file mode 100644 index 000000000..68c8d5c32 --- /dev/null +++ b/samples/powerpoint/shapes/shapes.yaml @@ -0,0 +1,216 @@ +order: 1 +id: powerpoint-shapes +name: Insert shape, line, and text box +description: Inserts geometric shapes, lines, and text boxes to a slide. +host: POWERPOINT +api_set: + PowerPointApi: '1.4' +script: + content: |- + document.getElementById("create-hexagon").addEventListener("click", () => tryCatch(createHexagon)); + document.getElementById("shrink-hexagon").addEventListener("click", () => tryCatch(shrinkHexagon)); + document.getElementById("move-hexagon").addEventListener("click", () => tryCatch(moveHexagon)); + document.getElementById("create-line").addEventListener("click", () => tryCatch(createLine)); + document.getElementById("create-text-box").addEventListener("click", () => tryCatch(createTextBox)); + document.getElementById("create-shape-with-text").addEventListener("click", () => tryCatch(createShapeWithText)); + document.getElementById("remove-all").addEventListener("click", () => tryCatch(removeAll)); + + async function createHexagon() { + // This function gets the collection of shapes on the first slide, + // and adds a hexagon shape to the collection, while specifying its + // location and size. Then it names the shape. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); + } + + async function shrinkHexagon() { + // This function gets the collection of shapes on the first slide, + // gets the first shape in the collection, and resets its size. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const hexagon: PowerPoint.Shape = shapes.getItemAt(0); + hexagon.height = 50; + hexagon.width = 50; + + await context.sync(); + }); + } + + async function moveHexagon() { + // This function gets the collection of shapes on the first slide, + // gets the first shape in the collection, and resets its location. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const hexagon: PowerPoint.Shape = shapes.getItemAt(0); + hexagon.top = 50; + hexagon.left = 150; + + await context.sync(); + }); + } + + async function createLine() { + // This function gets the collection of shapes on the first slide, + // and adds a line to the collection, while specifying its + // start and end points. Then it names the shape. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + + // For a line, left and top are the coordinates of the start point, + // while height and width are the coordinates of the end point. + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, + { + left: 400, + top: 200, + height: 20, + width: 150 + }); + line.name = "StraightLine"; + + await context.sync(); + }); + } + + async function createTextBox() { + // This function gets the collection of shapes on the first slide, + // and adds a text box to the collection, while specifying its text, + // location, and size. Then it names the text box. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", + { + left: 100, + top: 300, + height: 300, + width: 450 + }); + textbox.name = "Textbox"; + + return context.sync(); + }); + } + + async function createShapeWithText() { + // This function gets the collection of shapes on the first slide, + // and adds a brace pair, {}, to the collection, while specifying its + // location and size. Then it names the shape, sets its text and font + // color, and centers it inside the braces. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + left: 100, + top: 400, + height: 50, + width: 150 + }); + braces.name = "Braces"; + braces.textFrame.textRange.text = "Shape text"; + braces.textFrame.textRange.font.color = "purple"; + braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered; + + return context.sync(); + }); + } + + async function removeAll() { + // This function gets the collection of shapes on the first slide, + // and then iterates through them, deleting each one. + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); + } + + /** 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: |- +
    +

    This sample shows how to create, resize, move, and delete shapes.

    +
    +
    +

    Try it out

    +

    Begin by deleting all shapes that are currently on the slide.

    +

    + + +

    +

    Create, shrink, and move a shape.

    +

    + +

    + +

    + +

    + +

    Create other shapes.

    +

    + +

    + +

    + +

    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/powerpoint/slide-management/add-slides.yaml b/samples/powerpoint/slide-management/add-slides.yaml new file mode 100644 index 000000000..e7e5e89cb --- /dev/null +++ b/samples/powerpoint/slide-management/add-slides.yaml @@ -0,0 +1,104 @@ +order: 1 +id: powerpoint-add-slides +name: Add slides to a presentation +description: Adds a slide and optionally specifies the slide master and layout. +host: POWERPOINT +api_set: + PowerPointApi: '1.3' +script: + content: |- + document.getElementById("slide-masters").addEventListener("click", () => tryCatch(logSlideMasters)); + document.getElementById("add-slide").addEventListener("click", () => tryCatch(addSlide)); + + async function addSlide() { + const chosenMaster = (document.getElementById("master-id") as HTMLInputElement).value; + const chosenLayout = (document.getElementById("layout-id") as HTMLInputElement).value; + + await PowerPoint.run(async function(context) { + // Create a new slide using an existing master slide and layout. + const newSlideOptions: PowerPoint.AddSlideOptions = { + slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */ + layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */ + }; + context.presentation.slides.add(newSlideOptions); + await context.sync(); + }); + } + + async function logSlideMasters() { + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); + } + + /** 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: |- +
    +

    This sample shows how to add a slide and optionally to specify the slide master and layout of the slide.

    +
    +
    +

    Try it out

    +

    On the Home ribbon, open the New Slide drop down menu to see the slide masters and slide layouts in the presentation. Be sure there are at least two slide masters. To add a master, see Use + multiple slide masters in one presentation. The page will open in your browser.

    +

    Press Add slide to add a slide with the default layout of the default slide master to the end of the presentation.

    + +

    Press Log slide masters info to log to the console a list of all the slide masters, their child layouts, and the IDs of the masters and the layouts.

    + +

    Copy one of the slide master IDs from the console and enter it in the Master ID text box. (Example: 6147483651#7142061614)

    +

    +

    Copy one of the layout IDs from the console, under the same master you choose above, and enter it in the Layout ID text box. (Example: 2147483651#3142061614)

    +

    +

    Press Add slide again to add a slide with the corresponding master and layout.

    + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/slide-management/export-import-slide.yaml b/samples/powerpoint/slide-management/export-import-slide.yaml new file mode 100644 index 000000000..391895002 --- /dev/null +++ b/samples/powerpoint/slide-management/export-import-slide.yaml @@ -0,0 +1,306 @@ +order: 5 +id: powerpoint-slide-management-export-import-slide +name: Export and import slide +description: Shows how to export and import a slide. +host: POWERPOINT +api_set: + PowerPointApi: '1.8' +script: + content: | + document.getElementById("export-slide-button").addEventListener("click", () => tryCatch(exportSlide)); + document.getElementById("clear-exported-slide-button").addEventListener("click", () => tryCatch(clearExportedSlide)); + document.getElementById("import-slide-button").addEventListener("click", () => tryCatch(importSlide)); + document.getElementById("slide-image-button").addEventListener("click", () => tryCatch(addSlideImageToNewSlide)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function exportSlide() { + // Exports current slide. + await PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const slideBase64DataResult = slide.exportAsBase64(); + const imageBase64DataResult = slide.getImageAsBase64({ height: 300 }); + await context.sync(); + + localStorage.setItem("exportedSlide", slideBase64DataResult.value); + localStorage.setItem("exportedSlideImage", imageBase64DataResult.value); + + updateSlideImage(imageBase64DataResult.value); + + console.log("Slide was exported."); + }); + } + + function clearExportedSlide() { + // Clears exported slide. + localStorage.removeItem("exportedSlide"); + localStorage.removeItem("exportedSlideImage"); + updateSlideImage(""); + console.log("Exported slide was cleared."); + } + + async function importSlide() { + // Imports the slide that was most recently exported. + const slideBase64Data = localStorage.getItem("exportedSlide"); + if (slideBase64Data === null) { + console.warn("Unable to import. You must first export a slide."); + return; + } + + await PowerPoint.run(async (context) => { + const currentSlide = context.presentation.getSelectedSlides().getItemAt(0); + currentSlide.load("id"); + await context.sync(); + + context.presentation.insertSlidesFromBase64(slideBase64Data, { targetSlideId: currentSlide.id }); + }); + } + + async function getSlideImage(options?: PowerPoint.SlideGetImageOptions): Promise { + // Gets slide image. + return PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const imageBase64Result = slide.getImageAsBase64(options); + await context.sync(); + + return imageBase64Result.value; + }); + } + + async function getImageDimensions(base64Data: string): Promise<{ width: number; height: number }> { + // Gets image dimensions. + return new Promise((resolve, reject) => { + const image = new Image(); + image.onerror = () => { + reject(); + }; + image.onload = () => { + resolve({ width: image.width, height: image.height }); + }; + image.src = `data:image/png;base64,${base64Data}`; + }); + } + + async function addSlideWithImage(imageBase64): Promise { + // Adds a new slide including an image. + return PowerPoint.run(async (context) => { + const presentation = context.presentation; + const currentSlide = presentation.getSelectedSlides().getItemAt(0); + const slideCountResult = context.presentation.slides.getCount(); + + currentSlide.layout.load(); + await context.sync(); + + const slideCount = slideCountResult.value; + + console.log(`Adding slide using layout ${currentSlide.layout.id}`); + + // Add a new slide at the end of the presentation. + context.presentation.slides.add({ layoutId: currentSlide.layout.id }); + try { + await context.sync(); + } catch (err) { + console.error(`Unable to add slide (with layout from current slide). ${err}`); + + // Try adding without specifying the layout. + context.presentation.slides.add(); + + try { + await context.sync(); + } catch (err) { + console.error(`Unable to add slide. ${err}`); + throw err; + } + } + + console.log("Slide added"); + + // Get added slide. + const slide = context.presentation.slides.getItemAt(slideCount); + + slide.load(["id"]); + + await context.sync(); + + console.log(`Added slide id: ${slide.id}`); + + // Switch to the new slide. + context.presentation.setSelectedSlides([slide.id]); + try { + await context.sync(); + } catch (err) { + console.error(`Unable to switch to the new slide. ${err}`); + throw err; + } + + console.log("Switched to the added slide."); + + const activeSlide = context.presentation.getSelectedSlides().getItemAt(0); + activeSlide.load(["id"]); + await context.sync(); + + console.log(`Active slide id: ${activeSlide.id}`); + + const imageDimensions = await getImageDimensions(imageBase64); + const shapeAddOptions = { + height: imageDimensions.height, + width: imageDimensions.width + }; + + let shape; + + shape = await addImageToCurrentSlide(imageBase64); + shape.load(["id"]); + await context.sync(); + + // Select the added image. + activeSlide.setSelectedShapes([shape.id]); + await context.sync(); + }); + } + + async function addImageToCurrentSlide( + imageBase64: string, + options?: PowerPoint.ShapeAddOptions + ): Promise { + // Adds an image to the current slide. + const setSelectedDataOptions: Office.SetSelectedDataOptions = { + coercionType: Office.CoercionType.Image + }; + if (options) { + if (options.height) { + setSelectedDataOptions.imageHeight = options.height; + } + if (options.left) { + setSelectedDataOptions.imageLeft = options.left; + } + if (options.top) { + setSelectedDataOptions.imageTop = options.top; + } + if (options.width) { + setSelectedDataOptions.imageWidth = options.width; + } + } + + return new Promise((resolve, reject) => { + Office.context.document.setSelectedDataAsync( + imageBase64, + setSelectedDataOptions, + async (result: Office.AsyncResult) => { + if (result.error) { + console.error(`ERROR in setSelectedDataAsync(): ${result.error}`); + reject(result.error); + } else { + const shape = await PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.shapes.load(); + await context.sync(); + + return slide.shapes.items[slide.shapes.items.length - 1]; + }); + resolve(shape); + } + } + ); + }); + } + + async function addSlideImageToNewSlide() { + // Adds an image of current slide to the new slide. + const imageBase64 = await getSlideImage({ height: 500 }); + + await addSlideWithImage(imageBase64); + } + + function updateSlideImage(imageBase64: string) { + const slideImageElement = document.getElementById("slide-image") as HTMLImageElement; + slideImageElement.src = imageBase64 ? `data:image/png;base64,${imageBase64}` : ""; + } + + async function setup() { + await PowerPoint.run(async (context) => { + // Adds a new slide with some content. + const slideCountResult = context.presentation.slides.getCount(); + context.presentation.slides.add(); + await context.sync(); + + const newSlide = context.presentation.slides.getItemAt(slideCountResult.value); + newSlide.load("id"); + newSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon); + await context.sync(); + + console.log(`Added slide - ID: ${newSlide.id}`); + + // Switch to the new slide. + context.presentation.setSelectedSlides([newSlide.id]); + await context.sync(); + }); + } + + // 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: |- +
    + This sample demonstrates how to export and import a slide. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + +

    Once a slide has been exported, click the Import slide button to insert into the presentation.

    +

    To add it to a different presentation, open that presentation and select a slide. It will be inserted after the + selected slide.

    +
    +

    Click the following button to capture an image of the current slide and add it to a new slide at the end of the presentation.

    + +
    + 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; + } + + img { + border: 5px solid #555; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + 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 diff --git a/samples/powerpoint/slide-management/get-set-slides.yaml b/samples/powerpoint/slide-management/get-set-slides.yaml new file mode 100644 index 000000000..cbb58a752 --- /dev/null +++ b/samples/powerpoint/slide-management/get-set-slides.yaml @@ -0,0 +1,175 @@ +order: 4 +id: powerpoint-slide-management-get-set-slides +name: Get, set, load, and save slides +description: Get and set one or more selected slides. Load and save one or more slides. +host: POWERPOINT +api_set: + PowerPointApi: '1.5' +script: + content: |- + document.getElementById("getSelectedSlides").addEventListener("click", () => tryCatch(getSelectedSlides)); + document.getElementById("setSelectedSlides").addEventListener("click", () => tryCatch(setSelectedSlides)); + document.getElementById("deleteSlides").addEventListener("click", () => tryCatch(deleteSlides)); + document.getElementById("saveSlideSelection").addEventListener("click", () => tryCatch(saveSlideSelection)); + document.getElementById("loadSlideSelection").addEventListener("click", () => tryCatch(loadSlideSelection)); + + async function getSelectedSlides() { + // Gets the selected slides and displays their IDs on the task pane. + await PowerPoint.run(async (context) => { + let finalTable = ""; + context.presentation.load("slides"); + await context.sync(); + const allSlidesList = {}; + const allSlidesCount = context.presentation.slides.getCount(); + context.presentation.slides.load("items"); + await context.sync(); + let allSlideItems: PowerPoint.Slide[] = context.presentation.slides.items; + allSlideItems.map((slide, index) => { + allSlidesList[slide.id] = `Slide ${index + 1}`; + }); + + const checkbox = document.getElementById("id-check-usenative") as HTMLInputElement; + if (checkbox && checkbox.checked) { + context.presentation.load("tags"); + } + + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + finalTable += "
    getSelectedSlides.getCount returned:" + slideCount.value + "
    "; + finalTable += + "
    "; + slides.items.map((slide, index) => { + finalTable += ""; + }); + finalTable += "
    IndexId
    " + index + " - " + allSlidesList[slide.id] + "" + slide.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); + } + async function deleteSlides() { + // Deletes the selected slides. + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + slides.items.map((slide) => { + slide.delete(); + }); + }); + } + + async function setSelectedSlides() { + // Selects slides 2, 4, and 5. + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); + slide2.load("id"); + slide4.load("id"); + slide5.load("id"); + try { + await context.sync(); + } catch (error) { + console.warn("This action requires at least 5 slides in the presentation."); + return; + } + await context.sync(); + context.presentation.setSelectedSlides([slide2.id, slide4.id, slide5.id]); + await context.sync(); + }); + } + + let savedSlideSelection = []; + async function saveSlideSelection() { + // Saves which slides are currently selected so they can be reselected later. + await PowerPoint.run(async (context) => { + let finalTable = ""; + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + await context.sync(); + finalTable += "
    getSelectedSlides.getCount returned:" + slideCount.value + "
    "; + finalTable += + "
    "; + savedSlideSelection = []; + slides.load("items"); + await context.sync(); + slides.items.map((slide, index) => { + finalTable += ""; + savedSlideSelection.push(slide.id); + }); + finalTable += "
    IndexId
    " + index + "" + slide.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); + } + + async function loadSlideSelection() { + // Sets selection to the slides that were saved. + await PowerPoint.run(async (context) => { + context.presentation.setSelectedSlides(savedSlideSelection); + await context.sync(); + }); + } + + /** 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: |- +
    +

    This sample shows how to get selected slides, and how to select specific slides.

    +
    +
    +

    Try it out

    + +
    +
    +
    +
    + +
    + 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; + } + .content { + padding: 0 18px; + /* display: none; */ + overflow: hidden; + background-color: #f1f1f1; + max-height: 0; + transition: max-height 0.2s ease-out; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/powerpoint/basics/get-slide-metadata.yaml b/samples/powerpoint/slide-management/get-slide-metadata.yaml similarity index 74% rename from samples/powerpoint/basics/get-slide-metadata.yaml rename to samples/powerpoint/slide-management/get-slide-metadata.yaml index c507d2d43..35f71e6be 100644 --- a/samples/powerpoint/basics/get-slide-metadata.yaml +++ b/samples/powerpoint/slide-management/get-slide-metadata.yaml @@ -1,13 +1,13 @@ order: 3 id: powerpoint-basics-get-slide-metadata name: Get slide metadata -description: 'Gets the title, index, and ID of the selected slide(s).' +description: Gets the title, index, and ID of the selected slides. author: OfficeDev host: POWERPOINT api_set: {} script: content: |- - $("#get-slide-metadata").click(getSlideMetadata); + document.getElementById("get-slide-metadata").addEventListener("click", getSlideMetadata); function getSlideMetadata() { Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, @@ -23,11 +23,10 @@ script: language: typescript template: content: |- -
    +

    Demonstrates how to get slide metadata.

    Select one or more slides and click Get slide metadata to get the ID, title, and index of the slide(s).

    - @@ -43,17 +42,11 @@ style: margin-bottom: 5px; margin-left: 20px; min-width: 80px; - } + } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/powerpoint/slide-management/insert-slides.yaml b/samples/powerpoint/slide-management/insert-slides.yaml new file mode 100644 index 000000000..9429814d2 --- /dev/null +++ b/samples/powerpoint/slide-management/insert-slides.yaml @@ -0,0 +1,116 @@ +order: 2 +id: powerpoint-insert-slides +name: Insert slides from other presentation +description: Inserts slides from another PowerPoint file into the current presentation. +host: POWERPOINT +api_set: + PowerPointApi: '1.5' +script: + content: |- + document.getElementById("insert-all-slides").addEventListener("click", () => tryCatch(insertAllSlides)); + document.getElementById("insert-after-target-slide").addEventListener("click", () => tryCatch(insertAfterSelectedSlide)); + document.getElementById("file").addEventListener("change", () => tryCatch(storeFileAsBase64)); + + let chosenFileBase64; + + async function storeFileAsBase64() { + const reader = new FileReader(); + + reader.onload = async (event) => { + // Remove the metadata before the Base64-encoded string. + const startIndex = reader.result.toString().indexOf("base64,"); + const copyBase64 = reader.result.toString().substr(startIndex + 7); + + chosenFileBase64 = copyBase64; + }; + + // Read in the file and store a Base64-encoded copy as the reader.result + // property. This also triggers the onload event. + const myFile = document.getElementById("file") as HTMLInputElement; + reader.readAsDataURL(myFile.files[0]); + } + + async function insertAllSlides() { + await PowerPoint.run(async function(context) { + context.presentation.insertSlidesFromBase64(chosenFileBase64); + await context.sync(); + }); + } + + async function insertAfterSelectedSlide() { + await PowerPoint.run(async function(context) { + // Get the ID of the first selected slide. + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); + selected.load("id"); + await context.sync(); + + // Insert the other presentation after the selected slide. + const insertOptions: PowerPoint.InsertSlideOptions = { + formatting: PowerPoint.InsertSlideFormatting.useDestinationTheme, + targetSlideId: selected.id + }; + presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions); + await context.sync(); + }); + } + + /** 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: |- +
    +

    This sample shows how to insert slides from another presentation into the current presentation.

    +
    +
    +

    Try it out

    +

    +

      +
    1. Open this add-in in a brand new presentation.
    2. +
    3. Add at least 2 slides to the presentation.
    4. +
    5. Next, select a PowerPoint presentation from which to insert slides.
    6. +
    +
    + +
    +

    +

    Press Insert all slides to insert all the slides at the beginning of the + presentation. Source formatting is used.

    + +

    Select a slide and press Insert after selected slide. Destination formatting is used.

    + +

    To undo an insertion, click anywhere on the presentation and press Ctrl+Z.

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/tags/tags.yaml b/samples/powerpoint/tags/tags.yaml new file mode 100644 index 000000000..b2816d55d --- /dev/null +++ b/samples/powerpoint/tags/tags.yaml @@ -0,0 +1,204 @@ +id: powerpoint-tags +name: Work with tags +description: Use tags to process subsets of slides. +host: POWERPOINT +api_set: + PowerPointApi: '1.3' +script: + content: |- + document.getElementById("add-selected-slide-tag").addEventListener("click", () => tryCatch(addTagToSelectedSlide)); + document.getElementById("delete-slides-by-audience").addEventListener("click", () => tryCatch(deleteSlidesByAudience)); + document.getElementById("add-slide-tags").addEventListener("click", () => tryCatch(addMultipleSlideTags)); + document.getElementById("add-shape-tag").addEventListener("click", () => tryCatch(addShapeTag)); + document.getElementById("add-presentation-tag").addEventListener("click", () => tryCatch(addPresentationTag)); + document.getElementById("delete-presentation-tag").addEventListener("click", () => tryCatch(deletePresentationTag)); + + async function addTagToSelectedSlide() { + await PowerPoint.run(async function(context) { + let selectedSlideIndex = await getSelectedSlideIndex(); + + // Decrement because the getSelectedSlideByIndex method is 1-based, + // but the getItemAt method is 0-based. + selectedSlideIndex = selectedSlideIndex - 1; + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); + slide.tags.add("CUSTOMER_TYPE", "Premium"); + + await context.sync(); + + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); + audienceTag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(audienceTag.key) + " with value " + JSON.stringify(audienceTag.value)); + }); + } + + function getSelectedSlideIndex() { + // Wrap a call of one of the Common APIs in a Promise-returning + // function, so that it can be easily called within a run() function + // of an application-specific API. + return new OfficeExtension.Promise(function (resolve, reject) { + Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) { + try { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + reject(console.error(asyncResult.error.message)); + } else { + const result = asyncResult.value as any; + resolve(result.slides[0].index); + } + } catch (error) { + reject(console.log(error)); + } + }); + }); + } + + async function deleteSlidesByAudience() { + await PowerPoint.run(async function(context) { + const slides: PowerPoint.SlideCollection = context.presentation.slides; + slides.load("tags/key, tags/value"); + + await context.sync(); + + for (let i = 0; i < slides.items.length; i++) { + let currentSlide = slides.items[i]; + for (let j = 0; j < currentSlide.tags.items.length; j++) { + let currentTag: PowerPoint.Tag = currentSlide.tags.items[j]; + if (currentTag.key === "CUSTOMER_TYPE" && currentTag.value === "Premium") { + currentSlide.delete(); + } + } + } + + await context.sync(); + }); + } + + async function addMultipleSlideTags() { + await PowerPoint.run(async function(context) { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + slide.tags.add("OCEAN", "Indian"); + slide.tags.add("PLANET", "Jupiter"); + slide.tags.add("CONTINENT", "Antarctica"); + + await context.sync(); + + slide.tags.load("key, value"); + + await context.sync(); + + for (let i = 0; i < slide.tags.items.length; i++) { + console.log("Added key " + JSON.stringify(slide.tags.items[i].key) + " with value " + JSON.stringify(slide.tags.items[i].value)); + } + }); + } + + async function addShapeTag() { + await PowerPoint.run(async function(context) { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); + shape.tags.add("MOUNTAIN", "Denali"); + + await context.sync(); + + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); + myShapeTag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(myShapeTag.key) + " with value " + JSON.stringify(myShapeTag.value)); + }); + } + + async function addPresentationTag() { + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); + } + + async function deletePresentationTag() { + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + + presentationTags.delete("COLOR"); + + await context.sync(); + + console.log(JSON.stringify(presentationTags)); + }); + } + + /** 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: |- +
    +

    These snippets show how to use tags with the presentation and its slides and shapes.

    +
    +

    Try it out

    +

    1. Add several slides to the deck. Add content to each so they are visually distinct in the thumbnail pane.

    +

    2. Select a single slide and press Add tag to tag the slide to be shown only to premium customers.

    + +

    3. Repeat step 2 for another slide.

    +

    4. Press Delete premium customer slides to remove from the presentation slides that should only be shown to premium customers.

    + +

    5. Press Add slide tags to add mulitiple tags to the first slide of the presentation.

    + +

    6. Select the first slide and on the ribbon, navigate Insert > Illustrations > Shapes to add a shape to it. Press Add shape tag.

    + +

    7. Press Add presentation tag.

    + +

    8. Press Delete presentation tag.

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/powerpoint/text/get-set-textrange.yaml b/samples/powerpoint/text/get-set-textrange.yaml new file mode 100644 index 000000000..f18a6beab --- /dev/null +++ b/samples/powerpoint/text/get-set-textrange.yaml @@ -0,0 +1,191 @@ +order: 1 +id: powerpoint-text-get-set-textrange +name: Work with text range selections +description: Get, set, load, and save text range selections. +host: POWERPOINT +api_set: + PowerPointApi: '1.5' +script: + content: |- + document.getElementById("getSelectedTextRange").addEventListener("click", () => tryCatch(getSelectedTextRange)); + document.getElementById("setSelectedTextRange").addEventListener("click", () => tryCatch(setSelectedTextRange)); + document.getElementById("changeColor").addEventListener("click", () => tryCatch(changeColor)); + document.getElementById("saveTextSelection").addEventListener("click", () => tryCatch(saveTextSelection)); + document.getElementById("loadTextSelection").addEventListener("click", () => tryCatch(loadTextSelection)); + + async function getSelectedTextRange() { + // Gets the selected text range and prints data about the range on the task pane. + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + try { + await context.sync(); + } catch (error) { + console.warn("You must select only one range of text for this action to work."); + return; + } + textRange.load("text"); + textRange.load("start"); + textRange.load("length"); + await context.sync(); + let txtHtml = textRange.text; + txtHtml = txtHtml.replace(/\n/g, "
    "); + txtHtml = txtHtml.replace(/\r/g, "
    "); + txtHtml = txtHtml.replace(/\v/g, "
    "); + let txtExplained = textRange.text; + txtExplained = txtExplained.replace(/\n/g, "NL"); + txtExplained = txtExplained.replace(/\r/g, "CR"); + txtExplained = txtExplained.replace(/\v/g, "VV"); + let finalTable = ""; + finalTable += + "
    "; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += "
    IndexId
    Raw" + textRange.text + "
    Html" + txtHtml + "
    Exp" + txtExplained + "
    Start" + textRange.start + "
    Length" + textRange.length + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); + } + + async function setSelectedTextRange() { + // Selects the first 10 characters of the selected shape. + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); + } + + async function changeColor() { + // Sets the color of the selected text range to green. + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + textRange.font.color = "green"; + await context.sync(); + }); + } + + let savedTextSlideSelection = []; + let savedTextShapeSelection = []; + let savedTextTextRangeStart; + let savedTextTextRangeLength; + async function saveTextSelection() { + // Saves the range that is currently selected so it can be reselected later. + await PowerPoint.run(async (context) => { + let finalTable = ""; + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedTextSlideSelection = []; + slides.items.map((slide) => { + savedTextSlideSelection.push(slide.id); + }); + + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + shapes.load("items"); + await context.sync(); + savedTextShapeSelection = []; + shapes.items.map((shape) => { + savedTextShapeSelection.push(shape.id); + }); + const savedTextRange: PowerPoint.TextRange = context.presentation.getSelectedTextRangeOrNullObject(); + savedTextRange.load("start,length"); + await context.sync(); + if (savedTextRange.isNullObject) { + console.warn("You must select only one shape with text in it."); + return; + } + savedTextTextRangeStart = savedTextRange.start; + savedTextTextRangeLength = savedTextRange.length; + }); + } + + async function loadTextSelection() { + // Sets the range selection to the range that was saved previously. + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]); + const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]); + const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + textRange.setSelected(); + await context.sync(); + }); + } + + /** 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: |- +
    +

    This sample shows how to get selected text, and how to select specific text.

    +
    +
    +

    Try it out

    + +
    +
    +
    +
    + +
    + 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; + } + .content { + padding: 0 18px; + /* display: none; */ + overflow: hidden; + background-color: #f1f1f1; + max-height: 0; + transition: max-height 0.2s ease-out; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/project/basics/basic-common-api-call.yaml b/samples/project/basics/basic-common-api-call.yaml index 5e15a37cc..95a440ed7 100644 --- a/samples/project/basics/basic-common-api-call.yaml +++ b/samples/project/basics/basic-common-api-call.yaml @@ -7,8 +7,8 @@ host: PROJECT api_set: Selection: 1.1 script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, (asyncResult) => { @@ -21,24 +21,17 @@ script: } language: typescript template: - content: | + content: |- language: html style: - content: | - /* Your style goes here */ + content: /* Your style goes here */ language: css -libraries: | +libraries: |- https://appsforoffice.microsoft.com/lib/1/hosted/office.js - @types/office-js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - 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 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/project/default.yaml b/samples/project/default.yaml index 4e90aaa56..27aae8d65 100644 --- a/samples/project/default.yaml +++ b/samples/project/default.yaml @@ -5,8 +5,8 @@ author: OfficeDev host: PROJECT api_set: {} script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, (asyncResult) => { @@ -19,7 +19,7 @@ script: } language: typescript template: - content: | + content: |- @@ -37,15 +37,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/web/default.yaml b/samples/web/default.yaml index b8b93782f..dba053526 100644 --- a/samples/web/default.yaml +++ b/samples/web/default.yaml @@ -5,15 +5,15 @@ author: OfficeDev host: WEB api_set: {} script: - content: | - $("#run").click(run); + content: |- + document.getElementById("run").addEventListener("click", run); function run() { console.log("Your code goes here"); } language: typescript template: - content: | + content: |- @@ -31,12 +31,6 @@ style: min-width: 80px; } language: css -libraries: | - 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 \ No newline at end of file +libraries: |- + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/01-basics/basic-api-call-es5.yaml b/samples/word/01-basics/basic-api-call-es5.yaml index c27dbdf75..cf3ab1b5b 100644 --- a/samples/word/01-basics/basic-api-call-es5.yaml +++ b/samples/word/01-basics/basic-api-call-es5.yaml @@ -8,7 +8,7 @@ api_set: WordApi: '1.1' script: content: |- - $("#run").click(() => tryCatch(run)); + document.getElementById("run").addEventListener("click", () => tryCatch(run)); function run() { return Word.run(function (context) { @@ -23,7 +23,7 @@ script: }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. function tryCatch(callback) { Promise.resolve() .then(callback) @@ -35,7 +35,7 @@ script: language: typescript template: content: |- -
    +
    This sample executes a code snippet that prints the selected text to the console. Make sure to enter and select text before clicking "Print selection".
    +
    +
    +

    Try it out

    + Register event handler. + + Insert content controls. + + Remove event handler. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/content-control-ondatachanged-event.yaml b/samples/word/10-content-controls/content-control-ondatachanged-event.yaml new file mode 100644 index 000000000..9ca1c8006 --- /dev/null +++ b/samples/word/10-content-controls/content-control-ondatachanged-event.yaml @@ -0,0 +1,154 @@ +order: 5 +id: word-content-controls-content-control-ondatachanged-event +name: On changing data in content controls +description: Registers, triggers, and deregisters onDataChanged event that tracks when data is changed in content controls. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-content-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + contentControl.tag = "forTesting"; + } + + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function registerEventHandlers() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onDataChanged event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDataChanged.add(contentControlDataChanged); + contentControls.items[i].track(); + } + + await context.sync(); + + console.log("Added event handlers for when data is changed in content controls."); + } + }); + } + + async function contentControlDataChanged(event: Word.ContentControlDataChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where data was changed:`, event.ids); + }); + } + + async function deregisterEventHandlers() { + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers that were tracking when data is changed in content controls."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onDataChanged event on content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + 1. Insert content controls. + + 2. Register event handlers. + +

    3. Within a content control, make a change in the text.

    + 4. Remove event handlers. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/content-control-ondeleted-event.yaml b/samples/word/10-content-controls/content-control-ondeleted-event.yaml new file mode 100644 index 000000000..cdbf945ff --- /dev/null +++ b/samples/word/10-content-controls/content-control-ondeleted-event.yaml @@ -0,0 +1,174 @@ +order: 7 +id: word-content-controls-content-control-ondeleted-event +name: On deleting content controls +description: Registers, triggers, and deregisters onDeleted event that tracks the removal of content controls. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-content-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("delete-content-control").addEventListener("click", () => tryCatch(deleteContentControl)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + contentControl.tag = "forTesting"; + } + + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function registerEventHandlers() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onDeleted event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDeleted.add(contentControlDeleted); + contentControls.items[i].track(); + } + + await context.sync(); + + console.log("Added event handlers for when content controls are deleted."); + } + }); + } + + async function contentControlDeleted(event: Word.ContentControlDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were deleted:`, event.ids); + }); + } + + async function deleteContentControl() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("forTesting"); + contentControls.load("items"); + await context.sync(); + + if (contentControls.items.length === 0) { + console.log("There are no content controls in this document."); + } else { + console.log("Control to be deleted:", contentControls.items[0]); + contentControls.items[0].delete(false); + await context.sync(); + } + }); + } + + async function deregisterEventHandlers() { + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers that were tracking when content controls are deleted."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onDeleted event on content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + Insert content controls. + + Register event handlers. + + Delete first content control. + + Remove event handlers. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/content-control-onentered-event.yaml b/samples/word/10-content-controls/content-control-onentered-event.yaml new file mode 100644 index 000000000..cba1483af --- /dev/null +++ b/samples/word/10-content-controls/content-control-onentered-event.yaml @@ -0,0 +1,154 @@ +order: 3 +id: word-content-controls-content-control-onentered-event +name: On entering content controls +description: Registers, triggers, and deregisters onEntered event that tracks when the cursor is placed within content controls. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-content-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + contentControl.tag = "forTesting"; + } + + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function registerEventHandlers() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onEntered event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onEntered.add(contentControlEntered); + contentControls.items[i].track(); + } + + await context.sync(); + + console.log("Added event handlers for when the cursor is placed in content controls."); + } + }); + } + + async function contentControlEntered(event: Word.ContentControlEnteredEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was entered: ${event.ids[0]}`); + }); + } + + async function deregisterEventHandlers() { + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers that were tracking when the cursor is placed in content controls."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onEntered event on content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + 1. Insert content controls. + + 2. Register event handlers. + +

    3. Place the cursor in a content control.

    + 4. Remove event handlers. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/content-control-onexited-event.yaml b/samples/word/10-content-controls/content-control-onexited-event.yaml new file mode 100644 index 000000000..36950eef7 --- /dev/null +++ b/samples/word/10-content-controls/content-control-onexited-event.yaml @@ -0,0 +1,155 @@ +order: 6 +id: word-content-controls-content-control-onexited-event +name: On exiting content controls +description: Registers, triggers, and deregisters onExited event that tracks when the cursor is removed from within content controls. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-content-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + contentControl.tag = "forTesting"; + } + + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function registerEventHandlers() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onExited event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onExited.add(contentControlExited); + contentControls.items[i].track(); + } + + await context.sync(); + + console.log("Added event handlers for when the cursor is removed from within content controls."); + } + }); + } + + async function contentControlExited(event: Word.ContentControlExitedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was exited: ${event.ids[0]}`); + }); + } + + async function deregisterEventHandlers() { + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers that were tracking when the cursor is removed from within content controls."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onExited event on content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + 1. Insert content controls. + + 2. Register event handlers. + +

    3. Place cursor within a content control.

    +

    4. Place cursor in location outside of that content control.

    + 5. Remove event handlers. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml b/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml new file mode 100644 index 000000000..377dc3061 --- /dev/null +++ b/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml @@ -0,0 +1,153 @@ +order: 4 +id: word-content-controls-content-control-onselectionchanged-event +name: On changing selection in content controls +description: Registers, triggers, and deregisters onSelectionChanged event that tracks when selections are changed in content controls. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-content-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + contentControl.tag = "forTesting"; + } + + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function registerEventHandlers() { + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onSelectionChanged.add(contentControlSelectionChanged); + contentControls.items[i].track(); + } + + await context.sync(); + + console.log("Added event handlers for when selections are changed in content controls."); + } + }); + } + + async function contentControlSelectionChanged(event: Word.ContentControlSelectionChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where selection was changed:`, event.ids); + }); + } + + async function deregisterEventHandlers() { + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers that were tracking when selection is changed in content controls."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onSelectionChanged event on content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + 1. Insert content controls. + + 2. Register event handlers. + +

    3. Select text within a content control.

    + 4. Remove event handlers. + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/get-change-tracking-states.yaml b/samples/word/10-content-controls/get-change-tracking-states.yaml new file mode 100644 index 000000000..6e7804c55 --- /dev/null +++ b/samples/word/10-content-controls/get-change-tracking-states.yaml @@ -0,0 +1,167 @@ +order: 11 +id: word-content-controls-get-change-tracking-states +name: Get change tracking states of content controls +description: Gets change tracking states of content controls. +author: xiruatms +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("turn-on-change-tracking").addEventListener("click", () => tryCatch(turnOnChangeTracking)); + document.getElementById("insert-content-control").addEventListener("click", () => tryCatch(insertContentControlOnLastParagraph)); + document.getElementById("delete-content-control").addEventListener("click", () => tryCatch(deleteFirstContentControl)); + document.getElementById("turn-off-change-tracking").addEventListener("click", () => tryCatch(turnOffChangeTracking)); + document.getElementById("log-change-tracking-states").addEventListener("click", () => tryCatch(logChangeTrackingStates)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function turnOnChangeTracking() { + // Turns on change tracking. + await Word.run(async (context) => { + context.document.changeTrackingMode = Word.ChangeTrackingMode.trackAll; + await context.sync(); + console.log("Turned on change tracking."); + }); + } + + async function insertContentControlOnLastParagraph() { + // Inserts a content control on the last paragraph. + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load(); + paragraphs.getLast().insertContentControl("RichText"); + await context.sync(); + console.log("Inserted content control on last paragraph."); + }); + } + + async function deleteFirstContentControl() { + // Deletes the first content control found in the document body. + await Word.run(async (context) => { + context.document.body + .getContentControls() + .getFirst() + .delete(false); + await context.sync(); + console.log("Deleted the first content control."); + }); + } + + async function turnOffChangeTracking() { + // Turns off change tracking. + await Word.run(async (context) => { + context.document.changeTrackingMode = Word.ChangeTrackingMode.off; + await context.sync(); + console.log("Turned off change tracking."); + }); + } + + async function logChangeTrackingStates() { + // Logs the current change tracking states of the content controls. + await Word.run(async (context) => { + let trackAddedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.added]; + let trackDeletedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.deleted]; + let trackNormalArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.normal]; + + let addedContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackAddedArray); + let deletedContentControls = context.document.body + .getContentControls() + .getByChangeTrackingStates(trackDeletedArray); + let normalContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackNormalArray); + + addedContentControls.load(); + deletedContentControls.load(); + normalContentControls.load(); + await context.sync(); + + console.log(`Number of content controls in Added state: ${addedContentControls.items.length}`); + console.log(`Number of content controls in Deleted state: ${deletedContentControls.items.length}`); + console.log(`Number of content controls in Normal state: ${normalContentControls.items.length}`); + }); + } + + async function setup() { + // Adds 4 paragraphs then inserts content controls on the first three paragraphs. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + body.paragraphs.load(); + await context.sync(); + body.paragraphs.items[0].insertContentControl("PlainText"); + body.paragraphs.items[1].insertContentControl("PlainText"); + body.paragraphs.items[2].insertContentControl("RichText"); + console.log("Inserted content controls on the first three paragraphs."); + }); + } + + // 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: |- +
    + This sample demonstrates how to insert and delete control controls then get their change tracking state. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml b/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml new file mode 100644 index 000000000..de1450052 --- /dev/null +++ b/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml @@ -0,0 +1,240 @@ +order: 8 +id: word-content-controls-insert-and-change-checkbox-content-control +name: Manage checkbox content controls +description: Inserts, updates, retrieves, and deletes checkbox content controls. +host: WORD +api_set: + WordApi: '1.7' +script: + content: |- + document.getElementById("insert-controls").addEventListener("click", () => tryCatch(insertCheckboxContentControls)); + document.getElementById("toggle-control").addEventListener("click", () => tryCatch(toggleCheckboxContentControl)); + document.getElementById("change-controls").addEventListener("click", () => tryCatch(toggleCheckboxContentControls)); + document.getElementById("delete-control").addEventListener("click", () => tryCatch(deleteCheckboxContentControl)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertCheckboxContentControls() { + // Traverses each paragraph of the document and places a checkbox content control at the beginning of each. + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just start each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i] + .getRange(Word.RangeLocation.start) + .insertContentControl(Word.ContentControlType.checkBox); + } + console.log("Checkbox content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function toggleCheckboxContentControl() { + // Toggles the isChecked property of the first checkbox content control found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,checkboxContentControl/isChecked"); + + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,checkboxContentControl/isChecked"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked; + console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`); + selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + selectedContentControl.load("id,checkboxContentControl/isChecked"); + await context.sync(); + + console.log( + "isChecked state after:", + `id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}` + ); + }); + } + + async function toggleCheckboxContentControls() { + // Toggles the isChecked property on all checkbox content controls. + await Word.run(async (context) => { + let contentControls = context.document.getContentControls({ + types: [Word.ContentControlType.checkBox] + }); + contentControls.load("items"); + + await context.sync(); + + const length = contentControls.items.length; + console.log(`Number of checkbox content controls: ${length}`); + + if (length <= 0) { + return; + } + + const checkboxContentControls = []; + for (let i = 0; i < length; i++) { + let contentControl = contentControls.items[i]; + contentControl.load("id,checkboxContentControl/isChecked"); + checkboxContentControls.push(contentControl); + } + + await context.sync(); + + console.log("isChecked state before:"); + const updatedCheckboxContentControls = []; + for (let i = 0; i < checkboxContentControls.length; i++) { + const currentCheckboxContentControl = checkboxContentControls[i]; + const isCheckedBefore = currentCheckboxContentControl.checkboxContentControl.isChecked; + console.log(`id: ${currentCheckboxContentControl.id} ... isChecked: ${isCheckedBefore}`); + + currentCheckboxContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + currentCheckboxContentControl.load("id,checkboxContentControl/isChecked"); + updatedCheckboxContentControls.push(currentCheckboxContentControl); + } + + await context.sync(); + + console.log("isChecked state after:"); + for (let i = 0; i < updatedCheckboxContentControls.length; i++) { + const currentCheckboxContentControl = updatedCheckboxContentControls[i]; + console.log( + `id: ${currentCheckboxContentControl.id} ... isChecked: ${currentCheckboxContentControl.checkboxContentControl.isChecked}` + ); + } + }); + } + + async function deleteCheckboxContentControl() { + // Deletes the first checkbox content control found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id"); + + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + console.log(`About to delete checkbox content control with id: ${selectedContentControl.id}`); + selectedContentControl.delete(false); + await context.sync(); + + console.log("Deleted checkbox content control."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("Task 3", "Start"); + body.insertParagraph("Task 2", "Start"); + body.insertParagraph("Task 1", "Start"); + body.paragraphs.getLast().insertText("Task 4", "Replace"); + }); + } + + // 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. + if (error.code === Word.ErrorCodes.itemNotFound) { + console.warn("No checkbox content control is currently selected."); + } else { + console.error(error); + } + } + } + language: typescript +template: + content: |- +
    + This sample demonstrates how to insert, change, and delete checkbox content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    + Insert checkbox content controls on each paragraph. + +

    +

    + Modify isChecked property of the first checkbox content control found in your selected content. + +

    +

    + Modify isChecked property of all checkbox content controls. + +

    +

    + Delete the first checkbox content control found in your selected content. + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml b/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml new file mode 100644 index 000000000..75d803917 --- /dev/null +++ b/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml @@ -0,0 +1,316 @@ +order: 9 +id: word-content-controls-insert-and-change-combo-box-content-control +name: Manage combo box content controls +description: Inserts, updates, and deletes combo box content controls. +host: WORD +api_set: + WordApi: '1.9' +script: + content: |- + document.getElementById("insert-control").addEventListener("click", () => tryCatch(insertComboBoxContentControl)); + document.getElementById("add-item").addEventListener("click", () => tryCatch(addItemToComboBoxContentControl)); + document.getElementById("get-items").addEventListener("click", () => tryCatch(getListFromComboBoxContentControl)); + document.getElementById("delete-item").addEventListener("click", () => tryCatch(deleteItemFromComboBoxContentControl)); + document.getElementById("delete-list").addEventListener("click", () => tryCatch(deleteListFromComboBoxContentControl)); + document.getElementById("delete-control").addEventListener("click", () => tryCatch(deleteComboBoxContentControl)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertComboBoxContentControl() { + // Places a combo box content control at the end of the selection. + await Word.run(async (context) => { + let selection = context.document.getSelection(); + selection.getRange(Word.RangeLocation.end).insertContentControl(Word.ContentControlType.comboBox); + await context.sync(); + + console.log("Combo box content control inserted at the end of the selection."); + }); + } + + async function addItemToComboBoxContentControl() { + // Adds the provided list item to the first combo box content control in the selection. + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-add") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + selectedContentControl.comboBoxContentControl.addListItem(listItemText); + await context.sync(); + + console.log(`List item added to control with ID ${selectedContentControl.id}: ${listItemText}`); + }); + } + + async function getListFromComboBoxContentControl() { + // Gets the list items from the first combo box content control found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + let selectedComboBox: Word.ComboBoxContentControl = selectedContentControl.comboBoxContentControl; + selectedComboBox.listItems.load("items"); + await context.sync(); + + const currentItems: Word.ContentControlListItemCollection = selectedComboBox.listItems; + console.log(`The list from the combo box content control with ID ${selectedContentControl.id}:`, currentItems); + }); + } + + async function deleteItemFromComboBoxContentControl() { + // Deletes the provided list item from the first combo box content control in the selection. + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + let selectedComboBox: Word.ComboBoxContentControl = selectedContentControl.comboBoxContentControl; + selectedComboBox.listItems.load("items/*"); + await context.sync(); + + let listItems: Word.ContentControlListItemCollection = selectedContentControl.comboBoxContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`); + return; + } + + itemToDelete.delete(); + await context.sync(); + + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); + }); + } + + async function deleteListFromComboBoxContentControl() { + // Deletes the list items from first combo box content control found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + console.log(`About to delete the list from the combo box content control with ID ${selectedContentControl.id}`); + selectedContentControl.comboBoxContentControl.deleteAllListItems(); + await context.sync(); + + console.log("Deleted the list from the combo box content control."); + }); + } + + async function deleteComboBoxContentControl() { + // Deletes the first combo box content control found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + console.log(`About to delete combo box content control with ID ${selectedContentControl.id}`); + selectedContentControl.delete(false); + await context.sync(); + + console.log("Deleted combo box content control."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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. + if (error.code === Word.ErrorCodes.itemNotFound) { + console.warn("No combo box content control is currently selected."); + } else { + console.error(error); + } + } + } + language: typescript +template: + content: |- +
    + This sample demonstrates how to insert, change, and delete combo box content controls. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    + Insert a combo box content control after selected text. + +

    +

    +

    Add a unique list item to the first combo box content control found in your selected + content. +
    + + + +

    +

    + Get all list items from the first combo box content control found in your selected content. + +

    +

    +

    Delete a list item from the first combo box content control found in your selected + content. +
    + + + +

    +

    + Delete all list items from the first combo box content control found in your selected content. + +

    +

    + Delete the first combo box content control found in your selected content. + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/10-content-controls/insert-and-change-content-controls.yaml b/samples/word/10-content-controls/insert-and-change-content-controls.yaml index 11ce1a84e..0221fc952 100644 --- a/samples/word/10-content-controls/insert-and-change-content-controls.yaml +++ b/samples/word/10-content-controls/insert-and-change-content-controls.yaml @@ -1,16 +1,16 @@ order: 1 id: word-content-controls-insert-and-change-content-controls name: Content control basics -description: 'Inserts, updates, and retrieves content controls.' +description: Inserts, updates, and retrieves content controls. author: OfficeDev host: WORD api_set: WordApi: '1.1' script: - content: | - $("#insert-controls").click(() => tryCatch(insertContentControls)); - $("#change-controls").click(() => tryCatch(modifyContentControls)); - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("insert-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("change-controls").addEventListener("click", () => tryCatch(modifyContentControls)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); async function insertContentControls() { // Traverses each paragraph of the document and wraps a content control on each with either a even or odd tags. @@ -38,7 +38,7 @@ script: async function modifyContentControls() { // Adds title and colors to odd and even content controls and changes their appearance. await Word.run(async (context) => { - // Gets the complete sentence (as range) associated with the insertion point. + // Get the complete sentence (as range) associated with the insertion point. let evenContentControls = context.document.contentControls.getByTag("even"); let oddContentControls = context.document.contentControls.getByTag("odd"); evenContentControls.load("length"); @@ -47,17 +47,17 @@ script: await context.sync(); for (let i = 0; i < evenContentControls.items.length; i++) { - // Change a few properties and append a paragraph + // Change a few properties and append a paragraph. evenContentControls.items[i].set({ color: "red", title: "Odd ContentControl #" + (i + 1), - appearance: "Tags" + appearance: Word.ContentControlAppearance.tags }); evenContentControls.items[i].insertParagraph("This is an odd content control", "End"); } for (let j = 0; j < oddContentControls.items.length; j++) { - // Change a few properties and append a paragraph + // Change a few properties and append a paragraph. oddContentControls.items[j].set({ color: "green", title: "Even ContentControl #" + (j + 1), @@ -72,23 +72,24 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph("One more paragraph. ", "Start"); - context.document.body.insertParagraph("Inserting another paragraph. ", "Start"); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. ", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -100,18 +101,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to insert and change content control properties.
    - -
    +

    Set up

    - -
    +

    Try it out

    Insert content controls on each paragraph. +
    +
    +

    Try it out

    +

    + Insert a dropdown list content control after selected text. + +

    +

    +

    Add a unique list item to the first dropdown list content control found in your selected + content. +
    + + + +

    +

    + Get all list items from the first dropdown list content control found in your selected content. + +

    +

    +

    Delete a list item from the first dropdown list content control found in your selected + content. +
    + + + +

    +

    + Delete all list items from the first dropdown list content control found in your selected content. + +

    +

    + Delete the first dropdown list content control found in your selected content. + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/15-images/insert-and-get-pictures.yaml b/samples/word/15-images/insert-and-get-pictures.yaml index f2d2e0490..1857f2392 100644 --- a/samples/word/15-images/insert-and-get-pictures.yaml +++ b/samples/word/15-images/insert-and-get-pictures.yaml @@ -2,20 +2,17 @@ order: 1 id: word-images-insert-and-get-pictures name: Use inline pictures description: Inserts and gets inline pictures. -author: OfficeDev host: WORD api_set: - WordApi: '1.1' + WordApiDesktop: '1.1' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#insert").click(() => tryCatch(insertImage)); - $("#get").click(() => tryCatch(getImage)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("insert").addEventListener("click", () => tryCatch(insertImage)); + document.getElementById("get").addEventListener("click", () => tryCatch(getImage)); - /** - * Inserts an image anchored to the last paragraph. - */ async function insertImage() { + // Inserts an image anchored to the last paragraph. await Word.run(async (context) => { context.document.body.paragraphs .getLast() @@ -26,17 +23,15 @@ script: }); } - /** - * Get the first image in the document. - */ async function getImage() { + // Gets the first image in the document. await Word.run(async (context) => { - const firstPicture = context.document.body.inlinePictures.getFirst(); - firstPicture.load("width, height"); + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); await context.sync(); - console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`); - // Get the image encoded as base64. + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. const base64 = firstPicture.getBase64ImageSrc(); await context.sync(); @@ -44,26 +39,25 @@ script: }); } - /** - * Setup by adding a dummy paragraph. - */ async function setup() { + // Sets up by adding a dummy paragraph. await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document. ", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "End" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching Online cover page, header, and sidebar. Click Insert and then choose the elements you want from the different Online galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "End" ); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -78,18 +72,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to insert and get inline pictures in a document.
    - -
    +

    Set up

    - -
    +

    Try it out

    - -
    -

    Try it out

    -
    @@ -104,13 +107,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/20-lists/manage-list-styles.yaml b/samples/word/20-lists/manage-list-styles.yaml new file mode 100644 index 000000000..b382c43d4 --- /dev/null +++ b/samples/word/20-lists/manage-list-styles.yaml @@ -0,0 +1,110 @@ +order: 2 +id: word-lists-manage-styles +name: Get list styles +description: This sample shows how to get the list styles in the current document. +author: xiruatms +host: WORD +api_set: + WordApiDesktop: '1.1' +script: + content: |- + document.getElementById("count").addEventListener("click", () => tryCatch(getCount)); + document.getElementById("properties").addEventListener("click", () => tryCatch(getProperties)); + + async function getCount() { + // Gets the available list styles stored with the document. + await Word.run(async (context) => { + const styles: Word.StyleCollection = context.document.getStyles(); + const count = styles.getCount(); + + // Load object to log properties and their values in the console. + styles.load(); + await context.sync(); + + for (let i = 0; i <= count.value; i++) { + if (styles.items[i] && styles.items[i].type == "List") { + console.log(`List style name: ${styles.items[i].nameLocal}`, styles.items[i]); + } + } + }); + } + + async function getProperties() { + // Gets the properties of the specified style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); + } else { + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); + } + }); + } + + // 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: |- +
    + This sample shows how to get the list styles in the current document. +
    +
    +

    Try it out

    +

    + +

    + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/20-lists/organize-list.yaml b/samples/word/20-lists/organize-list.yaml new file mode 100644 index 000000000..9733c5a65 --- /dev/null +++ b/samples/word/20-lists/organize-list.yaml @@ -0,0 +1,141 @@ +order: 2 +id: word-lists-organize-list +name: Organize a list +description: Shows how to create and organize a list. +author: OfficeDev +host: WORD +api_set: + WordApi: '1.3' +script: + content: |- + document.getElementById("insert-list").addEventListener("click", () => tryCatch(insertOrganizeList)); + document.getElementById("get-list-props").addEventListener("click", () => tryCatch(getListProps)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertOrganizeList() { + // Inserts a list starting with the first paragraph then set numbering and bullet types of the list items. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Use the first paragraph to start a new list. + const list: Word.List = paragraphs.items[0].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set numbering for list level 1. + list.setLevelNumbering(0, Word.ListNumbering.arabic); + + // Set bullet type for list level 5. + list.setLevelBullet(4, Word.ListBullet.arrow); + + // Set list level for the last item in this list. + paragraph.listItem.level = 4; + + list.load("levelTypes"); + + await context.sync(); + }); + } + + async function getListProps() { + // Gets information about the first list in the document. + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); + + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; + } + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); + + await context.sync(); + + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); + } + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Create a list then customize the numbering and bullets. You can also organize the list items into multiple levels and change the style, alignment, etc.", + "Start" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to create and organize a list. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml b/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml index e5aa023ca..ad67db11b 100644 --- a/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml +++ b/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml @@ -7,15 +7,15 @@ host: WORD api_set: WordApi: '1.1' script: - content: | - $("#get-paragraph").click(() => tryCatch(getParagraph)); - $("#get-sentences").click(() => tryCatch(getSentences)); - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("get-paragraph").addEventListener("click", () => tryCatch(getParagraph)); + document.getElementById("get-sentences").addEventListener("click", () => tryCatch(getSentences)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); async function getParagraph() { await Word.run(async (context) => { // The collection of paragraphs of the current selection returns the full paragraphs contained in it. - let paragraph = context.document.getSelection().paragraphs.getFirst(); + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); paragraph.load("text"); await context.sync(); @@ -25,21 +25,21 @@ script: async function getSentences() { await Word.run(async (context) => { - // Gets the complete sentence (as range) associated with the insertion point. - let sentences = context.document + // Get the complete sentence (as range) associated with the insertion point. + const sentences: Word.RangeCollection = context.document .getSelection() .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); sentences.load("$none"); await context.sync(); - // Expands the range to the end of the paragraph to get all the complete sentences. - let sentencesToTheEndOfParagraph = sentences.items[0] + // Expand the range to the end of the paragraph to get all the complete sentences. + const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0] .getRange() .expandTo( context.document .getSelection() .paragraphs.getFirst() - .getRange("End") + .getRange(Word.RangeLocation.end) ) .getTextRanges(["."], false /* Don't trim spaces*/); sentencesToTheEndOfParagraph.load("text"); @@ -53,21 +53,22 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -79,18 +80,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to get the paragraph and paragraph sentences associated with the current insertion point.
    - -
    +

    Set up

    - -
    +

    Try it out

    Select an insertion point in the document.

    +

    +
    +

    Try it out

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/25-paragraph/get-word-count.yaml b/samples/word/25-paragraph/get-word-count.yaml index 23affcac2..95ea7e97d 100644 --- a/samples/word/25-paragraph/get-word-count.yaml +++ b/samples/word/25-paragraph/get-word-count.yaml @@ -7,16 +7,18 @@ host: WORD api_set: WordApi: '1.1' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#count").click(() => tryCatch(run)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("count").addEventListener("click", () => tryCatch(run)); async function run() { + // Counts how many times each term appears in the document. await Word.run(async (context) => { - let paragraphs = context.document.body.paragraphs; + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; paragraphs.load("text"); await context.sync(); + // Split up the document text using existing spaces as the delimiter. let text = []; paragraphs.items.forEach((item) => { let paragraph = item.text.trim(); @@ -30,6 +32,7 @@ script: } }); + // Determine the list of unique terms. let makeTextDistinct = new Set(text); let distinctText = Array.from(makeTextDistinct); let allSearchResults = []; @@ -38,7 +41,7 @@ script: let results = context.document.body.search(distinctText[i], { matchCase: true, matchWholeWord: true }); results.load("text"); - // Map search term with its results. + // Map each search term with its results. let correlatedResults = { searchTerm: distinctText[i], hits: results @@ -49,7 +52,7 @@ script: await context.sync(); - // Display counts. + // Display the count for each search term. allSearchResults.forEach((result) => { let length = result.hits.items.length; @@ -60,19 +63,20 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.insertParagraph( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.", + body.insertParagraph( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "End" ); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -84,18 +88,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to get the count for words and terms in the document body.
    - -
    +

    Set up

    - -
    +

    Try it out

    Get the word/term count.

    @@ -118,15 +120,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/25-paragraph/insert-formatted-text.yaml b/samples/word/25-paragraph/insert-formatted-text.yaml index 889aa2965..073882a0e 100644 --- a/samples/word/25-paragraph/insert-formatted-text.yaml +++ b/samples/word/25-paragraph/insert-formatted-text.yaml @@ -8,16 +8,16 @@ api_set: WordApi: '1.1' script: content: |- - $("#add-text").click(() => tryCatch(addFormattedText)); - $("#add-paragraph").click(() => tryCatch(addFormattedParagraph)); - $("#add-preset").click(() => tryCatch(addPreStyledFormattedText)); + document.getElementById("add-text").addEventListener("click", () => tryCatch(addFormattedText)); + document.getElementById("add-paragraph").addEventListener("click", () => tryCatch(addFormattedParagraph)); + document.getElementById("add-preset").addEventListener("click", () => tryCatch(addPreStyledFormattedText)); async function addFormattedText() { await Word.run(async (context) => { // Insert the sentence, then adjust the formatting. // Note that replace affects the calling object, in this case the entire document body. // A similar method can also be used at the range level. - let sentence = context.document.body.insertText( + const sentence: Word.Range = context.document.body.insertText( "This is some formatted text!", "Replace" ); @@ -34,7 +34,7 @@ script: async function addFormattedParagraph() { await Word.run(async (context) => { // Second sentence, let's insert it as a paragraph after the previously inserted one. - let secondSentence = context.document.body.insertParagraph( + const secondSentence: Word.Paragraph = context.document.body.insertParagraph( "This is the first text with a custom style.", "End" ); @@ -52,19 +52,19 @@ script: async function addPreStyledFormattedText() { await Word.run(async (context) => { - let sentence = context.document.body.insertParagraph( + const sentence: Word.Paragraph = context.document.body.insertParagraph( "To be or not to be", "End" ); // Use styleBuiltIn to use an enumeration of existing styles. If your style is custom make sure to use: range.style = "name of your style"; - sentence.styleBuiltIn = Word.Style.intenseReference; + sentence.styleBuiltIn = Word.BuiltInStyleName.intenseReference; await context.sync(); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -76,11 +76,10 @@ script: language: typescript template: content: |- -

    +
    This sample shows how to insert basic formatted text and apply built-in styles.
    - -
    +

    Try it out

    +

    2. Open the Header & Footer ribbon (refer to Edit your + existing headers and footers for details). +

    +

    Try it out

    +

    Apply to all pages

    + +
    To see the "Primary" header/footer in the document, turn off the Different First Page and + Different Odd & Even Pages options in the + Header & Footer ribbon.
    +

    Apply to the first page

    + + + +
    To see the "FirstPage" header/footer in the document, turn on the Different First Page option in the Header & Footer ribbon then scroll to the first page.
    +

    Apply to all even pages

    + + +
    To see the "EvenPages" header/footer in the document, turn on the Different Odd & Even Pages option in the Header & Footer ribbon then scroll to an even-numbered page.
    language: html style: @@ -69,13 +184,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/25-paragraph/insert-in-different-locations.yaml b/samples/word/25-paragraph/insert-in-different-locations.yaml index 144f50bc3..ad6572d46 100644 --- a/samples/word/25-paragraph/insert-in-different-locations.yaml +++ b/samples/word/25-paragraph/insert-in-different-locations.yaml @@ -7,18 +7,18 @@ host: WORD api_set: WordApi: '1.2' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#before").click(() => tryCatch(before)); - $("#start").click(() => tryCatch(start)); - $("#end").click(() => tryCatch(end)); - $("#after").click(() => tryCatch(after)); - $("#replace").click(() => tryCatch(replace)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("before").addEventListener("click", () => tryCatch(before)); + document.getElementById("start").addEventListener("click", () => tryCatch(start)); + document.getElementById("end").addEventListener("click", () => tryCatch(end)); + document.getElementById("after").addEventListener("click", () => tryCatch(after)); + document.getElementById("replace").addEventListener("click", () => tryCatch(replace)); async function before() { await Word.run(async (context) => { // Let's insert before the first paragraph. - let range = context.document.body.paragraphs.getFirst().insertParagraph("This is Before", "Before"); + const range: Word.Paragraph = context.document.body.paragraphs.getFirst().insertParagraph("This is Before", "Before"); range.font.highlightColor = "yellow"; await context.sync(); @@ -29,7 +29,7 @@ script: await Word.run(async (context) => { // This button assumes before() ran. // Get the next paragraph and insert text at the beginning. Note that there are invalid locations depending on the object. For instance, insertParagraph and "before" on a paragraph object is not a valid combination. - let range = context.document.body.paragraphs + const range: Word.Range = context.document.body.paragraphs .getFirst() .getNext() .insertText("This is Start", "Start"); @@ -43,7 +43,7 @@ script: async function end() { await Word.run(async (context) => { // Insert text at the end of a paragraph. - let range = context.document.body.paragraphs + const range: Word.Range = context.document.body.paragraphs .getFirst() .getNext() .insertText(" This is End", "End"); @@ -57,7 +57,7 @@ script: async function after() { await Word.run(async (context) => { // Insert a paragraph after an existing one. - let range = context.document.body.paragraphs + const range: Word.Paragraph = context.document.body.paragraphs .getFirst() .getNext() .insertParagraph("This is After", "After"); @@ -71,7 +71,7 @@ script: async function replace() { await Word.run(async (context) => { // Replace the last paragraph. - let range = context.document.body.paragraphs.getLast().insertText("Just replaced the last paragraph!", "Replace"); + const range: Word.Range = context.document.body.paragraphs.getLast().insertText("Just replaced the last paragraph!", "Replace"); range.font.highlightColor = "black"; range.font.color = "white"; @@ -81,15 +81,16 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); }); @@ -106,18 +107,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates a variety of insert locations available in the API.
    - -
    +

    Set up

    - -
    +

    Try it out

    - -
    +

    Try it out

    + +

    From the console, copy a paragraph ID and paste it into the following field.
    + + + +

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/25-paragraph/onchanged-event.yaml b/samples/word/25-paragraph/onchanged-event.yaml new file mode 100644 index 000000000..1653214ae --- /dev/null +++ b/samples/word/25-paragraph/onchanged-event.yaml @@ -0,0 +1,121 @@ +order: 11 +id: word-paragraph-onchanged-event +name: On changing content in paragraphs +description: Registers, triggers, and deregisters the onParagraphChanged event that tracks when content is changed in paragraphs. +host: WORD +api_set: + WordApi: '1.6' +script: + content: |- + document.getElementById("register-event-handler").addEventListener("click", () => tryCatch(registerEventHandler)); + document.getElementById("get-paragraph-by-id").addEventListener("click", () => tryCatch(getParagraphById)); + document.getElementById("deregister-event-handler").addEventListener("click", () => tryCatch(deregisterEventHandler)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContext; + + async function registerEventHandler() { + // Registers the onParagraphChanged event handler on the document. + await Word.run(async (context) => { + eventContext = context.document.onParagraphChanged.add(paragraphChanged); + await context.sync(); + + console.log("Added event handler for when content is changed in paragraphs."); + }); + } + + async function paragraphChanged(event: Word.ParagraphChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs where content was changed:`, event.uniqueLocalIds); + }); + } + + async function getParagraphById() { + await Word.run(async (context) => { + const paragraphId = (document.getElementById("paragraph-id") as HTMLInputElement).value; + const paragraph: Word.Paragraph = context.document.getParagraphByUniqueLocalId(paragraphId); + paragraph.load(); + await paragraph.context.sync(); + + console.log(paragraph); + }); + } + + async function deregisterEventHandler() { + await Word.run(eventContext.context, async (context) => { + eventContext.remove(); + await context.sync(); + }); + + eventContext = null; + console.log("Removed event handler that was tracking content changes in paragraphs."); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("Paragraph 1", "End"); + body.insertParagraph("Paragraph 2", "End"); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onChanged event with paragraphs. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + +

    +

    Within a paragraph, make a change in the text. Then, from the console, copy the paragraph + ID where content was changed and paste into the following field.
    + + + +

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/25-paragraph/ondeleted-event.yaml b/samples/word/25-paragraph/ondeleted-event.yaml new file mode 100644 index 000000000..248a6de4c --- /dev/null +++ b/samples/word/25-paragraph/ondeleted-event.yaml @@ -0,0 +1,121 @@ +order: 12 +id: word-paragraph-ondeleted-event +name: On deleting paragraphs +description: Registers, triggers, and deregisters the onParagraphDeleted event that tracks the removal of paragraphs. +host: WORD +api_set: + WordApi: '1.6' +script: + content: |- + document.getElementById("register-event-handler").addEventListener("click", () => tryCatch(registerEventHandler)); + document.getElementById("delete-paragraph").addEventListener("click", () => tryCatch(deleteParagraph)); + document.getElementById("deregister-event-handler").addEventListener("click", () => tryCatch(deregisterEventHandler)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContext; + + async function registerEventHandler() { + // Registers the onParagraphDeleted event handler on the document. + await Word.run(async (context) => { + eventContext = context.document.onParagraphDeleted.add(paragraphDeleted); + await context.sync(); + + console.log("Added event handlers for when paragraphs are deleted."); + }); + } + + async function paragraphDeleted(event: Word.ParagraphDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs that were deleted:`, event.uniqueLocalIds); + }); + } + + async function deleteParagraph() { + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("items"); + await context.sync(); + + if (paragraphs.items.length == 0) { + console.log("There are no paragraphs in this document."); + } else { + console.log("Paragraph to be deleted:", paragraphs.items[0]); + paragraphs.items[0].delete(); + await context.sync(); + } + }); + } + + async function deregisterEventHandler() { + await Word.run(eventContext.context, async (context) => { + eventContext.remove(); + await context.sync(); + }); + + eventContext = null; + console.log("Removed event handler that was tracking when paragraphs are deleted."); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("Paragraph 1", "End"); + body.insertParagraph("Paragraph 2", "End"); + body.insertParagraph("Paragraph 3", "End"); + }); + } + + // 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: |- +
    + This sample demonstrates how to use the onDeleted event with paragraphs. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/25-paragraph/paragraph-properties.yaml b/samples/word/25-paragraph/paragraph-properties.yaml index 525b97c2d..b0cb4b0af 100644 --- a/samples/word/25-paragraph/paragraph-properties.yaml +++ b/samples/word/25-paragraph/paragraph-properties.yaml @@ -1,22 +1,24 @@ order: 6 id: word-paragraph-paragraph-properties name: Paragraph properties -description: 'Sets indentation, space between paragraphs, and other paragraph properties.' +description: Sets indentation, space between paragraphs, and other paragraph properties. author: OfficeDev host: WORD api_set: - WordApi: '1.2' + WordApi: '1.1' script: - content: | - $("#indent").click(() => tryCatch(indent)); - $("#spacing").click(() => tryCatch(spacing)); - $("#space-after").click(() => tryCatch(spaceAfter)); - $("#align").click(() => tryCatch(align)); - $("#setup").click(() => tryCatch(setup)); + content: |- + document.getElementById("indent").addEventListener("click", () => tryCatch(indent)); + document.getElementById("spacing").addEventListener("click", () => tryCatch(spacing)); + document.getElementById("space-after").addEventListener("click", () => tryCatch(spaceAfter)); + document.getElementById("line-unit-spacing-after").addEventListener("click", () => tryCatch(spaceAfterInLines)); + document.getElementById("line-unit-spacing-before").addEventListener("click", () => tryCatch(spaceBeforeInLines)); + document.getElementById("align").addEventListener("click", () => tryCatch(align)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); async function indent() { await Word.run(async (context) => { - // Indents the first paragraph. + // Indent the first paragraph. context.document.body.paragraphs.getFirst().leftIndent = 75; //units = points return context.sync(); @@ -25,7 +27,7 @@ script: async function spacing() { await Word.run(async (context) => { - // Adjusts line spacing. + // Adjust line spacing. context.document.body.paragraphs.getFirst().lineSpacing = 20; await context.sync(); @@ -34,16 +36,34 @@ script: async function spaceAfter() { await Word.run(async (context) => { - // Adjust space between paragraphs. + // Set the space (in points) after the first paragraph. context.document.body.paragraphs.getFirst().spaceAfter = 20; await context.sync(); }); } + async function spaceAfterInLines() { + await Word.run(async (context) => { + // Set the space (in line units) after the first paragraph. + context.document.body.paragraphs.getFirst().lineUnitAfter = 1; + + await context.sync(); + }); + } + + async function spaceBeforeInLines() { + await Word.run(async (context) => { + // Set the space (in line units) before the first paragraph. + context.document.body.paragraphs.getFirst().lineUnitBefore = 1; + + await context.sync(); + }); + } + async function align() { await Word.run(async (context) => { - // Centers last paragraph alignment. + // Center last paragraph alignment. context.document.body.paragraphs.getLast().alignment = "Centered"; await context.sync(); @@ -52,23 +72,24 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); - context.document.body.paragraphs.getFirst().alignment = "Left"; - context.document.body.paragraphs.getLast().alignment = "Left"; + body.paragraphs.getFirst().alignment = "Left"; + body.paragraphs.getLast().alignment = Word.Alignment.left; }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -80,18 +101,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates paragraph property usage.
    - -
    +

    Set up

    - -
    +

    Try it out

    + +

    + +

    @@ -122,13 +149,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/25-paragraph/search.yaml b/samples/word/25-paragraph/search.yaml index f6d37bc1d..0dc258279 100644 --- a/samples/word/25-paragraph/search.yaml +++ b/samples/word/25-paragraph/search.yaml @@ -7,19 +7,20 @@ host: WORD api_set: WordApi: '1.1' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#basic-search").click(() => tryCatch(basicSearch)); - $("#wildcard-search").click(() => tryCatch(wildcardSearch)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("basic-search").addEventListener("click", () => tryCatch(basicSearch)); + document.getElementById("wildcard-search").addEventListener("click", () => tryCatch(wildcardSearch)); async function basicSearch() { + // Does a basic text search and highlights matches in the document. await Word.run(async (context) => { - let results = context.document.body.search("Online"); + const results : Word.RangeCollection = context.document.body.search("extend"); results.load("length"); await context.sync(); - // Let's traverse the search results... and highlight... + // Let's traverse the search results and highlight matches. for (let i = 0; i < results.items.length; i++) { results.items[i].font.highlightColor = "yellow"; } @@ -29,15 +30,15 @@ script: } async function wildcardSearch() { + // Does a wildcard search and highlights matches in the document. await Word.run(async (context) => { - // Check out how wildcard expression are built, also use the second parameter of the search method to include search modes - // (i.e. use wildcards). - let results = context.document.body.search("$*.[0-9][0-9]", { matchWildcards: true }); + // Construct a wildcard expression and set matchWildcards to true in order to use wildcards. + const results : Word.RangeCollection = context.document.body.search("$*.[0-9][0-9]", { matchWildcards: true }); results.load("length"); await context.sync(); - // Let's traverse the search results... and highlight... + // Let's traverse the search results and highlight matches. for (let i = 0; i < results.items.length; i++) { results.items[i].font.highlightColor = "red"; results.items[i].font.color = "white"; @@ -49,15 +50,16 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video ($10,000.00), you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching Online cover page, header, and sidebar. Click Insert and then choose the Online elements you want from the different Online galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); @@ -76,18 +78,16 @@ script: language: typescript template: content: |- -

    +
    This sample demonstrates basic and advanced search capabilities of the API.
    - -
    +

    Set up

    - -
    +

    Try it out

    +
    +
    +

    Try it out

    +

    Compare location of first paragraph with location of second paragraph

    + +

    Compare location of second paragraph with cursor's location

    +

    +

    Move cursor or select text in the document.
    + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/35-ranges/get-pages.yaml b/samples/word/35-ranges/get-pages.yaml new file mode 100644 index 000000000..15f5ca0e4 --- /dev/null +++ b/samples/word/35-ranges/get-pages.yaml @@ -0,0 +1,288 @@ +order: 4 +id: word-ranges-get-pages +name: Work with pages, panes, and windows +description: Shows how to work with pages, panes, and windows. +author: yilin4 +host: WORD +api_set: + WordApiDesktop: '1.2' +script: + content: | + document.getElementById("get-pages-selected-range").addEventListener("click", () => tryCatch(getPagesOfSelectedRange)); + document + .getElementById("get-pages-third-paragraph") + .addEventListener("click", () => tryCatch(getPagesOfThirdParagraph)); + document + .getElementById("get-pages-enclosing-viewport") + .addEventListener("click", () => tryCatch(getPagesEnclosingViewport)); + document.getElementById("get-all-pages").addEventListener("click", () => tryCatch(getAllPages)); + document.getElementById("get-all-panes").addEventListener("click", () => tryCatch(getAllPanes)); + document.getElementById("get-all-windows").addEventListener("click", () => tryCatch(getAllWindows)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function getPagesOfSelectedRange() { + await Word.run(async (context) => { + // Gets pages of the selection. + const pages: Word.PageCollection = context.document.getSelection().pages; + pages.load(); + await context.sync(); + + // Log info for pages included in selection. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index info for page ${i + 1} in the selection: ${pagesIndexes[i].index}`); + console.log("Text of that page in the selection:", pagesText[i].text); + } + }); + } + + async function getPagesOfThirdParagraph() { + await Word.run(async (context) => { + // Gets the pages that contain the third paragraph. + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load(); + await context.sync(); + + const paraThree = paragraphs.items[2]; + const rangeOfParagraph = paraThree.getRange(); + const pages: Word.PageCollection = rangeOfParagraph.pages; + pages.load(); + await context.sync(); + + // Log info for pages in range. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index of page ${i + 1} that contains the third paragraph: ${pagesIndexes[i].index}`); + console.log("Text of that page:", pagesText[i].text); + } + }); + } + + async function getPagesEnclosingViewport() { + await Word.run(async (context) => { + // Gets the pages enclosing the viewport. + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get pages enclosing the viewport. + const pages: Word.PageCollection = activePane.pagesEnclosingViewport; + pages.load(); + + await context.sync(); + + // Log the number of pages. + const pageCount = pages.items.length; + console.log(`Number of pages enclosing the viewport: ${pageCount}`); + + // Log index info of these pages. + const pagesIndexes = []; + for (let i = 0; i < pageCount; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + } + }); + } + + async function getAllPages() { + await Word.run(async (context) => { + // Gets the first paragraph of each page. + console.log("Getting first paragraph of each page..."); + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get all pages. + const pages: Word.PageCollection = activePane.pages; + pages.load(); + + await context.sync(); + + // Get page index and paragraphs of each page. + const pagesIndexes = []; + const pagesNumberOfParagraphs = []; + const pagesFirstParagraphText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const paragraphs = page.getRange().paragraphs; + paragraphs.load("items/length"); + pagesNumberOfParagraphs.push(paragraphs); + + const firstParagraph = paragraphs.getFirst(); + firstParagraph.load("text"); + pagesFirstParagraphText.push(firstParagraph); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + console.log(`Number of paragraphs: ${pagesNumberOfParagraphs[i].items.length}`); + console.log("First paragraph's text:", pagesFirstParagraphText[i].text); + } + }); + } + + async function getAllPanes() { + await Word.run(async (context) => { + // Gets all the panes in the active document window. + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load("panes/items/length"); + + await context.sync(); + + const panes: Word.PaneCollection = activeWindow.panes; + console.log(`Number of panes in the current document window: ${panes.items.length}`); + }); + } + + async function getAllWindows() { + await Word.run(async (context) => { + // Gets the document windows. + const windows: Word.WindowCollection = context.document.windows; + windows.load("windows/items/length"); + + await context.sync(); + + console.log(`Number of windows for this document: ${windows.items.length}`); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertBreak(Word.BreakType.page, Word.InsertLocation.end); + body.insertParagraph( + "Themes and styles also help keep your document coordinated. When you click design and choose a new Theme, the pictures, charts, and SmartArt graphics change to match your new theme. When you apply styles, your headings change to match the new theme.", + "End" + ); + body.insertText( + "Save time in Word with new buttons that show up where you need them. To change the way a picture fits in your document, click it and a button for layout options appears next to it. When you work on a table, click where you want to add a row or a column, and then click the plus sign.", + "Start" + ); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to work with pages, panes, and windows. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/35-ranges/scroll-to-range.yaml b/samples/word/35-ranges/scroll-to-range.yaml index d91ac37ed..b7fd13481 100644 --- a/samples/word/35-ranges/scroll-to-range.yaml +++ b/samples/word/35-ranges/scroll-to-range.yaml @@ -7,10 +7,10 @@ host: WORD api_set: WordApi: '1.2' script: - content: | - $("#setup").click(() => tryCatch(setup)); - $("#scroll").click(() => tryCatch(scroll)); - $("#scroll-end").click(() => tryCatch(scrollEnd)); + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("scroll").addEventListener("click", () => tryCatch(scroll)); + document.getElementById("scroll-end").addEventListener("click", () => tryCatch(scrollEnd)); async function scroll() { await Word.run(async (context) => { @@ -24,7 +24,7 @@ script: async function scrollEnd() { await Word.run(async (context) => { // Select can be at the start or end of a range; this by definition moves the insertion point without selecting the range. - context.document.body.paragraphs.getLast().select("End"); + context.document.body.paragraphs.getLast().select(Word.SelectionMode.end); await context.sync(); }); @@ -32,22 +32,23 @@ script: async function setup() { await Word.run(async (context) => { - context.document.body.clear(); - let firstSentence = context.document.body.insertParagraph( - "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.", + const body: Word.Body = context.document.body; + body.clear(); + const firstSentence: Word.Paragraph = body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", "Start" ); firstSentence.insertBreak(Word.BreakType.page, "After"); - context.document.body.paragraphs + body.paragraphs .getLast() .insertText( - "To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching Online cover page, header, and sidebar. Click Insert and then choose the Online elements you want from the different Online galleries.", + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", "Replace" ); }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -59,18 +60,16 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to scroll to a range.
    - -
    +

    Set up

    - -
    +

    Try it out

    - -
    +

    Try it out

    +

    Use custom style

    + + +

    + +

    + +

    +
    +

    Update custom style

    + +
    Note: Mixed and Unknown aren't valid when setting.
    + +
    +
    + + +
    + +
    +
    + + +
    + +
    +
    + + +
    + +
    +
    + + +
    + +
    +
    + + +
    + +
    +
    + + +
    + +
    +
    +

    Delete custom style

    + + +
    + +
    +
    +

    Import styles from JSON string

    + +
    + 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; + } + + .margin { + margin-top: 5px; + margin-bottom: 5px; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/40-tables/manage-formatting.yaml b/samples/word/40-tables/manage-formatting.yaml new file mode 100644 index 000000000..9929afcd4 --- /dev/null +++ b/samples/word/40-tables/manage-formatting.yaml @@ -0,0 +1,238 @@ +order: 2 +id: word-tables-manage-formatting +name: Table formatting +description: Gets the formatting details of a table, a table row, and a table cell, including borders, alignment, and cell padding. +author: OfficeDev +host: WORD +api_set: + WordApi: '1.3' +script: + content: |- + document.getElementById("get-table-alignment").addEventListener("click", () => tryCatch(getTableAlignment)); + document.getElementById("get-table-border").addEventListener("click", () => tryCatch(getTableBorder)); + document.getElementById("get-table-cell-padding").addEventListener("click", () => tryCatch(getTableCellPadding)); + document.getElementById("get-table-row-alignment").addEventListener("click", () => tryCatch(getTableRowAlignment)); + document.getElementById("get-table-row-border").addEventListener("click", () => tryCatch(getTableRowBorder)); + document.getElementById("get-table-row-cell-padding").addEventListener("click", () => tryCatch(getTableRowCellPadding)); + document.getElementById("get-table-cell-alignment").addEventListener("click", () => tryCatch(getTableCellAlignment)); + document.getElementById("get-table-cell-border").addEventListener("click", () => tryCatch(getTableCellBorder)); + document.getElementById("get-table-cell-cell-padding").addEventListener("click", () => tryCatch(getTableCellCellPadding)); + document.getElementById("setup").addEventListener("click", () => tryCatch(insertTable)); + + async function getTableAlignment() { + // Gets alignment details about the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table:`, `- Alignment of the table within the containing page column: ${firstTable.alignment}`, `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`, `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`); + }); + } + + async function getTableBorder() { + // Gets border details about the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); + } + + async function getTableCellPadding() { + // Gets cell padding details about the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const cellPaddingLocation = Word.CellPaddingLocation.right; + const cellPadding = firstTable.getCellPadding(cellPaddingLocation); + await context.sync(); + + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table: ${cellPadding.value} points` + ); + }); + } + + async function getTableRowAlignment() { + // Gets content alignment details about the first row of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + firstTableRow.load(["horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table's first row:`, `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`, `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`); + }); + } + + async function getTableRowBorder() { + // Gets border details about the first row of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const borderLocation = Word.BorderLocation.bottom; + const border: Word.TableBorder = firstTableRow.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table's first row:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); + } + + async function getTableRowCellPadding() { + // Gets cell padding details about the first row of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const cellPaddingLocation = Word.CellPaddingLocation.bottom; + const cellPadding = firstTableRow.getCellPadding(cellPaddingLocation); + await context.sync(); + + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table's first row: ${cellPadding.value} points` + ); + }); + } + + async function getTableCellAlignment() { + // Gets content alignment details about the first cell of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); + }); + } + + async function getTableCellBorder() { + // Gets border details about the first of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstCell: Word.TableCell = firstTable.getCell(0, 0); + const borderLocation = "Left"; + const border: Word.TableBorder = firstCell.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table's first cell:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); + } + + async function getTableCellCellPadding() { + // Gets cell padding details about the first cell of the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstCell: Word.TableCell = firstTable.getCell(0, 0); + const cellPaddingLocation = "Left"; + const cellPadding = firstCell.getCellPadding(cellPaddingLocation); + await context.sync(); + + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table's first cell: ${cellPadding.value} points` + ); + }); + } + + async function insertTable() { + await Word.run(async (context) => { + // Use a two-dimensional array to hold the initial table values. + const data = [ + ["Tokyo", "Beijing", "Seattle"], + ["Apple", "Orange", "Pineapple"] + ]; + const table = context.document.body.insertTable(2, 3, "Start", data); + table.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2; + table.styleFirstColumn = false; + + await context.sync(); + }); + } + + // 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: |- +
    + This sample shows how to get various formatting details about a table, a table row, and a table cell, including + borders, alignment, and cell padding. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Table formatting

    +

    + + + +

    +

    Table row formatting

    +

    + + + +

    +

    Table cell formatting

    +

    + + + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/40-tables/table-cell-access.yaml b/samples/word/40-tables/table-cell-access.yaml index 265b537e1..c4389b9d7 100644 --- a/samples/word/40-tables/table-cell-access.yaml +++ b/samples/word/40-tables/table-cell-access.yaml @@ -8,56 +8,58 @@ api_set: WordApi: '1.3' script: content: |- - $("#run").click(() => tryCatch(getTableCell)); - $("#setup").click(() => tryCatch(insertTable)); + document.getElementById("run").addEventListener("click", () => tryCatch(getTableCell)); + document.getElementById("setup").addEventListener("click", () => tryCatch(insertTable)); async function getTableCell() { + // Gets the content of the first cell in the first table. await Word.run(async (context) => { - let firstCell = context.document.body.tables.getFirst().getCell(0, 0).body; + const firstCell: Word.Body = context.document.body.tables.getFirst().getCell(0, 0).body; firstCell.load("text"); await context.sync(); - console.log("First cell text is " + firstCell.text); + console.log("First cell's text is: " + firstCell.text); }); } async function insertTable() { await Word.run(async (context) => { // Use a two-dimensional array to hold the initial table values. - let data = [ + const data = [ ["Tokyo", "Beijing", "Seattle"], ["Apple", "Orange", "Pineapple"] ]; - let table = context.document.body.insertTable(2, 3, "Start", data); - table.styleBuiltIn = Word.Style.gridTable5Dark_Accent2; + const table: Word.Table = context.document.body.insertTable(2, 3, "Start", data); + table.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2; table.styleFirstColumn = false; await context.sync(); }); } - /** Default helper for invoking an action and handling errors. */ + // 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); + // 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: |- -
    +
    This sample demonstrates how to get a cell from a table.
    - -
    -

    Try it out

    +
    +

    Set up

    - Get the contents of first cell.

    + +

    +
    +

    Try it out

    @@ -78,13 +80,7 @@ style: 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/45-shapes/group-ungroup.yaml b/samples/word/45-shapes/group-ungroup.yaml new file mode 100644 index 000000000..f00f561b8 --- /dev/null +++ b/samples/word/45-shapes/group-ungroup.yaml @@ -0,0 +1,269 @@ +order: 3 +id: word-shapes-group-ungroup +name: Group and ungroup shapes +description: Shows how to group and ungroup shapes. +host: WORD +api_set: + WordApiDesktop: '1.2' +script: + content: | + document.getElementById("group-shapes").addEventListener("click", () => tryCatch(groupShapes)); + document.getElementById("move-group").addEventListener("click", () => tryCatch(moveGroup)); + document.getElementById("scale-group").addEventListener("click", () => tryCatch(scaleGroup)); + document.getElementById("change-group-position").addEventListener("click", () => tryCatch(changeGroupPosition)); + document.getElementById("change-group-size").addEventListener("click", () => tryCatch(changeGroupSize)); + document.getElementById("ungroup-shapes").addEventListener("click", () => tryCatch(ungroupShapes)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function groupShapes() { + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); + + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); + return; + } + + console.log(`Number of shapes to group: ${numShapes}`); + + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); + + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); + }); + } + + async function moveGroup() { + await Word.run(async (context) => { + // Moves the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to move the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.moveHorizontally(-10); + firstShapeGroup.moveVertically(50); + + console.log("Moved the first shape group."); + }); + } + + async function scaleGroup() { + await Word.run(async (context) => { + // Scales the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize); + firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight); + + console.log("Scaled the first shape group."); + }); + } + + async function changeGroupPosition() { + await Word.run(async (context) => { + // Changes the position of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes); + firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin; + firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin; + + console.log("Changed the position of the first shape group."); + }); + } + + async function changeGroupSize() { + await Word.run(async (context) => { + // Changes the relative size of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log( + "About to change the relative size of the first shape group found in the document body:", + shapeGroup.shapes, + ); + firstShapeGroup.relativeHorizontalSize = Word.RelativeSize.insideMargin; + firstShapeGroup.relativeVerticalSize = Word.RelativeSize.bottomMargin; + firstShapeGroup.heightRelative = 50; + + console.log("Changed the relative size of the first shape group."); + }); + } + + async function ungroupShapes() { + await Word.run(async (context) => { + // Ungroups the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to ungroup the first shape group found in the document body:", shapeGroup.shapes); + shapeGroup.ungroup(); + + console.log("Ungrouped the first shape group."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + const lastParagraph: Word.Paragraph = body.paragraphs.getLast(); + + // Inserts a text box. + const textBoxOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100, + }; + lastParagraph.insertTextBox("placeholder text", textBoxOptions); + + // Inserts a geometric shape. + const geometricShapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + left: 120, + }; + lastParagraph.insertGeometricShape(Word.GeometricShapeType.star24, geometricShapeOptions); + + // Inserts a picture. + const pictureOptions: Word.InsertShapeOptions = { + top: 120, + left: 60, + height: 150, + width: 150, + }; + lastParagraph.insertPictureFromBase64(getPictureBase64(), pictureOptions); + + await context.sync(); + }); + } + + function getPictureBase64(): string { + // Returns Base64-encoded image data for a sample picture. + const pictureBase64 = + "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"; + return pictureBase64; + } + + // 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: |- +
    + This sample demonstrates how to group and ungroup shapes. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/45-shapes/manage-canvases.yaml b/samples/word/45-shapes/manage-canvases.yaml new file mode 100644 index 000000000..b72469008 --- /dev/null +++ b/samples/word/45-shapes/manage-canvases.yaml @@ -0,0 +1,166 @@ +order: 4 +id: word-shapes-manage-canvases +name: Work with canvases +description: Shows how to work with canvases. +host: WORD +api_set: + WordApiDesktop: '1.2' +script: + content: | + document.getElementById("insert-canvas").addEventListener("click", () => tryCatch(insertCanvas)); + document.getElementById("get-canvases").addEventListener("click", () => tryCatch(getCanvases)); + document.getElementById("get-first-canvas").addEventListener("click", () => tryCatch(getFirstCanvas)); + document.getElementById("move-first-canvas").addEventListener("click", () => tryCatch(moveFirstCanvas)); + document.getElementById("delete-first-canvas").addEventListener("click", () => tryCatch(deleteFirstCanvas)); + + async function insertCanvas() { + await Word.run(async (context) => { + // Inserts a canvas in the document. + const canvasShape: Word.Shape = context.document.getSelection().insertCanvas(); + canvasShape.load(); + await context.sync(); + + canvasShape.select(); + console.log("Inserted canvas:", canvasShape); + + const canvas: Word.Canvas = canvasShape.canvas; + canvas.load("shape,shapes"); + await context.sync(); + + console.log("Canvas object:", canvas); + }); + } + + async function getCanvases() { + await Word.run(async (context) => { + // Gets the canvases found in the document body. + const canvases: Word.ShapeCollection = context.document.body.shapes.getByTypes([Word.ShapeType.canvas]); + canvases.load("items"); + await context.sync(); + + if (canvases.items.length == 0) { + console.log("No canvases found in the document body."); + return; + } + + console.log("Canvases found in the document body:", canvases); + }); + } + + async function getFirstCanvas() { + await Word.run(async (context) => { + // Gets the first canvas found in the document body. + const canvasShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.canvas]) + .getFirstOrNullObject(); + canvasShape.load(); + canvasShape.load("canvas/shapes"); + await context.sync(); + + if (canvasShape.isNullObject) { + console.log("No canvases found in the document body."); + return; + } + + console.log("First canvas found in the document body:", canvasShape); + console.log("Shapes associated with the first canvas:", canvasShape.canvas.shapes); + canvasShape.select(); + }); + } + + async function moveFirstCanvas() { + await Word.run(async (context) => { + // Moves the first canvas found in the document body. + const canvasShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.canvas]) + .getFirstOrNullObject(); + canvasShape.load(); + canvasShape.load("canvas/shapes"); + await context.sync(); + + if (canvasShape.isNullObject) { + console.log("No canvases found in the document body."); + return; + } + + console.log("First canvas found in the document body:", canvasShape); + canvasShape.moveHorizontally(50); + canvasShape.moveVertically(-10); + console.log("Moved the first canvas."); + }); + } + + async function deleteFirstCanvas() { + await Word.run(async (context) => { + // Deletes the first canvas found in the document body. + const canvasShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.canvas]) + .getFirstOrNullObject(); + canvasShape.load(); + canvasShape.load("canvas/shapes"); + await context.sync(); + + if (canvasShape.isNullObject) { + console.log("No canvases found in the document body."); + return; + } + + console.log("First canvas found in the document body:", canvasShape); + canvasShape.delete(); + console.log("Deleted the first canvas."); + }); + } + + // 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: |- +
    + This sample demonstrates how to work with canvases. +
    +
    +

    Try it out

    + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/45-shapes/manage-geometric-shapes.yaml b/samples/word/45-shapes/manage-geometric-shapes.yaml new file mode 100644 index 000000000..85f037a1e --- /dev/null +++ b/samples/word/45-shapes/manage-geometric-shapes.yaml @@ -0,0 +1,256 @@ +order: 2 +id: word-shapes-manage-geometric-shapes +name: Manage geometric shapes +description: Shows how to work with geometric shapes. +host: WORD +api_set: + WordApiDesktop: '1.2' +script: + content: | + document.getElementById("insert-heptagon").addEventListener("click", () => tryCatch(insertGeometricShape_Heptagon)); + document.getElementById("insert-moon").addEventListener("click", () => tryCatch(insertGeometricShape_Moon)); + document.getElementById("get-geometric-shapes").addEventListener("click", () => tryCatch(getGeometricShapes)); + document.getElementById("get-moons").addEventListener("click", () => tryCatch(getMoonGeometricShapes)); + document.getElementById("get-first-geometric-shape").addEventListener("click", () => tryCatch(getFirstGeometricShape)); + document.getElementById("get-first-heptagon").addEventListener("click", () => tryCatch(getFirstHeptagon)); + document.getElementById("get-first-moon-fill").addEventListener("click", () => tryCatch(getFirstMoonColorFill)); + document.getElementById("clear-first-moon-fill").addEventListener("click", () => tryCatch(clearFirstMoonColorFill)); + document.getElementById("set-first-moon-fill").addEventListener("click", () => tryCatch(setFirstMoonColorFill)); + + async function insertGeometricShape_Heptagon() { + await Word.run(async (context) => { + // Inserts a heptagon geometric shape at the beginning of the selection. + const selection: Word.Range = context.document.getSelection(); + const shapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + }; + selection.insertGeometricShape(Word.GeometricShapeType.heptagon, shapeOptions); + await context.sync(); + + console.log("Inserted a heptagon."); + }); + } + + async function insertGeometricShape_Moon() { + await Word.run(async (context) => { + // Inserts a moon geometric shape at the beginning of the selection. + const selection: Word.Range = context.document.getSelection(); + const shapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + left: 120, + }; + selection.insertGeometricShape(Word.GeometricShapeType.moon, shapeOptions); + await context.sync(); + + console.log("Inserted a moon."); + }); + } + + async function getGeometricShapes() { + await Word.run(async (context) => { + // Gets the geometric shapes from the document body. + const geometricShapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + ]); + geometricShapes.load(); + await context.sync(); + + console.log("Geometric shapes found in the document body:", geometricShapes); + }); + } + + async function getMoonGeometricShapes() { + await Word.run(async (context) => { + // Gets the moon geometric shapes from the document body. + const moons: Word.ShapeCollection = context.document.body.shapes.getByGeometricTypes([ + Word.GeometricShapeType.moon, + ]); + moons.load(); + await context.sync(); + + console.log("Moons found in the document body:", moons); + }); + } + + async function getFirstGeometricShape() { + await Word.run(async (context) => { + // Gets the first geometric shape found in the document body. + const geometricShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.geometricShape]) + .getFirstOrNullObject(); + geometricShape.load(); + await context.sync(); + + if (geometricShape.isNullObject) { + console.log("No geometric shapes found in the document body."); + return; + } + + console.log( + `First geometric shape found in the document body is of type ${geometricShape.geometricShapeType}:`, + geometricShape, + ); + }); + } + + async function getFirstHeptagon() { + await Word.run(async (context) => { + // Gets the first heptagon found in the document body. + const heptagon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.heptagon]) + .getFirstOrNullObject(); + heptagon.load(); + await context.sync(); + + if (heptagon.isNullObject) { + console.log("No heptagons found in the document body."); + return; + } + + console.log("First heptagon found in the document body:", heptagon); + }); + } + + async function getFirstMoonColorFill() { + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); + } + + async function clearFirstMoonColorFill() { + await Word.run(async (context) => { + // Clears the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.clear(); + moonFill.load(); + await context.sync(); + + console.log("Cleared the color fill properties of the first moon found in the document body:", moonFill); + }); + } + + async function setFirstMoonColorFill() { + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } + + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); + + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); + + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); + } + + // 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: |- +
    + This sample demonstrates how to work with geometric shapes. +
    +
    +

    Try it out

    + + + + + + +

    Work with color fill properties of the first moon

    + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/45-shapes/manage-shapes-text-boxes.yaml b/samples/word/45-shapes/manage-shapes-text-boxes.yaml new file mode 100644 index 000000000..ef91e7153 --- /dev/null +++ b/samples/word/45-shapes/manage-shapes-text-boxes.yaml @@ -0,0 +1,415 @@ +order: 1 +id: word-shapes-manage-shapes-text-boxes +name: Work with shapes and text boxes +description: Shows how to work with shapes and text boxes. +author: yilin4 +host: WORD +api_set: + WordApiDesktop: '1.2' +script: + content: | + document + .getElementById("insert-text-box-into-current-selection") + .addEventListener("click", () => tryCatch(insertTextBoxIntoCurrentSelection)); + document.getElementById("get-text-boxes-in-main-doc").addEventListener("click", () => tryCatch(getTextBoxesInMainDoc)); + document + .getElementById("get-text-wrap-of-text-box-in-main-doc") + .addEventListener("click", () => tryCatch(getTextWrapOfTextBoxInMainDoc)); + document + .getElementById("set-text-wrap-of-text-box-in-main-doc") + .addEventListener("click", () => tryCatch(setTextWrapPropertiesOfTextBoxInMainDoc)); + document + .getElementById("get-text-frame-of-text-box-in-main-doc") + .addEventListener("click", () => tryCatch(getTextFrameOfTextBoxInMainDoc)); + document + .getElementById("set-text-frame-of-text-box-in-main-doc") + .addEventListener("click", () => tryCatch(setTextFramePropertiesOfTextBoxInMainDoc)); + document.getElementById("set-text-box-properties").addEventListener("click", () => tryCatch(setTextBoxProperties)); + document + .getElementById("get-text-from-text-box-in-main-doc") + .addEventListener("click", () => tryCatch(getTextFromTextBoxInMainDoc)); + document + .getElementById("insert-content-control-into-text-box") + .addEventListener("click", () => tryCatch(insertContentControlIntoTextBox)); + document + .getElementById("get-content-controls-in-text-box") + .addEventListener("click", () => tryCatch(getContentControlsInTextBox)); + document + .getElementById("insert-picture-at-start-of-text-box") + .addEventListener("click", () => tryCatch(insertPictureAtStartOfTextBox)); + document.getElementById("delete-first-text-box").addEventListener("click", () => tryCatch(deleteFirstTextBox)); + document + .getElementById("insert-text-box-in-header-at-first-paragraph") + .addEventListener("click", () => tryCatch(insertTextBoxInHeaderAtFirstParagraph)); + document.getElementById("get-text-boxes-in-header").addEventListener("click", () => tryCatch(getTextBoxesInHeader)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertTextBoxIntoCurrentSelection() { + await Word.run(async (context) => { + // Inserts a text box at the beginning of the selection. + const range: Word.Range = context.document.getSelection(); + const insertShapeOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100 + }; + + const newTextBox: Word.Shape = range.insertTextBox("placeholder text", insertShapeOptions); + await context.sync(); + + console.log("Inserted a text box at the beginning of the current selection."); + }); + } + + async function getTextBoxesInMainDoc() { + await Word.run(async (context) => { + // Gets text boxes in the main document. + const shapes: Word.ShapeCollection = context.document.body.shapes; + shapes.load(); + await context.sync(); + + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the main document: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the main document has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the main document doesn't have a text box.`); + } + }); + } else { + console.log("No shapes found in the main document."); + } + }); + } + + async function getTextWrapOfTextBoxInMainDoc() { + await Word.run(async (context) => { + // Gets text wrap properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textWrap"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + console.log("Text wrap properties of first text box:", shape.textWrap); + }); + } + + async function setTextWrapPropertiesOfTextBoxInMainDoc() { + await Word.run(async (context) => { + // Sets text wrap properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirstOrNullObject(); + firstShapeWithTextBox.load("textWrap"); + await context.sync(); + + if (firstShapeWithTextBox.isNullObject) { + console.log("No shapes with text boxes found in main document."); + return; + } + + const textWrap: Word.ShapeTextWrap = firstShapeWithTextBox.textWrap; + textWrap.type = Word.ShapeTextWrapType.square; + textWrap.side = Word.ShapeTextWrapSide.both; + + console.log("The first text box's text wrap properties were updated:", textWrap); + }); + } + + async function getTextFrameOfTextBoxInMainDoc() { + await Word.run(async (context) => { + // Gets the text frame of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + console.log("Text frame of first text box:", shape.textFrame); + }); + } + + async function setTextFramePropertiesOfTextBoxInMainDoc() { + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); + }); + } + + async function setTextBoxProperties() { + await Word.run(async (context) => { + // Sets the properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.top = 115; + firstShapeWithTextBox.left = 0; + firstShapeWithTextBox.width = 50; + firstShapeWithTextBox.height = 50; + await context.sync(); + + console.log("The first text box's properties were updated:", firstShapeWithTextBox); + }); + } + + async function getTextFromTextBoxInMainDoc() { + await Word.run(async (context) => { + // Gets text from the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("body/text"); + await context.sync(); + + console.log( + shape.isNullObject + ? "No shapes with text boxes found in the main document." + : `Text in first text box: ${shape.body.text}` + ); + }); + } + + async function insertContentControlIntoTextBox() { + await Word.run(async (context) => { + // Inserts a content control into the first paragraph in the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const firstParagraphInTextBox: Word.Paragraph = firstShapeWithTextBox.body.paragraphs.getFirst(); + const newControl: Word.ContentControl = firstParagraphInTextBox.insertContentControl(); + newControl.load(); + await context.sync(); + + console.log("New content control properties:", newControl); + }); + } + + async function getContentControlsInTextBox() { + await Word.run(async (context) => { + // Gets the content controls in the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const contentControlsInTextBox: Word.ContentControlCollection = firstShapeWithTextBox.body.contentControls; + contentControlsInTextBox.load(); + await context.sync(); + + console.log(`Number of content controls: ${contentControlsInTextBox.items.length}`); + }); + } + + async function insertPictureAtStartOfTextBox() { + await Word.run(async (context) => { + // Inserts a picture at the start of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const startRange: Word.Range = firstShapeWithTextBox.body.getRange(Word.RangeLocation.start); + const newPic: Word.InlinePicture = startRange.insertInlinePictureFromBase64( + getPictureBase64(), + Word.InsertLocation.start + ); + newPic.load(); + await context.sync(); + + console.log("New inline picture properties:", newPic); + }); + } + + async function deleteFirstTextBox() { + await Word.run(async (context) => { + // Deletes the first text box. + context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirst().delete(); + await context.sync(); + + console.log("The first text box in document was deleted."); + }); + } + + async function insertTextBoxInHeaderAtFirstParagraph() { + await Word.run(async (context) => { + // Inserts a text box at the beginning of the first paragraph in the header. + const headerFooterBody: Word.Body = context.document.sections.getFirst().getHeader(Word.HeaderFooterType.primary); + headerFooterBody.load("paragraphs"); + const firstParagraph: Word.Paragraph = headerFooterBody.paragraphs.getFirst(); + const insertShapeOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100 + }; + const newTextBox: Word.Shape = firstParagraph.insertTextBox("placeholder text", insertShapeOptions); + newTextBox.select(); + await context.sync(); + + console.log("Inserted a text box at the beginning of the first paragraph in the header."); + }); + } + + async function getTextBoxesInHeader() { + await Word.run(async (context) => { + // Gets text boxes in the header. + const shapes: Word.ShapeCollection = context.document.sections + .getFirst() + .getHeader(Word.HeaderFooterType.primary).shapes; + shapes.load(); + await context.sync(); + + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the header: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the header has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the header doesn't have a text box.`); + } + }); + } else { + console.log("No shapes found in the header."); + } + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start", + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace", + ); + }); + } + + function getPictureBase64(): string { + // Returns Base64-encoded image data for a sample picture. + const pictureBase64 = + "iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAABblBMVEX+7tEYMFlyg5v8zHXVgof///+hrL77qRnIWmBEWXq6MDgAF0/i1b//8dP+79QKJ1MAIFL8yWpugZz/+O/VzLwzTXR+jaP/z3PHzdjNaWvuxrLFT1n8znmMj5fFTFP25OHlsa2wqqJGW3z7pgCbqsH936oAJlWnssRzdoLTd1HTfINbY3a7tar90IxJVG0AH1ecmJH//90gN14AFU/nxInHVFL80YQAD03qv3LUrm7cwJLWjoLenpPRdXTQgoj15sz+57/7szr93KPbiWjUvZj95LnwzLmMX3L8wmz7rib8xnP8vVz91JT8ukvTz8i8vsORkJKvsLIAD1YwPViWnKZVYHbKuqHjwo3ur2/Pa2O+OTvHVETfj1tybm9qdYlsYlnkmmC0DSPirpvAq4bj5uuono7tu5vgpannnX3ksbSKg5bv0tTclJNFSlyZgpPqwsW4go2giWdbWV+3mmuWgpRcbolURmReS2embHkiRHBcZ6c8AAALcElEQVR4nO3di1cTVx4H8AyThmC484ghFzSxEDRhIRBIMEFQA1qoVhAqYBVd3UXcri1dd7fLdv3vdybJZF73zr2TufPyzPccew49hc6H331nZkylkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiQJ6wj2hH1JLKNo9p/sPB3X8rRUau/f2f56kML2k/n5+XFDSjzPQ7l95+swCqkfzDy1hnwvsLT9FRCF1I7Fpwt5Xt6PfRmF1LgNaBAqZdyNOVGwV9AkVMq4HOshR3iCAJqFalONr1HYRQGtQsXYvrONmjKj7xae0QnVuaO0/OiOlv3lfqI/1G4jgShhnzkIfzA/SNgAUoR9d0I9g/9wfjtsAiHocWZ8fIckLA1ad/SFB0jg+AGxhgNi9FvpU7TwGVHIl+QdtR9GfaTBCOdlIlA18vIzPqZC8kCjZT+mQnI31HInpkKqRqpGDhtADFpInCuGaUe9hBghrY+Xo7+xQgnn6Xth9EuIFNIPpDDsy6cISvg1tVGkkB4Y+ZlCjU34lBrIx6GCitAyyOzQ8mA7+nvfXixCigV33xf9tYwWg3B+/ICnAsbrKFwY8nae0figwnsUq3M34aCXZ3KphPa12+2SWjYZ8v0Pa1Jx4ikRSv1ga2Y8MIzH6aElAqFlRn/vQApRuB32FXoNSRiTad0hgkxI5E8piLlOStgX6DnfkBL7GhKFsS8iUfhN2FfoNWRh3ItIFsa9iBTCmBeRQhjz4ZRGGG8ilfB6jInEVVs/MTj5xUWwbSbUQNs2sZ2Kq9EilNup60qj3LUReT4mR2u2mIXyrtbx2nbjI/P+HpgTFoAYAQlU0rYJYXt3aASg+/zw8HBlkKWFuW5UkSbhsnH4RHxIKmtG8Lx2O5PJ1DhxkKqUW+hGk2gUyoJxhniE6Ivq3W0pAXQPVZ8ibHJ6qrl6JImmGppnecwn3XK7kBnEJOS4zlEUiUZh2zzLI4UQrv94GyPkOnMRJBqFyzghHKa0qfvsQk6KYF90bqUb93pZ72fz5Y+3DT6EsFqOtlC+bh1pXjSUtCq3tWTMsQm5VrSF/L6lkW7k1KsWM7jUjq3CXCFyRPOMb9hpLCtfb7TUvlWsYYUrVqG0Gm2hgbjfG2c61erxCRaYqS2J1o4YvQnDuvJeFtSV9zbfm+7hSTGD9ykpVq3ChagL1d1T/09PWLeOLdZYW2kchKbpfZMgrJ2K8RbyPKGEmRMp5kL40mURYyckFzHTjLkQrpPGmhMx3kIe/kRqp0Ux3kKlihlnY+2EE6MuhIYgiPxL25LbTMysSFEWQvjq8evs3Wu9nL15+4MdCdsvM47IWvG42q9j9c+RE4JXr29ms5pQzVtkHX9S94aG2JrquxVRqlZz7yN2Og5SW6rPJLz2BtkdlbTXN797qeS7zXX7YqdWq2VOTk7monTzBgDgPNsHmoTX3qBO2TRmP9hJpA7lRyESzafUe/c1n0V47S/EARa3YL1dh2He/Q26W2ruq9l6kL059FmFZ7giDoW41Zwq5PmwgClw/lf1+hWaEYcQXntFEMrPpzEpqBuv0EabvjCLikX4liA0n6zazpFhWLdIK8KzW0hgNmsW/sm5mcrbzsLQnjQBXWvj1HPmRshjgdpnAaFNGVhg9pYLofFDOIxQDunzVHAfX0QXwhIeOPw8J6TBBnRx3dAy1jgKzUfjGGEUi3hGKZSBA1D/TC6sngjSVEQHIfxQdMqq9p2hPbgHtvAN9YxCCD/mxwzJ54tF5R/617owtOUpuDGDLeMZSQhLRybg2LTaMi/G8nYhXwpvdQpupO3LtsFwc+YkhHBzzAzUel8RIQzzOQYAUnvnWw9mZlTUayvy7q2zM5QQ8ptlsy9/oQkv8nZhyE+3DW/zAfAtopaPrUJlR/jRUr+xsaI+hBYRwohshQX4mCyEGx+KeatvLF/ThYd5uzC8jmiKAO/esscoVMq3auepmkNdOI0QRuSRKaH0LSJd/TrhehnpUzQZXVhDCGFEHijadVyZwPUjjE/l6N+AGEvD2yVaglxkDoRww8FnLGINNZaGN+ebIqCAg506/9HJZ+iJ06gZPyqDKRLYE9qmdxSxOH1xMV1ErdqULEdAiNsmCDLkV4m+HilvqrNJGIHjbzD76dMsKn+D6+QCIsGREgJwf1HPw59/1r/4+4eRfBETgu7lYlrL4rdq4/yk/YtfRgSahaEuagDozuq+AVAjPhyRFyEhAHuzi0bgJ22IWfQGtAoBMv7zurNpo08R/qoJL70BLUJQL6Pi72226kdOZp5F6AloERZazQlbpqqnPgoV36XNZ26lnoAWIcdxUxWrsMk1/LuBUfXZeL0MgJ8Xf2Eo/E20EyvqHUadgj+9EqTuY3zp9GUP+OuDf4w6TdiF8H3/Dg0TsTK4hao+TIGdEewh2qehoX7+fLn4T49A42nivxqDO1AmKjYgJw2TqzJ6EMWpgH2i4vc2ypiE8J4GNBArtjvfuX6bZQF0LKAWj53QKNxoGAwTlUpF+TOBBHLiCgMhuEHhS3tuowbhsemGvuaUOk0gfeptRl3vQEILZVZCTQj/bb0B3CmSZyElkEEJB0J9lKHKsddWCnCTIPsS9oXw95YboOe7/SgrmH7IoIR94T1XFeQ6k96EYJYOmPY62Q+FJVc+ruPxMRtlmqADMmmkPeFv1gdpHJuo5PmZRUpfOs2ihKrwvUR2aRE7np8epu2EbEZSVfh7jt7XWimseQVSt1FGwrF3tBNhVWotMVh1g0vqRvofJsA8uQ9WG51WQ1wp11k8we+ihGwGmjH0ytPYMnPlgrqEYbQxpO+FaY97+0GwS88h8HiS7UkUPZCJcILYRptsT6HcNFIWwisisMX4MWHq5QwbIRnI/HkTFyMpCyHJx2QjaBG6KKH3AwziMMrlmL9UohukcIrYRpmcVpjiaqDxKqyQp3rWw0ywQvIo48djbQEKKRZrnMTa51boZeGdJ48yXMOHd9eMKLyqTDVFlyEDOebDzIjCqymqy3UfyY+XSNEdAxuFFc4fnpIOe59bIdWAP3o8n4l6F141/QSKvjwB7Ur4vZ8+LgI1/K/PQC4XstB3INfw4wVS9EL/gf50RGrhH/4DlWbq8dMJL0K/B5l+/HifBKXwf4EAlTmf9QafWkixamYSH17lRicMpo1yfmzxKYVBAZWxhnkzpRIGVkI/3qlIJQzMp3RE5ntgGmFQA6ka9u9UpBH+ERzQh9e3gm52BpMh3c2NPZ6FPhy2YZ9pzmYfBN5IfRGe4x9Nz84EPJL69B4whyL2iEF2Q39Wpnv4h+97RNt7gOMmVIZTh3aaDW5N2k9zjb1QqSL+/QLZmYeBApVlmy9HGeD8wU1MsotBDjT+vShafb/ADXT2XNygxSKiL8A+Ep1uwMLqgh890SlBC7ncasDErqt7eVmkVQ70L2sBddc11J8EaeRGWtNKTfVvpAnqmT3gfsJfG6ZbKEujGTunC6tz1tQ93g2G/qUtub/CJS0LR3WQKo/WysWqZE/reG5Uo4qZLNh+aXNlcYQS6B/7VhvS0Vqd/nZZchrHIx0aK7q5dxNThoiDX5r3raF0nKqzHKtEyf1JDgD1d1+m7A8Asrqk47VyR29o3n9nbtd1im/CzMMLR1u/SUdAb/ar5aa7By0QV+HuTBVMXtl8GGGzezraxXXMQ3+96bGOru6bAnNf7D608EUBgNXWKGW0nJ8BsOCtY4or1Ise5f+FKCBa2HtqBUwujWK0LqbBXMfThqVFO56CbgUNtAulwa0uYK2wkHM9WtiOecHkqRcj7UEAqH+ZwkVq5fS0ctzRcPxSNhtzC5yUc5NO03pFABQWRFc/w5jWC7oSpgr4TJoDLB0JdCfdBfH7VSbh0UPbSqnj5XvxK2aXP4P485IkSZIkSZIkSZIkSZIkSZIkSZIk8Tv/B3bBREdOWYS3AAAAAElFTkSuQmCC"; + return pictureBase64; + } + + // 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: |- +
    + This sample demonstrates how to work with shapes and text boxes. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Main document

    + + +

    The following buttons act on the first text box in the main document.

    + + + + + + + + + + +

    Header

    + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/compare-documents.yaml b/samples/word/50-document/compare-documents.yaml new file mode 100644 index 000000000..70ee0b554 --- /dev/null +++ b/samples/word/50-document/compare-documents.yaml @@ -0,0 +1,74 @@ +order: 16 +id: word-document-compare-documents +name: Compare documents +description: Compares two documents (the current one and a specified external one). +author: YijunMS +host: WORD +api_set: + WordApiDesktop: '1.1' +script: + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); + + async function run() { + // Compares the current document with a specified external document. + await Word.run(async (context) => { + // Absolute path of an online or local document. + const filePath = (document.getElementById("filePath") as HTMLInputElement).value; + // Options that configure the compare operation. + const options: Word.DocumentCompareOptions = { + compareTarget: Word.CompareTarget.compareTargetCurrent, + detectFormatChanges: false + // Other options you choose... + }; + context.document.compare(filePath, options); + + await context.sync(); + + console.log("Differences shown in the current document."); + }); + } + + // 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: |- +
    +

    This sample shows how to compare two documents: the current one and a specified external one.

    +
    +
    +

    Try it out

    + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/get-external-styles.yaml b/samples/word/50-document/get-external-styles.yaml new file mode 100644 index 000000000..3f7c74914 --- /dev/null +++ b/samples/word/50-document/get-external-styles.yaml @@ -0,0 +1,85 @@ +order: 13 +id: word-document-get-external-styles +name: Get styles from external document +description: This sample shows how to get styles from an external document. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("file").addEventListener("change", getBase64); + document.getElementById("get-external-styles").addEventListener("click", () => tryCatch(getExternalStyles)); + + let externalDocument; + + async function getExternalStyles() { + // Gets style info from another document passed in as a Base64-encoded string. + await Word.run(async (context) => { + const retrievedStyles = context.application.retrieveStylesFromBase64(externalDocument); + await context.sync(); + + console.log("Styles from the other document:", retrievedStyles.value); + }); + } + + function getBase64() { + // Retrieve the file and set up an HTML FileReader element. + const myFile = document.getElementById("file") as HTMLInputElement; + const reader = new FileReader(); + + reader.onload = (event) => { + // Remove the metadata before the Base64-encoded string. + const startIndex = reader.result.toString().indexOf("base64,"); + externalDocument = reader.result.toString().substr(startIndex + 7); + }; + + // Read the file as a data URL so that we can parse the Base64-encoded string. + reader.readAsDataURL(myFile.files[0]); + } + + // 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: |- +
    + This sample demonstrates how to get styles from an external document. +
    +
    +

    Try it out

    +

    Select a Word document to get its style info.

    +
    + +
    +
    +

    Get style info from the selected document.

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/insert-external-document.yaml b/samples/word/50-document/insert-external-document.yaml new file mode 100644 index 000000000..005d12d69 --- /dev/null +++ b/samples/word/50-document/insert-external-document.yaml @@ -0,0 +1,124 @@ +order: 3 +id: word-document-insert-external-document +name: Insert an external document +description: Inserts the content (with or without settings) of an external document into the current document. Settings include formatting, change-tracking mode, custom properties, and XML parts. +host: WORD +api_set: + WordApi: '1.7' +script: + content: |- + document.getElementById("file").addEventListener("change", getBase64); + document.getElementById("insert-document").addEventListener("click", () => tryCatch(insertDocument)); + document.getElementById("insert-document-with-settings").addEventListener("click", () => tryCatch(insertDocumentWithSettings)); + + let externalDocument; + + async function insertDocument() { + // Updates the text of the current document with the text from another document passed in as a Base64-encoded string. + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + const externalDoc: Word.DocumentCreated = context.application.createDocument(externalDocument); + await context.sync(); + + if (!Office.context.requirements.isSetSupported("WordApiHiddenDocument", "1.3")) { + console.warn("The WordApiHiddenDocument 1.3 requirement set isn't supported on this client so can't proceed. Try this action on a platform that supports this requirement set."); + return; + } + + const externalDocBody: Word.Body = externalDoc.body; + externalDocBody.load("text"); + await context.sync(); + + // Insert the external document's text at the beginning of the current document's body. + const externalDocBodyText = externalDocBody.text; + const currentDocBody: Word.Body = context.document.body; + currentDocBody.insertText(externalDocBodyText, Word.InsertLocation.start); + await context.sync(); + }); + } + + async function insertDocumentWithSettings() { + // Inserts content (applying selected settings) from another document passed in as a Base64-encoded string. + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + context.document.insertFileFromBase64(externalDocument, "Replace", { + importTheme: true, + importStyles: true, + importParagraphSpacing: true, + importPageColor: true, + importChangeTrackingMode: true, + importCustomProperties: true, + importCustomXmlParts: true, + importDifferentOddEvenPages: true + }); + await context.sync(); + }); + } + + function getBase64() { + // Retrieve the file and set up an HTML FileReader element. + const myFile = document.getElementById("file") as HTMLInputElement; + const reader = new FileReader(); + + reader.onload = (event) => { + // Remove the metadata before the Base64-encoded string. + const startIndex = reader.result.toString().indexOf("base64,"); + externalDocument = reader.result.toString().substr(startIndex + 7); + }; + + // Read the file as a data URL so that we can parse the Base64-encoded string. + reader.readAsDataURL(myFile.files[0]); + } + + // 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: |- +
    +

    This sample shows how to insert the body text from an external document into the current document.

    +
    +
    +

    Try it out

    +

    Select a Word document.

    +
    + +
    +
    +

    Insert the body text from the selected document.

    + +
    +

    Insert the body text with settings applied from the selected document.

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/insert-section-breaks.yaml b/samples/word/50-document/insert-section-breaks.yaml new file mode 100644 index 000000000..1ca46f47b --- /dev/null +++ b/samples/word/50-document/insert-section-breaks.yaml @@ -0,0 +1,137 @@ +order: 2 +id: word-document-insert-section-breaks +name: Add a section +description: Shows how to insert section breaks in the document. +host: WORD +api_set: + WordApi: '1.1' +script: + content: |- + document.getElementById("add-sectionNext").addEventListener("click", () => tryCatch(addNext)); + document.getElementById("add-sectionEven").addEventListener("click", () => tryCatch(addEven)); + document.getElementById("add-sectionOdd").addEventListener("click", () => tryCatch(addOdd)); + document.getElementById("add-sectionContinuous").addEventListener("click", () => tryCatch(addContinuous)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function addNext() { + // Inserts a section break on the next page. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionNext, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section break on next page."); + }); + } + + async function addEven() { + // Inserts a section break on the next even page. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionEven, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section break on next even page."); + }); + } + + async function addOdd() { + // Inserts a section break on the next odd page. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionOdd, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section break on next odd page."); + }); + } + + async function addContinuous() { + // Inserts a section without an associated page break. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionContinuous, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section without an associated page break."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample shows how to insert sections in the document. +
    +
    +

    Set up

    + +

    You should also show the formatting marks to see the section indicators. To learn more, refer to Show or hide tab marks in Word

    +
    +
    +

    Try it out

    + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/manage-annotations.yaml b/samples/word/50-document/manage-annotations.yaml new file mode 100644 index 000000000..344bbc495 --- /dev/null +++ b/samples/word/50-document/manage-annotations.yaml @@ -0,0 +1,361 @@ +order: 15 +id: word-document-manage-annotations +name: Manage annotations +description: Shows how to leverage the Writing Assistance API to manage annotations and use annotation events. +author: cbouzmsft +host: WORD +api_set: + WordApi: '1.8' +script: + content: |- + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("insert-annotations").addEventListener("click", () => tryCatch(insertAnnotations)); + document.getElementById("get-annotations").addEventListener("click", () => tryCatch(getAnnotations)); + document.getElementById("accept-first").addEventListener("click", () => tryCatch(acceptFirst)); + document.getElementById("reject-last").addEventListener("click", () => tryCatch(rejectLast)); + document.getElementById("delete-annotations").addEventListener("click", () => tryCatch(deleteAnnotations)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function registerEventHandlers() { + // Registers event handlers. + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); + }); + } + + async function paragraphChanged(args: Word.ParagraphChangedEventArgs) { + await Word.run(async (context) => { + const results = []; + for (let id of args.uniqueLocalIds) { + let para = context.document.getParagraphByUniqueLocalId(id); + para.load("uniqueLocalId"); + + results.push({ para: para, text: para.getText() }); + } + + await context.sync(); + + for (let result of results) { + console.log(`${args.type}: ID ${result.para.uniqueLocalId}:-`, result.text.value); + } + }); + } + + async function insertAnnotations() { + // Adds annotations to the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; + + const annotationIds = paragraph.insertAnnotations(annotationSet); + + await context.sync(); + + console.log("Annotations inserted:", annotationIds.value); + }); + } + + async function getAnnotations() { + // Gets annotations found in the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + console.log("Annotations found:"); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); + } + }); + } + + async function acceptFirst() { + // Accepts the first annotation found in the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Accepting ID ${annotation.id}...`); + annotation.critiqueAnnotation.accept(); + + await context.sync(); + break; + } + } + }); + } + + async function rejectLast() { + // Rejects the last annotation found in the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = annotations.items.length - 1; i >= 0; i--) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Rejecting ID ${annotation.id}...`); + annotation.critiqueAnnotation.reject(); + + await context.sync(); + break; + } + } + }); + } + + async function deleteAnnotations() { + // Deletes all annotations found in the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id"); + + await context.sync(); + + const ids = []; + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + ids.push(annotation.id); + annotation.delete(); + } + + await context.sync(); + + console.log("Annotations deleted:", ids); + }); + } + + async function onClickedHandler(args: Word.AnnotationClickedEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); + + await context.sync(); + + console.log(`AnnotationClicked: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } + + async function onHoveredHandler(args: Word.AnnotationHoveredEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); + + await context.sync(); + + console.log(`AnnotationHovered: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } + + async function onInsertedHandler(args: Word.AnnotationInsertedEventArgs) { + await Word.run(async (context) => { + const annotations = []; + for (let i = 0; i < args.ids.length; i++) { + let annotation: Word.Annotation = context.document.getAnnotationById(args.ids[i]); + annotation.load("id,critiqueAnnotation"); + + annotations.push(annotation); + } + + await context.sync(); + + for (let annotation of annotations) { + console.log(`AnnotationInserted: ID ${annotation.id}:`, annotation.critiqueAnnotation.critique); + } + }); + } + + async function onRemovedHandler(args: Word.AnnotationRemovedEventArgs) { + await Word.run(async (context) => { + for (let id of args.ids) { + console.log(`AnnotationRemoved: ID ${id}`); + } + }); + } + + async function onPopupActionHandler(args: Word.AnnotationPopupActionEventArgs) { + await Word.run(async (context) => { + let message = `AnnotationPopupAction: ID ${args.id} = `; + if (args.action === "Accept") { + message += `Accepted: ${args.critiqueSuggestion}`; + } else { + message += "Rejected"; + } + + console.log(message); + }); + } + + async function deregisterEventHandlers() { + // Deregisters event handlers. + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers."); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.insertParagraph( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "End" + ); + }); + } + + // 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: |- +
    +

    This sample demonstrates how to manage annotations and use annotation events.

    +

    Important: You need a Microsoft 365 subscription in order to use Annotation APIs. See GitHub issue 4953 for more information.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/manage-body.yaml b/samples/word/50-document/manage-body.yaml new file mode 100644 index 000000000..0051442b5 --- /dev/null +++ b/samples/word/50-document/manage-body.yaml @@ -0,0 +1,415 @@ +order: 1 +id: word-document-manage-body +name: Manage body +description: Shows how to manage the document body. +author: OfficeDev +host: WORD +api_set: + WordApi: '1.2' +script: + content: |- + document.getElementById("get-font-props").addEventListener("click", () => tryCatch(getFontProperties)); + document.getElementById("get-html").addEventListener("click", () => tryCatch(getHTML)); + document.getElementById("get-ooxml").addEventListener("click", () => tryCatch(getOOXML)); + document.getElementById("get-text").addEventListener("click", () => tryCatch(getText)); + document.getElementById("insert-content-control").addEventListener("click", () => tryCatch(insertContentControl)); + document.getElementById("insert-page-break").addEventListener("click", () => tryCatch(insertPageBreak)); + document.getElementById("file").addEventListener("change", getBase64); + document.getElementById("insert-external-body").addEventListener("click", () => tryCatch(insertExternalBody)); + document.getElementById("insert-html").addEventListener("click", () => tryCatch(insertHTML)); + document.getElementById("insert-image-inline").addEventListener("click", () => tryCatch(insertImageInline)); + document.getElementById("insert-ooxml").addEventListener("click", () => tryCatch(insertOOXML)); + document.getElementById("insert-text").addEventListener("click", () => tryCatch(insertText)); + document.getElementById("select").addEventListener("click", () => tryCatch(select)); + document.getElementById("clear").addEventListener("click", () => tryCatch(clear)); + document.getElementById("insert-paragraph").addEventListener("click", () => tryCatch(insertParagraph)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function getFontProperties() { + // Gets the style and the font size, font name, and font color properties on the body object. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to load font and style information for the document body. + body.load("font/size, font/name, font/color, style"); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + // Show font-related property values on the body object. + const results = + "Font size: " + + body.font.size + + "; Font name: " + + body.font.name + + "; Font color: " + + body.font.color + + "; Body style: " + + body.style; + + console.log(results); + }); + } + + async function getHTML() { + // Gets the HTML that represents the content of the body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to get the HTML contents of the body. + const bodyHTML = body.getHtml(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Body contents (HTML): " + bodyHTML.value); + }); + } + + async function getOOXML() { + // Gets the OOXML that represents the content of the body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to get the OOXML contents of the body. + const bodyOOXML = body.getOoxml(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Body contents (OOXML): " + bodyOOXML.value); + }); + } + + async function getText() { + // Gets the text content of the body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to load the text in document body. + body.load("text"); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Body contents (text): " + body.text); + }); + } + + async function insertContentControl() { + // Creates a content control using the document body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to wrap the body in a content control. + body.insertContentControl(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Wrapped the body in a content control."); + }); + } + + async function insertPageBreak() { + // Inserts a page break at the beginning of the document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert a page break at the start of the document body. + body.insertBreak(Word.BreakType.page, Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added a page break at the start of the document body."); + }); + } + + let externalDocument; + + function getBase64() { + // Retrieve the file and set up an HTML FileReader element. + const myFile = document.getElementById("file") as HTMLInputElement; + const reader = new FileReader(); + + reader.onload = (event) => { + // Remove the metadata before the Base64-encoded string. + const startIndex = reader.result.toString().indexOf("base64,"); + externalDocument = reader.result.toString().substr(startIndex + 7); + }; + + // Read the file as a data URL so that we can parse the Base64-encoded string. + reader.readAsDataURL(myFile.files[0]); + } + + async function insertExternalBody() { + // Inserts the body from the external document at the beginning of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert the Base64-encoded string representation of the body of the selected .docx file at the beginning of the current document. + body.insertFileFromBase64(externalDocument, Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added Base64-encoded text to the beginning of the document body."); + }); + } + + async function insertHTML() { + // Inserts the HTML at the beginning of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert HTML at the beginning of the document. + body.insertHtml("This is text inserted with body.insertHtml()", Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("HTML added to the beginning of the document body."); + }); + } + + async function insertImageInline() { + // Inserts an image inline at the beginning of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Base64-encoded image to insert inline. + const base64EncodedImg = + "iVBORw0KGgoAAAANSUhEUgAAAB4AAAANCAIAAAAxEEnAAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACFSURBVDhPtY1BEoQwDMP6/0+XgIMTBAeYoTqso9Rkx1zG+tNj1H94jgGzeNSjteO5vtQQuG2seO0av8LzGbe3anzRoJ4ybm/VeKEerAEbAUpW4aWQCmrGFWykRzGBCnYy2ha3oAIq2MloW9yCCqhgJ6NtcQsqoIKdjLbFLaiACnYyf2fODbrjZcXfr2F4AAAAAElFTkSuQmCC"; + + // Queue a command to insert a Base64-encoded image at the beginning of the current document. + body.insertInlinePictureFromBase64(base64EncodedImg, Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added a Base64-encoded image to the beginning of the document body."); + }); + } + + async function insertOOXML() { + // Inserts OOXML at the beginning of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert OOXML at the beginning of the body. + body.insertOoxml( + "This text has formatting directly applied to achieve its font size, color, line spacing, and paragraph spacing.", + Word.InsertLocation.start + ); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added OOXML to the beginning of the document body."); + }); + + // Read "Understand when and how to use Office Open XML in your Word add-in" for guidance on working with OOXML. + // https://learn.microsoft.com/office/dev/add-ins/word/create-better-add-ins-for-word-with-office-open-xml + + // The Word-Add-in-DocumentAssembly sample shows how you can use this API to assemble a document. + // https://github.com/OfficeDev/Word-Add-in-DocumentAssembly + } + + async function insertText() { + // Inserts text at the beginning of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert text at the beginning of the current document. + body.insertText('This is text inserted with body.insertText()', Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Text added to the beginning of the document body."); + }); + } + + async function select() { + // Selects the entire body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to select the document body. + // The Word UI will move to the selected document body. + body.select(); + + console.log("Selected the document body."); + }); + } + + async function clear() { + // Clears out the content from the document body. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to clear the contents of the body. + body.clear(); + + console.log("Cleared the body contents."); + }); + + // The Silly stories add-in sample shows how the clear method can be used to clear the contents of a document. + // https://aka.ms/sillystorywordaddin + } + + async function insertParagraph() { + // Inserts a paragraph at the end of this document. + // Run a batch operation against the Word object model. + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert a paragraph at the end of the current document. + body.insertParagraph("Content of a new paragraph", Word.InsertLocation.end); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Paragraph added at the end of the document body."); + }); + + // The Word-Add-in-DocumentAssembly sample shows how you can use the insertParagraph method to assemble a document. + // https://github.com/OfficeDev/Word-Add-in-DocumentAssembly + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample shows how to manage the content of the document body. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + + +

    Choose a Word document to copy its body into the current document.

    +
    + +
    +
    + + + + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/manage-change-tracking.yaml b/samples/word/50-document/manage-change-tracking.yaml new file mode 100644 index 000000000..e5b647f12 --- /dev/null +++ b/samples/word/50-document/manage-change-tracking.yaml @@ -0,0 +1,146 @@ +order: 4 +id: word-document-manage-change-tracking +name: Track changes +description: This sample shows how to get and set the change tracking mode and get the before and after of reviewed text. +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("get-change-tracking-mode").addEventListener("click", () => tryCatch(getChangeTrackingMode)); + document.getElementById("set-change-tracking-mode").addEventListener("click", () => tryCatch(setChangeTrackingMode)); + document.getElementById("get-reviewed-text").addEventListener("click", () => tryCatch(getReviewedText)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function getChangeTrackingMode() { + // Gets the current change tracking mode. + await Word.run(async (context) => { + const document: Word.Document = context.document; + document.load("changeTrackingMode"); + await context.sync(); + + if (document.changeTrackingMode === Word.ChangeTrackingMode.trackMineOnly) { + console.log("Only my changes are being tracked."); + } else if (document.changeTrackingMode === Word.ChangeTrackingMode.trackAll) { + console.log("Everyone's changes are being tracked."); + } else { + console.log("No changes are being tracked."); + } + }); + } + + async function setChangeTrackingMode() { + // Sets the change tracking mode. + await Word.run(async (context) => { + const mode = (document.querySelector("input[name='mode']:checked") as HTMLInputElement).value; + if (mode === "Track only my changes") { + context.document.changeTrackingMode = Word.ChangeTrackingMode.trackMineOnly; + } else if (mode === "Track everyone's changes") { + context.document.changeTrackingMode = Word.ChangeTrackingMode.trackAll; + } else { + context.document.changeTrackingMode = Word.ChangeTrackingMode.off; + } + + await context.sync(); + + getChangeTrackingMode(); + }); + } + + async function getReviewedText() { + // Gets the reviewed text. + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection(); + const before = range.getReviewedText(Word.ChangeTrackingVersion.original); + const after = range.getReviewedText(Word.ChangeTrackingVersion.current); + + await context.sync(); + + console.log("Reviewed text (before):", before.value, "Reviewed text (after):", after.value); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    +

    This sample shows basic operations of the Track Changes feature.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Get current change tracking mode

    + +

    Set change tracking mode

    +

    + +
    + +
    + +
    + +

    +

    Get reviewed text

    +

    + + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/manage-comments.yaml b/samples/word/50-document/manage-comments.yaml new file mode 100644 index 000000000..75a4ba5aa --- /dev/null +++ b/samples/word/50-document/manage-comments.yaml @@ -0,0 +1,297 @@ +order: 6 +id: word-document-manage-comments +name: Manage comments +description: This sample shows how to perform basic comments operations, including insert, reply, get, edit, resolve, and delete. +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("insert").addEventListener("click", () => tryCatch(insertComment)); + document.getElementById("edit").addEventListener("click", () => tryCatch(editFirstCommentInSelection)); + document.getElementById("reply").addEventListener("click", () => tryCatch(replyToFirstActiveCommentInSelection)); + document.getElementById("resolve").addEventListener("click", () => tryCatch(toggleResolvedStatusOfFirstCommentInSelection)); + document.getElementById("range").addEventListener("click", () => tryCatch(getFirstCommentRangeInSelection)); + document.getElementById("get-comments-in-selection").addEventListener("click", () => tryCatch(getCommentsInSelection)); + document.getElementById("get-replies-to-first-comment-in-selection").addEventListener("click", () => tryCatch(getRepliesToFirstCommentInSelection)); + document.getElementById("delete").addEventListener("click", () => tryCatch(deleteFirstCommentInSelection)); + document.getElementById("get-comments").addEventListener("click", () => tryCatch(getComments)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertComment() { + // Sets a comment on the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("comment-text") as HTMLInputElement).value; + const comment: Word.Comment = context.document.getSelection().insertComment(text); + + // Load object to log in the console. + comment.load(); + await context.sync(); + + console.log("Comment inserted:", comment); + }); + } + + async function editFirstCommentInSelection() { + // Edits the first active comment in the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("edit-comment-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (!firstActiveComment) { + console.warn("No active comment was found in the selection, so couldn't edit."); + return; + } + + firstActiveComment.content = text; + + // Load object to log in the console. + firstActiveComment.load(); + await context.sync(); + + console.log("Comment content changed:", firstActiveComment); + }); + } + + async function replyToFirstActiveCommentInSelection() { + // Replies to the first active comment in the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } + }); + } + + async function toggleResolvedStatusOfFirstCommentInSelection() { + // Toggles Resolved status of the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document + .getSelection() + .getComments() + .getFirstOrNullObject(); + comment.load("resolved"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to toggle."); + return; + } + + // Toggle resolved status. + // If the comment is active, set as resolved. + // If it's resolved, set resolved to false. + const resolvedBefore = comment.resolved; + console.log(`Comment Resolved status (before): ${resolvedBefore}`); + comment.resolved = !resolvedBefore; + comment.load("resolved"); + await context.sync(); + + console.log(`Comment Resolved status (after): ${comment.resolved}`); + }); + } + + async function getFirstCommentRangeInSelection() { + // Gets the range of the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); + }); + } + + async function getCommentsInSelection() { + // Gets the comments in the selected content. + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + + // Load objects to log in the console. + comments.load(); + await context.sync(); + + console.log("Comments:", comments); + }); + } + + async function getRepliesToFirstCommentInSelection() { + // Gets the replies to the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("replies"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no replies to get."); + return; + } + + const replies: Word.CommentReplyCollection = comment.replies; + console.log("Replies to the first comment:", replies); + }); + } + + async function deleteFirstCommentInSelection() { + // Deletes the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.delete(); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to delete."); + return; + } + + console.log("Comment deleted."); + }); + } + + async function getComments() { + // Gets the comments in the document body. + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.body.getComments(); + + // Load objects to log in the console. + comments.load(); + await context.sync(); + + console.log("All comments:", comments); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + // 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: |- +
    +

    This sample shows basic operations using comments.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Manage comments in selection

    +

    Select content in document body before proceeding.

    +

    + + + +

    +

    + + + +

    +

    + + + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    Manage comments in document body

    +

    + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-custom-xml-part-ns.yaml b/samples/word/50-document/manage-custom-xml-part-ns.yaml new file mode 100644 index 000000000..c40fe12a7 --- /dev/null +++ b/samples/word/50-document/manage-custom-xml-part-ns.yaml @@ -0,0 +1,306 @@ +order: 10 +id: word-document-manage-custom-xml-part-ns +name: Manage a CustomXmlPart with the namespace +description: This sample shows how to add, query, replace, edit, and delete a custom XML part in a document. +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("add-custom-xml-part").addEventListener("click", () => tryCatch(addCustomXmlPart)); + document.getElementById("query").addEventListener("click", () => tryCatch(query)); + document.getElementById("get-namespace").addEventListener("click", () => tryCatch(getNamespace)); + document.getElementById("get-by-namespace").addEventListener("click", () => tryCatch(getByNamespaceUri)); + document.getElementById("replace-custom-xml-part").addEventListener("click", () => tryCatch(replace)); + document.getElementById("insert-attribute").addEventListener("click", () => tryCatch(insertAttribute)); + document.getElementById("insert-element").addEventListener("click", () => tryCatch(insertElement)); + document.getElementById("delete-custom-xml-part").addEventListener("click", () => tryCatch(deleteCustomXmlPart)); + + async function addCustomXmlPart() { + // Adds a custom XML part. + // If you want to populate the CustomXml.namespaceUri property, you must include the xmlns attribute. + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load(["id", "namespaceUri"]); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log(`Added custom XML part with namespace URI ${customXmlPart.namespaceUri}:`, readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartIdNS", customXmlPart.id); + + await context.sync(); + }); + } + + async function query() { + // Original XML: JuanHongSally + + // Queries a custom XML part for elements matching the search terms. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/contoso:Reviewers"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); + + await context.sync(); + + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } + }); + } + + async function getNamespace() { + // Original XML: JuanHongSally + + // Gets the namespace URI from a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + customXmlPart.load("namespaceUri"); + await context.sync(); + + const namespaceUri = customXmlPart.namespaceUri; + console.log(`Namespace URI: ${JSON.stringify(namespaceUri)}`); + } else { + console.warn("Didn't find custom XML part."); + } + }); + } + + async function getByNamespaceUri() { + // Original XML: JuanHongSally + + // Gets the custom XML parts with the specified namespace URI. + await Word.run(async (context) => { + const namespaceUri = "http://schemas.contoso.com/review/1.0"; + console.log(`Specified namespace URI: ${namespaceUri}`); + const scopedCustomXmlParts: Word.CustomXmlPartScopedCollection = + context.document.customXmlParts.getByNamespace(namespaceUri); + scopedCustomXmlParts.load("items"); + await context.sync(); + + console.log(`Number of custom XML parts found with this namespace: ${!scopedCustomXmlParts.items ? 0 : scopedCustomXmlParts.items.length}`); + }); + } + + async function replace() { + // Original XML: JuanHongSally + + // Replaces a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const originalXmlBlob = customXmlPart.getXml(); + await context.sync(); + + let readableXml = addLineBreaksToXML(originalXmlBlob.value); + console.log("Original custom XML part:", readableXml); + + // The setXml method replaces the entire XML part. + customXmlPart.setXml( + "JohnHitomi" + ); + const updatedXmlBlob = customXmlPart.getXml(); + await context.sync(); + + readableXml = addLineBreaksToXML(updatedXmlBlob.value); + console.log("Replaced custom XML part:", readableXml); + } else { + console.warn("Didn't find custom XML part to replace."); + } + }); + } + + async function insertAttribute() { + // Original XML: JuanHongSally + + // Inserts an attribute into a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertAttribute method inserts an attribute with the given name and value into the element identified by the xpath parameter. + customXmlPart.insertAttribute( + "/contoso:Reviewers", + { contoso: "http://schemas.contoso.com/review/1.0" }, + "Nation", + "US" + ); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted attribute:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert attribute into."); + } + }); + } + + async function insertElement() { + // Original XML: JuanHongSally + + // Inserts an element into a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertElement method inserts the given XML under the parent element identified by the xpath parameter at the provided child position index. + customXmlPart.insertElement( + "/contoso:Reviewers", + "Mark", + { contoso: "http://schemas.contoso.com/review/1.0" }, + 0 + ); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted element:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert element into."); + } + }); + } + + async function deleteCustomXmlPart() { + // Original XML: JuanHongSally + + // Deletes a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.document.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + + await context.sync(); + + if (customXmlPart.isNullObject) { + console.log(`The XML part with the ID ${xmlPartIDSetting.value} has been deleted.`); + + // Delete the associated setting too. + xmlPartIDSetting.delete(); + + await context.sync(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.error( + `This is strange. The XML part with the id ${xmlPartIDSetting.value} wasn't deleted:`, + readableXml + ); + } + } else { + console.warn("Didn't find custom XML part to delete."); + } + }); + } + + function addLineBreaksToXML(xmlBlob: string): string { + const replaceValue = new RegExp(">"); + return xmlBlob.replace(/> <"); + } + + // 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: |- +
    +

    This sample shows how to add, query, replace, edit, and delete a custom XML part in a document.

    +

    Note: For your production add-in, make sure to create and host your own XML schema.

    +
    +
    +

    Try it out

    + + + + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-custom-xml-part.yaml b/samples/word/50-document/manage-custom-xml-part.yaml new file mode 100644 index 000000000..630a7587d --- /dev/null +++ b/samples/word/50-document/manage-custom-xml-part.yaml @@ -0,0 +1,214 @@ +order: 11 +id: word-document-manage-custom-xml-part +name: Manage a CustomXmlPart without the namespace +description: This sample shows how to add, query, edit, and delete a custom XML part in a document. +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("add-custom-xml-part").addEventListener("click", () => tryCatch(addCustomXmlPart)); + document.getElementById("query").addEventListener("click", () => tryCatch(query)); + document.getElementById("insert-attribute").addEventListener("click", () => tryCatch(insertAttribute)); + document.getElementById("insert-element").addEventListener("click", () => tryCatch(insertElement)); + document.getElementById("delete-custom-xml-part").addEventListener("click", () => tryCatch(deleteCustomXmlPart)); + + async function addCustomXmlPart() { + // Adds a custom XML part. + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Added custom XML part:", readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); + }); + } + + async function query() { + // Original XML: JuanHongSally + + // Queries a custom XML part for elements matching the search terms. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/Reviewers/Reviewer"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); + + await context.sync(); + + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } + }); + } + + async function insertAttribute() { + // Original XML: JuanHongSally + + // Inserts an attribute into a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertAttribute method inserts an attribute with the given name and value into the element identified by the xpath parameter. + customXmlPart.insertAttribute("/Reviewers", { contoso: "http://schemas.contoso.com/review/1.0" }, "Nation", "US"); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted attribute:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert attribute into."); + } + }); + } + + async function insertElement() { + // Original XML: JuanHongSally + + // Inserts an element into a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertElement method inserts the given XML under the parent element identified by the xpath parameter at the provided child position index. + customXmlPart.insertElement( + "/Reviewers", + "Mark", + { contoso: "http://schemas.contoso.com/review/1.0" }, + 0 + ); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted element:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert element into."); + } + }); + } + + async function deleteCustomXmlPart() { + // Original XML: JuanHongSally + + // Deletes a custom XML part. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.document.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + + await context.sync(); + + if (customXmlPart.isNullObject) { + console.log(`The XML part with the ID ${xmlPartIDSetting.value} has been deleted.`); + + // Delete the associated setting too. + xmlPartIDSetting.delete(); + + await context.sync(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.error(`This is strange. The XML part with the id ${xmlPartIDSetting.value} wasn't deleted:`, readableXml); + } + } else { + console.warn("Didn't find custom XML part to delete."); + } + }); + } + + function addLineBreaksToXML(xmlBlob: string): string { + const replaceValue = new RegExp(">"); + return xmlBlob.replace(/> <"); + } + + // 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: |- +
    +

    This sample shows how to add, query, edit, and delete a custom XML part in a document.

    +

    Note: For your production add-in, make sure to create and host your own XML schema.

    +
    +
    +

    Try it out

    + + + + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-fields.yaml b/samples/word/50-document/manage-fields.yaml new file mode 100644 index 000000000..b60163bee --- /dev/null +++ b/samples/word/50-document/manage-fields.yaml @@ -0,0 +1,242 @@ +order: 8 +id: word-document-manage-fields +name: Manage fields +description: This sample shows how to perform basic operations on fields, including insert, get, and delete. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-date-field").addEventListener("click", () => tryCatch(rangeInsertDateField)); + document.getElementById("get-first").addEventListener("click", () => tryCatch(getFirstField)); + document.getElementById("get-parent-body").addEventListener("click", () => tryCatch(getParentBodyOfFirstField)); + document.getElementById("get-all").addEventListener("click", () => tryCatch(getAllFields)); + document.getElementById("get-selected-field-and-update").addEventListener("click", () => tryCatch(getSelectedFieldAndUpdate)); + document.getElementById("get-selected-field-and-lock-or-unlock").addEventListener("click", () => tryCatch(getFieldAndLockOrUnlock)); + document.getElementById("delete-first-field").addEventListener("click", () => tryCatch(deleteFirstField)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function rangeInsertDateField() { + // Inserts a Date field before selection. + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection().getRange(); + + const field: Word.Field = range.insertField(Word.InsertLocation.before, Word.FieldType.date, '\\@ "M/d/yyyy h:mm am/pm"', true); + + field.load("result,code"); + await context.sync(); + + if (field.isNullObject) { + console.log("There are no fields in this document."); + } else { + console.log("Code of the field: " + field.code, "Result of the field: " + JSON.stringify(field.result)); + } + }); + } + + async function getFirstField() { + // Gets the first field in the document. + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } + }); + } + + async function getParentBodyOfFirstField() { + // Gets the parent body of the first field in the document. + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load("parentBody/text"); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + const parentBody: Word.Body = field.parentBody; + console.log("Text of first field's parent body: " + JSON.stringify(parentBody.text)); + } + }); + } + + async function getAllFields() { + // Gets all fields in the document body. + await Word.run(async (context) => { + const fields: Word.FieldCollection = context.document.body.fields.load("items"); + + await context.sync(); + + if (fields.items.length === 0) { + console.log("No fields in this document."); + } else { + fields.load(["code", "result"]); + await context.sync(); + + for (let i = 0; i < fields.items.length; i++) { + console.log(`Field ${i + 1}'s code: ${fields.items[i].code}`, `Field ${i + 1}'s result: ${JSON.stringify(fields.items[i].result)}`); + } + } + }); + } + + async function getSelectedFieldAndUpdate() { + // Gets and updates the first field in the selection. + await Word.run(async (context) => { + let field = context.document.getSelection().fields.getFirstOrNullObject(); + field.load(["code", "result", "type", "locked"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("No field in selection."); + } else { + console.log("Before updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + + field.updateResult(); + field.select(); + await context.sync(); + + field.load(["code", "result"]); + await context.sync(); + + console.log("After updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + } + }); + } + + async function getFieldAndLockOrUnlock() { + // Gets the first field in the selection and toggles between setting it to locked or unlocked. + await Word.run(async (context) => { + let field = context.document.getSelection().fields.getFirstOrNullObject(); + field.load(["code", "result", "type", "locked"]); + await context.sync(); + + if (field.isNullObject) { + console.log("The selection has no fields."); + } else { + console.log(`The first field in the selection is currently ${field.locked ? "locked" : "unlocked"}.`); + field.locked = !field.locked; + await context.sync(); + + console.log(`The first field in the selection is now ${field.locked ? "locked" : "unlocked"}.`); + } + }); + } + + async function deleteFirstField() { + // Deletes the first field in the document. + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + field.delete(); + await context.sync(); + + console.log("The first field in the document was deleted."); + } + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + }); + } + + // 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: |- +
    +

    This sample demonstrates how to manage fields, which are placeholders for dynamic data in your document. To learn + more about fields, refer to Insert, edit, and view + fields in Word.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Insert fields

    +

    First, select some text.

    +

    +

    Insert a Date field before the selection.
    + +

    +

    Get and update fields

    + + + + +
    +

    +

    Toggle the first field of the selection between locked and unlocked.
    + +

    +

    Delete fields

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-footnotes.yaml b/samples/word/50-document/manage-footnotes.yaml new file mode 100644 index 000000000..20115c5a3 --- /dev/null +++ b/samples/word/50-document/manage-footnotes.yaml @@ -0,0 +1,242 @@ +order: 7 +id: word-document-manage-footnotes +name: Manage footnotes +description: This sample shows how to perform basic footnote operations, including insert, get, and delete. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("insert-footnote").addEventListener("click", () => tryCatch(insertFootnote)); + document.getElementById("get-reference").addEventListener("click", () => tryCatch(getReference)); + document.getElementById("get-footnote-type").addEventListener("click", () => tryCatch(getFootnoteType)); + document.getElementById("get-footnote-body").addEventListener("click", () => tryCatch(getFootnoteBody)); + document.getElementById("get-next-footnote").addEventListener("click", () => tryCatch(getNextFootnote)); + document.getElementById("delete-footnote").addEventListener("click", () => tryCatch(deleteFootnote)); + document.getElementById("get-first-footnote").addEventListener("click", () => tryCatch(getFirstFootnote)); + document.getElementById("get-footnotes-from-body").addEventListener("click", () => tryCatch(getFootnotesFromBody)); + document.getElementById("get-footnotes-from-range").addEventListener("click", () => tryCatch(getFootnotesFromRange)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertFootnote() { + // Sets a footnote on the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("input-footnote") as HTMLInputElement).value; + const footnote: Word.NoteItem = context.document.getSelection().insertFootnote(text); + await context.sync(); + + console.log("Inserted footnote."); + }); + } + async function getReference() { + // Selects the footnote's reference mark in the document body. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/reference"); + await context.sync(); + + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + const reference: Word.Range = item.reference; + reference.select(); + await context.sync(); + + console.log(`Reference ${referenceNumber} is selected.`); + }); + } + async function getFootnoteType() { + // Gets the referenced note's item type and body type, which are both "Footnote". + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); + + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + console.log(`Note type of footnote ${referenceNumber}: ${item.type}`); + + item.body.load("type"); + await context.sync(); + + console.log(`Body type of note: ${item.body.type}`); + }); + } + async function getFootnoteBody() { + // Gets the text of the referenced footnote. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/body"); + await context.sync(); + + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const footnoteBody: Word.Range = footnotes.items[mark].body.getRange(); + footnoteBody.load("text"); + await context.sync(); + + console.log(`Text of footnote ${referenceNumber}: ${footnoteBody.text}`); + }); + } + async function getNextFootnote() { + // Selects the next footnote in the document body. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/reference"); + await context.sync(); + + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const reference: Word.Range = footnotes.items[mark].getNext().reference; + reference.select(); + console.log("Selected is the next footnote: " + (mark + 2)); + }); + } + async function deleteFootnote() { + // Deletes this referenced footnote. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); + + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + footnotes.items[mark].delete(); + await context.sync(); + + console.log("Footnote deleted."); + }); + } + async function getFirstFootnote() { + // Gets the first footnote in the document body and select its reference mark. + await Word.run(async (context) => { + const reference: Word.Range = context.document.body.footnotes.getFirst().reference; + reference.select(); + console.log("The first footnote is selected."); + }); + } + async function getFootnotesFromBody() { + // Gets the footnotes in the document body. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("length"); + await context.sync(); + + console.log("Number of footnotes in the document body: " + footnotes.items.length); + }); + } + async function getFootnotesFromRange() { + // Gets the footnotes in the selected document range. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.getSelection().footnotes; + footnotes.load("length"); + await context.sync(); + + console.log("Number of footnotes in the selected range: " + footnotes.items.length); + }); + } + async function setup() { + // Set two paragraphs of sample text. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + // 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: |- +
    +

    This sample shows basic operations using footnotes.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    Insert footnote

    +

    1. Select text in the document.

    +

    + + + +

    +

    3. Repeat steps 1 and 2 as often as you want.

    +

    Manage existing footnote

    +

    + + +

    +

    Note: Ensure the main document body has focus.

    + + + + + +

    Get footnotes

    + + +

    First, select text in the document. + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-settings.yaml b/samples/word/50-document/manage-settings.yaml new file mode 100644 index 000000000..a14fe7961 --- /dev/null +++ b/samples/word/50-document/manage-settings.yaml @@ -0,0 +1,121 @@ +order: 9 +id: word-document-manage-settings +name: Manage settings +description: This sample shows how to add, edit, get, and delete custom settings on a document. +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("add-edit-setting").addEventListener("click", () => tryCatch(addEditSetting)); + document.getElementById("get-all-settings").addEventListener("click", () => tryCatch(getAllSettings)); + document.getElementById("delete-all-settings").addEventListener("click", () => tryCatch(deleteAllSettings)); + + async function addEditSetting() { + // Adds a new custom setting or + // edits the value of an existing one. + await Word.run(async (context) => { + const key = (document.getElementById("key") as HTMLInputElement).value; + if (key == "") { + console.error("Key shouldn't be empty."); + return; + } + + const value = (document.getElementById("value") as HTMLInputElement).value; + const settings: Word.SettingCollection = context.document.settings; + const setting: Word.Setting = settings.add(key, value); + setting.load(); + await context.sync(); + + console.log("Setting added or edited:", setting); + }); + } + + async function getAllSettings() { + // Gets all custom settings this add-in set on this document. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + settings.load("items"); + await context.sync(); + + if (settings.items.length == 0) { + console.log("There are no settings."); + } else { + console.log("All settings:"); + for (let i = 0; i < settings.items.length; i++) { + console.log(settings.items[i]); + } + } + }); + } + + async function deleteAllSettings() { + // Deletes all custom settings this add-in had set on this document. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + settings.deleteAll(); + await context.sync(); + console.log("All settings deleted."); + }); + } + + // 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: |- +
    +

    This sample shows how to add, edit, get, and delete custom settings on a document. Settings created by an add-in + can + only be managed by that add-in.

    +
    +
    +

    Try it out

    +

    Add a new setting, or edit an existing one

    +
    + + +
    +
    + + +
    + +

    Get all settings

    + +

    Delete all settings

    + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/manage-styles.yaml b/samples/word/50-document/manage-styles.yaml new file mode 100644 index 000000000..0398d69e9 --- /dev/null +++ b/samples/word/50-document/manage-styles.yaml @@ -0,0 +1,342 @@ +order: 12 +id: word-document-manage-styles +name: Manage styles +description: This sample shows how to perform operations on the styles in the current document and how to add and delete custom styles. +host: WORD +api_set: + WordApiDesktop: '1.1' +script: + content: |- + document.getElementById("count").addEventListener("click", () => tryCatch(getCount)); + document.getElementById("add-style").addEventListener("click", () => tryCatch(addStyle)); + document.getElementById("properties").addEventListener("click", () => tryCatch(getProperties)); + document.getElementById("apply-style").addEventListener("click", () => tryCatch(applyStyle)); + document.getElementById("font-properties").addEventListener("click", () => tryCatch(setFontProperties)); + document.getElementById("paragraph-format").addEventListener("click", () => tryCatch(setParagraphFormat)); + document.getElementById("border-properties").addEventListener("click", () => tryCatch(setBorderProperties)); + document.getElementById("shading-properties").addEventListener("click", () => tryCatch(setShadingProperties)); + document.getElementById("delete-style").addEventListener("click", () => tryCatch(deleteStyle)); + + async function getCount() { + // Gets the number of available styles stored with the document. + await Word.run(async (context) => { + const styles: Word.StyleCollection = context.document.getStyles(); + const count = styles.getCount(); + await context.sync(); + + console.log(`Number of styles: ${count.value}`); + }); + } + + async function addStyle() { + // Adds a new style. + await Word.run(async (context) => { + const newStyleName = (document.getElementById("new-style-name") as HTMLInputElement).value; + if (newStyleName == "") { + console.warn("Enter a style name to add."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(newStyleName); + style.load(); + await context.sync(); + + if (!style.isNullObject) { + console.warn( + `There's an existing style with the same name '${newStyleName}'! Please provide another style name.` + ); + return; + } + + const newStyleType = ((document.getElementById("new-style-type") as HTMLSelectElement).value as unknown) as Word.StyleType; + context.document.addStyle(newStyleName, newStyleType); + await context.sync(); + + console.log(newStyleName + " has been added to the style list."); + }); + } + + async function getProperties() { + // Gets the properties of the specified style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + style.font.load(); + style.paragraphFormat.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + } + }); + } + + async function applyStyle() { + // Applies the specified style to a paragraph. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to apply."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else if (style.type != Word.StyleType.paragraph) { + console.log(`The '${styleName}' style isn't a paragraph style.`); + } else { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + const paragraph: Word.Paragraph = body.paragraphs.getFirst(); + paragraph.style = style.nameLocal; + console.log(`'${styleName}' style applied to first paragraph.`); + } + }); + } + + async function setFontProperties() { + // Updates font properties (e.g., color, size) of the specified style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update font properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const font: Word.Font = style.font; + font.color = "#FF0000"; + font.size = 20; + console.log(`Successfully updated font properties of the '${styleName}' style.`); + } + }); + } + + async function setParagraphFormat() { + // Sets certain aspects of the specified style's paragraph format e.g., the left indent size and the alignment. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update its paragraph format."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + style.paragraphFormat.leftIndent = 30; + style.paragraphFormat.alignment = Word.Alignment.centered; + console.log(`Successfully the paragraph format of the '${styleName}' style.`); + } + }); + } + + async function setBorderProperties() { + // Updates border properties (e.g., type, width, color) of the specified style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); + await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } + }); + } + + async function setShadingProperties() { + // Updates shading properties (e.g., texture, pattern colors) of the specified style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update shading properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const shading: Word.Shading = style.shading; + shading.load(); + await context.sync(); + + shading.backgroundPatternColor = "blue"; + shading.foregroundPatternColor = "yellow"; + shading.texture = Word.ShadingTextureType.darkTrellis; + + console.log("Updated shading."); + } + }); + } + + async function deleteStyle() { + // Deletes the custom style. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to delete."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + style.delete(); + console.log(`Successfully deleted custom style '${styleName}'.`); + } + }); + } + + // 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: |- +
    + This sample demonstrates how to manage styles. +
    +
    +

    Try it out

    +

    +

    Get current number of styles

    + +

    +

    Add a custom style

    +
    Give the style an alphanumeric name. Must start with a letter. Examples: NewName, newname1
    +

    + + +

    +

    + + +

    + +

    Use custom style

    + + +

    + +

    + +

    Update custom style

    + + +

    +

    Set font color to red and font size to 20.
    + +

    +

    Set paragraph left indent size to 30 and alignment to center.
    + +

    +

    Set outside border type to dashed, width to pt. 0.25, and color to green.
    + +

    +

    Set texture to DarkTrellis, foreground pattern color to yellow, and background pattern color to blue.
    + +

    Delete custom style

    +

    + + + +

    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/50-document/manage-tracked-changes.yaml b/samples/word/50-document/manage-tracked-changes.yaml new file mode 100644 index 000000000..30307f735 --- /dev/null +++ b/samples/word/50-document/manage-tracked-changes.yaml @@ -0,0 +1,210 @@ +order: 5 +id: word-document-manage-tracked-changes +name: Manage tracked changes +description: This samples shows how to manage tracked changes, including accepting and rejecting changes. +host: WORD +api_set: + WordApi: '1.6' +script: + content: |- + document.getElementById("get-all-tracked-changes").addEventListener("click", () => tryCatch(getAllTrackedChanges)); + document.getElementById("get-first-tracked-change-range").addEventListener("click", () => tryCatch(getFirstTrackedChangeRange)); + document.getElementById("get-next-tracked-change").addEventListener("click", () => tryCatch(getNextTrackedChange)); + document.getElementById("accept-first-tracked-change").addEventListener("click", () => tryCatch(acceptFirstTrackedChange)); + document.getElementById("reject-first-tracked-change").addEventListener("click", () => tryCatch(rejectFirstTrackedChange)); + document.getElementById("accept-all-tracked-changes").addEventListener("click", () => tryCatch(acceptAllTrackedChanges)); + document.getElementById("reject-all-tracked-changes").addEventListener("click", () => tryCatch(rejectAllTrackedChanges)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function getAllTrackedChanges() { + // Gets all tracked changes. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.load(); + await context.sync(); + + console.log(trackedChanges); + }); + } + + async function getFirstTrackedChangeRange() { + // Gets the range of the first tracked change. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + + const range: Word.Range = trackedChange.getRange(); + range.load(); + await context.sync(); + + console.log("range.text: " + range.text); + }); + } + + async function getNextTrackedChange() { + // Gets the next (second) tracked change. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + await context.sync(); + + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + + const nextTrackedChange: Word.TrackedChange = trackedChange.getNext(); + await context.sync(); + + nextTrackedChange.load(["author", "date", "text", "type"]); + await context.sync(); + + console.log(nextTrackedChange); + }); + } + + async function acceptFirstTrackedChange() { + // Accepts the first tracked change. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + trackedChange.load(); + await context.sync(); + + console.log("First tracked change:", trackedChange); + trackedChange.accept(); + console.log("Accepted the first tracked change."); + }); + } + + async function rejectFirstTrackedChange() { + // Rejects the first tracked change. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + trackedChange.load(); + await context.sync(); + + console.log("First tracked change:", trackedChange); + trackedChange.reject(); + console.log("Rejected the first tracked change."); + }); + } + + async function acceptAllTrackedChanges() { + // Accepts all tracked changes. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.acceptAll(); + console.log("Accepted all tracked changes."); + }); + } + + async function rejectAllTrackedChanges() { + // Rejects all tracked changes. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.rejectAll(); + console.log("Rejected all tracked changes."); + }); + } + + async function setup() { + // Updates the text and sets the font color to red. + await Word.run(async (context) => { + context.document.changeTrackingMode = Word.ChangeTrackingMode.off; + + context.document.body.insertText("AAA BBB CCC DDD EEE FFF", "Replace"); + + context.document.changeTrackingMode = Word.ChangeTrackingMode.trackAll; + context.document.body + .search("BBB") + .getFirst() + .insertText("WWW", "Replace"); + context.document.body + .search("DDD ") + .getFirst() + .delete(); + context.document.body + .search("FFF") + .getFirst() + .insertText("XXX ", "Start"); + }); + } + + // 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: |- +
    + This sample shows how to manage tracked changes. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + + + + + +
    +
    +

    First, choose the Add sample text button. + +

    +

    First, choose the Add sample text 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/50-document/save-close.yaml b/samples/word/50-document/save-close.yaml new file mode 100644 index 000000000..5f8f691dc --- /dev/null +++ b/samples/word/50-document/save-close.yaml @@ -0,0 +1,137 @@ +order: 14 +id: word-document-save-close +name: Manage document save and close +description: Shows how to manage saving and closing document. +host: WORD +api_set: + WordApi: '1.5' +script: + content: |- + document.getElementById("save-no-prompt").addEventListener("click", () => tryCatch(saveNoPrompt)); + document.getElementById("save-after-prompt").addEventListener("click", () => tryCatch(saveAfterPrompt)); + document.getElementById("close-after-save").addEventListener("click", () => tryCatch(closeAfterSave)); + document.getElementById("close-no-save").addEventListener("click", () => tryCatch(closeWithoutSave)); + document.getElementById("save").addEventListener("click", () => tryCatch(save)); + document.getElementById("close").addEventListener("click", () => tryCatch(close)); + + async function saveNoPrompt() { + // Saves the document with the provided file name + // if it hasn't been saved before. + await Word.run(async (context) => { + const text = (document.getElementById("fileName-text") as HTMLInputElement).value; + context.document.save(Word.SaveBehavior.save, text); + await context.sync(); + }); + } + + async function saveAfterPrompt() { + // If the document hasn't been saved before, prompts + // user with options for if or how they want to save. + await Word.run(async (context) => { + context.document.save(Word.SaveBehavior.prompt); + await context.sync(); + }); + } + + async function closeAfterSave() { + // Closes the document after saving. + await Word.run(async (context) => { + context.document.close(Word.CloseBehavior.save); + }); + } + + async function closeWithoutSave() { + // Closes the document without saving any changes. + await Word.run(async (context) => { + context.document.close(Word.CloseBehavior.skipSave); + await context.sync(); + }); + } + + async function save() { + // Saves the document with default behavior + // for current state of the document. + await Word.run(async (context) => { + context.document.save(); + await context.sync(); + }); + } + + async function close() { + // Closes the document with default behavior + // for current state of the document. + await Word.run(async (context) => { + context.document.close(); + }); + } + + // 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: |- +
    +

    This sample shows how to use the options for saving and closing the current document.

    +
    +
    +

    Try it out

    +

    + + + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/90-scenarios/correlated-objects-pattern.yaml b/samples/word/90-scenarios/correlated-objects-pattern.yaml new file mode 100644 index 000000000..32b972033 --- /dev/null +++ b/samples/word/90-scenarios/correlated-objects-pattern.yaml @@ -0,0 +1,166 @@ +order: 3 +id: word-scenarios-correlated-objects-pattern +name: Correlated objects pattern +description: Shows the performance benefits of avoiding `context.sync` calls in a loop. +author: OfficeDev +host: WORD +api_set: + WordApi: '1.4' +script: + content: |- + document.getElementById("replace-placeholders").addEventListener("click", () => tryCatch(replacePlaceholders)); + document.getElementById("replace-placeholders-slow").addEventListener("click", () => tryCatch(replacePlaceholdersSlow)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-lots-of-text").addEventListener("click", () => tryCatch(addLotsOfText)); + const jobMapping = [ + { job: "{Coordinator}", person: "Sally" }, + { job: "{Deputy}", person: "Bob" }, + { job: "{Manager}", person: "Kim" } + ]; + async function replacePlaceholders() { + Word.run(async (context) => { + const startTime = Date.now(); + let count = 0; + + // Find the locations of all the placeholder strings. + const allSearchResults = []; + for (let i = 0; i < jobMapping.length; i++) { + let options = Word.SearchOptions.newObject(context); + options.matchWildcards = false; + let searchResults = context.document.body.search(jobMapping[i].job, options); + searchResults.load('items'); + let correlatedSearchResult = { + rangesMatchingJob: searchResults, + personAssignedToJob: jobMapping[i].person + } + allSearchResults.push(correlatedSearchResult); + } + + // Sync to load those locations in the add-in. + await context.sync() + + // Replace the placeholder text at the known locations. + for (let i = 0; i < allSearchResults.length; i++) { + let correlatedObject = allSearchResults[i]; + + for (let j = 0; j < correlatedObject.rangesMatchingJob.items.length; j++) { + let targetRange = correlatedObject.rangesMatchingJob.items[j]; + let name = correlatedObject.personAssignedToJob; + targetRange.insertText(name, Word.InsertLocation.replace); + count++; + } + } + + await context.sync(); + console.log(`Replacing ${count} placeholders with the correlated objects pattern took ${Date.now() - startTime} milliseconds.`); + console.log() + }); + } + async function replacePlaceholdersSlow() { + Word.run(async (context) => { + const startTime = Date.now(); + let count = 0; + + // The context.sync calls in the loops will degrade performance. + for (let i = 0; i < jobMapping.length; i++) { + let options = Word.SearchOptions.newObject(context); + options.matchWildcards = false; + let searchResults = context.document.body.search(jobMapping[i].job, options); + searchResults.load('items'); + + await context.sync(); + + for (let j = 0; j < searchResults.items.length; j++) { + searchResults.items[j].insertText(jobMapping[i].person, Word.InsertLocation.replace); + count++; + await context.sync(); + } + } + console.log(`Replacing ${count} placeholders with in-loop sync statements took ${Date.now() - startTime} milliseconds.`); + }); + } + async function setup(timesToAddText: number = 1) { + await Word.run(async (context) => { + console.log("Setup beginning..."); + const body: Word.Body = context.document.body; + body.clear(); + while (timesToAddText > 0) { + body.insertParagraph( + "This defines the roles of {Coordinator}, {Deputy}, {Manager}.", + Word.InsertLocation.end + ); + body.insertParagraph( + "{Coordinator}: Oversees daily operations and ensures projects run smoothly by coordinating between different teams and resources.", + Word.InsertLocation.end + ); + body.insertParagraph( + "{Deputy}: Assists and supports senior management, often stepping in to make decisions or manage tasks in {Manager}'s absence.", + Word.InsertLocation.end + ); + body.insertParagraph( + "{Manager}: Leads the team, setting goals, planning strategies, and making decisions to achieve organizational objectives.", + Word.InsertLocation.end + ); + timesToAddText--; + } + await context.sync(); + console.log("Setup complete."); + }); + } + async function addLotsOfText() { + // Add the setup text 100 times. + setup(100); + } + // 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: |- +
    +

    This sample demonstrates the performance optimization gained from the correlated objects pattern. For more information, see Avoid using the context.sync method in loops.

    +
    +
    +

    Setup

    +

    Use Setup to create a basic text block with some placeholders. Use More text to create a longer text block to better see performance distinctions.

    + +
    +
    +

    Replace placeholder text

    + + +
    + 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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/samples/word/90-scenarios/doc-assembly.yaml b/samples/word/90-scenarios/doc-assembly.yaml index 6ecee3ef0..186206ba1 100644 --- a/samples/word/90-scenarios/doc-assembly.yaml +++ b/samples/word/90-scenarios/doc-assembly.yaml @@ -8,17 +8,17 @@ api_set: WordApi: '1.1' script: content: |- - $("#insert-header").click(() => tryCatch(insertHeader)); - $("#add-paragraphs").click(() => tryCatch(addParagraphs)); - $("#add-content-controls").click(() => tryCatch(addContentControls)); - $("#change-customer").click(() => tryCatch(changeCustomer)); - $("#add-footer").click(() => tryCatch(addFooter)); + document.getElementById("insert-header").addEventListener("click", () => tryCatch(insertHeader)); + document.getElementById("add-paragraphs").addEventListener("click", () => tryCatch(addParagraphs)); + document.getElementById("add-content-controls").addEventListener("click", () => tryCatch(addContentControls)); + document.getElementById("change-customer").addEventListener("click", () => tryCatch(changeCustomer)); + document.getElementById("add-footer").addEventListener("click", () => tryCatch(addFooter)); async function insertHeader() { await Word.run(async (context) => { - let header = context.document.body.insertText("This is a sample Heading 1 Title!!\n", + const header: Word.Range = context.document.body.insertText("This is a sample Heading 1 Title!!\n", "Start" /*this means at the beginning of the body */); - header.styleBuiltIn = Word.Style.heading1; + header.styleBuiltIn = Word.BuiltInStyleName.heading1; await context.sync(); }); @@ -26,29 +26,29 @@ script: async function addParagraphs() { await Word.run(async (context) => { - let paragraph = context.document.body.insertParagraph("Timeline", "End"); - paragraph.style = "Heading 2"; - let paragraph2 = context.document.body.insertParagraph("The Services shall commence on July 31, 2015, and shall continue through July 29, 2015.", "End"); - paragraph2.style = "Normal"; - let paragraph3 = context.document.body.insertParagraph("Project Costs by Phase", "End"); - paragraph3.style = "Heading 2"; + const paragraph: Word.Paragraph = context.document.body.insertParagraph("Timeline", "End"); + paragraph.styleBuiltIn = "Heading2"; + const paragraph2: Word.Paragraph = context.document.body.insertParagraph("The Services shall commence on July 31, 2015, and shall continue through July 29, 2015.", "End"); + paragraph2.styleBuiltIn = "Normal"; + const paragraph3: Word.Paragraph = context.document.body.insertParagraph("Project Costs by Phase", "End"); + paragraph3.styleBuiltIn = "Heading2"; // Note a content control with the title of "ProjectCosts" is added. Content will be replaced later. - let paragraph4 = context.document.body.insertParagraph("", "End"); - paragraph4.style = "Normal"; + const paragraph4: Word.Paragraph = context.document.body.insertParagraph("", "End"); + paragraph4.styleBuiltIn = "Normal"; paragraph4.font.highlightColor = "#FFFF00"; - let contentControl = paragraph4.insertContentControl(); + const contentControl: Word.ContentControl = paragraph4.insertContentControl(); contentControl.title = "ProjectCosts"; - let paragraph5 = context.document.body.insertParagraph("Project Team", "End"); - paragraph5.style = "Heading 2"; + const paragraph5: Word.Paragraph = context.document.body.insertParagraph("Project Team", "End"); + paragraph5.styleBuiltIn = "Heading2"; paragraph5.font.highlightColor = "#FFFFFF"; - let paragraph6 = context.document.body.insertParagraph("Terms of Work", "End"); - paragraph6.style = "Heading 1"; - let paragraph7 = context.document.body.insertParagraph("Contractor shall provide the Services and Deliverable(s) as follows:", "End"); - paragraph7.style = "Normal"; - let paragraph8 = context.document.body.insertParagraph("Out-of-Pocket Expenses / Invoice Procedures", "End"); - paragraph8.style = "Heading 2"; - let paragraph9 = context.document.body.insertParagraph("Client will be invoiced monthly for the consulting services and T&L expenses. Standard Contractor invoicing is assumed to be acceptable. Invoices are due upon receipt. client will be invoiced all costs associated with out-of-pocket expenses (including, without limitation, costs and expenses associated with meals, lodging, local transportation and any other applicable business expenses) listed on the invoice as a separate line item. Reimbursement for out-of-pocket expenses in connection with performance of this SOW, when authorized and up to the limits set forth in this SOW, shall be in accordance with Client's then-current published policies governing travel and associated business expenses, which information shall be provided by the Client Project Manager.", "End"); - paragraph9.style = "Normal"; + const paragraph6: Word.Paragraph = context.document.body.insertParagraph("Terms of Work", "End"); + paragraph6.styleBuiltIn = "Heading1"; + const paragraph7: Word.Paragraph = context.document.body.insertParagraph("Contractor shall provide the Services and Deliverable(s) as follows:", "End"); + paragraph7.styleBuiltIn = "Normal"; + const paragraph8: Word.Paragraph = context.document.body.insertParagraph("Out-of-Pocket Expenses / Invoice Procedures", "End"); + paragraph8.styleBuiltIn = "Heading2"; + const paragraph9 : Word.Paragraph= context.document.body.insertParagraph("Client will be invoiced monthly for the consulting services and T&L expenses. Standard Contractor invoicing is assumed to be acceptable. Invoices are due upon receipt. client will be invoiced all costs associated with out-of-pocket expenses (including, without limitation, costs and expenses associated with meals, lodging, local transportation and any other applicable business expenses) listed on the invoice as a separate line item. Reimbursement for out-of-pocket expenses in connection with performance of this SOW, when authorized and up to the limits set forth in this SOW, shall be in accordance with Client's then-current published policies governing travel and associated business expenses, which information shall be provided by the Client Project Manager.", "End"); + paragraph9.styleBuiltIn = "Normal"; // Insert a page break at the end of the document. context.document.body.insertBreak("Page", "End"); @@ -56,24 +56,24 @@ script: }); } - // Simulates creation of a template. First searches the document for instances of the string "Contractor", - // then changes the format of each search result, - // then wraps each search result within a content control, - // finally sets a tag and title property on each content control. async function addContentControls() { + // Simulates creation of a template. First searches the document for instances of the string "Contractor", + // then changes the format of each search result, + // then wraps each search result within a content control, + // finally sets a tag and title property on each content control. await Word.run(async (context) => { - let results = context.document.body.search("Contractor"); + const results: Word.RangeCollection = context.document.body.search("Contractor"); results.load("font/bold"); // Check to make sure these content controls haven't been added yet. - let customerContentControls = context.document.contentControls.getByTag("customer"); + const customerContentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("customer"); customerContentControls.load("text"); await context.sync(); if (customerContentControls.items.length === 0) { - for (var i = 0; i < results.items.length; i++) { + for (let i = 0; i < results.items.length; i++) { results.items[i].font.bold = true; - var cc = results.items[i].insertContentControl(); + let cc: Word.ContentControl = results.items[i].insertContentControl(); cc.tag = "customer"; // This value is used in the next step of this sample. cc.title = "Customer Name " + i; } @@ -84,7 +84,7 @@ script: async function changeCustomer() { await Word.run(async (context) => { - let contentControls = context.document.contentControls.getByTag("customer"); + const contentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("customer"); contentControls.load("text"); await context.sync(); @@ -106,7 +106,7 @@ script: }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -119,12 +119,11 @@ script: language: typescript template: content: |- -
    +
    This sample demonstrates how to use the basic document assembly objects. It creates a sample document, searches for text, creates a template, and adds paragraphs and footers.
    - -
    +

    Try it out

    - -
    +

    Try it out

    Set the styling of the first paragraph.

    +
    + 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/beta/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/99-preview-apis/insert-and-change-content-controls.yaml b/samples/word/99-preview-apis/insert-and-change-content-controls.yaml new file mode 100644 index 000000000..c4f5761e8 --- /dev/null +++ b/samples/word/99-preview-apis/insert-and-change-content-controls.yaml @@ -0,0 +1,201 @@ +id: word-insert-and-change-content-controls +name: Content control basics +description: Inserts, updates, and retrieves content controls. +author: OfficeDev +host: WORD +api_set: + WordApi: '1.10' +script: + content: | + document.getElementById("insert-controls").addEventListener("click", () => tryCatch(insertContentControls)); + document.getElementById("change-controls").addEventListener("click", () => tryCatch(modifyContentControls)); + document.getElementById("set-state").addEventListener("click", () => tryCatch(setState)); + document.getElementById("reset-state").addEventListener("click", () => tryCatch(resetState)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + async function insertContentControls() { + // Traverses each paragraph of the document and wraps a content control on each with either a even or odd tags. + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + + await context.sync(); + + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + // For even, tag "even". + if (i % 2 === 0) { + contentControl.tag = "even"; + } else { + contentControl.tag = "odd"; + } + } + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); + } + + async function modifyContentControls() { + // Adds title and colors to odd and even content controls and changes their appearance. + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + let evenContentControls = context.document.contentControls.getByTag("even"); + let oddContentControls = context.document.contentControls.getByTag("odd"); + evenContentControls.load("length"); + oddContentControls.load("length"); + + await context.sync(); + + for (let i = 0; i < evenContentControls.items.length; i++) { + // Change a few properties and append a paragraph. + evenContentControls.items[i].set({ + color: "red", + title: "Odd ContentControl #" + (i + 1), + appearance: Word.ContentControlAppearance.tags + }); + evenContentControls.items[i].insertParagraph("This is an odd content control", "End"); + } + + for (let j = 0; j < oddContentControls.items.length; j++) { + // Change a few properties and append a paragraph. + oddContentControls.items[j].set({ + color: "green", + title: "Even ContentControl #" + (j + 1), + appearance: "Tags" + }); + oddContentControls.items[j].insertHtml("This is an even content control", "End"); + } + + await context.sync(); + }); + } + + async function setState() { + // Sets the state of the first content control. + await Word.run(async (context) => { + const state = ((document.getElementById("state-to-set") as HTMLSelectElement) + .value as unknown) as Word.ContentControlState; + let firstContentControl = context.document.contentControls.getFirstOrNullObject(); + await context.sync(); + + if (firstContentControl.isNullObject) { + console.warn("There are no content controls in this document."); + return; + } + + firstContentControl.setState(state); + firstContentControl.load("id"); + await context.sync(); + + console.log(`Set state of first content control with ID ${firstContentControl.id} to ${state}.`); + }); + } + + async function resetState() { + // Resets the state of the first content control. + await Word.run(async (context) => { + let firstContentControl = context.document.contentControls.getFirstOrNullObject(); + await context.sync(); + + if (firstContentControl.isNullObject) { + console.warn("There are no content controls in this document."); + return; + } + + firstContentControl.resetState(); + firstContentControl.load("id"); + await context.sync(); + + console.log(`Reset state of first content control with ID: ${firstContentControl.id}`); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph("One more paragraph.", "Start"); + body.insertParagraph("Inserting another paragraph.", "Start"); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + + // 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: |- +
    + This sample demonstrates how to insert content controls and change their properties. +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    + Insert content controls on each paragraph. + +

    + Modify content control appearance and content. + +

    Preview features

    + Set state of first content control. +
    + + + +

    + Reset state of first content control. + +

    + 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/beta/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/99-preview-apis/manage-comments.yaml b/samples/word/99-preview-apis/manage-comments.yaml new file mode 100644 index 000000000..8935b24d3 --- /dev/null +++ b/samples/word/99-preview-apis/manage-comments.yaml @@ -0,0 +1,362 @@ +id: word-manage-comments +name: Manage comments +description: This sample shows how to perform operations on comments (including insert, reply, get, edit, resolve, and delete) and use comment events. +host: WORD +api_set: + WordApi: '1.10' +script: + content: |- + document.getElementById("register-event-handlers").addEventListener("click", () => tryCatch(registerEventHandlers)); + document.getElementById("insert").addEventListener("click", () => tryCatch(insertComment)); + document.getElementById("edit").addEventListener("click", () => tryCatch(editFirstCommentInSelection)); + document.getElementById("reply").addEventListener("click", () => tryCatch(replyToFirstActiveCommentInSelection)); + document.getElementById("resolve").addEventListener("click", () => tryCatch(toggleResolvedStatusOfFirstCommentInSelection)); + document.getElementById("range").addEventListener("click", () => tryCatch(getFirstCommentRangeInSelection)); + document.getElementById("get-comments-in-selection").addEventListener("click", () => tryCatch(getCommentsInSelection)); + document.getElementById("get-replies-to-first-comment-in-selection").addEventListener("click", () => tryCatch(getRepliesToFirstCommentInSelection)); + document.getElementById("delete").addEventListener("click", () => tryCatch(deleteFirstCommentInSelection)); + document.getElementById("get-comments").addEventListener("click", () => tryCatch(getComments)); + document.getElementById("deregister-event-handlers").addEventListener("click", () => tryCatch(deregisterEventHandlers)); + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + + let eventContexts = []; + + async function registerEventHandlers() { + // Registers event handlers. + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); + }); + } + + async function insertComment() { + // Sets a comment on the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("comment-text") as HTMLInputElement).value; + const comment: Word.Comment = context.document.getSelection().insertComment(text); + + // Load object to log in the console. + comment.load(); + await context.sync(); + + console.log("Comment inserted:", comment); + }); + } + + async function editFirstCommentInSelection() { + // Edits the first active comment in the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("edit-comment-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (!firstActiveComment) { + console.warn("No active comment was found in the selection, so couldn't edit."); + return; + } + + firstActiveComment.content = text; + + // Load object to log in the console. + firstActiveComment.load(); + await context.sync(); + + console.log("Comment content changed:", firstActiveComment); + }); + } + + async function replyToFirstActiveCommentInSelection() { + // Replies to the first active comment in the selected content. + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } + }); + } + + async function toggleResolvedStatusOfFirstCommentInSelection() { + // Toggles Resolved status of the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document + .getSelection() + .getComments() + .getFirstOrNullObject(); + comment.load("resolved"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to toggle."); + return; + } + + // Toggle resolved status. + // If the comment is active, set as resolved. + // If it's resolved, set resolved to false. + const resolvedBefore = comment.resolved; + console.log(`Comment Resolved status (before): ${resolvedBefore}`); + comment.resolved = !resolvedBefore; + comment.load("resolved"); + await context.sync(); + + console.log(`Comment Resolved status (after): ${comment.resolved}`); + }); + } + + async function getFirstCommentRangeInSelection() { + // Gets the range of the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); + }); + } + + async function getCommentsInSelection() { + // Gets the comments in the selected content. + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + + // Load objects to log in the console. + comments.load(); + await context.sync(); + + console.log("Comments:", comments); + }); + } + + async function getRepliesToFirstCommentInSelection() { + // Gets the replies to the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("replies"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no replies to get."); + return; + } + + const replies: Word.CommentReplyCollection = comment.replies; + console.log("Replies to the first comment:", replies); + }); + } + + async function deleteFirstCommentInSelection() { + // Deletes the first comment in the selected content. + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.delete(); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to delete."); + return; + } + + console.log("Comment deleted."); + }); + } + + async function getComments() { + // Gets the comments in the document body. + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.body.getComments(); + + // Load objects to log in the console. + comments.load(); + await context.sync(); + + console.log("All comments:", comments); + }); + } + + async function deregisterEventHandlers() { + // Deregisters event handlers. + await Word.run(async (context) => { + for (let i = 0; i < eventContexts.length; i++) { + await Word.run(eventContexts[i].context, async (context) => { + eventContexts[i].remove(); + }); + } + + await context.sync(); + + eventContexts = []; + console.log("Removed event handlers."); + }); + } + + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } + + async function onChangedHandler(event: Word.CommentEventArgs) { + await Word.run(async (context) => { + console.log( + `${event.type} event detected. ${event.changeType} change made. Event source: ${event.source}. Comment info:`, event.commentDetails + ); + }); + } + + async function setup() { + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + }); + } + // 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: |- +
    +

    This sample shows operations on comments and how to use comment events.

    +

    Important: Comment events APIs are currently in preview. If this snippet doesn't work, try using + Word + on a different platform.

    +
    +
    +

    Set up

    + +
    +
    +

    Try it out

    +

    + +

    +

    Manage comments in selection

    +

    Select content in document body before proceeding.

    +

    + + + +

    +

    + + + +

    +

    + + + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    Manage comments in document body

    +

    + +

    +

    + +

    +
    + 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/beta/hosted/office.js + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js-preview/index.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/word/default.yaml b/samples/word/default.yaml index 19d5ecb66..d6e45d828 100644 --- a/samples/word/default.yaml +++ b/samples/word/default.yaml @@ -1,13 +1,13 @@ id: word-word-default name: Blank snippet -description: Create a new snippet from a blank template. +description: Creates a new snippet from a blank template. author: OfficeDev host: WORD api_set: WordApi: '1.1' script: - content: | - $("#run").click(() => tryCatch(run)); + content: |- + document.getElementById("run").addEventListener("click", () => tryCatch(run)); async function run() { await Word.run(async (context) => { @@ -19,7 +19,7 @@ script: }); } - /** Default helper for invoking an action and handling errors. */ + // Default helper for invoking an action and handling errors. async function tryCatch(callback) { try { await callback(); @@ -31,7 +31,7 @@ script: } language: typescript template: - content: | + content: |- @@ -49,15 +49,9 @@ style: min-width: 80px; } language: css -libraries: | +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 + https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts - jquery@3.1.1 - @types/jquery@3.3.1 \ No newline at end of file + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css diff --git a/snippet-extractor-metadata/excel.xlsx b/snippet-extractor-metadata/excel.xlsx index f46a80d40..60920aee9 100644 Binary files a/snippet-extractor-metadata/excel.xlsx and b/snippet-extractor-metadata/excel.xlsx differ diff --git a/snippet-extractor-metadata/outlook.xlsx b/snippet-extractor-metadata/outlook.xlsx index 3848989d8..769da162a 100644 Binary files a/snippet-extractor-metadata/outlook.xlsx and b/snippet-extractor-metadata/outlook.xlsx differ diff --git a/snippet-extractor-metadata/powerpoint.xlsx b/snippet-extractor-metadata/powerpoint.xlsx new file mode 100644 index 000000000..d4a1aa15c Binary files /dev/null and b/snippet-extractor-metadata/powerpoint.xlsx differ diff --git a/snippet-extractor-metadata/word.xlsx b/snippet-extractor-metadata/word.xlsx index 91726c835..8ec0f93ba 100644 Binary files a/snippet-extractor-metadata/word.xlsx and b/snippet-extractor-metadata/word.xlsx differ diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml index 8e89fabde..c4136720d 100644 --- a/snippet-extractor-output/snippets.yaml +++ b/snippet-extractor-output/snippets.yaml @@ -1,7 +1,26 @@ -'Excel.Application#decimalSeparator:member': +Excel.AggregationFunction:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/culture-info.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + + + async function genericFunctionSwitch(functionType: + Excel.AggregationFunction) { + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + pivotTable.dataHierarchies.load("no-properties-needed"); + await context.sync(); + + pivotTable.dataHierarchies.items[0].summarizeBy = functionType; + pivotTable.dataHierarchies.items[1].summarizeBy = functionType; + await context.sync(); + }); + } +Excel.Application#decimalSeparator:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml + await Excel.run(async (context) => { context.application.load("decimalSeparator,thousandsSeparator"); @@ -26,56 +45,199 @@ await context.sync(); }); -'Excel.Application#suspendScreenUpdatingUntilNextSync:member(1)': +Excel.Application#calculate:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/90-scenarios/performance-optimization.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/performance-optimization.yaml + await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const rowCount = 500; - const columnCount = 20; + context.application.calculate(Excel.CalculationType.full); + }); +Excel.Application#suspendScreenUpdatingUntilNextSync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/performance-optimization.yaml - const startTime = Date.now(); - console.log("Starting..."); - if (pauseScreenPainting) { - // Note: Don't call `suspendScreenUpdatingUntilNextSync` repeatedly (such as in a loop). - // Repeated calls will cause the Excel window to flicker. - context.application.suspendScreenUpdatingUntilNextSync(); - } + await Excel.run(async (context) => { + // Recreate the data in the worksheet with random data. + const sheet = context.workbook.worksheets.getActiveWorksheet(); - for (let i = 0; i < rowCount; i++) { - for (let j = 0; j < columnCount; j++) { - let cell = sheet.getCell(i, j); - cell.values = [[i * j * Math.random()]]; - if (untrack) { - cell.untrack(); - } - } + const startTime = Date.now(); + console.log("Starting..."); + + // If other parts of the sample have toggled screen painting off, this will stop screen updating until context.sync is called. + if (pauseScreenPainting) { + context.application.suspendScreenUpdatingUntilNextSync(); + } + + for (let i = 1; i < ROW_COUNT; i++) { + for (let j = 1; j < COLUMN_COUNT; j++) { + let cell = sheet.getCell(i, j); + cell.values = [[i * j * Math.random()]]; + + // If other parts of the sample have toggled tracking off, we will avoid tracking this range and having to manage the proxy objects. + // For more information, see https://learn.microsoft.com/office/dev/add-ins/concepts/resource-limits-and-performance-optimization#untrack-unneeded-proxy-objects + if (untrack) { + cell.untrack(); + } } + } + + await context.sync(); + + console.log(`Ending. Adding ${ROW_COUNT * COLUMN_COUNT} cells took ${Date.now() - startTime} milliseconds`); + }); +Excel.ArrowheadLength:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.beginArrowheadLength = Excel.ArrowheadLength.long; + line.beginArrowheadWidth = Excel.ArrowheadWidth.wide; + line.beginArrowheadStyle = Excel.ArrowheadStyle.oval; + + line.endArrowheadLength = Excel.ArrowheadLength.long; + line.endArrowheadWidth = Excel.ArrowheadWidth.wide; + line.endArrowheadStyle = Excel.ArrowheadStyle.triangle; + + await context.sync(); + }); +Excel.ArrowheadStyle:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.beginArrowheadLength = Excel.ArrowheadLength.long; + line.beginArrowheadWidth = Excel.ArrowheadWidth.wide; + line.beginArrowheadStyle = Excel.ArrowheadStyle.oval; + + line.endArrowheadLength = Excel.ArrowheadLength.long; + line.endArrowheadWidth = Excel.ArrowheadWidth.wide; + line.endArrowheadStyle = Excel.ArrowheadStyle.triangle; + + await context.sync(); + }); +Excel.ArrowheadWidth:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.beginArrowheadLength = Excel.ArrowheadLength.long; + line.beginArrowheadWidth = Excel.ArrowheadWidth.wide; + line.beginArrowheadStyle = Excel.ArrowheadStyle.oval; + + line.endArrowheadLength = Excel.ArrowheadLength.long; + line.endArrowheadWidth = Excel.ArrowheadWidth.wide; + line.endArrowheadStyle = Excel.ArrowheadStyle.triangle; await context.sync(); + }); +Excel.AutoFillType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-auto-fill.yaml + - console.log(`Ending. Adding ${rowCount * columnCount} cells took ${Date.now() - startTime} milliseconds`); + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const sumCell = sheet.getRange("K4"); + + // Copy only the formatting, not the values and formulas. + sumCell.autoFill("K4:K7", Excel.AutoFillType.fillFormats); + sumCell.format.autofitColumns(); + await context.sync(); }); -'Excel.AutoFilter#apply:member(1)': +Excel.AutoFilter#apply:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-auto-filter.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function adds a percentage AutoFilter to the active worksheet + + // and applies the filter to a column of the used range. await Excel.run(async (context) => { + // Retrieve the active worksheet and the used range on that worksheet. const sheet = context.workbook.worksheets.getActiveWorksheet(); const farmData = sheet.getUsedRange(); - // This filter will only show the rows with the top 25% of values in column 3. - sheet.autoFilter.apply(farmData, 3, { criterion1: "25", filterOn: Excel.FilterOn.topPercent }); + // Add a filter that will only show the rows with the top 50% of values in column 3. + sheet.autoFilter.apply(farmData, 3, { + criterion1: "50", + filterOn: Excel.FilterOn.topPercent + }); + + await context.sync(); + }); +Excel.AutoFilter#clearColumnCriteria:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function clears the AutoFilter setting from one column. + + await Excel.run(async (context) => { + // Retrieve the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Clear the filter from only column 3. + sheet.autoFilter.clearColumnCriteria(3); + await context.sync(); + }); +Excel.AutoFilter#reapply:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function refreshes the AutoFilter to ensure that changes are + captured. + + await Excel.run(async (context) => { + // Retrieve the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Reapply the filter to capture changes. + sheet.autoFilter.reapply(); + await context.sync(); + }); +Excel.AutoFilter#remove:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function removes all AutoFilters from the active worksheet. + + await Excel.run(async (context) => { + // Retrieve the active worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Remove all filters. + sheet.autoFilter.remove(); await context.sync(); }); -'Excel.Binding#onDataChanged:member': +Excel.Binding#onDataChanged:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/data-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-changed.yaml + await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getItem("Sample"); @@ -87,10 +249,30 @@ await context.sync(); }); -'Excel.CellPropertiesFill#color:member': +Excel.BindingType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-disable-events.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const sumRange = sheet.getRange("B20:P20"); + sumRange.load("columnCount"); + await context.sync(); + + // add an event handler to each cell in the sum range + for (let i = 0; i < sumRange.columnCount; i++) { + let sumBinding = context.workbook.bindings.add(sumRange.getCell(0,i), Excel.BindingType.range, "SumBinding" + i); + sumBinding.onDataChanged.add(onSumChanged); + } + await context.sync(); + }); +Excel.BorderLineStyle:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getActiveWorksheet(); @@ -163,38 +345,11 @@ sheet.getUsedRange().format.autofitColumns(); await context.sync(); }); -'Excel.CellPropertiesFillLoadOptions#color:member': +Excel.BuiltInStyle:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml - - await Excel.run(async (context) => { - const cell = context.workbook.getActiveCell(); - - // Define the cell properties to get by setting the matching LoadOptions to true. - const propertiesToGet = cell.getCellProperties({ - address: true, - format: { - fill: { - color: true - }, - font: { - color: true - } - }, - style: true - }); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml - // Sync to get the data from the workbook. - await context.sync(); - const cellProperties = propertiesToGet.value[0][0]; - console.log( - `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); - }); -'Excel.CellPropertiesFont#color:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getActiveWorksheet(); @@ -267,9497 +422,30134 @@ sheet.getUsedRange().format.autofitColumns(); await context.sync(); }); -'Excel.CellPropertiesFontLoadOptions#color:member': +Excel.CalculationMode:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml - - await Excel.run(async (context) => { - const cell = context.workbook.getActiveCell(); - - // Define the cell properties to get by setting the matching LoadOptions to true. - const propertiesToGet = cell.getCellProperties({ - address: true, - format: { - fill: { - color: true - }, - font: { - color: true - } - }, - style: true - }); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-calculation.yaml - // Sync to get the data from the workbook. - await context.sync(); - const cellProperties = propertiesToGet.value[0][0]; - console.log( - `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); - }); -'Excel.CellPropertiesLoadOptions#address:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml await Excel.run(async (context) => { - const cell = context.workbook.getActiveCell(); - - // Define the cell properties to get by setting the matching LoadOptions to true. - const propertiesToGet = cell.getCellProperties({ - address: true, - format: { - fill: { - color: true - }, - font: { - color: true - } - }, - style: true - }); + context.application.calculationMode = Excel.CalculationMode.manual; + context.application.load("calculationMode"); + await context.sync(); - // Sync to get the data from the workbook. - await context.sync(); - const cellProperties = propertiesToGet.value[0][0]; - console.log( - `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); + console.log("Current calculation mode: " + context.application.calculationMode); }); -'Excel.CellValueConditionalFormat#format:member': +Excel.CalculationType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-calculation.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B21:E23"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.cellValue); - conditionalFormat.cellValue.format.font.color = "red"; - conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; - - await context.sync(); - }); -'Excel.CellValueConditionalFormat#rule:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B21:E23"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.cellValue); - conditionalFormat.cellValue.format.font.color = "red"; - conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; - - await context.sync(); + context.application.calculate(Excel.CalculationType.recalculate); + await context.sync(); }); -'Excel.ChartAxis#displayUnit:member': +Excel.CardLayoutSection:type: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-axis.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml - let chart = sheet.charts.getItemAt(0); - let categoryAxis = chart.axes.categoryAxis; - let valueAxis = chart.axes.valueAxis; - - // Load to get display unit. - valueAxis.load("displayUnit"); - await context.sync(); + function makeProductEntity(productID: number, productName: string, product?: + any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { /* Excel.EntityPropertyType */ + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + } + }, + layouts: { /* Excel.EntityViewLayouts */ + card: { /* Excel.EntityCardLayout */ + title: { property: "Product Name" }, + sections: [ /* Excel.CardLayoutSection */ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + } + ] + } + }, + provider: { + description: product.providerName, // Name of the data provider. Displays as a tooltip when hovering over the logo. Also displays as a fallback if the source address for the image is broken. + logoSourceAddress: product.sourceAddress, // Source URL of the logo to display. + logoTargetAddress: product.targetAddress // Destination URL that the logo navigates to when clicked. + } + }; - console.log("The vertical axis display unit is: " + valueAxis.displayUnit); - }); -'Excel.ChartAxis#showDisplayUnitLabel:member': + return entity; + } +Excel.CellBorder:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-axis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let chart = sheet.charts.getItemAt(0); - let axis = chart.axes.valueAxis; + const sheet = context.workbook.worksheets.getActiveWorksheet(); - // Remove display unit. - axis.showDisplayUnitLabel = false; + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; + + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + sheet.getUsedRange().format.autofitColumns(); await context.sync(); }); -'Excel.ChartFill#setSolidColor:member(1)': +Excel.CellControl:type: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-point.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); + const sheet = context.workbook.worksheets.getActiveWorksheet(); - let pointsCollection = sheet.charts.getItemAt(0).series.getItemAt(0).points; - let point = pointsCollection.getItemAt(2); + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); - // Set color for chart point. - point.format.fill.setSolidColor('red'); + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.CellControlType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml - await context.sync(); + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); }); -'Excel.ChartLegendFormat#font:member': +Excel.CellPropertiesFill#color:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-legend.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); + const sheet = context.workbook.worksheets.getActiveWorksheet(); - let chart = sheet.charts.getItemAt(0); - chart.legend.visible = true; + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; - // Format the legend font. - let font = chart.legend.format.font; - font.bold = true; - font.color = "red"; - font.italic = true; - font.size = 15; - font.name = "Calibri"; - font.underline = "Single"; + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + }); +Excel.CellPropertiesFillLoadOptions#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const cell = context.workbook.getActiveCell(); + + // Define the cell properties to get by setting the matching LoadOptions to true. + const propertiesToGet = cell.getCellProperties({ + address: true, + format: { + fill: { + color: true + }, + font: { + color: true + } + }, + style: true + }); + // Sync to get the data from the workbook. await context.sync(); + const cellProperties = propertiesToGet.value[0][0]; + console.log( + `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); }); -'Excel.ChartSeries#setBubbleSizes:member(1)': +Excel.CellPropertiesFont#color:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-bubble-chart.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; + + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + }); +Excel.CellPropertiesFontLoadOptions#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const cell = context.workbook.getActiveCell(); + + // Define the cell properties to get by setting the matching LoadOptions to true. + const propertiesToGet = cell.getCellProperties({ + address: true, + format: { + fill: { + color: true + }, + font: { + color: true + } + }, + style: true + }); + + // Sync to get the data from the workbook. + await context.sync(); + const cellProperties = propertiesToGet.value[0][0]; + console.log( + `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); + }); +Excel.CellPropertiesLoadOptions#address:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const cell = context.workbook.getActiveCell(); + + // Define the cell properties to get by setting the matching LoadOptions to true. + const propertiesToGet = cell.getCellProperties({ + address: true, + format: { + fill: { + color: true + }, + font: { + color: true + } + }, + style: true + }); + + // Sync to get the data from the workbook. + await context.sync(); + const cellProperties = propertiesToGet.value[0][0]; + console.log( + `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); + }); +Excel.CellValueConditionalFormat#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B21:E23"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + conditionalFormat.cellValue.format.font.color = "red"; + conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.CellValueConditionalFormat#rule:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B21:E23"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + conditionalFormat.cellValue.format.font.color = "red"; + conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.CellValueType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml + + + // This function sets the value of cell A1 to a #BUSY! error using data + types. + + await Excel.run(async (context) => { + // Retrieve the Sample worksheet and cell A1 on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const range = sheet.getRange("A1"); + + // Get the error data type and set its type to `busy`. + const error: Excel.ErrorCellValue = { + type: Excel.CellValueType.error, + errorType: Excel.ErrorCellValueType.busy + }; + + // Set cell A1 as the busy error. + range.valuesAsJson = [[error]]; + await context.sync(); + }); +Excel.Chart#getDataTableOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adds a data table to a chart that already exists on the + worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the data table object for the chart and set it to visible. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load("visible"); + chartDataTable.visible = true; + await context.sync(); + }); +Excel.Chart#onActivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + await Excel.run(async (context) => { + + const pieChart = context.workbook.worksheets.getActiveWorksheet().charts.getItem("Pie"); + + // Register the onActivated and onDeactivated event handlers. + pieChart.onActivated.add(chartActivated); + pieChart.onDeactivated.add(chartDeactivated); + + await context.sync(); + + console.log("Added handlers for Chart onActivated and onDeactivated events."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + async function chartActivated(event) { + await Excel.run(async (context) => { + // Retrieve the worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Retrieve the activated chart by ID and load the name of the chart. + const activatedChart = sheet.charts.getItem(event.chartId); + activatedChart.load(["name"]); + await context.sync(); + + // Print out the activated chart's data. + console.log(`A chart was activated. ID: ${event.chartId}. Chart name: ${activatedChart.name}.`); + }); + } +Excel.Chart#onDeactivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + await Excel.run(async (context) => { + + const pieChart = context.workbook.worksheets.getActiveWorksheet().charts.getItem("Pie"); + + // Register the onActivated and onDeactivated event handlers. + pieChart.onActivated.add(chartActivated); + pieChart.onDeactivated.add(chartDeactivated); + + await context.sync(); + + console.log("Added handlers for Chart onActivated and onDeactivated events."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + async function chartDeactivated(event) { + await Excel.run(async (context) => { + // Callback function for when the chart is deactivated. + console.log("The pie chart is NOT active."); + }); + } +Excel.ChartAxis#displayUnit:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let chart = sheet.charts.getItemAt(0); + let categoryAxis = chart.axes.categoryAxis; + let valueAxis = chart.axes.valueAxis; + + // Load to get display unit. + valueAxis.load("displayUnit"); + + await context.sync(); + + console.log("The vertical axis display unit is: " + valueAxis.displayUnit); + }); +Excel.ChartAxis#showDisplayUnitLabel:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + let chart = sheet.charts.getItemAt(0); + let axis = chart.axes.valueAxis; + + // Remove display unit. + axis.showDisplayUnitLabel = false; + + await context.sync(); + }); +Excel.ChartCollection#onActivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + await Excel.run(async (context) => { + + const pieChart = context.workbook.worksheets.getActiveWorksheet().charts.getItem("Pie"); + + // Register the onActivated and onDeactivated event handlers. + pieChart.onActivated.add(chartActivated); + pieChart.onDeactivated.add(chartDeactivated); + + await context.sync(); + + console.log("Added handlers for Chart onActivated and onDeactivated events."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + async function chartActivated(event) { + await Excel.run(async (context) => { + // Retrieve the worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Retrieve the activated chart by ID and load the name of the chart. + const activatedChart = sheet.charts.getItem(event.chartId); + activatedChart.load(["name"]); + await context.sync(); + + // Print out the activated chart's data. + console.log(`A chart was activated. ID: ${event.chartId}. Chart name: ${activatedChart.name}.`); + }); + } +Excel.ChartCollection#onDeactivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + await Excel.run(async (context) => { + + const pieChart = context.workbook.worksheets.getActiveWorksheet().charts.getItem("Pie"); + + // Register the onActivated and onDeactivated event handlers. + pieChart.onActivated.add(chartActivated); + pieChart.onDeactivated.add(chartDeactivated); + + await context.sync(); + + console.log("Added handlers for Chart onActivated and onDeactivated events."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml + + + async function chartDeactivated(event) { + await Excel.run(async (context) => { + // Callback function for when the chart is deactivated. + console.log("The pie chart is NOT active."); + }); + } +Excel.ChartDataLabel:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml + + + // This function styles substrings within data label text using font + formatting. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.load("points"); + await context.sync(); + + series.points.load("items"); + await context.sync(); + + // Style a substring in the first data label. + let searchString = "sports"; + let dataLabel = series.points.getItemAt(dataLabelInfo[0].index).dataLabel.load("text"); + await context.sync(); + let substringStart = dataLabel.text.indexOf(searchString); + let subLabel = dataLabel.getSubstring(substringStart, searchString.length); + subLabel.font.size = 13; + subLabel.font.bold = true; + + // Style a substring in the second data label. + searchString = "'Titanic'"; + dataLabel = series.points.getItemAt(dataLabelInfo[1].index).dataLabel.load("text"); + await context.sync(); + + substringStart = dataLabel.text.indexOf(searchString); + subLabel = dataLabel.getSubstring(substringStart, searchString.length); + subLabel.font.name = "Calibri"; + subLabel.font.size = 13; + subLabel.font.italic = true; + subLabel.font.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#showHorizontalBorder:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#showLegendKey:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#showOutlineBorder:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#showVerticalBorder:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTable#visible:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adds a data table to a chart that already exists on the + worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the data table object for the chart and set it to visible. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load("visible"); + chartDataTable.visible = true; + await context.sync(); + }); +Excel.ChartDataTableFormat#border:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartDataTableFormat#font:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml + + + // This function adjusts the display and format of a chart data table that + already exists on the worksheet. + + await Excel.run(async (context) => { + // Retrieve the chart named "SalesChart" from the "Sample" worksheet. + const chart = context.workbook.worksheets.getItem("Sample").charts.getItem("SalesChart"); + + // Get the chart data table object and load its properties. + const chartDataTable = chart.getDataTableOrNullObject(); + chartDataTable.load(); + + // Set the display properties of the chart data table. + chartDataTable.showLegendKey = true; + chartDataTable.showHorizontalBorder = false; + chartDataTable.showVerticalBorder = true; + chartDataTable.showOutlineBorder = true; + + // Retrieve the chart data table format object and set font and border properties. + const chartDataTableFormat = chartDataTable.format; + chartDataTableFormat.font.color = "#B76E79"; + chartDataTableFormat.font.name = "Comic Sans"; + chartDataTableFormat.border.color = "blue"; + await context.sync(); + }); +Excel.ChartFill#setSolidColor:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-point.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let pointsCollection = sheet.charts.getItemAt(0).series.getItemAt(0).points; + let point = pointsCollection.getItemAt(2); + + // Set color for chart point. + point.format.fill.setSolidColor('red'); + + await context.sync(); + }); +Excel.ChartLeaderLines:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code changes the format of leader lines. It adjusts color, + weight, and line style. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + const dataLabels = series.dataLabels; + const lineFormat = dataLabels.leaderLines.format; + + // Set leader line formatting properties. + lineFormat.line.color = "blue"; + lineFormat.line.weight = 2; + lineFormat.line.lineStyle = Excel.ChartLineStyle.dot; + + await context.sync(); + }); +Excel.ChartLeaderLinesFormat:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code changes the format of leader lines. It adjusts color, + weight, and line style. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + const dataLabels = series.dataLabels; + const lineFormat = dataLabels.leaderLines.format; + + // Set leader line formatting properties. + lineFormat.line.color = "blue"; + lineFormat.line.weight = 2; + lineFormat.line.lineStyle = Excel.ChartLineStyle.dot; + + await context.sync(); + }); +Excel.ChartLegendFormat#font:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-legend.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let chart = sheet.charts.getItemAt(0); + chart.legend.visible = true; + + // Format the legend font. + let font = chart.legend.format.font; + font.bold = true; + font.color = "red"; + font.italic = true; + font.size = 15; + font.name = "Calibri"; + font.underline = "Single"; + + await context.sync(); + }); +Excel.ChartPoint:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml + + + // This function adds data labels to specific chart points + + // and sets their text and position. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.points.load("dataLabel"); + await context.sync(); + + // Define properties for data label positioning and shape. + const labelProperties = [ + { + top: 70, + geometricShapeType: Excel.GeometricShapeType.rectangle + }, + { + top: 200, + geometricShapeType: Excel.GeometricShapeType.rectangle + } + ]; + + // Add data labels to specific chart points and set their text and properties. + for (let i = 0; i < dataLabelInfo.length; i++) { + const point = series.points.getItemAt(dataLabelInfo[i].index); + point.hasDataLabel = true; + + const dataLabel = point.dataLabel; + dataLabel.text = dataLabelInfo[i].news; + dataLabel.set(labelProperties[i]); + } + await context.sync(); + }); +Excel.ChartPointsCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml + + + // This function adds data labels to specific chart points + + // and sets their text and position. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + await context.sync(); + + const series = chart.series.getItemAt(0); + series.points.load("dataLabel"); + await context.sync(); + + // Define properties for data label positioning and shape. + const labelProperties = [ + { + top: 70, + geometricShapeType: Excel.GeometricShapeType.rectangle + }, + { + top: 200, + geometricShapeType: Excel.GeometricShapeType.rectangle + } + ]; + + // Add data labels to specific chart points and set their text and properties. + for (let i = 0; i < dataLabelInfo.length; i++) { + const point = series.points.getItemAt(dataLabelInfo[i].index); + point.hasDataLabel = true; + + const dataLabel = point.dataLabel; + dataLabel.text = dataLabelInfo[i].news; + dataLabel.set(labelProperties[i]); + } + await context.sync(); + }); +Excel.ChartSeries#getDimensionValues:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // The sample chart is of type `Excel.ChartType.bubble`. + const bubbleChart = sheet.charts.getItem("Product Chart"); + + // Get the first series in the chart. + const firstSeries = bubbleChart.series.getItemAt(0); + + // Get the values for the dimensions we're interested in. + const bubbleSize = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.bubbleSizes); + const xValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.xvalues); + const yValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.yvalues); + const category = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.categories); + + await context.sync(); + + // Log the information. + console.log(`Series ${category.value} - X:${xValues.value},Y:${yValues.value},Bubble:${bubbleSize.value}`); + }); +Excel.ChartSeries#setBubbleSizes:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml + + + await Excel.run(async (context) => { + /* + The table is expected to look like this: + Product, Inventory, Price, Current Market Share + Calamansi, 2000, $2.45, 10% + ... + + We want each bubble to represent a single row. + */ + + // Get the worksheet and table data. + const sheet = context.workbook.worksheets.getItem("Sample"); + const table = sheet.tables.getItem("Sales"); + const dataRange = table.getDataBodyRange(); + + // Get the table data without the row names. + const valueRange = dataRange.getOffsetRange(0, 1).getResizedRange(0, -1); + + // Create the chart. + const bubbleChart = sheet.charts.add(Excel.ChartType.bubble, valueRange); + bubbleChart.name = "Product Chart"; + + // Remove the default series, since we want a unique series for each row. + bubbleChart.series.getItemAt(0).delete(); + + // Load the data necessary to make a chart series. + dataRange.load(["rowCount", "values"]); + await context.sync(); + + // For each row, create a chart series (a bubble). + for (let i = 0; i < dataRange.rowCount; i++) { + const newSeries = bubbleChart.series.add(dataRange.values[i][0], i); + newSeries.setXAxisValues(dataRange.getCell(i, 1)); + newSeries.setValues(dataRange.getCell(i, 2)); + newSeries.setBubbleSizes(dataRange.getCell(i, 3)); + + // Show the product name and market share percentage. + newSeries.dataLabels.showSeriesName = true; + newSeries.dataLabels.showBubbleSize = true; + newSeries.dataLabels.showValue = false; + } + + await context.sync(); + }); +Excel.ChartSeries#getDimensionDataSourceString:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml + + + // This function retrieves the data source information of a chart series in + the Sample worksheet. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Get the first chart series from the first chart on the worksheet. + const seriesCollection = sheet.charts.getItemAt(0).series; + const series = seriesCollection.getItemAt(0); + + // Get the series data source string and type values. + const dataSourceString = series.getDimensionDataSourceString("Values"); + const dataSourceType = series.getDimensionDataSourceType("Values"); + + series.load("name"); + await context.sync(); + + // Log the data source information to the console. + console.log(series.name + " data source string: " + dataSourceString.value); + console.log(series.name + " data source type: " + dataSourceType.value); + }); +Excel.ChartSeries#getDimensionDataSourceType:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml + + + // This function retrieves the data source information of a chart series in + the Sample worksheet. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Get the first chart series from the first chart on the worksheet. + const seriesCollection = sheet.charts.getItemAt(0).series; + const series = seriesCollection.getItemAt(0); + + // Get the series data source string and type values. + const dataSourceString = series.getDimensionDataSourceString("Values"); + const dataSourceType = series.getDimensionDataSourceType("Values"); + + series.load("name"); + await context.sync(); + + // Log the data source information to the console. + console.log(series.name + " data source string: " + dataSourceString.value); + console.log(series.name + " data source type: " + dataSourceType.value); + }); +Excel.ChartSeries:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code adds data labels to the chart and positions them to + demonstrate leader lines. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + + // Enable data labels for the series. Leader lines are enabled by default. + series.hasDataLabels = true; + series.points.load("items"); + await context.sync(); + + // Load the top position for each data label. + series.points.items.forEach((point) => point.dataLabel.load("top")); + await context.sync(); + + // Move some data labels to create distance from their chart points. + const point1 = series.points.items[1]; + const point2 = series.points.items[2]; + point1.dataLabel.top -= 50; + point2.dataLabel.top += 50; + + // Format the data labels. + series.dataLabels.geometricShapeType = Excel.GeometricShapeType.rectangle; + series.dataLabels.showCategoryName = true; + series.dataLabels.format.border.weight = 1; + + await context.sync(); + }); +Excel.ChartSeries#hasDataLabels:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code adds data labels to the chart and positions them to + demonstrate leader lines. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + + // Enable data labels for the series. Leader lines are enabled by default. + series.hasDataLabels = true; + series.points.load("items"); + await context.sync(); + + // Load the top position for each data label. + series.points.items.forEach((point) => point.dataLabel.load("top")); + await context.sync(); + + // Move some data labels to create distance from their chart points. + const point1 = series.points.items[1]; + const point2 = series.points.items[2]; + point1.dataLabel.top -= 50; + point2.dataLabel.top += 50; + + // Format the data labels. + series.dataLabels.geometricShapeType = Excel.GeometricShapeType.rectangle; + series.dataLabels.showCategoryName = true; + series.dataLabels.format.border.weight = 1; + + await context.sync(); + }); +Excel.ChartSeries#points:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code adds data labels to the chart and positions them to + demonstrate leader lines. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + + // Enable data labels for the series. Leader lines are enabled by default. + series.hasDataLabels = true; + series.points.load("items"); + await context.sync(); + + // Load the top position for each data label. + series.points.items.forEach((point) => point.dataLabel.load("top")); + await context.sync(); + + // Move some data labels to create distance from their chart points. + const point1 = series.points.items[1]; + const point2 = series.points.items[2]; + point1.dataLabel.top -= 50; + point2.dataLabel.top += 50; + + // Format the data labels. + series.dataLabels.geometricShapeType = Excel.GeometricShapeType.rectangle; + series.dataLabels.showCategoryName = true; + series.dataLabels.format.border.weight = 1; + + await context.sync(); + }); +Excel.ChartSeries#showLeaderLines:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml + + + // The following code disables leader lines for chart data labels. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem(sheetName); + const chart = sheet.charts.getItemAt(0); + const series = chart.series.getItemAt(0); + const dataLabels = series.dataLabels; + + // Disable leader lines. + dataLabels.showLeaderLines = false; + + await context.sync(); + }); +Excel.ChartSeries#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const seriesCollection = sheet.charts.getItemAt(0).series; + seriesCollection.load("count"); + await context.sync(); + + if (seriesCollection.count > 0) { + const series = seriesCollection.getItemAt(0); + + // Delete the first series. + series.delete(); + } + + await context.sync(); + }); +Excel.ChartSeries#setValues:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let seriesCollection = sheet.charts.getItemAt(0); + let rangeSelection = sheet.getRange("C2:C7"); + let xRangeSelection = sheet.getRange("A1:A7"); + + // Add a series. + let newSeries = seriesCollection.series.add("Qtr2"); + newSeries.setValues(rangeSelection); + newSeries.setXAxisValues(xRangeSelection); + + await context.sync(); + }); +Excel.ChartSeries#markerBackgroundColor:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + let dataRange = sheet.getRange("A1:E7"); + + // Create an XY scatter chart. + let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); + chart.title.text = "Bicycle Parts Quarterly Sales"; + + let series = chart.series; + let series0 = series.getItemAt(0); + let series1 = series.getItemAt(1); + let series2 = series.getItemAt(2); + let series3 = series.getItemAt(3); + + // Set markers. + series0.markerStyle = "Dash"; + series0.markerForegroundColor = "black"; + series1.markerStyle = "Star"; + series1.markerForegroundColor = "black"; + series2.markerStyle = "X"; + series2.markerSize = 12; + series3.markerStyle = "Triangle"; + series3.markerBackgroundColor = "purple"; + + await context.sync(); + }); +Excel.ChartSeries#markerForegroundColor:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + let dataRange = sheet.getRange("A1:E7"); + + // Create an XY scatter chart. + let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); + chart.title.text = "Bicycle Parts Quarterly Sales"; + + let series = chart.series; + let series0 = series.getItemAt(0); + let series1 = series.getItemAt(1); + let series2 = series.getItemAt(2); + let series3 = series.getItemAt(3); + + // Set markers. + series0.markerStyle = "Dash"; + series0.markerForegroundColor = "black"; + series1.markerStyle = "Star"; + series1.markerForegroundColor = "black"; + series2.markerStyle = "X"; + series2.markerSize = 12; + series3.markerStyle = "Triangle"; + series3.markerBackgroundColor = "purple"; + + await context.sync(); + }); +Excel.ChartSeries#markerSize:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + let dataRange = sheet.getRange("A1:E7"); + + // Create an XY scatter chart. + let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); + chart.title.text = "Bicycle Parts Quarterly Sales"; + + let series = chart.series; + let series0 = series.getItemAt(0); + let series1 = series.getItemAt(1); + let series2 = series.getItemAt(2); + let series3 = series.getItemAt(3); + + // Set markers. + series0.markerStyle = "Dash"; + series0.markerForegroundColor = "black"; + series1.markerStyle = "Star"; + series1.markerForegroundColor = "black"; + series2.markerStyle = "X"; + series2.markerSize = 12; + series3.markerStyle = "Triangle"; + series3.markerBackgroundColor = "purple"; + + await context.sync(); + }); +Excel.ChartSeries#markerStyle:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + let dataRange = sheet.getRange("A1:E7"); + + // Create an XY scatter chart. + let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); + chart.title.text = "Bicycle Parts Quarterly Sales"; + + let series = chart.series; + let series0 = series.getItemAt(0); + let series1 = series.getItemAt(1); + let series2 = series.getItemAt(2); + let series3 = series.getItemAt(3); + + // Set markers. + series0.markerStyle = "Dash"; + series0.markerForegroundColor = "black"; + series1.markerStyle = "Star"; + series1.markerForegroundColor = "black"; + series2.markerStyle = "X"; + series2.markerSize = 12; + series3.markerStyle = "Triangle"; + series3.markerBackgroundColor = "purple"; + + await context.sync(); + }); +Excel.ChartSeriesBy:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml + + + await Excel.run(async (context) => { + // Create a new worksheet called "Sample" and activate it. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + // Create an a table named SalesTable on the Sample worksheet. + let expensesTable = sheet.tables.add("A1:E1", true); + expensesTable.name = "SalesTable"; + + expensesTable.getHeaderRowRange().values = [["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"]]; + expensesTable.rows.add(null, [ + ["Frames", 5000, 7000, 6544, 4377], + ["Saddles", 400, 323, 276, 651], + ["Brake levers", 12000, 8766, 8456, 9812], + ["Chains", 1550, 1088, 692, 853], + ["Mirrors", 225, 600, 923, 544], + ["Spokes", 6005, 7634, 4589, 8765] + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + sheet.activate(); + + // Create a line chart based on data from SalesTable. + let dataRange = sheet.getRange("A1:E7"); + let chart = sheet.charts.add("Line", dataRange, Excel.ChartSeriesBy.rows); + + // Position and style the chart. + chart.setPosition("A15", "E30"); + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + + await context.sync(); + }); +Excel.ChartSeriesDimension:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // The sample chart is of type `Excel.ChartType.bubble`. + const bubbleChart = sheet.charts.getItem("Product Chart"); + + // Get the first series in the chart. + const firstSeries = bubbleChart.series.getItemAt(0); + + // Get the values for the dimensions we're interested in. + const bubbleSize = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.bubbleSizes); + const xValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.xvalues); + const yValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.yvalues); + const category = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.categories); + + await context.sync(); + + // Log the information. + console.log(`Series ${category.value} - X:${xValues.value},Y:${yValues.value},Bubble:${bubbleSize.value}`); + }); +Excel.ChartTitle#getSubstring:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-title-format.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let chart = sheet.charts.getItemAt(0); + + // Get first seven characters of the title and color them green. + chart.title.getSubstring(0, 7).font.color = "Yellow"; + await context.sync(); + }); +Excel.ChartTitle#textOrientation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-title-format.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const title = sheet.charts.getItemAt(0).title; + title.textOrientation = -45; + + await context.sync(); + }); +Excel.ChartTrendline#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let seriesCollection = sheet.charts.getItemAt(0).series; + + // Get the trendline for series 1 and load its type property. + let trendline = seriesCollection.getItemAt(0).trendlines.getItem(0); + trendline.load("type"); + + await context.sync(); + + console.log("The trendline type is:" + trendline.type); + }); +Excel.ChartTrendlineCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let seriesCollection = sheet.charts.getItemAt(0).series; + + // Add a trendline. + seriesCollection.getItemAt(0).trendlines.add("Linear"); + + await context.sync(); + }); +Excel.ChartTrendlineFormat#line:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + let seriesCollection = sheet.charts.getItemAt(0).series; + let trendline = seriesCollection.getItemAt(0).trendlines.getItem(0); + + // Set format of the trendline to a solid, red line. + let line = trendline.format.line; + line.color = '#FF0000'; + + await context.sync(); + + console.log("The trendline color has been set to:" + line.color); + }); +Excel.ChartType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-create-several-charts.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + let salesTable = sheet.tables.getItem("SalesTable"); + + let dataRange = sheet.getRange("A1:E7"); + let chart = sheet.charts.add(Excel.ChartType.line, dataRange, "Auto"); + + chart.setPosition("A22", "F35"); + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + chart.title.text = "Bicycle Parts Quarterly Sales"; + + await context.sync(); + }); +Excel.CheckboxCellControl:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.ClearApplyTo:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + const productsRange = sheet.getRange("A3:A11"); + productsRange.load("values"); + + await context.sync(); + + // Clear all hyperlinks. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + + // Clear the hyperlink. + // This removes the hyperlink but does not update text format. + cellRange.clear(Excel.ClearApplyTo.hyperlinks); + + // Update text format. + cellRange.format.font.underline = Excel.RangeUnderlineStyle.none; + cellRange.format.font.color = "#000000"; + } + + await context.sync(); + }); +Excel.CloseBehavior:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml + + + await Excel.run(async (context) => { + context.workbook.close(Excel.CloseBehavior.skipSave); + }); +Excel.ColorScaleConditionalFormat#criteria:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.colorScale); + const criteria = { + minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, + midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, + maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } + }; + conditionalFormat.colorScale.criteria = criteria; + + await context.sync(); + }); +Excel.Comment#content:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + const comment = sheet.comments.getItemAt(0); + comment.content = "PLEASE add headers here."; + await context.sync(); + }); +Excel.Comment#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + + + await Excel.run(async (context) => { + context.workbook.comments.getItemByCell("Comments!A2").delete(); + await context.sync(); + }); +Excel.Comment#load:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + + + await Excel.run(async (context) => { + const comment = context.workbook.comments.getItemByCell("Comments!A2"); + comment.load(["authorEmail", "authorName", "creationDate"]); + await context.sync(); + + console.log(`${comment.creationDate.toDateString()}: ${comment.authorName} (${comment.authorEmail})`); + await context.sync(); + }); +Excel.Comment#resolved:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + sheet.comments.getItemAt(0).resolved = true; + await context.sync(); + }); +Excel.CommentCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + + // Note that an InvalidArgument error will be thrown if multiple cells passed to `comment.add`. + sheet.comments.add("A2", "TODO: add data."); + await context.sync(); + }); +Excel.CommentCollection#onAdded:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + await Excel.run(async (context) => { + const comments = context.workbook.worksheets.getActiveWorksheet().comments; + + // Register the onAdded, onChanged, and onDeleted comment event handlers. + comments.onAdded.add(commentAdded); + comments.onChanged.add(commentChanged); + comments.onDeleted.add(commentDeleted); + + await context.sync(); + + console.log("Added event handlers for when comments are added, changed, or deleted."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + async function commentAdded(event: Excel.CommentAddedEventArgs) { + // Retrieve the added comment using the comment ID. + // Note: This function assumes only a single comment is added at a time. + await Excel.run(async (context) => { + const addedComment = context.workbook.comments.getItem(event.commentDetails[0].commentId); + + // Load the added comment's data. + addedComment.load(["content", "authorName", "creationDate"]); + + await context.sync(); + + // Print out the added comment's data. + console.log(`A comment was added:`); + console.log(` ID: ${event.commentDetails[0].commentId}`); + console.log(` Comment content:${addedComment.content}`); + console.log(` Comment author:${addedComment.authorName}`); + console.log(` Creation date:${addedComment.creationDate}`); + }); + } +Excel.CommentCollection#onChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + await Excel.run(async (context) => { + const comments = context.workbook.worksheets.getActiveWorksheet().comments; + + // Register the onAdded, onChanged, and onDeleted comment event handlers. + comments.onAdded.add(commentAdded); + comments.onChanged.add(commentChanged); + comments.onDeleted.add(commentDeleted); + + await context.sync(); + + console.log("Added event handlers for when comments are added, changed, or deleted."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + async function commentChanged(event: Excel.CommentChangedEventArgs) { + // Retrieve the changed comment using the comment ID. + // Note: This function assumes only a single comment is changed at a time. + await Excel.run(async (context) => { + const changedComment = context.workbook.comments.getItem(event.commentDetails[0].commentId); + + // Load the changed comment's data. + changedComment.load(["content", "authorName", "creationDate"]); + + await context.sync(); + + // Print out the changed comment's data. + console.log(`A comment was changed:`); + console.log(` ID: ${event.commentDetails[0].commentId}`); + console.log(` Updated comment content: ${changedComment.content}`); + console.log(` Comment author: ${changedComment.authorName}`); + console.log(` Creation date: ${changedComment.creationDate}`); + }); + } +Excel.CommentCollection#onDeleted:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + await Excel.run(async (context) => { + const comments = context.workbook.worksheets.getActiveWorksheet().comments; + + // Register the onAdded, onChanged, and onDeleted comment event handlers. + comments.onAdded.add(commentAdded); + comments.onChanged.add(commentChanged); + comments.onDeleted.add(commentDeleted); + + await context.sync(); + + console.log("Added event handlers for when comments are added, changed, or deleted."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml + + + async function commentDeleted(event: Excel.CommentDeletedEventArgs) { + // Print out the deleted comment's ID. + // Note: This function assumes only a single comment is deleted at a time. + await Excel.run(async (context) => { + console.log(`A comment was deleted:`); + console.log(` ID: ${event.commentDetails[0].commentId}`); + }); + } +Excel.CommentReply#content:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + const comment = sheet.comments.getItemAt(0); + const reply = comment.replies.getItemAt(0); + reply.load("content"); + // Sync to load the content of the comment reply. + await context.sync(); + + // Append "Please!" to the end of the comment reply. + reply.content += " Please!"; + await context.sync(); + }); +Excel.CommentReply#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml + + + await Excel.run(async (context) => { + // Remove the first comment reply from this worksheet's first comment. + const sheet = context.workbook.worksheets.getItem("Comments"); + const comment = sheet.comments.getItemAt(0); + comment.replies.getItemAt(0).delete(); + await context.sync(); + }); +Excel.CommentReplyCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml + + + await Excel.run(async (context) => { + // Adds a reply to the first comment in this worksheet. + const sheet = context.workbook.worksheets.getItem("Comments"); + const comment = sheet.comments.getItemAt(0); + comment.replies.add("Add content to this worksheet."); + await context.sync(); + }); +Excel.CommentRichContent#mentions:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + const mention = { + email: "kakri@contoso.com", + id: 0, + name: "Kate Kristensen" + }; + + // This will tag the mention's name using the '@' syntax. + // They will be notified via email. + const commentBody = { + mentions: [mention], + richContent: '' + mention.name + " - Can you take a look?" + }; + + // Note that an InvalidArgument error will be thrown if multiple cells passed to `comment.add`. + sheet.comments.add("A1", commentBody, Excel.ContentType.mention); + await context.sync(); + }); +Excel.ConditionalCellValueRule#formula1:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B21:E23"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + conditionalFormat.cellValue.format.font.color = "red"; + conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.ConditionalCellValueRule#operator:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B21:E23"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + conditionalFormat.cellValue.format.font.color = "red"; + conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.ConditionalDataBarDirection:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.dataBar); + conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight; + + await context.sync(); + }); +Excel.ConditionalFormat#cellValue:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B21:E23"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + conditionalFormat.cellValue.format.font.color = "red"; + conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.ConditionalFormat#colorScale:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.colorScale); + const criteria = { + minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, + midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, + maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } + }; + conditionalFormat.colorScale.criteria = criteria; + + await context.sync(); + }); +Excel.ConditionalFormat#custom:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); + conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; + conditionalFormat.custom.format.font.color = "green"; + + await context.sync(); + }); +Excel.ConditionalFormat#dataBar:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.dataBar); + conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight; + + await context.sync(); + }); +Excel.ConditionalFormat#getRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const worksheetRange = sheet.getRange(); + worksheetRange.conditionalFormats.load("type"); + + await context.sync(); + + let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; + worksheetRange.conditionalFormats.items.forEach(item => { + cfRangePairs.push({ + cf: item, + range: item.getRange().load("address") + }); + }); + + await context.sync(); + + if (cfRangePairs.length > 0) { + cfRangePairs.forEach(item => { + console.log(item.cf.type); + }); + } else { + console.log("No conditional formats applied."); + } + }); +Excel.ConditionalFormat#iconSet:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalFormat#preset:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.presetCriteria); + conditionalFormat.preset.format.font.color = "white"; + conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; + + await context.sync(); + }); +Excel.ConditionalFormat#textComparison:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B16:D18"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.containsText); + conditionalFormat.textComparison.format.font.color = "red"; + conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; + + await context.sync(); + }); +Excel.ConditionalFormat#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const worksheetRange = sheet.getRange(); + worksheetRange.conditionalFormats.load("type"); + + await context.sync(); + + let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; + worksheetRange.conditionalFormats.items.forEach(item => { + cfRangePairs.push({ + cf: item, + range: item.getRange().load("address") + }); + }); + + await context.sync(); + + if (cfRangePairs.length > 0) { + cfRangePairs.forEach(item => { + console.log(item.cf.type); + }); + } else { + console.log("No conditional formats applied."); + } + }); +Excel.ConditionalFormatCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.colorScale); + const criteria = { + minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, + midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, + maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } + }; + conditionalFormat.colorScale.criteria = criteria; + + await context.sync(); + }); +Excel.ConditionalFormatCollection#clearAll:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange(); + range.conditionalFormats.clearAll(); + + await context.sync(); + + document.querySelectorAll(".conditional-formats").forEach(element => { + element.style.display = "none"; + }); + }); +Excel.ConditionalFormatCollection#getItemAt:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const worksheetRange = sheet.getRange(); + worksheetRange.conditionalFormats.load("type"); + + await context.sync(); + + let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; + worksheetRange.conditionalFormats.items.forEach(item => { + cfRangePairs.push({ + cf: item, + range: item.getRange().load("address") + }); + }); + + await context.sync(); + + if (cfRangePairs.length > 0) { + cfRangePairs.forEach(item => { + console.log(item.cf.type); + }); + } else { + console.log("No conditional formats applied."); + } + }); +Excel.ConditionalFormatColorCriterionType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.colorScale); + const criteria = { + minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, + midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, + maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } + }; + conditionalFormat.colorScale.criteria = criteria; + + await context.sync(); + }); +Excel.ConditionalFormatIconRuleType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalFormatPresetCriterion:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + queueCommandsToClearAllConditionalFormats(sheet); + + const temperatureDataRange = sheet.tables.getItem("TemperatureTable").getDataBodyRange(); + + /* When the priority property of ConditionalFormat objects + is not explicitly set, they are prioritized in the order + that they are added, with zero-based numbering: 0, 1, ... + Contradictions are resolved in favor of the format with + the lower priority number. In the example below, negative + numbers will get a green background, but NOT a blue font, + because priority goes to the format that gives them a red font. + */ + + // Set low numbers to bold, dark red font. This format will + // get priority 0. + const presetFormat = temperatureDataRange.conditionalFormats + .add(Excel.ConditionalFormatType.presetCriteria); + presetFormat.preset.format.font.color = "red"; + presetFormat.preset.format.font.bold = true; + presetFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevBelowAverage }; + + // Set negative numbers to blue font with green background. + // This format will get priority 1. + const cellValueFormat = temperatureDataRange.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + cellValueFormat.cellValue.format.font.color = "blue"; + cellValueFormat.cellValue.format.fill.color = "lightgreen"; + cellValueFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.ConditionalFormatRule#formula:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); + conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; + conditionalFormat.custom.format.font.color = "green"; + + await context.sync(); + }); +Excel.ConditionalFormatType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + queueCommandsToClearAllConditionalFormats(sheet); + + const temperatureDataRange = sheet.tables.getItem("TemperatureTable").getDataBodyRange(); + + /* When the priority property of ConditionalFormat objects + is not explicitly set, they are prioritized in the order + that they are added, with zero-based numbering: 0, 1, ... + Contradictions are resolved in favor of the format with + the lower priority number. In the example below, negative + numbers will get a green background, but NOT a blue font, + because priority goes to the format that gives them a red font. + */ + + // Set low numbers to bold, dark red font. This format will + // get priority 0. + const presetFormat = temperatureDataRange.conditionalFormats + .add(Excel.ConditionalFormatType.presetCriteria); + presetFormat.preset.format.font.color = "red"; + presetFormat.preset.format.font.bold = true; + presetFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevBelowAverage }; + + // Set negative numbers to blue font with green background. + // This format will get priority 1. + const cellValueFormat = temperatureDataRange.conditionalFormats + .add(Excel.ConditionalFormatType.cellValue); + cellValueFormat.cellValue.format.font.color = "blue"; + cellValueFormat.cellValue.format.fill.color = "lightgreen"; + cellValueFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; + + await context.sync(); + }); +Excel.ConditionalIconCriterion#formula:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalIconCriterion#operator:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalIconCriterion#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalIconCriterionOperator:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.ConditionalPresetCriteriaRule#criterion:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.presetCriteria); + conditionalFormat.preset.format.font.color = "white"; + conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; + + await context.sync(); + }); +Excel.ConditionalTextComparisonRule#text:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B16:D18"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.containsText); + conditionalFormat.textComparison.format.font.color = "red"; + conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; + + await context.sync(); + }); +Excel.ConditionalTextOperator:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B16:D18"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.containsText); + conditionalFormat.textComparison.format.font.color = "red"; + conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; + + await context.sync(); + }); +Excel.ConnectorType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.addLine(200, 50, 300, 150, Excel.ConnectorType.straight); + line.name = "StraightLine"; + await context.sync(); + }); +Excel.ContentType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Comments"); + const mention = { + email: "kakri@contoso.com", + id: 0, + name: "Kate Kristensen" + }; + + // This will tag the mention's name using the '@' syntax. + // They will be notified via email. + const commentBody = { + mentions: [mention], + richContent: '' + mention.name + " - Can you take a look?" + }; + + // Note that an InvalidArgument error will be thrown if multiple cells passed to `comment.add`. + sheet.comments.add("A1", commentBody, Excel.ContentType.mention); + await context.sync(); + }); +Excel.CultureInfo#datetimeFormat:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info-date-time.yaml + + + await Excel.run(async (context) => { + context.application.cultureInfo.datetimeFormat.load([ + "longDatePattern", + "shortDatePattern", + "dateSeparator", + "longTimePattern", + "timeSeparator" + ]); + await context.sync(); + + // Use the cultural settings API to retrieve the user's system date and time settings. + const systemLongDatePattern = context.application.cultureInfo.datetimeFormat.longDatePattern; + const systemShortDatePattern = context.application.cultureInfo.datetimeFormat.shortDatePattern; + const systemDateSeparator = context.application.cultureInfo.datetimeFormat.dateSeparator; + const systemLongTimePattern = context.application.cultureInfo.datetimeFormat.longTimePattern; + const systemTimeSeparator = context.application.cultureInfo.datetimeFormat.timeSeparator; + + // Write the date and time settings in your table. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const dateTimeData = sheet.getRange("A2:B6"); + dateTimeData.values = [ + ["Long date", systemLongDatePattern], + ["Short date", systemShortDatePattern], + ["Date separator", systemDateSeparator], + ["Long time format", systemLongTimePattern], + ["Time separator", systemTimeSeparator] + ]; + + sheet.tables + .getItemAt(0) + .getRange() + .format.autofitColumns(); + + await context.sync(); + }); +Excel.CustomConditionalFormat#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); + conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; + conditionalFormat.custom.format.font.color = "green"; + + await context.sync(); + }); +Excel.CustomPropertyCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml + + + await Excel.run(async (context) => { + // Get the key/value pair from the task pane. + const userKey = document.getElementById("key").textContent; + const userValue = document.getElementById("value").textContent; + + // Add the custom property. + const customDocProperties = context.workbook.properties.custom; + customDocProperties.add(userKey, userValue); + + await context.sync(); + + console.log(`Successfully set custom document property ${userKey}:${userValue}.`); + }); +Excel.CustomXmlPart#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.workbook.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + + await context.sync(); + + if (customXmlPart.isNullObject) { + document.getElementById("display-xml").textContent = `The XML part with the id ${xmlPartIDSetting.value} has been deleted.`; + + // Delete the unneeded setting too. + xmlPartIDSetting.delete(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + const strangeMessage = `This is strange. The XML part with the id ${xmlPartIDSetting.value} has not been deleted:\n${readableXml}` + document.getElementById("display-xml").textContent = strangeMessage; + } + + await context.sync(); + } + }); +Excel.CustomXmlPart#getXml:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + // You must have the xmlns attribute to populate the + // CustomXml.namespaceUri property. + const originalXml = "JuanHongSally"; + const customXmlPart = context.workbook.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + document.getElementById("display-xml").textContent = readableXml; + + // Store the XML part's ID in a setting. + const settings = context.workbook.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); + }); +Excel.CustomXmlPart#id:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + // You must have the xmlns attribute to populate the + // CustomXml.namespaceUri property. + const originalXml = "JuanHongSally"; + const customXmlPart = context.workbook.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + document.getElementById("display-xml").textContent = readableXml; + + // Store the XML part's ID in a setting. + const settings = context.workbook.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); + }); +Excel.CustomXmlPart#setXml:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + + // The setXml method does a whole-for-whole replacement + // of the entire XML. + customXmlPart.setXml("JohnHitomi"); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + document.getElementById("display-xml").textContent = readableXml; + await context.sync(); + } + }); +Excel.CustomXmlPartCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + // You must have the xmlns attribute to populate the + // CustomXml.namespaceUri property. + const originalXml = "JuanHongSally"; + const customXmlPart = context.workbook.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + document.getElementById("display-xml").textContent = readableXml; + + // Store the XML part's ID in a setting. + const settings = context.workbook.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); + }); +Excel.CustomXmlPartCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + + // The setXml method does a whole-for-whole replacement + // of the entire XML. + customXmlPart.setXml("JohnHitomi"); + const xmlBlob = customXmlPart.getXml(); + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + document.getElementById("display-xml").textContent = readableXml; + await context.sync(); + } + }); +Excel.CustomXmlPartCollection#getByNamespace:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + + + await Excel.run(async (context) => { + document.getElementById("display-xml").textContent = ""; + const contosoNamespace = "http://schemas.contoso.com/review/1.0"; + const customXmlParts = context.workbook.customXmlParts; + const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); + const numberOfPartsInNamespace = filteredXmlParts.getCount(); + + await context.sync(); + + if (numberOfPartsInNamespace.value == 1) { + const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); + const xmlBlob = onlyXmlPartInNamespace.getXml(); + + await context.sync(); + + // Make it a bit more readable. + const readableXml = xmlBlob.value.replace(/>\n<"); + + document.getElementById("display-xml").textContent = `The only XML part in the namespace ${contosoNamespace} is: + ${readableXml}`; + + } else { + console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); + } + + await context.sync(); + }); +Excel.CustomXmlPartScopedCollection#getItemOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.workbook.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + + await context.sync(); + + if (customXmlPart.isNullObject) { + document.getElementById("display-xml").textContent = `The XML part with the id ${xmlPartIDSetting.value} has been deleted.`; + + // Delete the unneeded setting too. + xmlPartIDSetting.delete(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + const strangeMessage = `This is strange. The XML part with the id ${xmlPartIDSetting.value} has not been deleted:\n${readableXml}` + document.getElementById("display-xml").textContent = strangeMessage; + } + + await context.sync(); + } + }); +Excel.CustomXmlPartScopedCollection#getCount:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + + + await Excel.run(async (context) => { + document.getElementById("display-xml").textContent = ""; + const contosoNamespace = "http://schemas.contoso.com/review/1.0"; + const customXmlParts = context.workbook.customXmlParts; + const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); + const numberOfPartsInNamespace = filteredXmlParts.getCount(); + + await context.sync(); + + if (numberOfPartsInNamespace.value == 1) { + const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); + const xmlBlob = onlyXmlPartInNamespace.getXml(); + + await context.sync(); + + // Make it a bit more readable. + const readableXml = xmlBlob.value.replace(/>\n<"); + + document.getElementById("display-xml").textContent = `The only XML part in the namespace ${contosoNamespace} is: + ${readableXml}`; + + } else { + console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); + } + + await context.sync(); + }); +Excel.CustomXmlPartScopedCollection#getOnlyItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + + + await Excel.run(async (context) => { + document.getElementById("display-xml").textContent = ""; + const contosoNamespace = "http://schemas.contoso.com/review/1.0"; + const customXmlParts = context.workbook.customXmlParts; + const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); + const numberOfPartsInNamespace = filteredXmlParts.getCount(); + + await context.sync(); + + if (numberOfPartsInNamespace.value == 1) { + const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); + const xmlBlob = onlyXmlPartInNamespace.getXml(); + + await context.sync(); + + // Make it a bit more readable. + const readableXml = xmlBlob.value.replace(/>\n<"); + + document.getElementById("display-xml").textContent = `The only XML part in the namespace ${contosoNamespace} is: + ${readableXml}`; + + } else { + console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); + } + + await context.sync(); + }); +Excel.DataBarConditionalFormat#barDirection:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.dataBar); + conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight; + + await context.sync(); + }); +Excel.DataPivotHierarchy#showAs:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm"); + const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale"); + + farmDataHierarchy.load("showAs"); + wholesaleDataHierarchy.load("showAs"); + await context.sync(); + + // Show the crates of each fruit type sold at the farm as a percentage of the column's total. + let farmShowAs = farmDataHierarchy.showAs; + farmShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; + farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); + farmDataHierarchy.showAs = farmShowAs; + + let wholesaleShowAs = wholesaleDataHierarchy.showAs; + wholesaleShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; + wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); + wholesaleDataHierarchy.showAs = wholesaleShowAs; + await context.sync(); + }); +Excel.DataPivotHierarchy#name:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + const dataHierarchies = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales").dataHierarchies + dataHierarchies.load("no-properties-needed"); + await context.sync(); + + dataHierarchies.items[0].name = "Farm Sales"; + dataHierarchies.items[1].name = "Wholesale"; + await context.sync(); + }); +Excel.DataValidationErrorAlert:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + rankingRange.dataValidation.clear(); + + let greaterThanZeroRule = { + wholeNumber: { + formula1: 0, + operator: Excel.DataValidationOperator.greaterThan + } + }; + rankingRange.dataValidation.rule = greaterThanZeroRule; + + rankingRange.dataValidation.prompt = { + message: "Please enter a positive number.", + showPrompt: true, + title: "Positive numbers only." + }; + + rankingRange.dataValidation.errorAlert = { + message: "Sorry, only positive numbers are allowed", + showAlert: true, + style: "Stop", + title: "Negative Number Entered" + }; + + await context.sync(); + }); +Excel.DataValidation#errorAlert:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const commentsRange = + sheet.tables.getItem("NameOptionsTable").columns.getItem("Comments").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + commentsRange.dataValidation.clear(); + + // If the value of A2 is contained in the value of C2, then + // SEARCH(A2,C2) returns the number where it begins. Otherwise, + // it does not return a number. + let redundantStringRule = { + custom: { + formula: "=NOT(ISNUMBER(SEARCH(A2,C2)))" + } + }; + commentsRange.dataValidation.rule = redundantStringRule; + commentsRange.dataValidation.errorAlert = { + message: "It is redundant to include the baby name in the comment.", + showAlert: true, + style: "Information", + title: "Baby Name in Comment" + }; + + await context.sync(); + }); +Excel.DataValidation#prompt:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + rankingRange.dataValidation.clear(); + + let greaterThanZeroRule = { + wholeNumber: { + formula1: 0, + operator: Excel.DataValidationOperator.greaterThan + } + }; + rankingRange.dataValidation.rule = greaterThanZeroRule; + + rankingRange.dataValidation.prompt = { + message: "Please enter a positive number.", + showPrompt: true, + title: "Positive numbers only." + }; + + rankingRange.dataValidation.errorAlert = { + message: "Sorry, only positive numbers are allowed", + showAlert: true, + style: "Stop", + title: "Negative Number Entered" + }; + + await context.sync(); + }); +Excel.DataValidation#rule:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const nameRange = + sheet.tables.getItem("NameOptionsTable").columns.getItem("Baby Name").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + nameRange.dataValidation.clear(); + + const nameSourceRange = context.workbook.worksheets.getItem("Names").getRange("A1:A3"); + + let approvedListRule = { + list: { + inCellDropDown: true, + source: nameSourceRange + } + }; + nameRange.dataValidation.rule = approvedListRule; + + await context.sync(); + }); +Excel.DataValidationOperator:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + rankingRange.dataValidation.clear(); + + let greaterThanZeroRule = { + wholeNumber: { + formula1: 0, + operator: Excel.DataValidationOperator.greaterThan + } + }; + rankingRange.dataValidation.rule = greaterThanZeroRule; + + rankingRange.dataValidation.prompt = { + message: "Please enter a positive number.", + showPrompt: true, + title: "Positive numbers only." + }; + + rankingRange.dataValidation.errorAlert = { + message: "Sorry, only positive numbers are allowed", + showAlert: true, + style: "Stop", + title: "Negative Number Entered" + }; + + await context.sync(); + }); +Excel.DataValidationRule#list:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const nameRange = + sheet.tables.getItem("NameOptionsTable").columns.getItem("Baby Name").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + nameRange.dataValidation.clear(); + + const nameSourceRange = context.workbook.worksheets.getItem("Names").getRange("A1:A3"); + + let approvedListRule = { + list: { + inCellDropDown: true, + source: nameSourceRange + } + }; + nameRange.dataValidation.rule = approvedListRule; + + await context.sync(); + }); +Excel.DataValidationRule#wholeNumber:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Decision"); + const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); + + // When you are developing, it is a good practice to + // clear the dataValidation object with each run of your code. + rankingRange.dataValidation.clear(); + + let greaterThanZeroRule = { + wholeNumber: { + formula1: 0, + operator: Excel.DataValidationOperator.greaterThan + } + }; + rankingRange.dataValidation.rule = greaterThanZeroRule; + + rankingRange.dataValidation.prompt = { + message: "Please enter a positive number.", + showPrompt: true, + title: "Positive numbers only." + }; + + rankingRange.dataValidation.errorAlert = { + message: "Sorry, only positive numbers are allowed", + showAlert: true, + style: "Stop", + title: "Negative Number Entered" + }; + + await context.sync(); + }); +Excel.DateFilterCondition:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a date-based PivotFilter. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. + // If it's not already there, add "Date Updated" to the hierarchies. + let dateHierarchy = pivotTable.rowHierarchies.getItemOrNullObject("Date Updated"); + await context.sync(); + if (dateHierarchy.isNullObject) { + dateHierarchy = pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Date Updated")); + } + + // Apply a date filter to filter out anything logged before August. + const filterField = dateHierarchy.fields.getItem("Date Updated"); + const dateFilter = { + condition: Excel.DateFilterCondition.afterOrEqualTo, + comparator: { + date: "2020-08-01", + specificity: Excel.FilterDatetimeSpecificity.month + } + }; + filterField.applyFilter({ dateFilter: dateFilter }); + + await context.sync(); + }); +Excel.DeleteShiftDirection:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + + + // This function deletes data from a range and sets the delete shift + direction to "up". + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("A5:F5"); + range.delete(Excel.DeleteShiftDirection.up); + }); +Excel.DocumentProperties#custom:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml + + + await Excel.run(async (context) => { + // Load the keys and values of all custom properties. + const customDocProperties = context.workbook.properties.custom; + customDocProperties.load(["key", "value"]); + await context.sync(); + + // Log each custom property to the console. + // Note that your document may have more properties than those you have set using this snippet. + customDocProperties.items.forEach((property) => { + console.log(`${property.key}:${property.value}`); + }); + }); +Excel.DoubleCellValue#numberFormat:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + + + // This function creates a double data type, + + // and sets the format of this data type as a currency. + + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const currencyRange = sheet.getRange("A2"); + + // Write a number formatted as currency to cell A2. + currencyRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 12.34, + numberFormat: "$* #,##0.00" + } + ] + ]; + + await context.sync(); + }); +Excel.DoubleCellValue#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + + + // This function creates a double data type, + + // and sets the format of this data type as a date. + + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const dateRange = sheet.getRange("A1"); + + // Write a number formatted as a date to cell A1. + dateRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 32889.0, + numberFormat: "m/d/yyyy" + } + ] + ]; + await context.sync(); + }); +Excel.DynamicFilterCriteria:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/filter-data.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + const expensesTable = sheet.tables.getItem("ExpensesTable"); + + let filter = expensesTable.columns.getItem("Amount").filter; + filter.apply({ + filterOn: Excel.FilterOn.dynamic, + dynamicCriteria: Excel.DynamicFilterCriteria.belowAverage + }); + + filter = expensesTable.columns.getItem("Category").filter; + filter.apply({ + filterOn: Excel.FilterOn.values, + values: ["Restaurant", "Groceries"] + }); + + await context.sync(); + }); +Excel.EntityCardLayout:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml + + + function makeProductEntity(productID: number, productName: string, product?: + any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { /* Excel.EntityPropertyType */ + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + } + }, + layouts: { /* Excel.EntityViewLayouts */ + card: { /* Excel.EntityCardLayout */ + title: { property: "Product Name" }, + sections: [ /* Excel.CardLayoutSection */ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + } + ] + } + }, + provider: { + description: product.providerName, // Name of the data provider. Displays as a tooltip when hovering over the logo. Also displays as a fallback if the source address for the image is broken. + logoSourceAddress: product.sourceAddress, // Source URL of the logo to display. + logoTargetAddress: product.targetAddress // Destination URL that the logo navigates to when clicked. + } + }; + + return entity; + } +Excel.EntityCompactLayoutIcons:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-icons.yaml + + + function createEntitiesWithIcons(icons): Excel.EntityCellValue[][] { + /* This method creates an entity data type for each + * icon in the `EntityCompactLayoutIcons` enum, + * and then displays the icon name with its icon. + */ + let entities = []; + icons.forEach(function(iconName, index, array) { + let icon = iconNames[iconName]; + entities.push([ + { + type: "Entity", + text: iconName, + properties: {}, + layouts: { + compact: { + icon + } + } + } + ]); + }); + return entities; + } +Excel.EntityPropertyType:type: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml + + + function makeProductEntity(productID: number, productName: string, product?: + any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { /* Excel.EntityPropertyType */ + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + } + }, + layouts: { /* Excel.EntityViewLayouts */ + card: { /* Excel.EntityCardLayout */ + title: { property: "Product Name" }, + sections: [ /* Excel.CardLayoutSection */ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + } + ] + } + }, + provider: { + description: product.providerName, // Name of the data provider. Displays as a tooltip when hovering over the logo. Also displays as a fallback if the source address for the image is broken. + logoSourceAddress: product.sourceAddress, // Source URL of the logo to display. + logoTargetAddress: product.targetAddress // Destination URL that the logo navigates to when clicked. + } + }; + + return entity; + } +Excel.EntityViewLayouts:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml + + + function makeProductEntity(productID: number, productName: string, product?: + any) { + const entity: Excel.EntityCellValue = { + type: Excel.CellValueType.entity, + text: productName, + properties: { /* Excel.EntityPropertyType */ + "Product ID": { + type: Excel.CellValueType.string, + basicValue: productID.toString() || "" + }, + "Product Name": { + type: Excel.CellValueType.string, + basicValue: productName || "" + }, + "Quantity Per Unit": { + type: Excel.CellValueType.string, + basicValue: product.quantityPerUnit || "" + }, + // Add Unit Price as a formatted number. + "Unit Price": { + type: Excel.CellValueType.formattedNumber, + basicValue: product.unitPrice, + numberFormat: "$* #,##0.00" + } + }, + layouts: { /* Excel.EntityViewLayouts */ + card: { /* Excel.EntityCardLayout */ + title: { property: "Product Name" }, + sections: [ /* Excel.CardLayoutSection */ + { + layout: "List", + properties: ["Product ID"] + }, + { + layout: "List", + title: "Quantity and price", + collapsible: true, + collapsed: false, + properties: ["Quantity Per Unit", "Unit Price"] + } + ] + } + }, + provider: { + description: product.providerName, // Name of the data provider. Displays as a tooltip when hovering over the logo. Also displays as a fallback if the source address for the image is broken. + logoSourceAddress: product.sourceAddress, // Source URL of the logo to display. + logoTargetAddress: product.targetAddress // Destination URL that the logo navigates to when clicked. + } + }; + + return entity; + } +Excel.ErrorCellValue:type: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml + + + // This function sets the value of cell A1 to a #BUSY! error using data + types. + + await Excel.run(async (context) => { + // Retrieve the Sample worksheet and cell A1 on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const range = sheet.getRange("A1"); + + // Get the error data type and set its type to `busy`. + const error: Excel.ErrorCellValue = { + type: Excel.CellValueType.error, + errorType: Excel.ErrorCellValueType.busy + }; + + // Set cell A1 as the busy error. + range.valuesAsJson = [[error]]; + await context.sync(); + }); +Excel.ErrorCellValueType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml + + + // This function sets the value of cell A1 to a #BUSY! error using data + types. + + await Excel.run(async (context) => { + // Retrieve the Sample worksheet and cell A1 on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const range = sheet.getRange("A1"); + + // Get the error data type and set its type to `busy`. + const error: Excel.ErrorCellValue = { + type: Excel.CellValueType.error, + errorType: Excel.ErrorCellValueType.busy + }; + + // Set cell A1 as the busy error. + range.valuesAsJson = [[error]]; + await context.sync(); + }); +Excel.FillPattern:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; + + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + }); +Excel.FilterCriteria#filterOn:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function adds a percentage AutoFilter to the active worksheet + + // and applies the filter to a column of the used range. + + await Excel.run(async (context) => { + // Retrieve the active worksheet and the used range on that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const farmData = sheet.getUsedRange(); + + // Add a filter that will only show the rows with the top 50% of values in column 3. + sheet.autoFilter.apply(farmData, 3, { + criterion1: "50", + filterOn: Excel.FilterOn.topPercent + }); + + await context.sync(); + }); +Excel.FilterDatetimeSpecificity:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a date-based PivotFilter. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. + // If it's not already there, add "Date Updated" to the hierarchies. + let dateHierarchy = pivotTable.rowHierarchies.getItemOrNullObject("Date Updated"); + await context.sync(); + if (dateHierarchy.isNullObject) { + dateHierarchy = pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Date Updated")); + } + + // Apply a date filter to filter out anything logged before August. + const filterField = dateHierarchy.fields.getItem("Date Updated"); + const dateFilter = { + condition: Excel.DateFilterCondition.afterOrEqualTo, + comparator: { + date: "2020-08-01", + specificity: Excel.FilterDatetimeSpecificity.month + } + }; + filterField.applyFilter({ dateFilter: dateFilter }); + + await context.sync(); + }); +Excel.Functions:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-built-in-functions.yaml + + + await Excel.run(async (context) => { + // This function uses VLOOKUP to find data in the "Wrench" row on the worksheet. + let range = context.workbook.worksheets.getItem("Sample").getRange("A1:D4"); + + // Get the value in the second column in the "Wrench" row. + let unitSoldInNov = context.workbook.functions.vlookup("Wrench", range, 2, false); + unitSoldInNov.load("value"); + + await context.sync(); + console.log(" Number of wrenches sold in November = " + unitSoldInNov.value); + }); +Excel.Functions#vlookup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-built-in-functions.yaml + + + await Excel.run(async (context) => { + // This function uses VLOOKUP to find data in the "Wrench" row on the worksheet. + let range = context.workbook.worksheets.getItem("Sample").getRange("A1:D4"); + + // Get the value in the second column in the "Wrench" row. + let unitSoldInNov = context.workbook.functions.vlookup("Wrench", range, 2, false); + unitSoldInNov.load("value"); + + await context.sync(); + console.log(" Number of wrenches sold in November = " + unitSoldInNov.value); + }); +Excel.Functions#sum:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-built-in-functions.yaml + + + await Excel.run(async (context) => { + // This function uses VLOOKUP to find data in the "Wrench" row + // on the worksheet, and then it uses SUM to combine the values. + let range = context.workbook.worksheets.getItem("Sample").getRange("A1:D4"); + + // Get the values in the second, third, and fourth columns in the "Wrench" row, + // and combine those values with SUM. + let sumOfTwoLookups = context.workbook.functions.sum( + context.workbook.functions.vlookup("Wrench", range, 2, false), + context.workbook.functions.vlookup("Wrench", range, 3, false), + context.workbook.functions.vlookup("Wrench", range, 4, false) + ); + sumOfTwoLookups.load("value"); + + await context.sync(); + console.log(" Number of wrenches sold in November, December, and January = " + sumOfTwoLookups.value); + }); +Excel.GeometricShapeType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.hexagon); + shape.left = 5; + shape.top = 5; + shape.height = 175; + shape.width = 200; + await context.sync(); + }); +Excel.GroupOption:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml + + + Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Group the larger, main level. Note that the outline controls + // will be on row 10, meaning 4-9 will collapse and expand. + sheet.getRange("4:9").group(Excel.GroupOption.byRows); + + // Group the smaller, sublevels. Note that the outline controls + // will be on rows 6 and 9, meaning 4-5 and 7-8 will collapse and expand. + sheet.getRange("4:5").group(Excel.GroupOption.byRows); + sheet.getRange("7:8").group(Excel.GroupOption.byRows); + await context.sync(); + }); +Excel.HorizontalAlignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-merged-ranges.yaml + + + await Excel.run(async (context) => { + // Retrieve the worksheet and the table in that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const tableRange = sheet.getRange("B2:E6"); + + // Create a merged range in the first row of the table. + const chartTitle = tableRange.getRow(0); + chartTitle.merge(true); + + // Format the merged range. + chartTitle.format.horizontalAlignment = "Center"; + + await context.sync(); + }); +Excel.IconSet:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.IconSetConditionalFormat#criteria:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.IconSetConditionalFormat#style:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B8:E13"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.iconSet); + const iconSetCF = conditionalFormat.iconSet; + iconSetCF.style = Excel.IconSet.threeTriangles; + + /* + The iconSetCF.criteria array is automatically prepopulated with + criterion elements whose properties have been given default settings. + You can't write to each property of a criterion directly. Instead, + replace the whole criteria object. + + With a "three*" icon set style, such as "threeTriangles", the third + element in the criteria array (criteria[2]) defines the "top" icon; + e.g., a green triangle. The second (criteria[1]) defines the "middle" + icon. The first (criteria[0]) defines the "low" icon, but it + can often be left empty as the following object shows, because every + cell that does not match the other two criteria always gets the low + icon. + */ + iconSetCF.criteria = [ + {} as any, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=700" + }, + { + type: Excel.ConditionalFormatIconRuleType.number, + operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, + formula: "=1000", + } + ]; + + await context.sync(); + }); +Excel.Image#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const image = sheet.shapes.getItem("Image").image; + image.load("format"); + await context.sync(); + + console.log("The image's format is: " + image.format); + await context.sync(); + }); +Excel.InsertShiftDirection:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/insert-delete-clear-range.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B4:E4"); + + range.insert(Excel.InsertShiftDirection.down); + + await context.sync(); + }); +Excel.KeyboardDirection:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml + + + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Specify the direction with the `KeyboardDirection` enum. + const direction = Excel.KeyboardDirection.up; + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get the top-most cell of the current used range. + // This method acts like the Ctrl+Arrow key keyboard shortcut while a range is selected. + const rangeEdge = range.getRangeEdge( + direction, + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + rangeEdge.select(); + + await context.sync(); + }); +Excel.LabelFilterCondition:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter based on the strings of item labels. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Get the "Type" field. + const field = pivotTable.hierarchies.getItem("Type").fields.getItem("Type"); + + // Filter out any types that start with "L" ("Lemons" and "Limes" in this case). + const filter: Excel.PivotLabelFilter = { + condition: Excel.LabelFilterCondition.beginsWith, + substring: "L", + exclusive: true + }; + + // Apply the label filter to the field. + field.applyFilter({ labelFilter: filter }); + + await context.sync(); + }); +Excel.Line#connectBeginShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.connectBeginShape(shapes.getItem("Left"), 2); + line.connectEndShape(shapes.getItem("Right"), 0); + await context.sync(); + }); +Excel.Line#connectEndShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.connectBeginShape(shapes.getItem("Left"), 2); + line.connectEndShape(shapes.getItem("Right"), 0); + await context.sync(); + }); +Excel.Line#disconnectBeginShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.disconnectBeginShape(); + line.disconnectEndShape(); + await context.sync(); + }); +Excel.Line#disconnectEndShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.disconnectBeginShape(); + line.disconnectEndShape(); + await context.sync(); + }); +Excel.NamedItem:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml + + + await Excel.run(async (context) => { + // Log all the named items in the active worksheet. + const namedItems = context.workbook.worksheets.getActiveWorksheet().names.load(); + await context.sync(); + + console.log("This worksheet contains " + namedItems.items.length + " named items."); + + for (let i = 0; i < namedItems.items.length; i++) { + const namedItem : Excel.NamedItem = namedItems.items[i]; + console.log(JSON.stringify(namedItem)) + "\n"; + } + + await context.sync(); + }); +Excel.NamedItem#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const totalName = sheet.names.getItemOrNullObject("TotalAmount"); + totalName.load(); + await context.sync(); + + if (totalName.value) { + totalName.delete(); + + // Replace the named item (TotalAmount) with the actual formula for TotalAmount to avoid displaying #NAME in the cell. + sheet.getRange("D11").values = [["=SUM(ExpensesTable[AMOUNT])"]]; + } else { + console.log("No named item created for the formula."); + } + + await context.sync(); + }); +Excel.NamedItem#formula:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/update-named-item.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Get the named item + const myNamedItem = sheet.names.getItemOrNullObject("MyRange"); + myNamedItem.load("name, formula"); + await context.sync(); + + if (myNamedItem.isNullObject) { + console.log(`There is no named item. Create it with "Add named item for a range" first.`); + } else { + // Update named item to point to the second range + myNamedItem.formula = "=Sample!$B$10:$D$14"; + sheet.getRange("B10:D14").select(); + await context.sync(); + + console.log(`Just updated the named item "${myNamedItem.name}" -- it's now located here: ${myNamedItem.formula}`); + } + }); +Excel.NamedItemCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const headerRange = sheet.getRange("A1:D1"); + + sheet.names.add("ExpensesHeader", headerRange); + const namedItems = sheet.names.load("name, type"); + + await context.sync(); + }); +Excel.Note:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +Excel.Note#content:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the content in the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); +Excel.Note#height:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +Excel.Note#visible:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function sets the note on cell A1 to visible. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); +Excel.Note#width:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +Excel.Note#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function deletes the note from cell A2. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItem("A2"); + note.delete(); + + await context.sync(); + }); +Excel.NoteCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function adds a note to the selected cell. + + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); +Excel.NoteCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function adds a note to the selected cell. + + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); +Excel.NoteCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function sets the note on cell A1 to visible. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); +Excel.NoteCollection#getItemAt:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the content in the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); +Excel.NumberFormatInfo#numberDecimalSeparator:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml + + + // This will convert a number like "14,37" to "14.37" + + // (assuming the system decimal separator is "."). + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + const decimalSource = sheet.getRange("B2"); + + decimalSource.load("values"); + + context.application.cultureInfo.numberFormat.load("numberDecimalSeparator"); + + await context.sync(); + + + const systemDecimalSeparator = + context.application.cultureInfo.numberFormat.numberDecimalSeparator; + + const oldDecimalString: string = decimalSource.values[0][0]; + + + // This assumes the input column is standardized to use "," as the decimal + separator. + + const newDecimalString = oldDecimalString.replace(",", + systemDecimalSeparator); + + + const resultRange = sheet.getRange("C2"); + + resultRange.values = [[newDecimalString]]; + + resultRange.format.autofitColumns(); + + await context.sync(); + }); +Excel.NumberFormatInfo#numberGroupSeparator:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml + + + await Excel.run(async (context) => { + // This will convert a number like "123-456-789" to "123,456,789" + // (assuming the system thousands separator is ","). + const sheet = context.workbook.worksheets.getItem("Sample"); + const bigNumberSource = sheet.getRange("B3"); + bigNumberSource.load("values"); + context.application.cultureInfo.numberFormat.load("numberGroupSeparator"); + await context.sync(); + + const systemThousandsSeparator = context.application.cultureInfo.numberFormat.numberGroupSeparator; + const oldBigNumberString: string = bigNumberSource.values[0][0]; + + // This assumes the input column is standardized to use "-" as the number group separator. + const newBigNumberString = oldBigNumberString.replace(/-/g, systemThousandsSeparator); + + const resultRange = sheet.getRange("C3"); + resultRange.values = [[newBigNumberString]]; + resultRange.format.autofitColumns(); + await context.sync(); + }); +Excel.PageBreakCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.horizontalPageBreaks.add("A21:E21"); + await context.sync(); + }); +Excel.PageLayout#centerHorizontally:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.centerHorizontally = true; + farmSheet.pageLayout.centerVertically = true; + await context.sync(); + }); +Excel.PageLayout#centerVertically:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.centerHorizontally = true; + farmSheet.pageLayout.centerVertically = true; + await context.sync(); + }); +Excel.PageLayout#orientation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.orientation = Excel.PageOrientation.landscape; + await context.sync(); + }); +Excel.PageLayout#setPrintArea:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.setPrintArea("A1:D41"); + await context.sync(); + }); +Excel.PageLayout#setPrintTitleRows:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.setPrintTitleRows("$1:$1"); + await context.sync(); + }); +Excel.PageLayout#zoom:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.zoom = { scale: 200 }; + await context.sync(); + }); +Excel.PageOrientation:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml + + + await Excel.run(async (context) => { + const farmSheet = context.workbook.worksheets.getItem("Print"); + farmSheet.pageLayout.orientation = Excel.PageOrientation.landscape; + await context.sync(); + }); +Excel.PictureFormat:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Image"); + const result = shape.getAsImage(Excel.PictureFormat.png); + await context.sync(); + + const imageString = result.value; + // Your add-in would save this string as a .png file. + console.log("The image's Base64-encoded string: " + imageString); + }); +Excel.PivotField#clearAllFilters:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Clear all the PivotFilters. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + pivotTable.hierarchies.load("name"); + await context.sync(); + + // Clear the filters on each PivotField. + pivotTable.hierarchies.items.forEach((hierarchy) => { + hierarchy.fields.getItem(hierarchy.name).clearAllFilters(); + }); + await context.sync(); + }); +Excel.PivotFilters#dateFilter:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a date-based PivotFilter. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. + // If it's not already there, add "Date Updated" to the hierarchies. + let dateHierarchy = pivotTable.rowHierarchies.getItemOrNullObject("Date Updated"); + await context.sync(); + if (dateHierarchy.isNullObject) { + dateHierarchy = pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Date Updated")); + } + + // Apply a date filter to filter out anything logged before August. + const filterField = dateHierarchy.fields.getItem("Date Updated"); + const dateFilter = { + condition: Excel.DateFilterCondition.afterOrEqualTo, + comparator: { + date: "2020-08-01", + specificity: Excel.FilterDatetimeSpecificity.month + } + }; + filterField.applyFilter({ dateFilter: dateFilter }); + + await context.sync(); + }); +Excel.PivotFilters#labelFilter:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter based on the strings of item labels. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Get the "Type" field. + const field = pivotTable.hierarchies.getItem("Type").fields.getItem("Type"); + + // Filter out any types that start with "L" ("Lemons" and "Limes" in this case). + const filter: Excel.PivotLabelFilter = { + condition: Excel.LabelFilterCondition.beginsWith, + substring: "L", + exclusive: true + }; + + // Apply the label filter to the field. + field.applyFilter({ labelFilter: filter }); + + await context.sync(); + }); +Excel.PivotFilters#manualFilter:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter on manually-selected items. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. + // If it's not already there, add "Classification" to the hierarchies. + let classHierarchy = pivotTable.filterHierarchies.getItemOrNullObject("Classification"); + await context.sync(); + if (classHierarchy.isNullObject) { + classHierarchy = pivotTable.filterHierarchies.add(pivotTable.hierarchies.getItem("Classification")); + } + + // Apply a manual filter to include only a specific PivotItem (the string "Organic"). + const filterField = classHierarchy.fields.getItem("Classification"); + const manualFilter = { selectedItems: ["Organic"]}; + filterField.applyFilter({ manualFilter: manualFilter }); + + await context.sync(); + }); +Excel.PivotFilters#valueFilter:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter on the values correlated with a row. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Get the "Farm" field. + const field = pivotTable.hierarchies.getItem("Farm").fields.getItem("Farm"); + + // Filter to only include rows with more than 500 wholesale crates sold. + const filter: Excel.PivotValueFilter = { + condition: Excel.ValueFilterCondition.greaterThan, + comparator: 500, + value: "Sum of Crates Sold Wholesale" + }; + + // Apply the value filter to the field. + field.applyFilter({ valueFilter: filter }); + + await context.sync(); + }); +Excel.PivotHierarchy#fields:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter on the values correlated with a row. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Get the "Farm" field. + const field = pivotTable.hierarchies.getItem("Farm").fields.getItem("Farm"); + + // Filter to only include rows with more than 500 wholesale crates sold. + const filter: Excel.PivotValueFilter = { + condition: Excel.ValueFilterCondition.greaterThan, + comparator: 500, + value: "Sum of Crates Sold Wholesale" + }; + + // Apply the value filter to the field. + field.applyFilter({ valueFilter: filter }); + + await context.sync(); + }); +Excel.PivotLayout#getDataBodyRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // The layout controls the ranges used by the PivotTable. + const range = pivotTable.layout.getDataBodyRange(); + + // Get all the data hierarchy totals. + const grandTotalRange = range.getLastRow(); + grandTotalRange.load("address"); + await context.sync(); + + // Use the wholesale and farm sale totals to make a final sum. + const masterTotalRange = context.workbook.worksheets.getActiveWorksheet().getRange("B27:C27"); + masterTotalRange.formulas = [["All Crates", "=SUM(" + grandTotalRange.address + ")"]]; + await context.sync(); + }); +Excel.PivotLayout#altTextDescription:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Set the alt text for the displayed PivotTable. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.altTextTitle = "Farm Sales PivotTable"; + pivotLayout.altTextDescription = "A summary of fruit sales. It is pivoted on farm name, and fruit type. The aggregated data is both the sums of crates sold at the farms and the sums of crates sold wholesale."; + console.log("Adding alt text. Check the PivotTable settings to see the changes."); + + await context.sync(); + }); +Excel.PivotLayout#displayBlankLineAfterEachItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Add a blank row after each PivotItem in the row hierarchy. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.displayBlankLineAfterEachItem(true); + console.log("Setting `PivotLayout.displayBlankLineAfterEachItem` to true."); + + await context.sync(); + }); +Excel.PivotLayout#emptyCellText:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Set a default value for an empty cell in the PivotTable. This doesn't include cells left blank by the layout. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.emptyCellText = "--"; + + // Set the text alignment to match the rest of the PivotTable. + pivotLayout.getDataBodyRange().format.horizontalAlignment = Excel.HorizontalAlignment.right; + await context.sync(); + }); +Excel.PivotLayout#fillEmptyCells:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Toggle whether empty cells are filled with a default value. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.load("fillEmptyCells"); + await context.sync(); + + let fillToSet = !pivotLayout.fillEmptyCells; + console.log(`Filling empty cells? - ${fillToSet}`); + + pivotLayout.fillEmptyCells = fillToSet; + await context.sync(); + }); +Excel.PivotLayout#layoutType:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Change the PivotLayout.type to a new type. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + pivotTable.layout.load("layoutType"); + await context.sync(); + + // Cycle between the three layout types. + if (pivotTable.layout.layoutType === "Compact") { + pivotTable.layout.layoutType = "Outline"; + } else if (pivotTable.layout.layoutType === "Outline") { + pivotTable.layout.layoutType = "Tabular"; + } else { + pivotTable.layout.layoutType = "Compact"; + } + + await context.sync(); + console.log("Pivot layout is now " + pivotTable.layout.layoutType); + }); +Excel.PivotLayout#preserveFormatting:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Set whether the PivotTable keeps the established format after it is refreshed and recalculated. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.load("preserveFormatting"); + await context.sync(); + + let preserveFormattingToSet = !pivotLayout.preserveFormatting; + console.log(`Preserve the formatting PivotTable after a refresh? - ${preserveFormattingToSet}`); + + pivotLayout.preserveFormatting = preserveFormattingToSet; + await context.sync(); + }); +Excel.PivotLayout#repeatAllItemLabels:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Repeat the PivotItem labels for each row used by another level of the row hierarchy. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.repeatAllItemLabels(true); + console.log("Setting `PivotLayout.repeatAllItemLabels` to true."); + + await context.sync(); + }); +Excel.PivotLayout#showColumnGrandTotals:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Turn the grand totals on and off for the rows and columns. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]); + await context.sync(); + + let showColumnTotals = !pivotLayout.showColumnGrandTotals; + let showRowTotals = !pivotLayout.showRowGrandTotals; + console.log(`Show column grand totals? - ${showColumnTotals}`); + console.log(`Show row grand totals? - ${showRowTotals}`); + + pivotLayout.showColumnGrandTotals = showColumnTotals; + pivotLayout.showRowGrandTotals = showRowTotals; + + await context.sync(); + }); +Excel.PivotLayout#showFieldHeaders:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Turn the field headers on and off for the row and column hierarchies. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + pivotLayout.load("showFieldHeaders"); + await context.sync(); + + let showHeaders = !pivotLayout.showFieldHeaders; + console.log(`Show field headers? - ${showHeaders}`); + pivotLayout.showFieldHeaders = showHeaders; + await context.sync(); + }); +Excel.PivotLayout#showRowGrandTotals:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml + + + await Excel.run(async (context) => { + // Turn the grand totals on and off for the rows and columns. + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + const pivotLayout = pivotTable.layout; + + pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]); + await context.sync(); + + let showColumnTotals = !pivotLayout.showColumnGrandTotals; + let showRowTotals = !pivotLayout.showRowGrandTotals; + console.log(`Show column grand totals? - ${showColumnTotals}`); + console.log(`Show row grand totals? - ${showRowTotals}`); + + pivotLayout.showColumnGrandTotals = showColumnTotals; + pivotLayout.showRowGrandTotals = showRowTotals; + + await context.sync(); + }); +Excel.PivotTable#columnHierarchies:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Check if the PivotTable already has a column. + const column = pivotTable.columnHierarchies.getItemOrNullObject("Farm"); + column.load("id"); + await context.sync(); + + if (column.isNullObject) { + // Adding the farm column to the column hierarchy automatically removes it from the row hierarchy. + pivotTable.columnHierarchies.add(pivotTable.hierarchies.getItem("Farm")); + } else { + pivotTable.columnHierarchies.remove(column); + } + + await context.sync(); + }); +Excel.PivotTable#dataHierarchies:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold at Farm")); + pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold Wholesale")); + + await context.sync(); + }); +Excel.PivotTable#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + context.workbook.worksheets.getItem("Pivot").pivotTables.getItem("Farm Sales").delete(); + + await context.sync(); + }); +Excel.PivotTable#layout:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + pivotTable.layout.load("layoutType"); + await context.sync(); + + // Cycle between the three layout types. + if (pivotTable.layout.layoutType === "Compact") { + pivotTable.layout.layoutType = "Outline"; + } else if (pivotTable.layout.layoutType === "Outline") { + pivotTable.layout.layoutType = "Tabular"; + } else { + pivotTable.layout.layoutType = "Compact"; + } + await context.sync(); + console.log("Pivot layout is now " + pivotTable.layout.layoutType); + }); +Excel.PivotTable#getDataSourceString:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-source-data.yaml + + + // This function logs information about the data source of a PivotTable. + + await Excel.run(async (context) => { + const worksheet = context.workbook.worksheets.getItem("TotalPivot"); + const pivotTable = worksheet.pivotTables.getItem("All Farm Sales"); + + // Retrieve the type and string representation of the data source of the PivotTable. + const pivotTableDataSourceType = pivotTable.getDataSourceType(); + const pivotTableDataSourceString = pivotTable.getDataSourceString(); + await context.sync(); + + // Log the data source information. + console.log("Data source: " + pivotTableDataSourceString.value); + console.log("Source type: " + pivotTableDataSourceType.value); + }); +Excel.PivotTable#getDataSourceType:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-source-data.yaml + + + // This function logs information about the data source of a PivotTable. + + await Excel.run(async (context) => { + const worksheet = context.workbook.worksheets.getItem("TotalPivot"); + const pivotTable = worksheet.pivotTables.getItem("All Farm Sales"); + + // Retrieve the type and string representation of the data source of the PivotTable. + const pivotTableDataSourceType = pivotTable.getDataSourceType(); + const pivotTableDataSourceString = pivotTable.getDataSourceString(); + await context.sync(); + + // Log the data source information. + console.log("Data source: " + pivotTableDataSourceString.value); + console.log("Source type: " + pivotTableDataSourceType.value); + }); +Excel.PivotTable#filterHierarchies:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + + + async function filter(functionType: Excel.AggregationFunction) { + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + const filters = pivotTable.filterHierarchies; + const filter = filters.getItemOrNullObject("Classification"); + filter.load(); + await context.sync(); + + // Add the Classification hierarchy to the filter, if it's not already there. + if (filter.isNullObject) { + filters.add(pivotTable.hierarchies.getItem("Classification")); + await context.sync(); + } + }); + } +Excel.PivotTable#refresh:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-refresh.yaml + + + // This function refreshes the "Farm Sales" PivotTable, + + // which updates the PivotTable with changes made to the source table. + + await Excel.run(async (context) => { + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + pivotTable.refresh(); + await context.sync(); + }); +Excel.PivotTableCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + + + await Excel.run(async (context) => { + const rangeToAnalyze = context.workbook.worksheets.getItem("Data").getRange("A1:E21"); + const rangeToPlacePivot = context.workbook.worksheets.getItem("Pivot").getRange("A2"); + context.workbook.worksheets.getItem("Pivot").pivotTables.add("Farm Sales", rangeToAnalyze, rangeToPlacePivot); + + await context.sync(); + }); +Excel.PivotTableCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-refresh.yaml + + + // This function refreshes the "Farm Sales" PivotTable, + + // which updates the PivotTable with changes made to the source table. + + await Excel.run(async (context) => { + const pivotTable = context.workbook.pivotTables.getItem("Farm Sales"); + pivotTable.refresh(); + await context.sync(); + }); +Excel.PresetCriteriaConditionalFormat#rule:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:M5"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.presetCriteria); + conditionalFormat.preset.format.font.color = "white"; + conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; + + await context.sync(); + }); +Excel.Range#clearOrResetContents:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove all content from the Analysis column. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Clear all the data from the second column. + range.clearOrResetContents(); + await context.sync(); + }); +Excel.Range#control:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.Range#values:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Change the value of the checkbox in B3. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("B3"); + + range.values = [["TRUE"]]; + await context.sync(); + }); +Excel.Range#valuesAsJson:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + + + // This function creates a double data type, + + // and sets the format of this data type as a date. + + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const dateRange = sheet.getRange("A1"); + + // Write a number formatted as a date to cell A1. + dateRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 32889.0, + numberFormat: "m/d/yyyy" + } + ] + ]; + await context.sync(); + }); +Excel.Range#getDirectDependents:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-direct-dependents.yaml + + + await Excel.run(async (context) => { + // Direct dependents are cells that contain formulas that refer to other cells. + let range = context.workbook.getActiveCell(); + let directDependents = range.getDirectDependents(); + range.load("address"); + directDependents.areas.load("address"); + await context.sync(); + + console.log(`Direct dependent cells of ${range.address}:`); + + // Use the direct dependents API to loop through direct dependents of the active cell. + for (let i = 0; i < directDependents.areas.items.length; i++) { + // Highlight and print the address of each dependent cell. + directDependents.areas.items[i].format.fill.color = "Yellow"; + console.log(` ${directDependents.areas.items[i].address}`); + } + await context.sync(); + }); +Excel.Range#sort:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + + + async function sortTopToBottom(criteria: string) { + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("A1:E5"); + + // Find the column header that provides the sort criteria. + const header = range.find(criteria, {}); + header.load("columnIndex"); + await context.sync(); + + range.sort.apply( + [ + { + key: header.columnIndex, + sortOn: Excel.SortOn.value + } + ], + false /*matchCase*/, + true /*hasHeaders*/, + Excel.SortOrientation.rows + ); + await context.sync(); + }); + } +Excel.Range#getMergedAreasOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-merged-ranges.yaml + + + await Excel.run(async (context) => { + // Retrieve the worksheet and the table in that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const tableRange = sheet.getRange("B2:E6"); + + // Retrieve the merged range within the table and load its details. + const mergedAreas = tableRange.getMergedAreasOrNullObject(); + mergedAreas.load("address"); + mergedAreas.load("cellCount"); + + // Select the merged range. + const range = mergedAreas.areas.getItemAt(0); + range.select(); + await context.sync(); + + // Print out the details of the `mergedAreas` range object. + console.log(`Address of the merged range: ${mergedAreas.address}`); + console.log(`Number of cells in the merged range: ${mergedAreas.cellCount}`); + + await context.sync(); + }); +Excel.Range#merge:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-merged-ranges.yaml + + + await Excel.run(async (context) => { + // Retrieve the worksheet and the table in that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const tableRange = sheet.getRange("B2:E6"); + + // Create a merged range in the first row of the table. + const chartTitle = tableRange.getRow(0); + chartTitle.merge(true); + + // Format the merged range. + chartTitle.format.horizontalAlignment = "Center"; + + await context.sync(); + }); +Excel.Range#group:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml + + + Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Group the larger, main level. Note that the outline controls + // will be on row 10, meaning 4-9 will collapse and expand. + sheet.getRange("4:9").group(Excel.GroupOption.byRows); + + // Group the smaller, sublevels. Note that the outline controls + // will be on rows 6 and 9, meaning 4-5 and 7-8 will collapse and expand. + sheet.getRange("4:5").group(Excel.GroupOption.byRows); + sheet.getRange("7:8").group(Excel.GroupOption.byRows); + await context.sync(); + }); +Excel.Range#ungroup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml + + + Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // This removes two levels of groups from the "A1-R10" range. + // Any groups at the same level on the same dimension will be removed by a single call. + sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byRows); + sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byRows); + sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byColumns); + sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byColumns); + await context.sync(); + }); +Excel.Range#getPivotTables:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + + + await Excel.run(async (context) => { + const activeRange = context.workbook.getSelectedRange(); + + // Get all the PivotTables that intersect with this range. + const partiallyContainedPivotTables = activeRange.getPivotTables(); + // Get all the PivotTables that are completely contained within this range. + const fullyContainedPivotTables = activeRange.getPivotTables(true); + + partiallyContainedPivotTables.load("name"); + fullyContainedPivotTables.load("name"); + await context.sync(); + + // Display the names in the console. + console.log("PivotTables in the current range:") + partiallyContainedPivotTables.items.forEach((pivotTable) => { + console.log(`\t${pivotTable.name}`); + }); + console.log("PivotTables completely contained in the current range:") + fullyContainedPivotTables.items.forEach((pivotTable) => { + console.log(`\t${pivotTable.name}`); + }); + }); +Excel.Range#getDirectPrecedents:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/precedents.yaml + + + await Excel.run(async (context) => { + // Precedents are cells referenced by the formula in a cell. + // A "direct precedent" is a cell directly referenced by the selected formula. + let range = context.workbook.getActiveCell(); + let directPrecedents = range.getDirectPrecedents(); + range.load("address"); + directPrecedents.areas.load("address"); + await context.sync(); + + console.log(`Direct precedent cells of ${range.address}:`); + + // Use the direct precedents API to loop through precedents of the active cell. + for (let i = 0; i < directPrecedents.areas.items.length; i++) { + // Highlight and console the address of each precedent cell. + directPrecedents.areas.items[i].format.fill.color = "Yellow"; + console.log(` ${directPrecedents.areas.items[i].address}`); + } + await context.sync(); + }); +Excel.Range#getPrecedents:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/precedents.yaml + + + await Excel.run(async (context) => { + // Precedents are cells referenced by the formula in a cell. + let range = context.workbook.getActiveCell(); + let precedents = range.getPrecedents(); + range.load("address"); + precedents.areas.load("address"); + await context.sync(); + + console.log(`All precedent cells of ${range.address}:`); + + // Use the precedents API to loop through precedents of the active cell. + for (let i = 0; i < precedents.areas.items.length; i++) { + // Highlight and console the address of each precedent cell. + precedents.areas.items[i].format.fill.color = "Orange"; + console.log(` ${precedents.areas.items[i].address}`); + } + await context.sync(); + }); +Excel.Range#getSpecialCells:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml + + + await Excel.run(async (context) => { + + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const usedRange = sheet.getUsedRange(); + + // Find the ranges with either text or logical (boolean) values. + const formulaRanges = usedRange.getSpecialCells("Constants", "LogicalText"); + formulaRanges.format.fill.color = "orange"; + + return context.sync(); + }); +Excel.Range#autoFill:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-auto-fill.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const sumCell = sheet.getRange("P4"); + + // Copy everything. The formulas will be contextually updated based on their new locations. + sumCell.autoFill("P4:P7", Excel.AutoFillType.fillCopy); + sumCell.format.autofitColumns(); + await context.sync(); + }); +Excel.Range#getCellProperties:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const cell = context.workbook.getActiveCell(); + + // Define the cell properties to get by setting the matching LoadOptions to true. + const propertiesToGet = cell.getCellProperties({ + address: true, + format: { + fill: { + color: true + }, + font: { + color: true + } + }, + style: true + }); + + // Sync to get the data from the workbook. + await context.sync(); + const cellProperties = propertiesToGet.value[0][0]; + console.log( + `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); + }); +Excel.Range#setCellProperties:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; + + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + }); +Excel.Range#copyFrom:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-copyfrom.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + // Place a label in front of the copied data. + sheet.getRange("F2").values = [["Copied Formula"]]; + + // Copy a range preserving the formulas. + // Note: non-formula values are copied over as is. + sheet.getRange("G2").copyFrom("A1:E1", Excel.RangeCopyType.formulas); + await context.sync(); + }); +Excel.Range#moveTo:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-copyfrom.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + // Place a label in front of the moved data. + sheet.getRange("F12").values = [["Moved Range:"]]; + + // Move the range from A1:E1 to G12:K12. + sheet.getRange("A1:E1").moveTo("G12"); + await context.sync(); + }); +Excel.Range#getDependents:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-dependents.yaml + + + // This function highlights all the dependent cells of the active cell. + + // Dependent cells contain formulas that refer to other cells. + + await Excel.run(async (context) => { + // Get addresses of the active cell's dependent cells. + const range = context.workbook.getActiveCell(); + const dependents = range.getDependents(); + range.load("address"); + dependents.areas.load("address"); + await context.sync(); + + console.log(`All dependent cells of ${range.address}:`); + + // Use the dependents API to loop through dependents of the active cell. + for (let i = 0; i < dependents.areas.items.length; i++) { + // Highlight and print out the address of each dependent cell. + dependents.areas.items[i].format.fill.color = "Orange"; + console.log(` ${dependents.areas.items[i].address}`); + } + await context.sync(); + }); +Excel.Range#getSpillingToRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/dynamic-arrays.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Set G4 to a formula that returns a dynamic array. + const targetCell = sheet.getRange("G4"); + targetCell.formulas = [["=A4:D4"]]; + + // Get the address of the cells that the dynamic array spilled into. + const spillRange = targetCell.getSpillingToRange(); + spillRange.load("address"); + + // Fit the columns for readability. + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + + console.log(`Copying the table headers spilled into ${spillRange.address}.`); + }); +Excel.Range#find:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-find.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const table = sheet.tables.getItem("ExpensesTable"); + const searchRange = table.getRange(); + + // NOTE: If no match is found, an ItemNotFound error + // is thrown when Range.find is evaluated. + const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value; + const foundRange = searchRange.find(searchText, { + completeMatch: isCompleteMatchToggle, + matchCase: isMatchCaseToggle, + searchDirection: searchDirectionToggle + }); + + foundRange.load("address"); + await context.sync(); + + + console.log(foundRange.address); + }); +Excel.Range#findOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-find.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const table = sheet.tables.getItem("ExpensesTable"); + const searchRange = table.getRange(); + const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value; + const foundRange = searchRange.findOrNullObject(searchText, { + completeMatch: isCompleteMatchToggle, + matchCase: isMatchCaseToggle, + searchDirection: searchDirectionToggle + }); + + foundRange.load("address"); + await context.sync(); + + if (foundRange.isNullObject) { + console.log("Text not found"); + } else { + console.log(foundRange.address); + } + }); +Excel.Range#getExtendedRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml + + + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Specify the direction with the `KeyboardDirection` enum. + const direction = Excel.KeyboardDirection.down; + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get all the cells from the currently selected range to the bottom-most edge of the used range. + // This method acts like the Ctrl+Shift+Arrow key keyboard shortcut while a range is selected. + const extendedRange = range.getExtendedRange( + direction, + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + extendedRange.select(); + + await context.sync(); + }); +Excel.Range#getRangeEdge:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml + + + await Excel.run(async (context) => { + // Get the selected range. + const range = context.workbook.getSelectedRange(); + + // Specify the direction with the `KeyboardDirection` enum. + const direction = Excel.KeyboardDirection.up; + + // Get the active cell in the workbook. + const activeCell = context.workbook.getActiveCell(); + + // Get the top-most cell of the current used range. + // This method acts like the Ctrl+Arrow key keyboard shortcut while a range is selected. + const rangeEdge = range.getRangeEdge( + direction, + activeCell // If the selected range contains more than one cell, the active cell must be defined. + ); + rangeEdge.select(); + + await context.sync(); + }); +Excel.Range#hyperlink:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + let productsRange = sheet.getRange("A3:A5"); + productsRange.load("values"); + + await context.sync(); + + // Create a hyperlink to a URL + // for each product name in the first table. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + let cellText = productsRange.values[i][0]; + + let hyperlink = { + textToDisplay: cellText, + screenTip: "Search Bing for '" + cellText + "'", + address: "https://www.bing.com/?q=" + cellText + } + cellRange.hyperlink = hyperlink; + } + + await context.sync(); + }); +Excel.Range#getIntersectionOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-relationships.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + // We want the most recent quarter that has data, so + // exclude quarters without data and get the last of + // the remaining columns. + const usedDataRange = dataRange.getUsedRange(true /* valuesOnly */); + const currentQuarterRange = usedDataRange.getLastColumn(); + + // Asian and European teams have separate contests. + const asianSalesRange = sheet.getRange("A2:E4"); + const europeanSalesRange = sheet.getRange("A5:E7"); + + // The data for each chart is the intersection of the + // current quarter column and the rows for the continent. + const asianContestRange = asianSalesRange.getIntersectionOrNullObject(currentQuarterRange); + const europeanContestRange = europeanSalesRange.getIntersectionOrNullObject(currentQuarterRange); + + // Must sync before you can test the output of *OrNullObject + // method/property. + await context.sync(); + + if (asianContestRange.isNullObject) { + // See the declaration of this function for how to + // test this code path. + reportMissingData("Asian"); + } else { + createContinentChart( + sheet, + "Asian", + asianContestRange, + "A9", + "F24" + ); + } + + if (europeanContestRange.isNullObject) { + // See the declaration of this function for how to + // test this code path. + reportMissingData("European"); + } else { + createContinentChart( + sheet, + "European", + europeanContestRange, + "A25", + "F40" + ); + } + + await context.sync(); + }); +Excel.Range#getUsedRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-relationships.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + // We want the most recent quarter that has data, so + // exclude quarters without data and get the last of + // the remaining columns. + const usedDataRange = dataRange.getUsedRange(true /* valuesOnly */); + const currentQuarterRange = usedDataRange.getLastColumn(); + + // Asian and European teams have separate contests. + const asianSalesRange = sheet.getRange("A2:E4"); + const europeanSalesRange = sheet.getRange("A5:E7"); + + // The data for each chart is the intersection of the + // current quarter column and the rows for the continent. + const asianContestRange = asianSalesRange.getIntersectionOrNullObject(currentQuarterRange); + const europeanContestRange = europeanSalesRange.getIntersectionOrNullObject(currentQuarterRange); + + // Must sync before you can test the output of *OrNullObject + // method/property. + await context.sync(); + + if (asianContestRange.isNullObject) { + // See the declaration of this function for how to + // test this code path. + reportMissingData("Asian"); + } else { + createContinentChart( + sheet, + "Asian", + asianContestRange, + "A9", + "F24" + ); + } + + if (europeanContestRange.isNullObject) { + // See the declaration of this function for how to + // test this code path. + reportMissingData("European"); + } else { + createContinentChart( + sheet, + "European", + europeanContestRange, + "A25", + "F40" + ); + } + + await context.sync(); + }); +Excel.Range#removeDuplicates:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-remove-duplicates.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:D11"); + + const deleteResult = range.removeDuplicates([0],true); + deleteResult.load(); + await context.sync(); + + console.log(deleteResult.removed + " entries with duplicate names removed."); + console.log(deleteResult.uniqueRemaining + " entries with unique names remain in the range."); + }); +Excel.Range#style:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let worksheet = context.workbook.worksheets.getItem("Sample"); + let range = worksheet.getRange("A1:E1"); + + // Apply built-in style. + // Styles are in the Home tab ribbon. + range.style = Excel.BuiltInStyle.neutral; + range.format.horizontalAlignment = "Right"; + + await context.sync(); + }); +Excel.Range#getUsedRangeOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/used-range.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const salesTable = sheet.tables.getItem("SalesTable"); + const dataRange = salesTable.getDataBodyRange(); + + // Pass true so only cells with values count as used + const usedDataRange = dataRange.getUsedRangeOrNullObject( + true /* valuesOnly */ + ); + + //Must sync before reading value returned from *OrNullObject method/property. + await context.sync(); + + if (usedDataRange.isNullObject) { + console.log("Need Data to Make Chart"); + console.log("To create a meaningful chart, press 'Fill the table' (or add names to the Product column and numbers to some of the other cells). Then press 'Try to create chart' again."); + } else { + const chart = sheet.charts.add( + Excel.ChartType.columnClustered, + dataRange, + "Columns" + ); + chart.setPosition("A15", "F30"); + chart.title.text = "Quarterly sales chart"; + chart.legend.position = "Right"; + chart.legend.format.fill.setSolidColor("white"); + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "black"; + } + + await context.sync(); + }); +Excel.Range#set:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/multiple-property-set.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + const sourceRange = sheet.getRange("B2:E2"); + sourceRange.load("format/fill/color, format/font/name, format/font/color"); + await context.sync(); + + // Set properties based on the loaded and synced + // source range. + const targetRange = sheet.getRange("B7:E7"); + targetRange.set(sourceRange); + targetRange.format.autofitColumns(); + await context.sync(); + }); +Excel.RangeAreas#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml + + + await Excel.run(async (context) => { + + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const usedRange = sheet.getUsedRange(); + + // Find the ranges with formulas. + const formulaRanges = usedRange.getSpecialCells("Formulas"); + formulaRanges.format.fill.color = "lightgreen"; + + await context.sync(); + }); +Excel.RangeCopyType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-copyfrom.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + // Place a label in front of the copied data. + sheet.getRange("F2").values = [["Copied Formula"]]; + + // Copy a range preserving the formulas. + // Note: non-formula values are copied over as is. + sheet.getRange("G2").copyFrom("A1:E1", Excel.RangeCopyType.formulas); + await context.sync(); + }); +Excel.RangeFormat#textOrientation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-text-orientation.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:E2"); + + // Set textOrientation to either an integer between -90 and 90 + // or to 180 for vertically-oriented text. + range.format.textOrientation = 90; + + await context.sync(); + }); +Excel.RangeHyperlink#address:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + let productsRange = sheet.getRange("A3:A5"); + productsRange.load("values"); + + await context.sync(); + + // Create a hyperlink to a URL + // for each product name in the first table. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + let cellText = productsRange.values[i][0]; + + let hyperlink = { + textToDisplay: cellText, + screenTip: "Search Bing for '" + cellText + "'", + address: "https://www.bing.com/?q=" + cellText + } + cellRange.hyperlink = hyperlink; + } + + await context.sync(); + }); +Excel.RangeHyperlink#documentReference:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + let productsRange = sheet.getRange("A9:A11"); + productsRange.load("values"); + + await context.sync(); + + // Create a hyperlink to a location within the workbook + // for each product name in the second table. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + let cellText = productsRange.values[i][0]; + + let hyperlink = { + textToDisplay: cellText, + screenTip: "Navigate to the '" + cellText + "' worksheet", + documentReference: cellText + "!A1" + } + cellRange.hyperlink = hyperlink; + } + + await context.sync(); + }); +Excel.RangeHyperlink#screenTip:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + let productsRange = sheet.getRange("A3:A5"); + productsRange.load("values"); + + await context.sync(); + + // Create a hyperlink to a URL + // for each product name in the first table. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + let cellText = productsRange.values[i][0]; + + let hyperlink = { + textToDisplay: cellText, + screenTip: "Search Bing for '" + cellText + "'", + address: "https://www.bing.com/?q=" + cellText + } + cellRange.hyperlink = hyperlink; + } + + await context.sync(); + }); +Excel.RangeHyperlink#textToDisplay:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + let productsRange = sheet.getRange("A3:A5"); + productsRange.load("values"); + + await context.sync(); + + // Create a hyperlink to a URL + // for each product name in the first table. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + let cellText = productsRange.values[i][0]; + + let hyperlink = { + textToDisplay: cellText, + screenTip: "Search Bing for '" + cellText + "'", + address: "https://www.bing.com/?q=" + cellText + } + cellRange.hyperlink = hyperlink; + } + + await context.sync(); + }); +Excel.RangeUnderlineStyle:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Orders"); + + const productsRange = sheet.getRange("A3:A11"); + productsRange.load("values"); + + await context.sync(); + + // Clear all hyperlinks. + for (let i = 0; i < productsRange.values.length; i++) { + let cellRange = productsRange.getCell(i, 0); + + // Clear the hyperlink. + // This removes the hyperlink but does not update text format. + cellRange.clear(Excel.ClearApplyTo.hyperlinks); + + // Update text format. + cellRange.format.font.underline = Excel.RangeUnderlineStyle.none; + cellRange.format.font.color = "#000000"; + } + + await context.sync(); + }); +Excel.ReadingOrder:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let style = context.workbook.styles.getItem("Diagonal Orientation Style"); + style.load("textOrientation, horizontalAlignment, autoIndent, readingOrder, wrapText, includeProtection, shrinkToFit, locked"); + + await context.sync(); + + console.log("Orientation: " + style.textOrientation); + console.log("Horizontal alignment: " + style.horizontalAlignment); + console.log("Add indent: " + style.autoIndent); + console.log("Reading order: " + style.readingOrder); + console.log("Wrap text: " + style.wrapText); + console.log("Include protection: " + style.includeProtection); + console.log("Shrink to fit: " + style.shrinkToFit); + console.log("Style locked: " + style.locked); + }); +Excel.RemoveDuplicatesResult#uniqueRemaining:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-remove-duplicates.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B2:D11"); + + const deleteResult = range.removeDuplicates([0],true); + deleteResult.load(); + await context.sync(); + + console.log(deleteResult.removed + " entries with duplicate names removed."); + console.log(deleteResult.uniqueRemaining + " entries with unique names remain in the range."); + }); +Excel.Runtime#enableEvents:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-disable-events.yaml + + + await Excel.run(async (context) => { + context.runtime.load("enableEvents"); + await context.sync(); + + // check if events are enabled and toggle accordingly + const eventBoolean = !context.runtime.enableEvents + context.runtime.enableEvents = eventBoolean; + if (eventBoolean) { + console.log("Events are currently on."); + } else { + console.log("Events are currently off."); + } + + await context.sync(); + }); +Excel.SaveBehavior:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml + + + await Excel.run(async (context) => { + context.workbook.save(Excel.SaveBehavior.prompt); + }); +Excel.SearchDirection:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-find.yaml + + + searchDirectionToggle = searchDirectionToggle === + Excel.SearchDirection.forward ? Excel.SearchDirection.backwards : + Excel.SearchDirection.forward; + + console.log("Search direction = " + searchDirectionToggle); +Excel.SettableCellProperties#style:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Creating the SettableCellProperties objects to use for the range. + // In your add-in, these should be created once, outside the function. + const topHeaderProps: Excel.SettableCellProperties = { + // The style property takes a string matching the name of an Excel style. + // Built-in style names are listed in the `BuiltInStyle` enum. + // Note that a style will overwrite any formatting, + // so do not use the format property with the style property. + style: "Heading1" + }; + + const headerProps: Excel.SettableCellProperties = { + // Any subproperties of format that are not set will not be changed when these cell properties are set. + format: { + fill: { + color: "Blue" + }, + font: { + color: "White", + bold: true + } + } + }; + + const nonApplicableProps: Excel.SettableCellProperties = { + format: { + fill: { + pattern: Excel.FillPattern.gray25 + }, + font: { + color: "Gray", + italic: true + } + } + }; + + const matchupScoreProps: Excel.SettableCellProperties = { + format: { + borders: { + bottom: { + style: Excel.BorderLineStyle.continuous + }, + left: { + style: Excel.BorderLineStyle.continuous + }, + right: { + style: Excel.BorderLineStyle.continuous + }, + top: { + style: Excel.BorderLineStyle.continuous + } + } + } + }; + + const range = sheet.getRange("A1:E5"); + + // You can use empty JSON objects to avoid changing a cell's properties. + range.setCellProperties([ + [topHeaderProps, {}, {}, {}, {}], + [{}, {}, headerProps, headerProps, headerProps], + [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], + [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] + ]); + + sheet.getUsedRange().format.autofitColumns(); + await context.sync(); + }); +Excel.Setting#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-get-change-delete-settings.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + let needsReview = settings.getItem("NeedsReview"); + needsReview.delete(); + needsReview = settings.getItemOrNullObject("NeedsReview"); + + await context.sync(); + + if (needsReview.isNullObject) { + console.log("The setting has been deleted"); + } else { + console.log("The setting was not deleted"); + } + + await context.sync(); + }); +Excel.SettingCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + settings.onSettingsChanged.add(onChangedSetting); + + await context.sync(); + console.log("Settings changed handler registered."); + }); +Excel.SettingCollection#onSettingsChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + settings.onSettingsChanged.add(onChangedSetting); + + await context.sync(); + console.log("Settings changed handler registered."); + }); +Excel.SettingCollection#getItemOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-get-change-delete-settings.yaml + + + await Excel.run(async (context) => { + const settings = context.workbook.settings; + let needsReview = settings.getItem("NeedsReview"); + needsReview.delete(); + needsReview = settings.getItemOrNullObject("NeedsReview"); + + await context.sync(); + + if (needsReview.isNullObject) { + console.log("The setting has been deleted"); + } else { + console.log("The setting was not deleted"); + } + + await context.sync(); + }); +Excel.Shape#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + + + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Shapes").delete(); + const sheet = context.workbook.worksheets.add("Shapes"); + + const shapes = sheet.shapes; + + // load all the shapes in the collection without loading their properties + shapes.load("items/$none"); + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + await context.sync(); + }); +Excel.Shape#fill:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.smileyFace); + shape.left = 300; + shape.top = 100; + shape.height = 100; + shape.width = 100; + shape.fill.foregroundColor = "yellow" + await context.sync(); + }); +Excel.Shape#rotation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.triangle); + shape.left = 100; + shape.top = 300; + shape.height = 150; + shape.width = 200; + shape.rotation = 45; + shape.fill.clear(); + await context.sync(); + }); +Excel.Shape#group:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-groups.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + + const shapeGroup = sheet.shapes.getItem("Group").group; + shapeGroup.ungroup(); + console.log("Shapes ungrouped"); + + await context.sync(); + }); +Excel.Shape#getAsImage:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Image"); + const result = shape.getAsImage(Excel.PictureFormat.png); + await context.sync(); + + const imageString = result.value; + // Your add-in would save this string as a .png file. + console.log("The image's Base64-encoded string: " + imageString); + }); +Excel.Shape#incrementRotation:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Image"); + shape.incrementRotation(180); + await context.sync(); + }); +Excel.Shape#line:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.getItem("StraightLine").line; + line.beginArrowheadLength = Excel.ArrowheadLength.long; + line.beginArrowheadWidth = Excel.ArrowheadWidth.wide; + line.beginArrowheadStyle = Excel.ArrowheadStyle.oval; + + line.endArrowheadLength = Excel.ArrowheadLength.long; + line.endArrowheadWidth = Excel.ArrowheadWidth.wide; + line.endArrowheadStyle = Excel.ArrowheadStyle.triangle; + + await context.sync(); + }); +Excel.Shape#incrementLeft:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Square") + shape.incrementLeft(-25); + await context.sync(); + }); +Excel.Shape#incrementTop:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Pentagon") + shape.incrementTop(25); + await context.sync(); + }); +Excel.Shape#lockAspectRatio:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Octagon") + shape.lockAspectRatio = true; + shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize); + await context.sync(); + }); +Excel.Shape#scaleHeight:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Octagon") + shape.lockAspectRatio = true; + shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize); + await context.sync(); + }); +Excel.Shape#setZOrder:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Octagon") + shape.setZOrder(Excel.ShapeZOrder.sendBackward); + await context.sync(); + }); +Excel.ShapeAutoSize:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const textbox = shapes.getItem("Textbox"); + textbox.textFrame.autoSizeSetting = Excel.ShapeAutoSize.autoSizeShapeToFitText; + await context.sync(); + }); +Excel.ShapeCollection#addGeometricShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.hexagon); + shape.left = 5; + shape.top = 5; + shape.height = 175; + shape.width = 200; + await context.sync(); + }); +Excel.ShapeCollection#addGroup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-groups.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const square = sheet.shapes.getItem("Square"); + const pentagon = sheet.shapes.getItem("Pentagon"); + const octagon = sheet.shapes.getItem("Octagon"); + + const shapeGroup = sheet.shapes.addGroup([square, pentagon, octagon]); + shapeGroup.name = "Group"; + console.log("Shapes grouped"); + + await context.sync(); + }); +Excel.ShapeCollection#addImage:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml + + + const myFile = document.getElementById("selectedFile") as HTMLInputElement; + + const reader = new FileReader(); + + + reader.onload = (event) => { + Excel.run((context) => { + const startIndex = reader.result.toString().indexOf("base64,"); + const myBase64 = reader.result.toString().substr(startIndex + 7); + const sheet = context.workbook.worksheets.getItem("Shapes"); + const image = sheet.shapes.addImage(myBase64); + image.name = "Image"; + return context.sync(); + }); + }; + + + // Read in the image file as a data URL. + + reader.readAsDataURL(myFile.files[0]); +Excel.ShapeCollection#addLine:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const line = shapes.addLine(200, 50, 300, 150, Excel.ConnectorType.straight); + line.name = "StraightLine"; + await context.sync(); + }); +Excel.ShapeCollection#addTextBox:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const textbox = shapes.addTextBox("A box with text"); + textbox.left = 100; + textbox.top = 100; + textbox.height = 20; + textbox.width = 175; + textbox.name = "Textbox"; + await context.sync(); + }); +Excel.ShapeGroup#ungroup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-groups.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + + const shapeGroup = sheet.shapes.getItem("Group").group; + shapeGroup.ungroup(); + console.log("Shapes ungrouped"); + + await context.sync(); + }); +Excel.ShapeScaleType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Octagon") + shape.lockAspectRatio = true; + shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize); + await context.sync(); + }); +Excel.ShapeTextHorizontalAlignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const textbox = shapes.getItem("Textbox"); + textbox.textFrame.horizontalAlignment = Excel.ShapeTextHorizontalAlignment.center; + await context.sync(); + }); +Excel.ShapeZOrder:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Shapes"); + const shape = sheet.shapes.getItem("Octagon") + shape.setZOrder(Excel.ShapeZOrder.sendBackward); + await context.sync(); + }); +Excel.SheetVisibility:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-visibility.yaml + + + await Excel.run(async (context) => { + + const visibleSheets = await filterWorksheetsByVisibility(context, Excel.SheetVisibility.visible); + + if (visibleSheets.length > 1) { + console.log(`Hiding worksheet named "${visibleSheets[0].name}"...`); + + visibleSheets[0].visibility = Excel.SheetVisibility.hidden; + + await context.sync(); + + } else { + console.log("Cannot hide the only visible worksheet"); + } + }); +Excel.ShowAsCalculation:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm"); + const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale"); + + farmDataHierarchy.load("showAs"); + wholesaleDataHierarchy.load("showAs"); + await context.sync(); + + // Show the crates of each fruit type sold at the farm as a percentage of the column's total. + let farmShowAs = farmDataHierarchy.showAs; + farmShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; + farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); + farmDataHierarchy.showAs = farmShowAs; + + let wholesaleShowAs = wholesaleDataHierarchy.showAs; + wholesaleShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; + wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); + wholesaleDataHierarchy.showAs = wholesaleShowAs; + await context.sync(); + }); +Excel.ShowAsRule#baseItem:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml + + + await Excel.run(async (context) => { + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm"); + const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale"); + + farmDataHierarchy.load("showAs"); + wholesaleDataHierarchy.load("showAs"); + await context.sync(); + + // Show the difference between crate sales of the "A Farms" and the other farms. + // This difference is both aggregated and shown for individual fruit types (where applicable). + let farmShowAs = farmDataHierarchy.showAs; + farmShowAs.calculation = Excel.ShowAsCalculation.differenceFrom; + farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm"); + farmShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms"); + farmDataHierarchy.showAs = farmShowAs; + + let wholesaleShowAs = wholesaleDataHierarchy.showAs; + wholesaleShowAs.calculation = Excel.ShowAsCalculation.differenceFrom; + wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm"); + wholesaleShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms"); + wholesaleDataHierarchy.showAs = wholesaleShowAs; + await context.sync(); + }); +Excel.Slicer#clearFilters:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const slicer = context.workbook.slicers.getItem("Fruit Slicer"); + slicer.clearFilters(); + await context.sync(); + }); +Excel.Slicer#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + sheet.slicers.getItemAt(0).delete(); + await context.sync(); + }); +Excel.Slicer#selectItems:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const slicer = context.workbook.slicers.getItem("Fruit Slicer"); + slicer.selectItems(["Lemon", "Lime", "Orange"]); + await context.sync(); + }); +Excel.Slicer#style:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const slicer = context.workbook.slicers.getItem("Fruit Slicer"); + slicer.style = "SlicerStyleLight6"; + await context.sync(); + }); +Excel.SlicerCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Pivot"); + const slicer = sheet.slicers.add( + "Farm Sales", /* The slicer data source. For PivotTables, this can be the PivotTable object reference or name. */ + "Type" /* The field in the data source to filter by. For PivotTables, this can be a PivotField object reference or ID. */ + ); + slicer.name = "Fruit Slicer"; + await context.sync(); + }); +Excel.SlicerCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const slicer = context.workbook.slicers.getItem("Fruit Slicer"); + slicer.caption = "Fruit Types"; + slicer.left = 395; + slicer.top = 15; + slicer.height = 135; + slicer.width = 150; + await context.sync(); + }); +Excel.SortOn:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + + + async function sortTopToBottom(criteria: string) { + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("A1:E5"); + + // Find the column header that provides the sort criteria. + const header = range.find(criteria, {}); + header.load("columnIndex"); + await context.sync(); + + range.sort.apply( + [ + { + key: header.columnIndex, + sortOn: Excel.SortOn.value + } + ], + false /*matchCase*/, + true /*hasHeaders*/, + Excel.SortOrientation.rows + ); + await context.sync(); + }); + } +Excel.SortOrientation:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + + + async function sortLeftToRight(criteria: string) { + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("A1:E5"); + + // Find the row header that provides the sort criteria. + const header = range.find(criteria, {}); + header.load("rowIndex"); + await context.sync(); + + range.sort.apply( + [ + { + key: header.rowIndex, + sortOn: Excel.SortOn.value + } + ], + false /*matchCase*/, + true /*hasHeaders*/, + Excel.SortOrientation.columns + ); + await context.sync(); + }); + } +CustomFunctions.StreamingInvocation#setResult:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/streaming-function.yaml + + + /** @CustomFunction + * @description Increments the cell with a given amount at a specified interval in milliseconds. + * @param {number} amount - The amount to add to the cell value on each increment. + * @param {number} interval - The time in milliseconds to wait before the next increment on the cell. + * @param {CustomFunctions.StreamingInvocation} invocation - Parameter to send results to Excel + * or respond to the user canceling the function. + * @returns An incrementing value. + */ + function increment(amount: number, interval: number, invocation: + CustomFunctions.StreamingInvocation): void { + let result = 0; + const timer = setInterval(() => { + result += amount; + invocation.setResult(result); + }, interval); + + invocation.onCanceled = () => { + clearInterval(timer); + } + } +Excel.Style#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let style = context.workbook.styles.getItem("Diagonal Orientation Style"); + + // Delete the diagonal orientation style from the style collection. + // Styles are in the Home tab ribbon. + style.delete(); + + await context.sync(); + + console.log("Successfully deleted the diagonal orientation style from the Home tab ribbon."); + }); +Excel.Style#font:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let style = context.workbook.styles.getItem("Normal"); + style.font.load("bold, color, italic, name, size"); + style.fill.load("color"); + + await context.sync(); + + console.log("Bold: " + style.font.bold); + console.log("Font color: " + style.font.color); + console.log("Italic: " + style.font.italic); + console.log("Name: " + style.font.name); + console.log("Size: " + style.font.size); + console.log("Fill color: " + style.fill.color); + }); +Excel.Style#horizontalAlignment:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let worksheet = context.workbook.worksheets.getItem("Sample"); + let range = worksheet.getRange("A1:E1"); + + // Apply built-in style. + // Styles are in the Home tab ribbon. + range.style = Excel.BuiltInStyle.neutral; + range.format.horizontalAlignment = "Right"; + + await context.sync(); + }); +Excel.Style#load:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let style = context.workbook.styles.getItem("Diagonal Orientation Style"); + style.load("textOrientation, horizontalAlignment, autoIndent, readingOrder, wrapText, includeProtection, shrinkToFit, locked"); + + await context.sync(); + + console.log("Orientation: " + style.textOrientation); + console.log("Horizontal alignment: " + style.horizontalAlignment); + console.log("Add indent: " + style.autoIndent); + console.log("Reading order: " + style.readingOrder); + console.log("Wrap text: " + style.wrapText); + console.log("Include protection: " + style.includeProtection); + console.log("Shrink to fit: " + style.shrinkToFit); + console.log("Style locked: " + style.locked); + }); +Excel.StyleCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let styles = context.workbook.styles; + + // Add a new style to the style collection. + // Styles is in the Home tab ribbon. + styles.add("Diagonal Orientation Style"); + + let newStyle = styles.getItem("Diagonal Orientation Style"); + + // The "Diagonal Orientation Style" properties. + newStyle.textOrientation = 38; + newStyle.autoIndent = true; + newStyle.includeProtection = true; + newStyle.shrinkToFit = true; + newStyle.locked = false; + + await context.sync(); + + console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + }); +Excel.StyleCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let styles = context.workbook.styles; + + // Add a new style to the style collection. + // Styles is in the Home tab ribbon. + styles.add("Diagonal Orientation Style"); + + let newStyle = styles.getItem("Diagonal Orientation Style"); + + // The "Diagonal Orientation Style" properties. + newStyle.textOrientation = 38; + newStyle.autoIndent = true; + newStyle.includeProtection = true; + newStyle.shrinkToFit = true; + newStyle.locked = false; + + await context.sync(); + + console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + }); +Excel.Table#onChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-table-changed.yaml + + + await Excel.run(async (context) => { + let table = context.workbook.tables.getItemAt(0); + table.onChanged.add(onChange); + + await context.sync(); + console.log("A handler has been registered for the onChanged event"); + }); +Excel.Table#onSelectionChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-table-changed.yaml + + + await Excel.run(async (context) => { + let table = context.workbook.tables.getItemAt(0); + table.onSelectionChanged.add(onSelectionChange); + + await context.sync(); + console.log("A handler has been registered for table onSelectionChanged event"); + }); +Excel.Table#resize:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/resize-table.yaml + + + await Excel.run(async (context) => { + // Retrieve the worksheet and a table on that worksheet. + const sheet = context.workbook.worksheets.getItem("Sample"); + const expensesTable = sheet.tables.getItem("ExpensesTable"); + + // Resize the table. + expensesTable.resize("A1:D20"); + + await context.sync(); + }); +Excel.TableChangedEventArgs#details:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-change-event-details.yaml + + + async function onTableChanged(eventArgs: Excel.TableChangedEventArgs) { + await Excel.run(async (context) => { + const details = eventArgs.details; + const address = eventArgs.address; + + console.log(`Change at ${address}: was ${details.valueBefore}(${details.valueTypeBefore}),` + + ` now is ${details.valueAfter}(${details.valueTypeAfter})`); + }); + } +Excel.TableChangedEventArgs#tableId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-tablecollection-changed.yaml + + + async function onChange(event) { + await Excel.run(async (context) => { + let table = context.workbook.tables.getItem(event.tableId); + let worksheet = context.workbook.worksheets.getItem(event.worksheetId); + worksheet.load("name"); + + await context.sync(); + + console.log("Handler for table collection onChanged event has been triggered. Data changed address: " + event.address); + console.log("Table Id : " + event.tableId); + console.log("Worksheet Id : " + worksheet.name); + }); + } +Excel.TableChangedEventArgs#worksheetId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-tablecollection-changed.yaml + + + async function onChange(event) { + await Excel.run(async (context) => { + let table = context.workbook.tables.getItem(event.tableId); + let worksheet = context.workbook.worksheets.getItem(event.worksheetId); + worksheet.load("name"); + + await context.sync(); + + console.log("Handler for table collection onChanged event has been triggered. Data changed address: " + event.address); + console.log("Table Id : " + event.tableId); + console.log("Worksheet Id : " + worksheet.name); + }); + } +Excel.TableCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.TableCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove checkboxes from the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the checkboxes back to boolean values. + range.control = { + type: Excel.CellControlType.empty + }; + await context.sync(); + }); +Excel.TableCollection#onChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-tablecollection-changed.yaml + + + await Excel.run(async (context) => { + let tables = context.workbook.tables; + tables.onChanged.add(onChange); + + await context.sync(); + console.log("A handler has been registered for the table collection onChanged event"); + }); +Excel.TableColumn#getDataBodyRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.TableColumnCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +Excel.TableColumnCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove all content from the Analysis column. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Clear all the data from the second column. + range.clearOrResetContents(); + await context.sync(); + }); +Excel.TableSelectionChangedEventArgs#address:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-table-changed.yaml + + + async function onSelectionChange(args) { + await Excel.run(async (context) => { + console.log("Handler for table onSelectionChanged event has been triggered. The new selection is: " + args.address); + }); + } +Excel.TextConditionalFormat#format:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B16:D18"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.containsText); + conditionalFormat.textComparison.format.font.color = "red"; + conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; + + await context.sync(); + }); +Excel.TextConditionalFormat#rule:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("B16:D18"); + const conditionalFormat = range.conditionalFormats + .add(Excel.ConditionalFormatType.containsText); + conditionalFormat.textComparison.format.font.color = "red"; + conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; + + await context.sync(); + }); +Excel.TextFrame#deleteText:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml + + + await Excel.run(async (context) => { + const shapes = context.workbook.worksheets.getItem("Shapes").shapes; + const textbox = shapes.getItem("Textbox"); + textbox.textFrame.deleteText(); + await context.sync(); + }); +Excel.ValueFilterCondition:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + + + await Excel.run(async (context) => { + // Add a PivotFilter to filter on the values correlated with a row. + + // Get the PivotTable. + const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + + // Get the "Farm" field. + const field = pivotTable.hierarchies.getItem("Farm").fields.getItem("Farm"); + + // Filter to only include rows with more than 500 wholesale crates sold. + const filter: Excel.PivotValueFilter = { + condition: Excel.ValueFilterCondition.greaterThan, + comparator: 500, + value: "Sum of Crates Sold Wholesale" + }; + + // Apply the value filter to the field. + field.applyFilter({ valueFilter: filter }); + + await context.sync(); + }); +Excel.VerticalAlignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let worksheet = context.workbook.worksheets.getItem("Sample"); + let range = worksheet.getRange("A1:E1"); + // Apply new style. + range.style = ("Diagonal Orientation Style"); + range.format.verticalAlignment = "Justify"; + + await context.sync(); + }); +Excel.WebImageCellValue#address:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml + + + // This function retrieves the image URL from the selected cell and opens + that image in a new browser tab. + + await Excel.run(async (context) => { + // Load the active cell information. + const activeCell = context.workbook.getActiveCell(); + activeCell.load("valuesAsJson"); + await context.sync(); + + // Get image URL from the active cell. + const values = activeCell.valuesAsJson; + const webImageData = values[0][0] as Excel.WebImageCellValue; + const webImageUrl = webImageData.address; + + if (!webImageUrl) { + console.log("The selected cell is missing an image URL. Select a cell that contains an image."); + return; + } + + // Open the image URL in a new browser tab. + const tab = window.open(webImageData.address, "_blank"); + }); +Excel.WebImageCellValue#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml + + + // This function inserts a web image into the currently selected cell. + + await Excel.run(async (context) => { + // Retrieve image data from the task pane and then clear the input fields. + const imageUrl = (document.getElementById("url") as HTMLInputElement).value; + const imageAltText = (document.getElementById("alt-text") as HTMLInputElement).value; + clearForm(); + + // Load the active cell. + const activeCell = context.workbook.getActiveCell(); + activeCell.load(); + await context.sync(); + + if (!imageUrl) { + console.log("Please enter an image URL."); + return; + } + + // Create a web image object and assign the image details. + const webImage: Excel.WebImageCellValue = { + type: "WebImage", /* The string equivalent of `Excel.CellValueType.webImage`. */ + address: imageUrl, + altText: imageAltText + }; + + // Insert web image into the active cell. + activeCell.valuesAsJson = [[webImage]]; + + await context.sync(); + }); +Excel.Workbook#properties:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/properties.yaml + + + await Excel.run(async (context) => { + let titleValue = "Excel document properties API"; + let subjectValue = "Set and get document properties"; + let keywordsValue = "Set and get operations"; + let commentsValue = "This is an Excel document properties API code sample"; + let categoryValue = "Office Add-ins"; + let managerValue = "John"; + let companyValue = "Microsoft"; + + let docProperties = context.workbook.properties; + + // Set the writeable document properties. + docProperties.title = titleValue; + docProperties.subject = subjectValue; + docProperties.keywords = keywordsValue; + docProperties.comments = commentsValue; + docProperties.category = categoryValue; + docProperties.manager = managerValue; + docProperties.company = companyValue; + + await context.sync(); + + console.log("Set the following document properties: title, subject, keywords, comments, category, manager, company."); + }); +Excel.Workbook#onActivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-activated.yaml + + + async function workbookActivated(event: Excel.WorkbookActivatedEventArgs) { + await Excel.run(async (context) => { + // Callback function for when the workbook is activated. + console.log("The workbook was activated."); + }); + } + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-activated.yaml + + + await Excel.run(async (context) => { + const workbook = context.workbook; + + // Register the workbook activated event handler. + workbook.onActivated.add(workbookActivated); + + await context.sync(); + console.log("Added event handler for workbook activated."); + }); +Excel.Workbook#pivotTables:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + + + await Excel.run(async (context) => { + // Get the names of all the PivotTables in the workbook. + const pivotTables = context.workbook.pivotTables; + pivotTables.load("name"); + await context.sync(); + + // Display the names in the console. + console.log("PivotTables in the workbook:") + pivotTables.items.forEach((pivotTable) => { + console.log(`\t${pivotTable.name}`); + }); + }); +Excel.Workbook#getSelectedRanges:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml + + + await Excel.run(async (context) => { + + const selectedRanges = context.workbook.getSelectedRanges(); + selectedRanges.format.fill.color = "lightblue"; + + await context.sync(); + }) +Excel.Workbook#styles:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml + + + await Excel.run(async (context) => { + let styles = context.workbook.styles; + + // Add a new style to the style collection. + // Styles is in the Home tab ribbon. + styles.add("Diagonal Orientation Style"); + + let newStyle = styles.getItem("Diagonal Orientation Style"); + + // The "Diagonal Orientation Style" properties. + newStyle.textOrientation = 38; + newStyle.autoIndent = true; + newStyle.includeProtection = true; + newStyle.shrinkToFit = true; + newStyle.locked = false; + + await context.sync(); + + console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + }); +Excel.Workbook#getActiveShapeOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-get-active.yaml + + + // This method gets the active shape and displays it as an image in the task + pane. + + await Excel.run(async (context) => { + // Get the currently active shape, if any. + const activeShape = context.workbook.getActiveShapeOrNullObject(); + + if (activeShape) { + // Convert the active shape to an image. + const shapeImage = activeShape.getAsImage(Excel.PictureFormat.png); + await context.sync(); + + // Display the image in the task pane. + const imageContainer = document.getElementById("image"); + imageContainer.innerHTML = ''; // Clear the container before adding a new image. + const imageElement = document.createElement("img"); + imageElement.src = "data:image/png;base64," + shapeImage.value; + imageContainer.appendChild(imageElement); + } else { + console.log("No active shape"); + } + }); +Excel.Workbook#getActiveCell:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-get-active-cell.yaml + + + await Excel.run(async (context) => { + + let myWorkbook = context.workbook; + let activeCell = myWorkbook.getActiveCell(); + activeCell.load("address"); + + await context.sync(); + + console.log("The active cell is " + activeCell.address); + }); +Excel.Workbook#insertWorksheetsFromBase64:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml + + + // Retrieve the file and set up an HTML FileReader element. + + const myFile = document.getElementById("file") as HTMLInputElement; + + const reader = new FileReader(); + + + reader.onload = (event) => { + // Remove the metadata before the Base64-encoded string. + const startIndex = reader.result.toString().indexOf("base64,"); + externalWorkbook = reader.result.toString().substr(startIndex + 7); + }; + + + // Read the file as a data URL so that we can parse the Base64-encoded + string. + + reader.readAsDataURL(myFile.files[0]); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml + + + await Excel.run(async (context) => { + // Retrieve the source workbook. + const workbook = context.workbook; + + // Set up the insert options. + const options = { + sheetNamesToInsert: [], // Insert all the worksheets from the source workbook. + positionType: Excel.WorksheetPositionType.after, // Insert after the `relativeTo` sheet. + relativeTo: "Sheet1" // The sheet relative to which the other worksheets will be inserted. Used with `positionType`. + }; + + // Insert the new worksheets. + workbook.insertWorksheetsFromBase64(externalWorkbook, options); + await context.sync(); + }); +Excel.Workbook#close:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml + + + await Excel.run(async (context) => { + context.workbook.close(Excel.CloseBehavior.save); + }); +Excel.Workbook#save:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml + + + await Excel.run(async (context) => { + context.workbook.save(Excel.SaveBehavior.save); + }); +Excel.WorkbookProtection#protect:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml + + + let password = await passwordHandler(); + + passwordHelper(password); + + await Excel.run(async (context) => { + let workbook = context.workbook; + workbook.load("protection/protected"); + + await context.sync(); + + if (!workbook.protection.protected) { + workbook.protection.protect(password); + } + }); +Excel.WorkbookProtection#unprotect:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml + + + let password = await passwordHandler(); + + passwordHelper(password); + + await Excel.run(async (context) => { + let workbook = context.workbook; + workbook.protection.unprotect(password); + }); +Excel.WorkbookRangeAreas#areas:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/precedents.yaml + + + await Excel.run(async (context) => { + // Precedents are cells referenced by the formula in a cell. + // A "direct precedent" is a cell directly referenced by the selected formula. + let range = context.workbook.getActiveCell(); + let directPrecedents = range.getDirectPrecedents(); + range.load("address"); + directPrecedents.areas.load("address"); + await context.sync(); + + console.log(`Direct precedent cells of ${range.address}:`); + + // Use the direct precedents API to loop through precedents of the active cell. + for (let i = 0; i < directPrecedents.areas.items.length; i++) { + // Highlight and console the address of each precedent cell. + directPrecedents.areas.items[i].format.fill.color = "Yellow"; + console.log(` ${directPrecedents.areas.items[i].address}`); + } + await context.sync(); + }); +Excel.Worksheet#customProperties:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml + + + await Excel.run(async (context) => { + // Load the keys and values of all custom properties in the current worksheet. + const customWorksheetProperties = context.workbook.worksheets.getActiveWorksheet().customProperties; + customWorksheetProperties.load(["key", "value"]); + await context.sync(); + + // Log each custom property to the console. + // Note that your document may have more properties than those you have set using this snippet. + customWorksheetProperties.items.forEach((property) => { + console.log(`${property.key}:${property.value}`); + }); + }); +Excel.Worksheet#onColumnSorted:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + + + await Excel.run(async (context) => { + console.log("Adding column handler"); + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // This will fire whenever a column has been moved as the result of a sort action. + sheet.onColumnSorted.add((event) => { + return Excel.run((context) => { + console.log("Column sorted: " + event.address); + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Clear formatting for section, then highlight the sorted area. + sheet.getRange("A1:E5").format.fill.clear(); + if (event.address !== "") { + sheet.getRanges(event.address).format.fill.color = "yellow"; + } + + return context.sync(); + }); + }); + }); +Excel.Worksheet#onRowSorted:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml + + + await Excel.run(async (context) => { + console.log("Adding row handler"); + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // This will fire whenever a row has been moved as the result of a sort action. + sheet.onRowSorted.add((event) => { + return Excel.run((context) => { + console.log("Row sorted: " + event.address); + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Clear formatting for section, then highlight the sorted area. + sheet.getRange("A1:E5").format.fill.clear(); + if (event.address !== "") { + sheet.getRanges(event.address).format.fill.color = "yellow"; + } + + return context.sync(); + }); + }); + }); +Excel.Worksheet#onSingleClicked:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-worksheet-single-click.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + sheet.onSingleClicked.add((event) => { + return Excel.run((context) => { + console.log(`Click detected at ${event.address} (pixel offset from upper-left cell corner: ${event.offsetX}, ${event.offsetY})`); + return context.sync(); + }); + }); + + console.log("The worksheet click handler is registered."); + + await context.sync(); + }); +Excel.Worksheet#onFormulaChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-formula-changed.yaml + + + await Excel.run(async (context) => { + // Retrieve the worksheet named "Sample". + let sheet = context.workbook.worksheets.getItem("Sample"); + + // Register the formula changed event handler for this worksheet. + sheet.onFormulaChanged.add(formulaChangeHandler); + await context.sync(); + + console.log("Registered a formula changed event handler for this worksheet."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-formula-changed.yaml + + + async function formulaChangeHandler(event: + Excel.WorksheetFormulaChangedEventArgs) { + await Excel.run(async (context) => { + // Retrieve details about the formula change event. + const cellAddress = event.formulaDetails[0].cellAddress; + const previousFormula = event.formulaDetails[0].previousFormula; + const source = event.source; + + // Print out the change event details. + console.log( + `The formula in cell ${cellAddress} changed. + The previous formula was: ${previousFormula}. + The source of the change was: ${source}.` + ); + }); + } +Excel.Worksheet#onChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets.getItem("Sample"); + sheet.onChanged.add(onChange); + await context.sync(); + + console.log("Added a worksheet-level data-changed event handler."); + }); +Excel.Worksheet#onProtectionChanged:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + + + // This function registers an event handler for the onProtectionChanged + event of a worksheet. + + await Excel.run(async (context) => { + // Set "Sample" as the active worksheet. + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + sheet.activate(); + + // Register the onProtectionChanged event handler. + sheet.onProtectionChanged.add(checkProtection); + await context.sync(); + console.log("Added a worksheet protection change event handler."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + + + async function checkProtection(event: + Excel.WorksheetProtectionChangedEventArgs) { + // This function is an event handler that returns the protection status of a worksheet + // and information about the changed worksheet. + await Excel.run(async (context) => { + const protectionStatus = event.isProtected; + const worksheetId = event.worksheetId; + const source = event.source; + console.log("Protection status changed. Protection status is now: " + protectionStatus + "."); + console.log(" ID of changed worksheet: " + worksheetId + "."); + console.log(" Source of change event: " + source + "."); + }); + } +Excel.Worksheet#showOutlineLevels:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml + + + Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // This shows the top 3 outline levels; collapsing any additional sublevels. + sheet.showOutlineLevels(3, 3); + await context.sync(); + }); +Excel.Worksheet#slicers:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Pivot"); + const slicer = sheet.slicers.add( + "Farm Sales", /* The slicer data source. For PivotTables, this can be the PivotTable object reference or name. */ + "Type" /* The field in the data source to filter by. For PivotTables, this can be a PivotField object reference or ID. */ + ); + slicer.name = "Fruit Slicer"; + await context.sync(); + }); +Excel.Worksheet#pivotTables:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + + + await Excel.run(async (context) => { + // Get the names of all the PivotTables in the current worksheet. + const pivotTables = context.workbook.worksheets.getActiveWorksheet().pivotTables; + pivotTables.load("name"); + await context.sync(); + + // Display the names in the console. + console.log("PivotTables in the current worksheet:") + pivotTables.items.forEach((pivotTable) => { + console.log(`\t${pivotTable.name}`); + }); + }); +Excel.Worksheet#getRanges:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml + + + await Excel.run(async (context) => { + + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const specifiedRanges = sheet.getRanges("D3:D5, G3:G5"); + specifiedRanges.format.fill.color = "pink"; + + await context.sync(); + }) +Excel.Worksheet#autoFilter:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml + + + // This function adds a percentage AutoFilter to the active worksheet + + // and applies the filter to a column of the used range. + + await Excel.run(async (context) => { + // Retrieve the active worksheet and the used range on that worksheet. + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const farmData = sheet.getUsedRange(); + + // Add a filter that will only show the rows with the top 50% of values in column 3. + sheet.autoFilter.apply(farmData, 3, { + criterion1: "50", + filterOn: Excel.FilterOn.topPercent + }); + + await context.sync(); + }); +Excel.Worksheet#copy:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-copy.yaml + + + await Excel.run(async (context) => { + + let myWorkbook = context.workbook; + let sampleSheet = myWorkbook.worksheets.getActiveWorksheet(); + let copiedSheet = sampleSheet.copy("End") + + sampleSheet.load("name"); + copiedSheet.load("name"); + + await context.sync(); + + console.log("'" + sampleSheet.name + "' was copied to '" + copiedSheet.name + "'") + }); +Excel.Worksheet#findAllOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-find-all.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const foundRanges = sheet.findAllOrNullObject("Complete", { + completeMatch: true, + matchCase: false + }); + + await context.sync(); + + if (foundRanges.isNullObject) { + console.log("No complete projects"); + } else { + foundRanges.format.fill.color = "green" + } + }); +Excel.Worksheet#showGridlines:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/gridlines.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + sheet.showGridlines = true; + + await context.sync(); + }); +Excel.Worksheet#getNext:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + + + await Excel.run(async (context) => { + const sheets = context.workbook.worksheets; + + // We don't want to include the default worksheet that was created + // when the workbook was created, so our "firstSheet" will be the one + // after the literal first. Note chaining of navigation methods. + const firstSheet = sheets.getFirst().getNext(); + const lastSheet = sheets.getLast(); + const firstTaxRateRange = firstSheet.getRange("B2"); + const lastTaxRateRange = lastSheet.getRange("B2"); + + firstSheet.load("name"); + lastSheet.load("name"); + firstTaxRateRange.load("text"); + lastTaxRateRange.load("text"); + + await context.sync(); + + let firstYear = firstSheet.name.substr(5, 4); + let lastYear = lastSheet.name.substr(5, 4); + console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + + await context.sync(); + }); +Excel.Worksheet#getPrevious:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + + + await Excel.run(async (context) => { + const sheets = context.workbook.worksheets; + const currentSheet = sheets.getActiveWorksheet(); + const previousYearSheet = currentSheet.getPrevious(); + const currentTaxDueRange = currentSheet.getRange("C2"); + const previousTaxDueRange = previousYearSheet.getRange("C2"); + + currentSheet.load("name"); + previousYearSheet.load("name"); + currentTaxDueRange.load("text"); + previousTaxDueRange.load("text"); + + await context.sync(); + + let currentYear = currentSheet.name.substr(5, 4); + let previousYear = previousYearSheet.name.substr(5, 4); + console.log("Two Year Tax Due Comparison", `Tax due for ${currentYear} was ${currentTaxDueRange.text[0][0]}\nTax due for ${previousYear} was ${previousTaxDueRange.text[0][0]}`) + + await context.sync(); + }); +Excel.Worksheet#tabColor:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/tab-color.yaml + + + await Excel.run(async (context) => { + const activeSheet = context.workbook.worksheets.getActiveWorksheet(); + activeSheet.tabColor = "#FF0000"; + + await context.sync(); + }); +Excel.WorksheetAddedEventArgs#worksheetId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + async function onWorksheetAdd(event) { + await Excel.run(async (context) => { + console.log( + "Handler for worksheet onAdded event has been triggered. Newly added worksheet Id : " + + event.worksheetId + ); + }); + } +Excel.WorksheetChangedEventArgs#changeDirectionState:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + + + async function onChange(event: Excel.WorksheetChangedEventArgs) { + // This function is an event handler that returns the address, trigger source, + // and insert or delete shift directions of the change. + await Excel.run(async (context) => { + // Return the address where change occurred. + console.log(`Handler for worksheet onChanged event has been triggered.`); + console.log(` Data changed address: ` + event.address); + + // Return the source of the event that triggered the change. + console.log(` Data change trigger source: ` + event.triggerSource); + + // Note:insertShiftDirection and deleteShiftDirection are exclusive and both enums can't have a value at the same time. + // If one has a value, then the other will return undefined. + + // If the insert shift direction is defined, return it. + if (event.changeDirectionState.insertShiftDirection) { + console.log(` Cells inserted shift direction: ` + event.changeDirectionState.insertShiftDirection); + } + + // If the delete shift direction is defined, return it. + if (event.changeDirectionState.deleteShiftDirection) { + console.log(` Cells deleted shift direction: ` + event.changeDirectionState.deleteShiftDirection); + } + }); + } + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + + + // This function deletes data from a range and sets the delete shift + direction to "up". + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const range = sheet.getRange("A5:F5"); + range.delete(Excel.DeleteShiftDirection.up); + }); +Excel.WorksheetChangedEventArgs#triggerSource:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml + + + async function onChange(event: Excel.WorksheetChangedEventArgs) { + // This function is an event handler that returns the address, trigger source, + // and insert or delete shift directions of the change. + await Excel.run(async (context) => { + // Return the address where change occurred. + console.log(`Handler for worksheet onChanged event has been triggered.`); + console.log(` Data changed address: ` + event.address); + + // Return the source of the event that triggered the change. + console.log(` Data change trigger source: ` + event.triggerSource); + + // Note:insertShiftDirection and deleteShiftDirection are exclusive and both enums can't have a value at the same time. + // If one has a value, then the other will return undefined. + + // If the insert shift direction is defined, return it. + if (event.changeDirectionState.insertShiftDirection) { + console.log(` Cells inserted shift direction: ` + event.changeDirectionState.insertShiftDirection); + } + + // If the delete shift direction is defined, return it. + if (event.changeDirectionState.deleteShiftDirection) { + console.log(` Cells deleted shift direction: ` + event.changeDirectionState.deleteShiftDirection); + } + }); + } +Excel.WorksheetCollection#onActivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + await Excel.run(async (context) => { + let sheets = context.workbook.worksheets; + sheets.onActivated.add(onActivate); + + await context.sync(); + console.log("A handler has been registered for the OnActivate event."); + }); +Excel.WorksheetCollection#onAdded:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + await Excel.run(async (context) => { + let sheet = context.workbook.worksheets; + sheet.onAdded.add(onWorksheetAdd); + + await context.sync(); + console.log("A handler has been registered for the OnAdded event."); + }); +Excel.WorksheetCollection#onDeactivated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + + + await Excel.run(async (context) => { + let sheets = context.workbook.worksheets; + sheets.onDeactivated.add(onDeactivate); + + await context.sync(); + console.log("A handler has been registered for the OnDeactivate event."); + }); +Excel.WorksheetCollection#getFirst:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + + + await Excel.run(async (context) => { + const sheets = context.workbook.worksheets; + + // We don't want to include the default worksheet that was created + // when the workbook was created, so our "firstSheet" will be the one + // after the literal first. Note chaining of navigation methods. + const firstSheet = sheets.getFirst().getNext(); + const lastSheet = sheets.getLast(); + const firstTaxRateRange = firstSheet.getRange("B2"); + const lastTaxRateRange = lastSheet.getRange("B2"); + + firstSheet.load("name"); + lastSheet.load("name"); + firstTaxRateRange.load("text"); + lastTaxRateRange.load("text"); + + await context.sync(); + + let firstYear = firstSheet.name.substr(5, 4); + let lastYear = lastSheet.name.substr(5, 4); + console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + + await context.sync(); + }); +Excel.WorksheetCollection#getLast:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + + + await Excel.run(async (context) => { + const sheets = context.workbook.worksheets; + + // We don't want to include the default worksheet that was created + // when the workbook was created, so our "firstSheet" will be the one + // after the literal first. Note chaining of navigation methods. + const firstSheet = sheets.getFirst().getNext(); + const lastSheet = sheets.getLast(); + const firstTaxRateRange = firstSheet.getRange("B2"); + const lastTaxRateRange = lastSheet.getRange("B2"); + + firstSheet.load("name"); + lastSheet.load("name"); + firstTaxRateRange.load("text"); + lastTaxRateRange.load("text"); + + await context.sync(); + + let firstYear = firstSheet.name.substr(5, 4); + let lastYear = lastSheet.name.substr(5, 4); + console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + + await context.sync(); + }); +Excel.WorksheetCustomPropertyCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml + + + await Excel.run(async (context) => { + // Get the key/value pair from the task pane. + const userKey = document.getElementById("key").textContent; + const userValue = document.getElementById("value").textContent; + + // Add the custom property. + const customWorksheetProperties = context.workbook.worksheets.getActiveWorksheet().customProperties; + customWorksheetProperties.add(userKey, userValue); + + await context.sync(); + + console.log(`Successfully set custom worksheet property ${userKey}:${userValue}.`); + }); +Excel.WorksheetFreezePanes#freezeAt:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Freeze the specified range in top-and-left-most pane of the worksheet. + sheet.freezePanes.freezeAt(sheet.getRange("H2:K5")); + + await context.sync(); + }); +Excel.WorksheetFreezePanes#freezeColumns:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Freeze the first two columns in the worksheet. + sheet.freezePanes.freezeColumns(2); + + await context.sync(); + }); +Excel.WorksheetFreezePanes#freezeRows:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + + // Freeze the top two rows in the worksheet. + sheet.freezePanes.freezeRows(2); + + await context.sync(); + }); +Excel.WorksheetFreezePanes#getLocationOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + const frozenRange = sheet.freezePanes.getLocationOrNullObject(); + frozenRange.load("address"); + + await context.sync(); + + if (frozenRange.isNullObject) { + console.log(`The worksheet does not contain a frozen pane.`); + } else { + console.log(`The address of the frozen range (cells that are frozen in the top-and-left-most pane) is "${frozenRange.address}"`); + } + }); +Excel.WorksheetFreezePanes#unfreeze:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Sample"); + sheet.freezePanes.unfreeze(); + + await context.sync(); + }); +Excel.WorksheetPositionType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml + + + await Excel.run(async (context) => { + // Retrieve the source workbook. + const workbook = context.workbook; + + // Set up the insert options. + const options = { + sheetNamesToInsert: [], // Insert all the worksheets from the source workbook. + positionType: Excel.WorksheetPositionType.after, // Insert after the `relativeTo` sheet. + relativeTo: "Sheet1" // The sheet relative to which the other worksheets will be inserted. Used with `positionType`. + }; + + // Insert the new worksheets. + workbook.insertWorksheetsFromBase64(externalWorkbook, options); + await context.sync(); + }); +Excel.WorksheetProtection#protect:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml + + + let password = await passwordHandler(); + + passwordHelper(password); + + await Excel.run(async (context) => { + let activeSheet = context.workbook.worksheets.getActiveWorksheet(); + activeSheet.load("protection/protected"); + + await context.sync(); + + if (!activeSheet.protection.protected) { + activeSheet.protection.protect(null, password); + } + }); +Excel.WorksheetProtection#unprotect:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml + + + let password = await passwordHandler(); + + passwordHelper(password); + + await Excel.run(async (context) => { + let activeSheet = context.workbook.worksheets.getActiveWorksheet(); + activeSheet.protection.unprotect(password); + }); +Excel.WorksheetProtectionChangedEventArgs#isProtected:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + + + async function checkProtection(event: + Excel.WorksheetProtectionChangedEventArgs) { + // This function is an event handler that returns the protection status of a worksheet + // and information about the changed worksheet. + await Excel.run(async (context) => { + const protectionStatus = event.isProtected; + const worksheetId = event.worksheetId; + const source = event.source; + console.log("Protection status changed. Protection status is now: " + protectionStatus + "."); + console.log(" ID of changed worksheet: " + worksheetId + "."); + console.log(" Source of change event: " + source + "."); + }); + } +Excel.WorksheetProtectionChangedEventArgs#source:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + + + async function checkProtection(event: + Excel.WorksheetProtectionChangedEventArgs) { + // This function is an event handler that returns the protection status of a worksheet + // and information about the changed worksheet. + await Excel.run(async (context) => { + const protectionStatus = event.isProtected; + const worksheetId = event.worksheetId; + const source = event.source; + console.log("Protection status changed. Protection status is now: " + protectionStatus + "."); + console.log(" ID of changed worksheet: " + worksheetId + "."); + console.log(" Source of change event: " + source + "."); + }); + } +Excel.WorksheetProtectionChangedEventArgs#worksheetId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml + + + async function checkProtection(event: + Excel.WorksheetProtectionChangedEventArgs) { + // This function is an event handler that returns the protection status of a worksheet + // and information about the changed worksheet. + await Excel.run(async (context) => { + const protectionStatus = event.isProtected; + const worksheetId = event.worksheetId; + const source = event.source; + console.log("Protection status changed. Protection status is now: " + protectionStatus + "."); + console.log(" ID of changed worksheet: " + worksheetId + "."); + console.log(" Source of change event: " + source + "."); + }); + } +Excel.WorksheetSingleClickedEventArgs#address:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-worksheet-single-click.yaml + + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + sheet.onSingleClicked.add((event) => { + return Excel.run((context) => { + console.log(`Click detected at ${event.address} (pixel offset from upper-left cell corner: ${event.offsetX}, ${event.offsetY})`); + return context.sync(); + }); + }); + + console.log("The worksheet click handler is registered."); + + await context.sync(); + }); +Office.AppointmentCompose#addFileAttachmentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + const attachmentUrl = (document.getElementById("attachmentUrl") as + HTMLInputElement).value; + + Office.context.mailbox.item.addFileAttachmentAsync( + attachmentUrl, + getFileName(attachmentUrl), + { isInline: false }, + (result) => { + console.log(result); + } + ); +Office.AppointmentCompose#addFileAttachmentFromBase64Async:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + const base64String = + "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + base64String, + "logo.png", + { isInline: false }, + (result) => { + console.log(result); + } + ); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Set the signature for the current item with inline image. + + const modIcon1Base64 = + "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + modIcon1Base64, + "myImage.png", + { isInline: true }, + function(result) { + if (result.status == Office.AsyncResultStatus.Succeeded) { + const signature = (document.getElementById("signature") as HTMLInputElement).value + ""; + console.log(`Setting signature to "${signature}".`); + Office.context.mailbox.item.body.setSignatureAsync( + signature, + { coercionType: "html" }, + function(asyncResult) { + console.log(`setSignatureAsync: ${asyncResult.status}`); + } + ); + } else { + console.error(`addFileAttachmentFromBase64Async: ${result.error}`); + } + } + ); +Office.AppointmentCompose#categories:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Categories assigned to this item:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + // Note: In order for you to successfully add a category, + + // it must be in the mailbox categories master list. + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const masterCategories = asyncResult.value; + if (masterCategories && masterCategories.length > 0) { + // Grab the first category from the master list. + const categoryToAdd = [masterCategories[0].displayName]; + Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully assigned category '${categoryToAdd}' to item.`); + } else { + console.log("categories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + // Grab the first category assigned to this item. + const categoryToRemove = [categories[0].displayName]; + Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); + } else { + console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#close:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close.yaml + + + Office.context.mailbox.item.close(); +Office.AppointmentCompose#disableClientSignatureAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Disable the client signature. + + Office.context.mailbox.item.disableClientSignatureAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("disableClientSignatureAsync succeeded"); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#end:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + + + Office.context.mailbox.item.end.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + const time = result.value; + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + + + Office.context.mailbox.item.start.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Get start date failed with message ${result.error.message}`); + return; + } + + const end = result.value; // Set end to current start date and time. + end.setDate(end.getDate() + 1); // Set end as 1 day later than start date. + Office.context.mailbox.item.end.setAsync(end, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Set end date failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set end date and time to ${end}`); + }); + }); +Office.AppointmentCompose#enhancedLocation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + Office.context.mailbox.item.enhancedLocation.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to get locations. Error message: ${result.error.message}`); + return; + } + const places = result.value; + if (places && places.length > 0) { + result.value.forEach(function(place) { + console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); + if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { + console.log("Email address: " + place.emailAddress); + } + }); + } else { + console.log("There are no locations."); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + const locations = [ + { + id: "Contoso", + type: Office.MailboxEnums.LocationType.Custom + }, + { + id: "room500@test.com", + type: Office.MailboxEnums.LocationType.Room + } + ]; + + Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => + { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully added locations ${JSON.stringify(locations)}`); + } else { + console.error(`Failed to add locations. Error message: ${result.error.message}`); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + const locations = [ + { + id: "Contoso", + type: Office.MailboxEnums.LocationType.Custom + }, + { + id: "room500@test.com", + type: Office.MailboxEnums.LocationType.Room + } + ]; + + Office.context.mailbox.item.enhancedLocation.removeAsync(locations, (result) + => { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully removed locations ${JSON.stringify(locations)}`); + } else { + console.error(`Failed to remove locations. Error message: ${result.error.message}`); + } + }); +Office.AppointmentCompose#getAttachmentContentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + + + // Gets the attachments of the current message or appointment in compose + mode. The getAttachmentsAsync call can only be used in compose mode. + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.log(result.error.message); + return; + } + + if (result.value.length <= 0) { + console.log("Mail item has no attachments."); + return; + } + + for (let i = 0; i < result.value.length; i++) { + // Log the attachment type and its contents to the console. + Office.context.mailbox.item.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); + } + }); +Office.AppointmentCompose#getAttachmentsAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + if (result.value.length > 0) { + for (let i = 0; i < result.value.length; i++) { + const attachment = result.value[i]; + let attachmentType; + switch (attachment.attachmentType) { + case Office.MailboxEnums.AttachmentType.Cloud: + attachmentType = "Attachment is stored in a cloud location"; + break; + case Office.MailboxEnums.AttachmentType.File: + attachmentType = "Attachment is a file"; + break; + case Office.MailboxEnums.AttachmentType.Item: + attachmentType = "Attachment is an Exchange item"; + break; + } + console.log( + "ID: " + + attachment.id + + "\n" + + "Type: " + + attachmentType + + "\n" + + "Name: " + + attachment.name + + "\n" + + "Size: " + + attachment.size + + "\n" + + "isInline: " + + attachment.isInline + ); + } + } else { + console.log("No attachments on this message."); + } + }); +Office.AppointmentCompose#getItemIdAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/item-id-compose.yaml + + + Office.context.mailbox.item.getItemIdAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`getItemIdAsync failed with message: ${result.error.message}`); + return; + } + + console.log(result.value); + }); +Office.AppointmentCompose#getSelectedDataAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-selected-data.yaml + + + Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const text = asyncResult.value.data; + const prop = asyncResult.value.sourceProperty; + console.log("Selected text in " + prop + ": " + text); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#getSharedPropertiesAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + + + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; + } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); + }); +Office.AppointmentCompose#isAllDayEvent:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml + + + Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Is this an all-day event? " + asyncResult.value); + } else { + console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml + + + Office.context.mailbox.item.isAllDayEvent.setAsync(true, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Appointment set to all-day event."); + } + }); +Office.AppointmentCompose#isClientSignatureEnabledAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Check if the client signature is currently enabled. + + Office.context.mailbox.item.isClientSignatureEnabledAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("isClientSignatureEnabledAsync succeeded with result: " + asyncResult.value); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#itemType:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.AppointmentCompose#loadCustomPropertiesAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + Office.context.mailbox.item.loadCustomPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); + return; + } + + customProps = result.value; + console.log("Loaded the CustomProperties object."); + }); +Office.AppointmentCompose#location:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + + + Office.context.mailbox.item.location.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Appointment location: ${result.value}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + + + const location = "my office"; + + Office.context.mailbox.item.location.setAsync(location, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set location to ${location}`); + }); +Office.AppointmentCompose#notificationMessages:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a progress indicator to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, + message: "Progress indicator with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Non-persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: false + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a persistent information notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: true + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Replaces a notification message of a given key with another message. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.replaceAsync( + id, + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Notification message with id = " + id + " has been replaced with an informational message.", + icon: "icon2", + persistent: false + }, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Removes a notification message from the current mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.removeAsync(id, + handleResult); +Office.AppointmentCompose#optionalAttendees:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + + + Office.context.mailbox.item.optionalAttendees.getAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptOptionalAttendees = asyncResult.value; + for (let i = 0; i < apptOptionalAttendees.length; i++) { + console.log( + "Optional attendees: " + + apptOptionalAttendees[i].displayName + + " (" + + apptOptionalAttendees[i].emailAddress + + ") - response: " + + apptOptionalAttendees[i].appointmentResponse + ); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + + + const email = (document.getElementById("emailOptional") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.optionalAttendees.setAsync(emailArray, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting optional attendees field."); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#organizer:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + + + Office.context.mailbox.item.organizer.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptOrganizer = asyncResult.value; + console.log("Organizer: " + apptOrganizer.displayName + " (" + apptOrganizer.emailAddress + ")"); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#recurrence:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + Office.context.mailbox.item.recurrence.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const recurrence = asyncResult.value; + if (recurrence === null) { + console.log("This is a single appointment."); + } else { + console.log(`Recurrence pattern: ${JSON.stringify(recurrence)}`); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.AppointmentCompose#removeAttachmentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.removeAttachmentAsync( + (document.getElementById("attachmentId") as HTMLInputElement).value, + (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(`Attachment removed successfully.`); + } + ); +Office.AppointmentCompose#requiredAttendees:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + + + Office.context.mailbox.item.requiredAttendees.getAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptRequiredAttendees = asyncResult.value; + for (let i = 0; i < apptRequiredAttendees.length; i++) { + console.log( + "Required attendees: " + + apptRequiredAttendees[i].displayName + + " (" + + apptRequiredAttendees[i].emailAddress + + ") - response: " + + apptRequiredAttendees[i].appointmentResponse + ); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + + + const email = (document.getElementById("emailRequired") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.requiredAttendees.setAsync(emailArray, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting required attendees field."); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#saveAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/save.yaml + + + Office.context.mailbox.item.saveAsync(function (result) { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`saveAsync succeeded, itemId is ${result.value}`); + } + else { + console.error(`saveAsync failed with message ${result.error.message}`); + } + }); +Office.AppointmentCompose#sendAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/send-async.yaml + + + // This snippet sends the current message or appointment being composed. + + Office.context.mailbox.item.sendAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + }); +Office.AppointmentCompose#sensitivity:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + + + Office.context.mailbox.item.sensitivity.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Sensitivity: " + asyncResult.value); + } else { + console.log("Failed to get sensitivity: " + JSON.stringify(asyncResult.error)); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + + + Office.context.mailbox.item.sensitivity.setAsync( + Office.MailboxEnums.AppointmentSensitivityType.Private, + function callback(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Successfully set appointment sensitivity."); + } + } + ); +Office.AppointmentCompose#sensitivityLabel:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + + + // This snippet gets the current mail item's sensitivity label. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.mailbox.item.sensitivityLabel.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.AppointmentCompose#seriesId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml + + + const seriesId = Office.context.mailbox.item.seriesId; + + + if (seriesId === undefined) { + console.log("This is a message that's not a meeting request."); + } else if (seriesId === null) { + console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); + } else { + console.log("This is an instance belonging to series with ID " + seriesId); + } +Office.AppointmentCompose#sessionData:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("The sessionData is " + JSON.stringify(asyncResult.value)); + } else { + console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.AppointmentCompose#setSelectedDataAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/set-selected-data.yaml + + + Office.context.mailbox.item.setSelectedDataAsync("Replaced", + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Selected text has been updated successfully."); + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentCompose#start:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + + + Office.context.mailbox.item.start.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + const time = result.value; + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + + + const start = new Date(); // Represents current date and time. + + start.setDate(start.getDate() + 2); // Add 2 days to current date. + + Office.context.mailbox.item.start.setAsync(start, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set start date and time to ${start}`); + }); +Office.AppointmentCompose#subject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + + + Office.context.mailbox.item.subject.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Subject: ${result.value}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + + + let subject = "Hello World!"; + + Office.context.mailbox.item.subject.setAsync(subject, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set subject to ${subject}`); + }); +Office.AppointmentForm:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-appointment.yaml + + + const start = new Date(); + + const end = new Date(); + + end.setHours(start.getHours() + 1); + + + // The async version is only available starting with requirement set 1.9, + + // and provides a callback when the new appointment form has been created. + + Office.context.mailbox.displayNewAppointmentFormAsync( + { + requiredAttendees: ["bob@contoso.com"], + optionalAttendees: ["sam@contoso.com"], + start: start, + end: end, + location: "Home", + subject: "meeting", + resources: ["projector@contoso.com"], + body: "Hello World!" + }, + function(asyncResult) { + console.log(JSON.stringify(asyncResult)); + } + ); +Office.AppointmentRead#attachments:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml + + + const item = Office.context.mailbox.item; + + + if (item.attachments.length > 0) { + for (let i = 0; i < item.attachments.length; i++) { + const attachment = item.attachments[i]; + console.log(`${i+1}. Name: ${attachment.name}`); + console.log(`ID: ${attachment.id}`); + console.log(`Type: ${attachment.attachmentType}`); + console.log(`Inline content: ${attachment.isInline}`); + console.log(`Size: ${attachment.size}`); + } + } else { + console.log("This mail item doesn't contain any attachments."); + } +Office.AppointmentRead#categories:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Categories assigned to this item:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + // Note: In order for you to successfully add a category, + + // it must be in the mailbox categories master list. + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const masterCategories = asyncResult.value; + if (masterCategories && masterCategories.length > 0) { + // Grab the first category from the master list. + const categoryToAdd = [masterCategories[0].displayName]; + Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully assigned category '${categoryToAdd}' to item.`); + } else { + console.log("categories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + // Grab the first category assigned to this item. + const categoryToRemove = [categories[0].displayName]; + Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); + } else { + console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.AppointmentRead#dateTimeCreated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + + + console.log(`Creation date and time: + ${Office.context.mailbox.item.dateTimeCreated}`); +Office.AppointmentRead#dateTimeModified:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml + + + console.log(`Date and time item last modified: + ${Office.context.mailbox.item.dateTimeModified}`); +Office.AppointmentRead#displayReplyAllForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyAllForm("This is a reply ALL with + some bold text."); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // Create the reply with attachments. + + Office.context.mailbox.item.displayReplyAllForm({ + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); + } + }); +Office.AppointmentRead#displayReplyAllFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyAllFormAsync("This is a reply ALL + with some bold text.", function( + asyncResult + ) { + console.log(JSON.stringify(asyncResult)); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAAF3klEQVR4Xt2aMcolRRSFdQUuwSW4AAMzU8ENzAIMDA1NzHUBgqmZkbG4ADGVQRgGZBBElAERRPg9eC+PQ73qc6u66lZ3v48bzH+7uqr6VN/T1f3mjafT8Pr7b37+8G3En99+5akTcAqB/n7+48uP3vvp3TdvgT//+uE7P3woBwv07+s/Xn32jKXhwKF/Xr3wpgdxpEC/ffnp8/ffKkQpAg3QDDr6Ocs5RiCzm0ILEQca02qB7u2mPQ4xpnUCabtBWDWFdbfYmBYJ1HLZN6PBP3794uOiAcdKY0oXKLQbFE71jkBS33FrjClRoNBuXjx7J/QUNNCdZBtTikAtdtO1+JBA34Z5xjRfIG03I/YBTYVMScY0U6DQbsbXGdevF2C6Mc0RKLQbHEUbbz0MZNKPuYnGNCpQaDdY0iQTDR9zU4xpSCB9t+PQ719/7k3T0P49bkw7BQrtZnBajTS+uIwYU7dA4ZzynrhMWF/3sc+YOgQK7WaiNQpCh9bRu36tAmm7wT2MovOmaUAaPY3G6DKmWCBtNzaYN80EJjIuDUejMSmBUC/abnCrL3Di8IEwErhAvUGrCxRa4C+ffLDAicMVmhW42K2VLgUK67zlFXwcqL9GmltseUXlDirOvMXIbqKdHc/vieGTIJoE6rL93djNWwy9OHwqRCyQqM+J6LpeFj4bIhZoTWVdWCCLBbvkY93HwqdCdJg0AheQ/XRf9mivhk+C6BMIscawUdR5m0MRPjzRLZAFZMo2pnBHlhE+NhELJGa5YNO42Jh8VCIWCBnMEu8WRf4WC147sAxYjGLcjPDxiCaBDMxS+MKCF1cUdXbF+UhEh0CGqDjksz9CZ++2fRiiWyCgKw532QJjEhMYCR+A2COQoStuwcYyw5i8a2K/QIZ+Ei/YWM41Ju+UGBUI6Bses4eIqf6Nzkc+43N4j8QEgQxdcZApe2OJdRp/R/G+iGkCGbriFmws9TqF4b0QkwUC4SNmwcYSu419xuTnE/MFMrCSRT9FZG8s9xmTn0xkCQSKfu4Di5y9sew1Jj+NOFIgC1hG9q+y7b+s+QnE8QJZYJ0n/g+rKvoBYuFNibMIZJG9sYQx6Y8n3o44l0AILDKWOtW/xf/g8RbE6QSygGVkbyyrxuTHiJMKZLHgjbcY0bPEqQWySN1YFmN5lriAQBZJxlSM4lniMgIhMjaWxRCeJa4kkAWcdaIxFZ17lrieQBazNpZFt54lriqQBXZ9g8ZUdOhZ4toCIWxj6UP2U/TmWSJRoDU/9V1YIIDdcONr9L64dond2P19T8QjmDSDdUYhTJHpcR7z90Am/bVBx6NtFLcIv+pXAzfgo71qaFAmWx9linjYl9UWIJN4zD3454527ncD+DP7g5nBgyI8S5xCIIMHzbCbKjwowrPESQXyVD48aHXcWCDc7dm/Wxk8qKcymfZN2gJ+mfqDDODhPJUDLmTrAeotiFaBLJI2IwYP5KnZ2IaeByrC2xEVgdCFeCfIqzgexVNT0T9Ab30VqAgEwneCjIrj/j01CVFTFuKrQF0gQ/wCaQHJJ1Yc9+ypYcKawgXqrwJKIEPfmRMrjrv11BhTZh4LZGAdhDFNqTju0FN70TW1ZTdVWgUCoTFh1JGK46481U9YU70fITsEMrQxjVQc9+OpTnRNhXZTpVsgI5zKjorjHjzVjK6pkWXbKZCBm1kYU2/F8bmeakDXVJfdVBkSCGB+wpi6lo5P9FSEvpF77abKqECGNqbGiuNTPLWNrikc2mE3VeYIZOj1DCuOG3uqhq6pEbupMlMgA7PfMiY9e27pqTvEGozbTZX5AgFtTFsVx208ReiammI3VVIEMrQxYbWLS+KjnvofXVMT7aZKokCGKIqi4viQp3pOTyJdIAO3wJYx3SqOk/hT1FSS3VRZJBDQxlQUkaipPLupsk4gQxuTjmy7qbJaIEM4SzXW2E2VYwQyhDHdYqXdVDlSIKCNabHdVDlYIOPemA6xmyqnEMgwYzrQbio8Pf0HxndUxitiwgUAAAAASUVORK5CYII=", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyAllFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); + } + ); +Office.AppointmentRead#displayReplyForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyForm("This is a reply with some + text in italics."); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // Create the reply with attachments. + + Office.context.mailbox.item.displayReplyForm({ + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + console.log("Created a reply with attachments."); + } + }); +Office.AppointmentRead#displayReplyFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyFormAsync("This is a reply with + some text in italics.", function( + asyncResult + ) { + console.log(JSON.stringify(asyncResult)); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created reply with attachments."); + } + ); +Office.AppointmentRead#end:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml + + + const time = Office.context.mailbox.item.end; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment ends (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.AppointmentRead#enhancedLocation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + Office.context.mailbox.item.enhancedLocation.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to get locations. Error message: ${result.error.message}`); + return; + } + const places = result.value; + if (places && places.length > 0) { + result.value.forEach(function(place) { + console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); + if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { + console.log("Email address: " + place.emailAddress); + } + }); + } else { + console.log("There are no locations."); + } + }); +Office.AppointmentRead#getAttachmentContentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + + + // Gets the attachments of the current message or appointment in read mode. + The item.attachments call can only be used in read mode. + + const item = Office.context.mailbox.item; + + const attachments = item.attachments; + + if (attachments.length <= 0) { + console.log("Mail item has no attachments."); + return; + } + + + for (let i = 0; i < attachments.length; i++) { + // Log the attachment type and its contents to the console. + item.getAttachmentContentAsync(attachments[i].id, handleAttachmentsCallback); + } +Office.AppointmentRead#getRegExMatches:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + // This API only works when you click on the highlighted word "ScriptLab". + + console.log(Office.context.mailbox.item.getRegExMatches()); +Office.AppointmentRead#getRegExMatchesByName:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + // This API only works when you click on the highlighted word "ScriptLab". + + console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); +Office.AppointmentRead#getSelectedRegExMatches:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + const matches = Office.context.mailbox.item.getSelectedRegExMatches(); + + if (matches) { + console.log(matches); + } else { + console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); + } +Office.AppointmentRead#getSharedPropertiesAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + + + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; + } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); + }); +Office.AppointmentRead#itemClass:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-read.yaml + + + console.log(`Item class: ${Office.context.mailbox.item.itemClass}`); +Office.AppointmentRead#itemType:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.AppointmentRead#loadCustomPropertiesAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + Office.context.mailbox.item.loadCustomPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); + return; + } + + customProps = result.value; + console.log("Loaded the CustomProperties object."); + }); +Office.AppointmentRead#location:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-location-read.yaml + + + console.log(`Appointment location: + ${Office.context.mailbox.item.location}`); +Office.AppointmentRead#normalizedSubject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml + + + console.log(`Normalized subject: + ${Office.context.mailbox.item.normalizedSubject}`); +Office.AppointmentRead#notificationMessages:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a progress indicator to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, + message: "Progress indicator with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Non-persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: false + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a persistent information notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: true + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Replaces a notification message of a given key with another message. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.replaceAsync( + id, + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Notification message with id = " + id + " has been replaced with an informational message.", + icon: "icon2", + persistent: false + }, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Removes a notification message from the current mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.removeAsync(id, + handleResult); +Office.AppointmentRead#optionalAttendees:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml + + + const apptOptionalAttendees = Office.context.mailbox.item.optionalAttendees; + + console.log("Optional attendees:"); + + for (let i = 0; i < apptOptionalAttendees.length; i++) { + console.log( + apptOptionalAttendees[i].displayName + + " (" + + apptOptionalAttendees[i].emailAddress + + ") - response: " + + apptOptionalAttendees[i].appointmentResponse + ); + } +Office.AppointmentRead#organizer:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml + + + const apptOrganizer = Office.context.mailbox.item.organizer; + + console.log("Organizer: " + apptOrganizer.displayName + " (" + + apptOrganizer.emailAddress + ")"); +Office.AppointmentRead#recurrence:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-recurrence-read.yaml + + + const recurrence = Office.context.mailbox.item.recurrence; + + + if (recurrence === undefined) { + console.log("This item is a message but not a meeting request."); + } else if (recurrence === null) { + console.log("This is a single appointment."); + } else { + console.log(JSON.stringify(recurrence)); + } +Office.AppointmentRead#requiredAttendees:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml + + + const apptRequiredAttendees = Office.context.mailbox.item.requiredAttendees; + + console.log("Required attendees:"); + + for (let i = 0; i < apptRequiredAttendees.length; i++) { + console.log( + apptRequiredAttendees[i].displayName + + " (" + + apptRequiredAttendees[i].emailAddress + + ") - response: " + + apptRequiredAttendees[i].appointmentResponse + ); + } +Office.AppointmentRead#seriesId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml + + + const seriesId = Office.context.mailbox.item.seriesId; + + + if (seriesId === undefined) { + console.log("This is a message that's not a meeting request."); + } else if (seriesId === null) { + console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); + } else { + console.log("This is an instance belonging to series with ID " + seriesId); + } +Office.AppointmentRead#start:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml + + + const time = Office.context.mailbox.item.start; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment starts (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.AppointmentRead#subject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-subject-read.yaml + + + console.log(`Subject: ${Office.context.mailbox.item.subject}`); +Office.AttachmentDetails:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml + + + const item = Office.context.mailbox.item; + + + if (item.attachments.length > 0) { + for (let i = 0; i < item.attachments.length; i++) { + const attachment = item.attachments[i]; + console.log(`${i+1}. Name: ${attachment.name}`); + console.log(`ID: ${attachment.id}`); + console.log(`Type: ${attachment.attachmentType}`); + console.log(`Inline content: ${attachment.isInline}`); + console.log(`Size: ${attachment.size}`); + } + } else { + console.log("This mail item doesn't contain any attachments."); + } +Office.AttachmentDetailsCompose:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + if (result.value.length > 0) { + for (let i = 0; i < result.value.length; i++) { + const attachment = result.value[i]; + let attachmentType; + switch (attachment.attachmentType) { + case Office.MailboxEnums.AttachmentType.Cloud: + attachmentType = "Attachment is stored in a cloud location"; + break; + case Office.MailboxEnums.AttachmentType.File: + attachmentType = "Attachment is a file"; + break; + case Office.MailboxEnums.AttachmentType.Item: + attachmentType = "Attachment is an Exchange item"; + break; + } + console.log( + "ID: " + + attachment.id + + "\n" + + "Type: " + + attachmentType + + "\n" + + "Name: " + + attachment.name + + "\n" + + "Size: " + + attachment.size + + "\n" + + "isInline: " + + attachment.isInline + ); + } + } else { + console.log("No attachments on this message."); + } + }); +Office.Body:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/add-inline-base64-image.yaml + + + // Get the current body of the message or appointment. + + Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, + (bodyResult) => { + if (bodyResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to get body: ${bodyResult.error.message}`); + return; + } + + // Add the Base64-encoded image to the end of the body. + const options = { isInline: true, asyncContext: bodyResult.value }; + Office.context.mailbox.item.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => { + if (attachResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to attach file: ${attachResult.error.message}`); + return; + } + + let body = attachResult.asyncContext; + body += ''; + + Office.context.mailbox.item.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => { + if (setResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to set body: ${setResult.error.message}`); + return; + } + + console.log("Inline Base64-encoded image added to the end of the body."); + }); + }); + }); +Office.Body#appendOnSendAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/append-text-on-send.yaml + + + // This snippet appends text to the end of the message or appointment's body + once it's sent. + + const text = (document.getElementById("text-field") as + HTMLInputElement).value; + + + // It's recommended to call getTypeAsync and pass its returned value to the + options.coercionType parameter of the appendOnSendAsync call. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.appendOnSendAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" will be appended to the body once the message or appointment is sent. Send the mail item to test this feature.`); + }); + }); +Office.Body#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/add-inline-base64-image.yaml + + + // Get the current body of the message or appointment. + + Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, + (bodyResult) => { + if (bodyResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to get body: ${bodyResult.error.message}`); + return; + } + + // Add the Base64-encoded image to the end of the body. + const options = { isInline: true, asyncContext: bodyResult.value }; + Office.context.mailbox.item.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => { + if (attachResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to attach file: ${attachResult.error.message}`); + return; + } + + let body = attachResult.asyncContext; + body += ''; + + Office.context.mailbox.item.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => { + if (setResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to set body: ${setResult.error.message}`); + return; + } + + console.log("Inline Base64-encoded image added to the end of the body."); + }); + }); + }); +Office.Body#getTypeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-body-format.yaml + + + // Get the mail item's body format (plain text or HTML) and log it to the + console. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log("Body format: " + asyncResult.value); + }); +Office.Body#prependAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-to-item-body.yaml + + + /* This snippet adds text to the beginning of the message or appointment's + body. + + When prepending a link in HTML markup to the body, you can disable the online link preview by setting the anchor tag's id attribute to "LPNoLP". For example, 'Click here!'. + */ + + const text = (document.getElementById("text-field") as + HTMLInputElement).value; + + + // It's recommended to call getTypeAsync and pass its returned value to the + options.coercionType parameter of the prependAsync call. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.prependAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" prepended to the body.`); + }); + }); +Office.Body#prependOnSendAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-on-send.yaml + + + // This snippet prepends text to the beginning of the message or + appointment's body once it's sent. + + const text = (document.getElementById("text-field") as + HTMLInputElement).value; + + + // It's recommended to call getTypeAsync and pass its returned value to the + options.coercionType parameter of the prependOnSendAsync call. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.prependOnSendAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" will be prepended to the body once the message or appointment is sent. Send the mail item to test this feature.`); + }); + }); +Office.Body#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/add-inline-base64-image.yaml + + + // Get the current body of the message or appointment. + + Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, + (bodyResult) => { + if (bodyResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to get body: ${bodyResult.error.message}`); + return; + } + + // Add the Base64-encoded image to the end of the body. + const options = { isInline: true, asyncContext: bodyResult.value }; + Office.context.mailbox.item.addFileAttachmentFromBase64Async(base64String, "sample.png", options, (attachResult) => { + if (attachResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to attach file: ${attachResult.error.message}`); + return; + } + + let body = attachResult.asyncContext; + body += ''; + + Office.context.mailbox.item.body.setAsync(body, { coercionType: Office.CoercionType.Html }, (setResult) => { + if (setResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Failed to set body: ${setResult.error.message}`); + return; + } + + console.log("Inline Base64-encoded image added to the end of the body."); + }); + }); + }); +Office.Body#setSelectedDataAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/replace-selected-text.yaml + + + /* This snippet replaces selected text in a message or appointment's body + with specified text. + + If you want to use a link in HTML markup as a value of the setSelectedDataAsync call's data parameter, you can disable online link preview by setting the anchor tag's id attribute to "LPNoLP". For example, 'Click here!'. + */ + + const text = (document.getElementById("text-field") as + HTMLInputElement).value; + + + // It's recommended to call getTypeAsync and pass its returned value to the + options.coercionType parameter of the prependAsync call. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.setSelectedDataAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`Replaced selected text with "${text}".`); + }); + }); +Office.Body#setSignatureAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Set the signature for the current item with inline image. + + const modIcon1Base64 = + "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + modIcon1Base64, + "myImage.png", + { isInline: true }, + function(result) { + if (result.status == Office.AsyncResultStatus.Succeeded) { + const signature = (document.getElementById("signature") as HTMLInputElement).value + ""; + console.log(`Setting signature to "${signature}".`); + Office.context.mailbox.item.body.setSignatureAsync( + signature, + { coercionType: "html" }, + function(asyncResult) { + console.log(`setSignatureAsync: ${asyncResult.status}`); + } + ); + } else { + console.error(`addFileAttachmentFromBase64Async: ${result.error}`); + } + } + ); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Set the signature for the current item. + + const signature = (document.getElementById("signature") as + HTMLInputElement).value; + + console.log(`Setting signature to "${signature}".`); + + Office.context.mailbox.item.body.setSignatureAsync(signature, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("setSignatureAsync succeeded"); + } else { + console.error(asyncResult.error); + } + }); +Office.Categories#addAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + // Note: In order for you to successfully add a category, + + // it must be in the mailbox categories master list. + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const masterCategories = asyncResult.value; + if (masterCategories && masterCategories.length > 0) { + // Grab the first category from the master list. + const categoryToAdd = [masterCategories[0].displayName]; + Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully assigned category '${categoryToAdd}' to item.`); + } else { + console.log("categories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.Categories#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Categories assigned to this item:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.Categories#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + // Grab the first category assigned to this item. + const categoryToRemove = [categories[0].displayName]; + Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); + } else { + console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.CoercionTypeOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/append-text-on-send.yaml + + + // This snippet appends text to the end of the message or appointment's body + once it's sent. + + const text = (document.getElementById("text-field") as + HTMLInputElement).value; + + + // It's recommended to call getTypeAsync and pass its returned value to the + options.coercionType parameter of the appendOnSendAsync call. + + Office.context.mailbox.item.body.getTypeAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + const bodyFormat = asyncResult.value; + Office.context.mailbox.item.body.appendOnSendAsync(text, { coercionType: bodyFormat }, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log(`"${text}" will be appended to the body once the message or appointment is sent. Send the mail item to test this feature.`); + }); + }); +Office.CustomProperties#get:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + const propertyName = (document.getElementById("get-property-name") as + HTMLInputElement).value; + + const propertyValue = customProps.get(propertyName); + + console.log(`The value of custom property "${propertyName}" is + "${propertyValue}".`); +Office.CustomProperties#getAll:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + let allCustomProps; + + if (Office.context.requirements.isSetSupported("Mailbox", "1.9")) { + allCustomProps = customProps.getAll(); + } else { + allCustomProps = customProps["rawData"]; + } + + + console.log(allCustomProps); +Office.CustomProperties#remove:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + const propertyName = (document.getElementById("remove-property-name") as + HTMLInputElement).value; + + customProps.remove(propertyName); + + console.log(`Custom property "${propertyName}" removed.`); +Office.CustomProperties#saveAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + customProps.saveAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`saveAsync failed with message ${result.error.message}`); + return; + } + + console.log(`Custom properties saved with status: ${result.status}`); + }); +Office.CustomProperties#set:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + const propertyName = (document.getElementById("set-property-name") as + HTMLInputElement).value; + + const propertyValue = (document.getElementById("property-value") as + HTMLInputElement).value; + + customProps.set(propertyName, propertyValue); + + console.log(`Custom property "${propertyName}" set to value + "${propertyValue}".`); +Office.DelayDeliveryTime#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml + + + // This snippet gets the delivery date and time of a message. + + Office.context.mailbox.item.delayDeliveryTime.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + const deliveryDate = asyncResult.value; + if (deliveryDate === 0) { + console.log("Your message will be delivered immediately when you select Send."); + } else { + const date = new Date(deliveryDate); + console.log(`Message delivery date and time: ${date.toString()}`); + } + }); +Office.DelayDeliveryTime#setAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml + + + function setDeliveryDate(minutes) { + // This snippet sets the delivery date and time of a message. + const currentTime = new Date().getTime(); + const milliseconds = totalDelay * 60000; + const timeDelay = new Date(currentTime + milliseconds); + Office.context.mailbox.item.delayDeliveryTime.setAsync(timeDelay, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + if (minutes === 1440) { + console.log(`Delayed delivery by an additional one day.`); + } else { + console.log(`Delayed delivery by an additional ${minutes} minutes.`); + } + }); + } +Office.Diagnostics:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml + + + // This function gets a mailbox's diagnostic information, such as Outlook + client and version, and logs it to the console. + + const diagnostics = Office.context.mailbox.diagnostics; + + console.log(`Client application: ${diagnostics.hostName}`); + + console.log(`Client version: ${diagnostics.hostVersion}`); + + + switch (diagnostics.OWAView) { + case undefined: + console.log("Current view (Outlook on the web only): Not applicable. An Outlook desktop client is in use."); + break; + case Office.MailboxEnums.OWAView.OneColumnNarrow: + console.log("Current view (Outlook on the web only): Viewed from an older generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.OneColumn: + console.log("Current view (Outlook on the web only): Viewed from a newer generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.TwoColumns: + console.log("Current view (Outlook on the web only): Viewed from a tablet"); + break; + case Office.MailboxEnums.OWAView.ThreeColumns: + console.log("Current view (Outlook on the web only): Viewed from a desktop computer"); + break; + } +Office.Display#body:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + + + // This snippet temporarily sets the content displayed in the body of a + message in read mode. + + // The set content will remain visible until the user switches to a + different message in the Reading Pane or closes the window of the current + message. + + const bodyText = (document.getElementById("body-text-field") as + HTMLInputElement).value; + + Office.context.mailbox.item.display.body.setAsync(bodyText, (asyncResult) => + { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the body."); + }); +Office.Display#subject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + + + // This snippet temporarily sets the content displayed in the subject field + of a message in read mode. + + // The set content will remain visible until the user switches to a + different message in the Reading Pane or closes the window of the current + message. + + const subjectText = (document.getElementById("subject-text-field") as + HTMLInputElement).value; + + Office.context.mailbox.item.display.subject.setAsync(subjectText, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the subject field."); + }); +Office.DisplayedBody#setAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + + + // This snippet temporarily sets the content displayed in the body of a + message in read mode. + + // The set content will remain visible until the user switches to a + different message in the Reading Pane or closes the window of the current + message. + + const bodyText = (document.getElementById("body-text-field") as + HTMLInputElement).value; + + Office.context.mailbox.item.display.body.setAsync(bodyText, (asyncResult) => + { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the body."); + }); +Office.DisplayedSubject#setAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + + + // This snippet temporarily sets the content displayed in the subject field + of a message in read mode. + + // The set content will remain visible until the user switches to a + different message in the Reading Pane or closes the window of the current + message. + + const subjectText = (document.getElementById("subject-text-field") as + HTMLInputElement).value; + + Office.context.mailbox.item.display.subject.setAsync(subjectText, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the subject field."); + }); +Office.DragAndDropEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } +Office.DragoverEventData:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } +Office.DropEventData:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } +Office.DroppedItems:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } +Office.DroppedItemDetails:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml + + + function dragAndDropEventHandler(event) { + Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => { + console.log(`Event type: ${event.type}`); + + const eventData = event.dragAndDropEventData; + console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`); + + if (eventData.type == "drop") { + console.log("Items dropped into task pane."); + const files = eventData.dataTransfer.files; + files.forEach((file) => { + const content = file.fileContent; + const name = file.name; + const fileType = file.type; + console.log(`File name: ${name}`); + console.log(`File type: ${fileType}`); + console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`); + }); + } + }); + } +Office.EnhancedLocation#addAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + const locations = [ + { + id: "Contoso", + type: Office.MailboxEnums.LocationType.Custom + }, + { + id: "room500@test.com", + type: Office.MailboxEnums.LocationType.Room + } + ]; + + Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => + { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully added locations ${JSON.stringify(locations)}`); + } else { + console.error(`Failed to add locations. Error message: ${result.error.message}`); + } + }); +Office.EnhancedLocation#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + Office.context.mailbox.item.enhancedLocation.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to get locations. Error message: ${result.error.message}`); + return; + } + const places = result.value; + if (places && places.length > 0) { + result.value.forEach(function(place) { + console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); + if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { + console.log("Email address: " + place.emailAddress); + } + }); + } else { + console.log("There are no locations."); + } + }); +Office.EnhancedLocation#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + const locations = [ + { + id: "Contoso", + type: Office.MailboxEnums.LocationType.Custom + }, + { + id: "room500@test.com", + type: Office.MailboxEnums.LocationType.Room + } + ]; + + Office.context.mailbox.item.enhancedLocation.removeAsync(locations, (result) + => { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully removed locations ${JSON.stringify(locations)}`); + } else { + console.error(`Failed to remove locations. Error message: ${result.error.message}`); + } + }); +Office.From#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + + + Office.context.mailbox.item.from.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgFrom = asyncResult.value; + console.log("Message from: " + msgFrom.displayName + " (" + msgFrom.emailAddress + ")"); + } else { + console.error(asyncResult.error); + } + }); +Office.InternetHeaders#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + + + Office.context.mailbox.item.internetHeaders.getAsync( + ["preferred-fruit", "preferred-vegetable", "best-vegetable", "nonexistent-header"], + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Selected headers: " + JSON.stringify(asyncResult.value)); + } else { + console.log("Error getting selected headers: " + JSON.stringify(asyncResult.error)); + } + } + ); +Office.InternetHeaders#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + + + Office.context.mailbox.item.internetHeaders.removeAsync( + ["best-vegetable", "nonexistent-header"], + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully removed selected headers"); + } else { + console.log("Error removing selected headers: " + JSON.stringify(asyncResult.error)); + } + } + ); +Office.InternetHeaders#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + + + Office.context.mailbox.item.internetHeaders.setAsync( + { "preferred-fruit": "orange", "preferred-vegetable": "broccoli", "best-vegetable": "spinach" }, + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully set headers"); + } else { + console.log("Error setting headers: " + JSON.stringify(asyncResult.error)); + } + } + + ); +Office.IsAllDayEvent#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml + + + Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Is this an all-day event? " + asyncResult.value); + } else { + console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.IsAllDayEvent#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml + + + Office.context.mailbox.item.isAllDayEvent.setAsync(true, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Appointment set to all-day event."); + } + }); +Office.Item:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.LocalClientTime:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml + + + const time = Office.context.mailbox.item.start; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment starts (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.Location#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + + + Office.context.mailbox.item.location.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Appointment location: ${result.value}`); + }); +Office.Location#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + + + const location = "my office"; + + Office.context.mailbox.item.location.setAsync(location, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set location to ${location}`); + }); +Office.Mailbox#convertToEwsId:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + + + // Get the EWS URL and EWS item ID. + + console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + + const ewsId = Office.context.mailbox.item.itemId; + + console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + + + // Convert the EWS item ID to a REST-formatted ID. + + const restId = Office.context.mailbox.convertToRestId(ewsId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("REST item ID: " + restId); + + + // Convert the REST-formatted ID back to an EWS-formatted ID. + + const ewsId2 = Office.context.mailbox.convertToEwsId(restId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("EWS ID (from REST ID): " + ewsId2); +Office.Mailbox#convertToLocalClientTime:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml + + + const time = Office.context.mailbox.item.start; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment starts (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.Mailbox#convertToRestId:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + + + // Get the EWS URL and EWS item ID. + + console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + + const ewsId = Office.context.mailbox.item.itemId; + + console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + + + // Convert the EWS item ID to a REST-formatted ID. + + const restId = Office.context.mailbox.convertToRestId(ewsId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("REST item ID: " + restId); + + + // Convert the REST-formatted ID back to an EWS-formatted ID. + + const ewsId2 = Office.context.mailbox.convertToEwsId(restId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("EWS ID (from REST ID): " + ewsId2); +Office.Mailbox#diagnostics:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml + + + // This function gets a mailbox's diagnostic information, such as Outlook + client and version, and logs it to the console. + + const diagnostics = Office.context.mailbox.diagnostics; + + console.log(`Client application: ${diagnostics.hostName}`); + + console.log(`Client version: ${diagnostics.hostVersion}`); + + + switch (diagnostics.OWAView) { + case undefined: + console.log("Current view (Outlook on the web only): Not applicable. An Outlook desktop client is in use."); + break; + case Office.MailboxEnums.OWAView.OneColumnNarrow: + console.log("Current view (Outlook on the web only): Viewed from an older generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.OneColumn: + console.log("Current view (Outlook on the web only): Viewed from a newer generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.TwoColumns: + console.log("Current view (Outlook on the web only): Viewed from a tablet"); + break; + case Office.MailboxEnums.OWAView.ThreeColumns: + console.log("Current view (Outlook on the web only): Viewed from a desktop computer"); + break; + } +Office.Mailbox#displayAppointmentForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-appointment.yaml + + + const itemId = (document.getElementById("itemId") as + HTMLInputElement).value; + + Office.context.mailbox.displayAppointmentForm(itemId); +Office.Mailbox#displayAppointmentFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-appointment.yaml + + + const itemId = (document.getElementById("itemId") as + HTMLInputElement).value; + + + // The async version will return error 9049 if the item is not found. + + // The async version is only available starting with requirement set 1.9. + + Office.context.mailbox.displayAppointmentFormAsync(itemId, + function(asyncResult) { + console.log("Result: " + JSON.stringify(asyncResult)); + }); +Office.Mailbox#displayMessageForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-message.yaml + + + const itemId = (document.getElementById("itemId") as + HTMLInputElement).value; + + Office.context.mailbox.displayMessageForm(itemId); +Office.Mailbox#displayMessageFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-message.yaml + + + const itemId = (document.getElementById("itemId") as + HTMLInputElement).value; + + + // The async version will return error 9049 if the item is not found. + + // The async version is only available starting with requirement set 1.9. + + Office.context.mailbox.displayMessageFormAsync(itemId, function + (asyncResult) { + console.log("Result: " + JSON.stringify(asyncResult)); + }); +Office.Mailbox#displayNewAppointmentForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-appointment.yaml + + + const start = new Date(); + + const end = new Date(); + + end.setHours(start.getHours() + 1); + + + Office.context.mailbox.displayNewAppointmentForm({ + requiredAttendees: ["bob@contoso.com"], + optionalAttendees: ["sam@contoso.com"], + start: start, + end: end, + location: "Home", + subject: "meeting", + resources: ["projector@contoso.com"], + body: "Hello World!" + }); +Office.Mailbox#displayNewAppointmentFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-appointment.yaml + + + const start = new Date(); + + const end = new Date(); + + end.setHours(start.getHours() + 1); + + + // The async version is only available starting with requirement set 1.9, + + // and provides a callback when the new appointment form has been created. + + Office.context.mailbox.displayNewAppointmentFormAsync( + { + requiredAttendees: ["bob@contoso.com"], + optionalAttendees: ["sam@contoso.com"], + start: start, + end: end, + location: "Home", + subject: "meeting", + resources: ["projector@contoso.com"], + body: "Hello World!" + }, + function(asyncResult) { + console.log(JSON.stringify(asyncResult)); + } + ); +Office.Mailbox#displayNewMessageForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-message.yaml + + + Office.context.mailbox.displayNewMessageForm({ + toRecipients: Office.context.mailbox.item.to, // Copies the To line from current item + ccRecipients: ["sam@contoso.com"], + subject: "Outlook add-ins are cool!", + htmlBody: 'Hello World!
    ', + attachments: [ + { + type: "file", + name: "image.png", + url: "https://i.imgur.com/9S36xvA.jpg", + isInline: true + } + ] + }); +Office.Mailbox#displayNewMessageFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-message.yaml + + + // The async version is only available starting with requirement set 1.9, + + // and provides a callback when the new message form has been created. + + Office.context.mailbox.displayNewMessageFormAsync( + { + toRecipients: Office.context.mailbox.item.to, // Copies the To line from current item + ccRecipients: ["sam@contoso.com"], + subject: "Outlook add-ins are cool!", + htmlBody: 'Hello World!
    ', + attachments: [ + { + type: "file", + name: "image.png", + url: "https://i.imgur.com/9S36xvA.jpg", + isInline: true + } + ] + }, + (asyncResult) => { + console.log(JSON.stringify(asyncResult)); + } + ); +Office.Mailbox#ewsUrl:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + + + // Get the EWS URL and EWS item ID. + + console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + + const ewsId = Office.context.mailbox.item.itemId; + + console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + + + // Convert the EWS item ID to a REST-formatted ID. + + const restId = Office.context.mailbox.convertToRestId(ewsId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("REST item ID: " + restId); + + + // Convert the REST-formatted ID back to an EWS-formatted ID. + + const ewsId2 = Office.context.mailbox.convertToEwsId(restId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("EWS ID (from REST ID): " + ewsId2); +Office.Mailbox#getCallbackTokenAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml + + + Office.context.mailbox.getCallbackTokenAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Token retrieval failed with message: ${result.error.message}`); + return; + } + + console.log(result.value); + }); +Office.Mailbox#getSelectedItemsAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-message-properties.yaml + + + // Retrieves the selected messages' properties and logs them to the console. + + Office.context.mailbox.getSelectedItemsAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + asyncResult.value.forEach((message) => { + console.log(`Item ID: ${message.itemId}`); + console.log(`Conversation ID: ${message.conversationId}`); + console.log(`Internet message ID: ${message.internetMessageId}`); + console.log(`Subject: ${message.subject}`); + console.log(`Item type: ${message.itemType}`); + console.log(`Item mode: ${message.itemMode}`); + console.log(`Has attachment: ${message.hasAttachment}`); + }); + }); +Office.Mailbox#getUserIdentityTokenAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml + + + Office.context.mailbox.getUserIdentityTokenAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Token retrieval failed with message: ${result.error.message}`) + return; + } + + console.log(result.value); + }); +Office.Mailbox#loadItemByIdAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml + + + async function getSenderEmailAddress(item) { + const itemId = item.itemId; + await new Promise((resolve) => { + Office.context.mailbox.loadItemByIdAsync(itemId, (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.log(result.error.message); + return; + } + + const loadedItem = result.value; + const sender = loadedItem.from.emailAddress; + appendToListItem(sender); + + // Unload the current message before processing another selected message. + loadedItem.unloadAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + resolve(); + }); + }); + }); + } +Office.Mailbox#makeEwsRequestAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml + + + const ewsId = Office.context.mailbox.item.itemId; + + const request = ` + + + + + AllProperties + + + + + + + `; + + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(getUID(result.value)); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml + + + const request = ''+ + ' '+ + ' '+ + ' '+ + ' '+ + ' '+ + ' '+ + ' Hello, Outlook!'+ + ' This message was sent from a ScriptLab code sample, used from ' + Office.context.mailbox.diagnostics.hostName + ', version ' + Office.context.mailbox.diagnostics.hostVersion + '!'+ + ' '+ + ' ' + Office.context.mailbox.userProfile.emailAddress + ''+ + ' '+ + ' '+ + ' '+ + ' '+ + ' '+ + ''; + + Office.context.mailbox.makeEwsRequestAsync(request, (result) => { + console.log(result); + }); +Office.Mailbox#masterCategories:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Master categories:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories in the master list."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + const masterCategoriesToAdd = [ + { + displayName: "TestCategory", + color: Office.MailboxEnums.CategoryColor.Preset0 + } + ]; + + + Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully added categories to master list"); + } else { + console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + const masterCategoriesToRemove = ["TestCategory"]; + + + Office.context.mailbox.masterCategories.removeAsync(masterCategoriesToRemove, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully removed categories from master list"); + } else { + console.log("masterCategories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); +Office.MailboxEnums.ActionType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational message with actions to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + + const itemId = Office.context.mailbox.item.itemId; + + const details = { + type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage, + message: "This is an insight notification with id = " + id, + icon: "PG.Icon.16", + actions: [ + { + actionText: "Open insight", + actionType: Office.MailboxEnums.ActionType.ShowTaskPane, + // Identify whether the current mail item is in read or compose mode to set the appropriate commandId value. + commandId: (itemId == undefined ? "PG.HelpCommand.Compose" : "PG.HelpCommand.Read"), + contextData: { a: "aValue", b: "bValue" } + } + ] + }; + + + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); +Office.MailboxEnums.AppointmentSensitivityType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + + + Office.context.mailbox.item.sensitivity.setAsync( + Office.MailboxEnums.AppointmentSensitivityType.Private, + function callback(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Successfully set appointment sensitivity."); + } + } + ); +Office.MailboxEnums.AttachmentContentFormat:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + + + function handleAttachmentsCallback(result) { + // Identifies whether the attachment is a Base64-encoded string, .eml file, .icalendar file, or a URL. + switch (result.value.format) { + case Office.MailboxEnums.AttachmentContentFormat.Base64: + // Handle file attachment. + console.log("Attachment is a Base64-encoded string."); + break; + case Office.MailboxEnums.AttachmentContentFormat.Eml: + // Handle email item attachment. + console.log("Attachment is a message."); + break; + case Office.MailboxEnums.AttachmentContentFormat.ICalendar: + // Handle .icalender attachment. + console.log("Attachment is a calendar item."); + break; + case Office.MailboxEnums.AttachmentContentFormat.Url: + // Handle cloud attachment. + console.log("Attachment is a cloud attachment."); + break; + default: + // Handle attachment formats that aren't supported. + } + + console.log(result.value.content); + } +Office.MailboxEnums.AttachmentType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + if (result.value.length > 0) { + for (let i = 0; i < result.value.length; i++) { + const attachment = result.value[i]; + let attachmentType; + switch (attachment.attachmentType) { + case Office.MailboxEnums.AttachmentType.Cloud: + attachmentType = "Attachment is stored in a cloud location"; + break; + case Office.MailboxEnums.AttachmentType.File: + attachmentType = "Attachment is a file"; + break; + case Office.MailboxEnums.AttachmentType.Item: + attachmentType = "Attachment is an Exchange item"; + break; + } + console.log( + "ID: " + + attachment.id + + "\n" + + "Type: " + + attachmentType + + "\n" + + "Name: " + + attachment.name + + "\n" + + "Size: " + + attachment.size + + "\n" + + "isInline: " + + attachment.isInline + ); + } + } else { + console.log("No attachments on this message."); + } + }); +Office.MailboxEnums.CategoryColor:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + const masterCategoriesToAdd = [ + { + displayName: "TestCategory", + color: Office.MailboxEnums.CategoryColor.Preset0 + } + ]; + + + Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully added categories to master list"); + } else { + console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message); + } + }); +Office.MailboxEnums.ComposeType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Get the compose type of the current message. + + Office.context.mailbox.item.getComposeTypeAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log( + "getComposeTypeAsync succeeded with composeType: " + + asyncResult.value.composeType + + " and coercionType: " + + asyncResult.value.coercionType + ); + } else { + console.error(asyncResult.error); + } + }); +Office.MailboxEnums.Days:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.MailboxEnums.ItemNotificationMessageType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an error notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ErrorMessage, + message: "Error notification message with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); +Office.MailboxEnums.ItemType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.MailboxEnums.LocationType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + + + const locations = [ + { + id: "Contoso", + type: Office.MailboxEnums.LocationType.Custom + }, + { + id: "room500@test.com", + type: Office.MailboxEnums.LocationType.Room + } + ]; + + Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => + { + if (result.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully added locations ${JSON.stringify(locations)}`); + } else { + console.error(`Failed to add locations. Error message: ${result.error.message}`); + } + }); +Office.MailboxEnums.Month:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.MailboxEnums.OWAView:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml + + + // This function gets a mailbox's diagnostic information, such as Outlook + client and version, and logs it to the console. + + const diagnostics = Office.context.mailbox.diagnostics; + + console.log(`Client application: ${diagnostics.hostName}`); + + console.log(`Client version: ${diagnostics.hostVersion}`); + + + switch (diagnostics.OWAView) { + case undefined: + console.log("Current view (Outlook on the web only): Not applicable. An Outlook desktop client is in use."); + break; + case Office.MailboxEnums.OWAView.OneColumnNarrow: + console.log("Current view (Outlook on the web only): Viewed from an older generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.OneColumn: + console.log("Current view (Outlook on the web only): Viewed from a newer generation mobile phone"); + break; + case Office.MailboxEnums.OWAView.TwoColumns: + console.log("Current view (Outlook on the web only): Viewed from a tablet"); + break; + case Office.MailboxEnums.OWAView.ThreeColumns: + console.log("Current view (Outlook on the web only): Viewed from a desktop computer"); + break; + } +Office.MailboxEnums.RecipientType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml + + + const msgTo = Office.context.mailbox.item.to; + + const distributionLists = []; + + const externalRecipients = []; + + const internalRecipients = []; + + const otherRecipients = []; + + for (let i = 0; i < msgTo.length; i++) { + switch (msgTo[i].recipientType) { + case Office.MailboxEnums.RecipientType.DistributionList: + distributionLists.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.ExternalUser: + externalRecipients.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.User: + internalRecipients.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.Other: + otherRecipients.push(msgTo[i]); + } + } + + + if (distributionLists.length > 0) { + console.log("Distribution Lists:"); + distributionLists.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (externalRecipients.length > 0) { + console.log("External Recipients:"); + externalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (internalRecipients.length > 0) { + console.log("Internal Recipients:"); + internalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (otherRecipients.length > 0) { + console.log("Other Recipients:"); + otherRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } +Office.MailboxEnums.RecurrenceTimeZone:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.MailboxEnums.RecurrenceType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.MailboxEnums.ResponseType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml + + + function organizeByResponse(attendees) { + const accepted = []; + const declined = []; + const noResponse = []; + const tentative = []; + attendees.forEach(attendee => { + switch (attendee.appointmentResponse) { + case Office.MailboxEnums.ResponseType.Accepted: + accepted.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Declined: + declined.push(attendee); + break; + case Office.MailboxEnums.ResponseType.None: + noResponse.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Tentative: + tentative.push(attendee); + break; + case Office.MailboxEnums.ResponseType.Organizer: + console.log(`Organizer: ${attendee.displayName}, ${attendee.emailAddress}`); + break; + } + }); + + // List attendees by their response. + console.log("Accepted: "); + printAttendees(accepted); + console.log("Declined: "); + printAttendees(declined); + console.log("Tentative: "); + printAttendees(tentative); + console.log("No response: "); + printAttendees(noResponse); + } +Office.MailboxEnums.RestVersion:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml + + + // Get the EWS URL and EWS item ID. + + console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + + const ewsId = Office.context.mailbox.item.itemId; + + console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + + + // Convert the EWS item ID to a REST-formatted ID. + + const restId = Office.context.mailbox.convertToRestId(ewsId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("REST item ID: " + restId); + + + // Convert the REST-formatted ID back to an EWS-formatted ID. + + const ewsId2 = Office.context.mailbox.convertToEwsId(restId, + Office.MailboxEnums.RestVersion.v2_0); + + console.log("EWS ID (from REST ID): " + ewsId2); +Office.MailboxEnums.SourceProperty:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-selected-data.yaml + + + Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const text = asyncResult.value.data; + const prop = asyncResult.value.sourceProperty; + console.log("Selected text in " + prop + ": " + text); + } else { + console.error(asyncResult.error); + } + }); +Office.MailboxEnums.WeekNumber:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.MasterCategories#addAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + const masterCategoriesToAdd = [ + { + displayName: "TestCategory", + color: Office.MailboxEnums.CategoryColor.Preset0 + } + ]; + + + Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully added categories to master list"); + } else { + console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message); + } + }); +Office.MasterCategories#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Master categories:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories in the master list."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.MasterCategories#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml + + + const masterCategoriesToRemove = ["TestCategory"]; + + + Office.context.mailbox.masterCategories.removeAsync(masterCategoriesToRemove, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Successfully removed categories from master list"); + } else { + console.log("masterCategories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); +Office.MessageCompose:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + const attachmentUrl = (document.getElementById("attachmentUrl") as + HTMLInputElement).value; + + Office.context.mailbox.item.addFileAttachmentAsync( + attachmentUrl, + getFileName(attachmentUrl), + { isInline: false }, + (result) => { + console.log(result); + } + ); +Office.MessageCompose#addFileAttachmentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + const attachmentUrl = (document.getElementById("attachmentUrl") as + HTMLInputElement).value; + + Office.context.mailbox.item.addFileAttachmentAsync( + attachmentUrl, + getFileName(attachmentUrl), + { isInline: false }, + (result) => { + console.log(result); + } + ); +Office.MessageCompose#addFileAttachmentFromBase64Async:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + const base64String = + "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + base64String, + "logo.png", + { isInline: false }, + (result) => { + console.log(result); + } + ); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Set the signature for the current item with inline image. + + const modIcon1Base64 = + "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + + Office.context.mailbox.item.addFileAttachmentFromBase64Async( + modIcon1Base64, + "myImage.png", + { isInline: true }, + function(result) { + if (result.status == Office.AsyncResultStatus.Succeeded) { + const signature = (document.getElementById("signature") as HTMLInputElement).value + ""; + console.log(`Setting signature to "${signature}".`); + Office.context.mailbox.item.body.setSignatureAsync( + signature, + { coercionType: "html" }, + function(asyncResult) { + console.log(`setSignatureAsync: ${asyncResult.status}`); + } + ); + } else { + console.error(`addFileAttachmentFromBase64Async: ${result.error}`); + } + } + ); +Office.MessageCompose#bcc:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + + + Office.context.mailbox.item.bcc.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgBcc = asyncResult.value; + console.log("Message being blind-copied to:"); + for (let i = 0; i < msgBcc.length; i++) { + console.log(msgBcc[i].displayName + " (" + msgBcc[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + + + const email = (document.getElementById("emailBcc") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.bcc.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting Bcc field."); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#categories:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Categories assigned to this item:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + // Note: In order for you to successfully add a category, + + // it must be in the mailbox categories master list. + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const masterCategories = asyncResult.value; + if (masterCategories && masterCategories.length > 0) { + // Grab the first category from the master list. + const categoryToAdd = [masterCategories[0].displayName]; + Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully assigned category '${categoryToAdd}' to item.`); + } else { + console.log("categories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + // Grab the first category assigned to this item. + const categoryToRemove = [categories[0].displayName]; + Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); + } else { + console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#cc:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + + + Office.context.mailbox.item.cc.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgCc = asyncResult.value; + console.log("Message being copied to:"); + for (let i = 0; i < msgCc.length; i++) { + console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + + + const email = (document.getElementById("emailCc") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.cc.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting Cc field."); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#close:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close.yaml + + + Office.context.mailbox.item.close(); +Office.MessageCompose#closeAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close-async.yaml + + + // This snippet closes the current message being composed and discards any + unsaved changes when the optional property, discardItem, is set to true. + + // The API call works on a new message being composed, a reply, or an + existing draft. + + // When discardItem is set to false or isn't defined on a new message with + unsaved changes, the user is prompted to save a draft, discard the changes, + or cancel the close operation. + + Office.context.mailbox.item.closeAsync( + { discardItem: true }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + }); +Office.MessageCompose#conversationId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + + + console.log(`Conversation ID: + ${Office.context.mailbox.item.conversationId}`); +Office.MessageCompose#delayDeliveryTime:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml + + + function setDeliveryDate(minutes) { + // This snippet sets the delivery date and time of a message. + const currentTime = new Date().getTime(); + const milliseconds = totalDelay * 60000; + const timeDelay = new Date(currentTime + milliseconds); + Office.context.mailbox.item.delayDeliveryTime.setAsync(timeDelay, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + if (minutes === 1440) { + console.log(`Delayed delivery by an additional one day.`); + } else { + console.log(`Delayed delivery by an additional ${minutes} minutes.`); + } + }); + } +Office.MessageCompose#disableClientSignatureAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Disable the client signature. + + Office.context.mailbox.item.disableClientSignatureAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("disableClientSignatureAsync succeeded"); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#from:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + + + Office.context.mailbox.item.from.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgFrom = asyncResult.value; + console.log("Message from: " + msgFrom.displayName + " (" + msgFrom.emailAddress + ")"); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#getAttachmentContentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + + + // Gets the attachments of the current message or appointment in compose + mode. The getAttachmentsAsync call can only be used in compose mode. + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.log(result.error.message); + return; + } + + if (result.value.length <= 0) { + console.log("Mail item has no attachments."); + return; + } + + for (let i = 0; i < result.value.length; i++) { + // Log the attachment type and its contents to the console. + Office.context.mailbox.item.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); + } + }); +Office.MessageCompose#getAttachmentsAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.getAttachmentsAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + if (result.value.length > 0) { + for (let i = 0; i < result.value.length; i++) { + const attachment = result.value[i]; + let attachmentType; + switch (attachment.attachmentType) { + case Office.MailboxEnums.AttachmentType.Cloud: + attachmentType = "Attachment is stored in a cloud location"; + break; + case Office.MailboxEnums.AttachmentType.File: + attachmentType = "Attachment is a file"; + break; + case Office.MailboxEnums.AttachmentType.Item: + attachmentType = "Attachment is an Exchange item"; + break; + } + console.log( + "ID: " + + attachment.id + + "\n" + + "Type: " + + attachmentType + + "\n" + + "Name: " + + attachment.name + + "\n" + + "Size: " + + attachment.size + + "\n" + + "isInline: " + + attachment.isInline + ); + } + } else { + console.log("No attachments on this message."); + } + }); +Office.MessageCompose#getComposeTypeAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Get the compose type of the current message. + + Office.context.mailbox.item.getComposeTypeAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log( + "getComposeTypeAsync succeeded with composeType: " + + asyncResult.value.composeType + + " and coercionType: " + + asyncResult.value.coercionType + ); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#getConversationIndexAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-index.yaml + + + // This snippet returns the Base64-encoded position of the current message + in a conversation thread (PR_CONVERSATION_INDEX). + + // The API call is supported on a message being composed and isn't supported + on read items or appointments. + + Office.context.mailbox.item.getConversationIndexAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.log(result.error.message); + return; + } + + const conversationIndex = result.value; + if (conversationIndex) { + console.log("Position in the conversation thread: " + conversationIndex); + } else { + console.log("The current message doesn't belong to a conversation thread."); + } + }); +Office.MessageCompose#getItemClassAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-async.yaml + + + // This snippet returns the Exchange Web Services item class property + (PR_MESSAGE_CLASS) of the current message. + + // The API call is only supported on a message being composed. + + Office.context.mailbox.item.getItemClassAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + + console.log("Item class of the current message: " + asyncResult.value); + }); +Office.MessageCompose#getItemIdAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/item-id-compose.yaml + + + Office.context.mailbox.item.getItemIdAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`getItemIdAsync failed with message: ${result.error.message}`); + return; + } + + console.log(result.value); + }); +Office.MessageCompose#getSelectedDataAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-selected-data.yaml + + + Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const text = asyncResult.value.data; + const prop = asyncResult.value.sourceProperty; + console.log("Selected text in " + prop + ": " + text); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#getSharedPropertiesAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + + + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; + } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); + }); +Office.MessageCompose#inReplyTo:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-in-reply-to.yaml + + + // This snippet gets the ID of the message being replied to by the current + message (PR_IN_REPLY_TO_ID). + + // The API call is supported on messages being composed and isn't supported + on read items. + + const inReplyTo = Office.context.mailbox.item.inReplyTo; + + if (inReplyTo) { + console.log("ID of the message being replied to: " + inReplyTo); + } else { + console.log("No InReplyTo property available for this message"); + } +Office.MessageCompose#internetHeaders:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml + + + Office.context.mailbox.item.internetHeaders.getAsync( + ["preferred-fruit", "preferred-vegetable", "best-vegetable", "nonexistent-header"], + function (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Selected headers: " + JSON.stringify(asyncResult.value)); + } else { + console.log("Error getting selected headers: " + JSON.stringify(asyncResult.error)); + } + } + ); +Office.MessageCompose#isClientSignatureEnabledAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml + + + // Check if the client signature is currently enabled. + + Office.context.mailbox.item.isClientSignatureEnabledAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("isClientSignatureEnabledAsync succeeded with result: " + asyncResult.value); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#itemType:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.MessageCompose#loadCustomPropertiesAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + Office.context.mailbox.item.loadCustomPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); + return; + } + + customProps = result.value; + console.log("Loaded the CustomProperties object."); + }); +Office.MessageCompose#notificationMessages:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a progress indicator to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, + message: "Progress indicator with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Non-persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: false + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a persistent information notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: true + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Replaces a notification message of a given key with another message. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.replaceAsync( + id, + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Notification message with id = " + id + " has been replaced with an informational message.", + icon: "icon2", + persistent: false + }, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Removes a notification message from the current mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.removeAsync(id, + handleResult); +Office.MessageCompose#removeAttachmentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml + + + Office.context.mailbox.item.removeAttachmentAsync( + (document.getElementById("attachmentId") as HTMLInputElement).value, + (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(result.error.message); + return; + } + + console.log(`Attachment removed successfully.`); + } + ); +Office.MessageCompose#sendAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/send-async.yaml + + + // This snippet sends the current message or appointment being composed. + + Office.context.mailbox.item.sendAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Action failed with error: " + asyncResult.error.message); + return; + } + }); +Office.MessageCompose#sensitivityLabel:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + + + // This snippet gets the current mail item's sensitivity label. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.mailbox.item.sensitivityLabel.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.MessageCompose#seriesId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml + + + const seriesId = Office.context.mailbox.item.seriesId; + + + if (seriesId === undefined) { + console.log("This is a message that's not a meeting request."); + } else if (seriesId === null) { + console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); + } else { + console.log("This is an instance belonging to series with ID " + seriesId); + } +Office.MessageCompose#sessionData:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("The sessionData is " + JSON.stringify(asyncResult.value)); + } else { + console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.MessageCompose#setSelectedDataAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/set-selected-data.yaml + + + Office.context.mailbox.item.setSelectedDataAsync("Replaced", + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Selected text has been updated successfully."); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageCompose#subject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + + + Office.context.mailbox.item.subject.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Subject: ${result.value}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + + + let subject = "Hello World!"; + + Office.context.mailbox.item.subject.setAsync(subject, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set subject to ${subject}`); + }); +Office.MessageCompose#to:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + + + Office.context.mailbox.item.to.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgTo = asyncResult.value; + console.log("Message being sent to:"); + for (let i = 0; i < msgTo.length; i++) { + console.log(msgTo[i].displayName + " (" + msgTo[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + + + const email = (document.getElementById("emailTo") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.to.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting To field."); + } else { + console.error(asyncResult.error); + } + }); +Office.MessageRead:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml + + + const item = Office.context.mailbox.item; + + + if (item.attachments.length > 0) { + for (let i = 0; i < item.attachments.length; i++) { + const attachment = item.attachments[i]; + console.log(`${i+1}. Name: ${attachment.name}`); + console.log(`ID: ${attachment.id}`); + console.log(`Type: ${attachment.attachmentType}`); + console.log(`Inline content: ${attachment.isInline}`); + console.log(`Size: ${attachment.size}`); + } + } else { + console.log("This mail item doesn't contain any attachments."); + } +Office.MessageRead#attachments:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml + + + const item = Office.context.mailbox.item; + + + if (item.attachments.length > 0) { + for (let i = 0; i < item.attachments.length; i++) { + const attachment = item.attachments[i]; + console.log(`${i+1}. Name: ${attachment.name}`); + console.log(`ID: ${attachment.id}`); + console.log(`Type: ${attachment.attachmentType}`); + console.log(`Inline content: ${attachment.isInline}`); + console.log(`Size: ${attachment.size}`); + } + } else { + console.log("This mail item doesn't contain any attachments."); + } +Office.MessageRead#categories:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + console.log("Categories assigned to this item:"); + console.log(JSON.stringify(categories)); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + // Note: In order for you to successfully add a category, + + // it must be in the mailbox categories master list. + + + Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const masterCategories = asyncResult.value; + if (masterCategories && masterCategories.length > 0) { + // Grab the first category from the master list. + const categoryToAdd = [masterCategories[0].displayName]; + Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully assigned category '${categoryToAdd}' to item.`); + } else { + console.log("categories.addAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml + + + Office.context.mailbox.item.categories.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const categories = asyncResult.value; + if (categories && categories.length > 0) { + // Grab the first category assigned to this item. + const categoryToRemove = [categories[0].displayName]; + Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); + } else { + console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("There are no categories assigned to this item."); + } + } else { + console.error(asyncResult.error); + } + }); +Office.MessageRead#cc:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml + + + const msgCc = Office.context.mailbox.item.cc; + + console.log("Message copied to:"); + + for (let i = 0; i < msgCc.length; i++) { + console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); + } +Office.MessageRead#conversationId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + + + console.log(`Conversation ID: + ${Office.context.mailbox.item.conversationId}`); +Office.MessageRead#dateTimeCreated:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + + + console.log(`Creation date and time: + ${Office.context.mailbox.item.dateTimeCreated}`); +Office.MessageRead#dateTimeModified:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml + + + console.log(`Date and time item last modified: + ${Office.context.mailbox.item.dateTimeModified}`); +Office.MessageRead#display:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml + + + // This snippet temporarily sets the content displayed in the body of a + message in read mode. + + // The set content will remain visible until the user switches to a + different message in the Reading Pane or closes the window of the current + message. + + const bodyText = (document.getElementById("body-text-field") as + HTMLInputElement).value; + + Office.context.mailbox.item.display.body.setAsync(bodyText, (asyncResult) => + { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Action failed with error: ${asyncResult.error.message}`); + return; + } + + console.log("Temporarily set the content displayed in the body."); + }); +Office.MessageRead#displayReplyAllForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyAllForm("This is a reply ALL with + some bold text."); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // Create the reply with attachments. + + Office.context.mailbox.item.displayReplyAllForm({ + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); + } + }); +Office.MessageRead#displayReplyAllFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyAllFormAsync("This is a reply ALL + with some bold text.", function( + asyncResult + ) { + console.log(JSON.stringify(asyncResult)); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyAllFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created a reply-all form with attachments."); + } + ); +Office.MessageRead#displayReplyForm:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyForm("This is a reply with some + text in italics."); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // Create the reply with attachments. + + Office.context.mailbox.item.displayReplyForm({ + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment], + callback: (result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + console.log("Created a reply with attachments."); + } + }); +Office.MessageRead#displayReplyFormAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml + + + Office.context.mailbox.item.displayReplyFormAsync("This is a reply with + some text in italics.", function( + asyncResult + ) { + console.log(JSON.stringify(asyncResult)); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created reply with attachments."); + } + ); +Office.MessageRead#end:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml + + + const time = Office.context.mailbox.item.end; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment ends (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.MessageRead#from:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml + + + const msgFrom = Office.context.mailbox.item.from; + + console.log("Message received from: " + msgFrom.displayName + " (" + + msgFrom.emailAddress + ")"); +Office.MessageRead#getAllInternetHeadersAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml + + + Office.context.mailbox.item.getAllInternetHeadersAsync(function + (asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Internet headers received successfully"); + if (asyncResult.value.match(/preferred-fruit:.*/gim)) { + console.log("Sender's preferred fruit: " + asyncResult.value.match(/preferred-fruit:.*/gim)[0].slice(17)); + } else { + console.log("Didn't receive header with sender's preferred fruit"); + } + if (asyncResult.value.match(/preferred-vegetable:.*/gim)) { + console.log( + "Sender's preferred vegetable: " + asyncResult.value.match(/preferred-vegetable:.*/gim)[0].slice(21) + ); + } else { + console.log("Didn't receive header with sender's preferred vegetable"); + } + } else { + console.log("Error getting internet headers: " + JSON.stringify(asyncResult.error)); + } + }); +Office.MessageRead#getAsFileAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-eml-format.yaml + + + Office.context.mailbox.item.getAsFileAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(`Error encountered during processing: ${asyncResult.error.message}`); + return; + } + + console.log(asyncResult.value); + }); +Office.MessageRead#getAttachmentContentAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml + + + // Gets the attachments of the current message or appointment in read mode. + The item.attachments call can only be used in read mode. + + const item = Office.context.mailbox.item; + + const attachments = item.attachments; + + if (attachments.length <= 0) { + console.log("Mail item has no attachments."); + return; + } + + + for (let i = 0; i < attachments.length; i++) { + // Log the attachment type and its contents to the console. + item.getAttachmentContentAsync(attachments[i].id, handleAttachmentsCallback); + } +Office.MessageRead#getRegExMatches:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + // This API only works when you click on the highlighted word "ScriptLab". + + console.log(Office.context.mailbox.item.getRegExMatches()); +Office.MessageRead#getRegExMatchesByName:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + // This API only works when you click on the highlighted word "ScriptLab". + + console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); +Office.MessageRead#getSelectedRegExMatches:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml + + + const matches = Office.context.mailbox.item.getSelectedRegExMatches(); + + if (matches) { + console.log(matches); + } else { + console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); + } +Office.MessageRead#getSharedPropertiesAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + + + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; + } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); + }); +Office.MessageRead#internetMessageId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml + + + console.log(`Internet message ID: + ${Office.context.mailbox.item.internetMessageId}`); +Office.MessageRead#itemClass:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-read.yaml + + + console.log(`Item class: ${Office.context.mailbox.item.itemClass}`); +Office.MessageRead#itemType:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml + + + const itemType = Office.context.mailbox.item.itemType; + + switch (itemType) { + case Office.MailboxEnums.ItemType.Appointment: + console.log(`Current item is an ${itemType}.`); + break; + case Office.MailboxEnums.ItemType.Message: + console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`); + break; + } +Office.MessageRead#loadCustomPropertiesAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + + + Office.context.mailbox.item.loadCustomPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); + return; + } + + customProps = result.value; + console.log("Loaded the CustomProperties object."); + }); +Office.MessageRead#location:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-location-read.yaml + + + console.log(`Appointment location: + ${Office.context.mailbox.item.location}`); +Office.MessageRead#normalizedSubject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml + + + console.log(`Normalized subject: + ${Office.context.mailbox.item.normalizedSubject}`); +Office.MessageRead#notificationMessages:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a progress indicator to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, + message: "Progress indicator with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Non-persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: false + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a persistent information notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: true + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Replaces a notification message of a given key with another message. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.replaceAsync( + id, + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Notification message with id = " + id + " has been replaced with an informational message.", + icon: "icon2", + persistent: false + }, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Removes a notification message from the current mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.removeAsync(id, + handleResult); +Office.MessageRead#recurrence:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-recurrence-read.yaml + + + const recurrence = Office.context.mailbox.item.recurrence; + + + if (recurrence === undefined) { + console.log("This item is a message but not a meeting request."); + } else if (recurrence === null) { + console.log("This is a single appointment."); + } else { + console.log(JSON.stringify(recurrence)); + } +Office.MessageRead#sender:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml + + + const msgSender = Office.context.mailbox.item.sender; + + console.log("Sender: " + msgSender.displayName + " (" + + msgSender.emailAddress + ")"); +Office.MessageRead#seriesId:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml + + + const seriesId = Office.context.mailbox.item.seriesId; + + + if (seriesId === undefined) { + console.log("This is a message that's not a meeting request."); + } else if (seriesId === null) { + console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); + } else { + console.log("This is an instance belonging to series with ID " + seriesId); + } +Office.MessageRead#start:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml + + + const time = Office.context.mailbox.item.start; + + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + + console.log(`Appointment starts (local): ${localTime.month + + 1}/${localTime.date}/${localTime.year}, + ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); +Office.MessageRead#subject:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-subject-read.yaml + + + console.log(`Subject: ${Office.context.mailbox.item.subject}`); +Office.MessageRead#to:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml + + + const msgTo = Office.context.mailbox.item.to; + + const distributionLists = []; + + const externalRecipients = []; + + const internalRecipients = []; + + const otherRecipients = []; + + for (let i = 0; i < msgTo.length; i++) { + switch (msgTo[i].recipientType) { + case Office.MailboxEnums.RecipientType.DistributionList: + distributionLists.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.ExternalUser: + externalRecipients.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.User: + internalRecipients.push(msgTo[i]); + break; + case Office.MailboxEnums.RecipientType.Other: + otherRecipients.push(msgTo[i]); + } + } + + + if (distributionLists.length > 0) { + console.log("Distribution Lists:"); + distributionLists.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (externalRecipients.length > 0) { + console.log("External Recipients:"); + externalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (internalRecipients.length > 0) { + console.log("Internal Recipients:"); + internalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } + + + if (otherRecipients.length > 0) { + console.log("Other Recipients:"); + otherRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`)); + } +Office.NotificationMessageAction:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational message with actions to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + + const itemId = Office.context.mailbox.item.itemId; + + const details = { + type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage, + message: "This is an insight notification with id = " + id, + icon: "PG.Icon.16", + actions: [ + { + actionText: "Open insight", + actionType: Office.MailboxEnums.ActionType.ShowTaskPane, + // Identify whether the current mail item is in read or compose mode to set the appropriate commandId value. + commandId: (itemId == undefined ? "PG.HelpCommand.Compose" : "PG.HelpCommand.Read"), + contextData: { a: "aValue", b: "bValue" } + } + ] + }; + + + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); +Office.NotificationMessageDetails:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); +Office.NotificationMessages#addAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a progress indicator to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator, + message: "Progress indicator with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an informational notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Non-persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: false + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds a persistent information notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Persistent informational notification message with id = " + id, + icon: "PG.Icon.16", + persistent: true + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Adds an error notification to the mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + const details = + { + type: Office.MailboxEnums.ItemNotificationMessageType.ErrorMessage, + message: "Error notification message with id = " + id + }; + Office.context.mailbox.item.notificationMessages.addAsync(id, details, + handleResult); +Office.NotificationMessages#getAllAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Gets all the notification messages and their keys for the current mail + item. + + Office.context.mailbox.item.notificationMessages.getAllAsync((asyncResult) + => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + console.log(asyncResult.value); + }); +Office.NotificationMessages#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Removes a notification message from the current mail item. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.removeAsync(id, + handleResult); +Office.NotificationMessages#replaceAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml + + + // Replaces a notification message of a given key with another message. + + const id = (document.getElementById("notificationId") as + HTMLInputElement).value; + + Office.context.mailbox.item.notificationMessages.replaceAsync( + id, + { + type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage, + message: "Notification message with id = " + id + " has been replaced with an informational message.", + icon: "icon2", + persistent: false + }, + handleResult); +Office.Organizer#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + + + Office.context.mailbox.item.organizer.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptOrganizer = asyncResult.value; + console.log("Organizer: " + apptOrganizer.displayName + " (" + apptOrganizer.emailAddress + ")"); + } else { + console.error(asyncResult.error); + } + }); +Office.Recipients#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + + + Office.context.mailbox.item.bcc.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgBcc = asyncResult.value; + console.log("Message being blind-copied to:"); + for (let i = 0; i < msgBcc.length; i++) { + console.log(msgBcc[i].displayName + " (" + msgBcc[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + + + Office.context.mailbox.item.cc.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgCc = asyncResult.value; + console.log("Message being copied to:"); + for (let i = 0; i < msgCc.length; i++) { + console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + + + Office.context.mailbox.item.optionalAttendees.getAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptOptionalAttendees = asyncResult.value; + for (let i = 0; i < apptOptionalAttendees.length; i++) { + console.log( + "Optional attendees: " + + apptOptionalAttendees[i].displayName + + " (" + + apptOptionalAttendees[i].emailAddress + + ") - response: " + + apptOptionalAttendees[i].appointmentResponse + ); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + + + Office.context.mailbox.item.requiredAttendees.getAsync(function(asyncResult) + { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const apptRequiredAttendees = asyncResult.value; + for (let i = 0; i < apptRequiredAttendees.length; i++) { + console.log( + "Required attendees: " + + apptRequiredAttendees[i].displayName + + " (" + + apptRequiredAttendees[i].emailAddress + + ") - response: " + + apptRequiredAttendees[i].appointmentResponse + ); + } + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + + + Office.context.mailbox.item.to.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const msgTo = asyncResult.value; + console.log("Message being sent to:"); + for (let i = 0; i < msgTo.length; i++) { + console.log(msgTo[i].displayName + " (" + msgTo[i].emailAddress + ")"); + } + } else { + console.error(asyncResult.error); + } + }); +Office.Recipients#setAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + + + const email = (document.getElementById("emailBcc") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.bcc.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting Bcc field."); + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + + + const email = (document.getElementById("emailCc") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.cc.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting Cc field."); + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + + + const email = (document.getElementById("emailOptional") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.optionalAttendees.setAsync(emailArray, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting optional attendees field."); + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + + + const email = (document.getElementById("emailRequired") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.requiredAttendees.setAsync(emailArray, + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting required attendees field."); + } else { + console.error(asyncResult.error); + } + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + + + const email = (document.getElementById("emailTo") as + HTMLInputElement).value; + + const emailArray = [email]; + + Office.context.mailbox.item.to.setAsync(emailArray, function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Succeeded in setting To field."); + } else { + console.error(asyncResult.error); + } + }); +Office.Recurrence#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + Office.context.mailbox.item.recurrence.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const recurrence = asyncResult.value; + if (recurrence === null) { + console.log("This is a single appointment."); + } else { + console.log(`Recurrence pattern: ${JSON.stringify(recurrence)}`); + } + } else { + console.error(asyncResult.error); + } + }); +Office.Recurrence#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + + + // Important: Can only set the recurrence pattern of an appointment series. + + + const currentDate = new Date(); + + let seriesTimeObject: Office.SeriesTime; + + // Set series start date to tomorrow. + + seriesTimeObject.setStartDate(currentDate.getFullYear(), + currentDate.getMonth(), currentDate.getDay() + 1); + + // Set series end date to one year from now. + + seriesTimeObject.setEndDate(currentDate.getFullYear() + 1, + currentDate.getMonth() + 1, currentDate.getDay()); + + // Set start time to 1:30 PM. + + seriesTimeObject.setStartTime(13, 30); + + // Set duration to 30 minutes. + + seriesTimeObject.setDuration(30); + + + const pattern: Office.Recurrence = { + seriesTime: seriesTimeObject, + recurrenceType: Office.MailboxEnums.RecurrenceType.Yearly, + recurrenceProperties: { + interval: 1, + dayOfWeek: Office.MailboxEnums.Days.Tue, + weekNumber: Office.MailboxEnums.WeekNumber.Second, + month: Office.MailboxEnums.Month.Sep + }, + recurrenceTimeZone: { name: Office.MailboxEnums.RecurrenceTimeZone.PacificStandardTime } + }; + + + Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { + if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + return; + } + console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + }); +Office.ReplyFormAttachment:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created reply with attachments."); + } + ); +Office.ReplyFormData:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml + + + // Define attachments. + + const base64Attachment = { + base64file: + "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", + inLine: true, + name: "script_lab.png", + type: Office.MailboxEnums.AttachmentType.Base64 + }; + + const fileAttachment = { + inLine: true, + name: "dog.jpg", + type: Office.MailboxEnums.AttachmentType.File, + url: "https://i.imgur.com/9S36xvA.jpg" + }; + + const itemAttachment = { + itemId: Office.context.mailbox.item.itemId, + name: "test_email.msg", + type: Office.MailboxEnums.AttachmentType.Item + }; + + + // The async version was introduced in requirement set 1.9. + + // It provides a callback when the new appointment form has been created. + + Office.context.mailbox.item.displayReplyFormAsync( + { + htmlBody: + "This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.

    ", + attachments: [base64Attachment, fileAttachment, itemAttachment] + }, + (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.error(`Action failed with message ${asyncResult.error.message}`); + return; + } + + console.log("Created reply with attachments."); + } + ); +Office.RoamingSettings#get:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml + + + const settingName = (document.getElementById("settingName") as + HTMLInputElement).value; + + const settingValue = Office.context.roamingSettings.get(settingName); + + (document.getElementById("settingValue") as HTMLInputElement).value = + settingValue; + + console.log(`The value of setting "${settingName}" is "${settingValue}".`); +Office.RoamingSettings#remove:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml + + + // Remove the specified setting from the mailbox. + + const settingName = (document.getElementById("settingName") as + HTMLInputElement).value; + + Office.context.roamingSettings.remove(settingName); + + console.log(`The "${settingName}" setting has been removed.`); +Office.RoamingSettings#saveAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml + + + // Save settings in the mailbox to make it available in future sessions. + + Office.context.roamingSettings.saveAsync(function(result) { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + } else { + console.log(`Settings saved with status: ${result.status}`); + } + }); +Office.RoamingSettings#set:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml + + + const settingName = (document.getElementById("settingName") as + HTMLInputElement).value; + + const settingValue = (document.getElementById("settingValue") as + HTMLInputElement).value; + + Office.context.roamingSettings.set(settingName, settingValue); + + console.log(`Setting "${settingName}" set to value "${settingValue}".`); +Office.SelectedItemDetails:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-message-properties.yaml + + + // Retrieves the selected messages' properties and logs them to the console. + + Office.context.mailbox.getSelectedItemsAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log(asyncResult.error.message); + return; + } + + asyncResult.value.forEach((message) => { + console.log(`Item ID: ${message.itemId}`); + console.log(`Conversation ID: ${message.conversationId}`); + console.log(`Internet message ID: ${message.internetMessageId}`); + console.log(`Subject: ${message.subject}`); + console.log(`Item type: ${message.itemType}`); + console.log(`Item mode: ${message.itemMode}`); + console.log(`Has attachment: ${message.hasAttachment}`); + }); + }); +Office.Sensitivity#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + + + Office.context.mailbox.item.sensitivity.getAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("Sensitivity: " + asyncResult.value); + } else { + console.log("Failed to get sensitivity: " + JSON.stringify(asyncResult.error)); + } + }); +Office.Sensitivity#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml + + + Office.context.mailbox.item.sensitivity.setAsync( + Office.MailboxEnums.AppointmentSensitivityType.Private, + function callback(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Failed) { + console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); + } else { + console.log("Successfully set appointment sensitivity."); + } + } + ); +Office.SensitivityLabel#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + + + // This snippet gets the current mail item's sensitivity label. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.mailbox.item.sensitivityLabel.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.SensitivityLabel#setAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml + + + // This snippet sets the sensitivity label on the current mail item. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.sensitivityLabelsCatalog.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const catalog = asyncResult.value; + if (catalog.length > 0) { + var id = catalog[0].id; + Office.context.mailbox.item.sensitivityLabel.setAsync(id, (asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.status); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } + else { + console.log("Catalog list is empty"); + } + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.SensitivityLabelsCatalog#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml + + + // This snippet gets all available sensitivity labels from the catalog. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) { + Office.context.sensitivityLabelsCatalog.getAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + const catalog = asyncResult.value; + console.log("Sensitivity Labels Catalog:"); + console.log(JSON.stringify(catalog)); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.SensitivityLabelsCatalog#getIsEnabledAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml + + + // This snippet determines if the sensitivity labels catalog is enabled on + the current mailbox. + + Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log(asyncResult.value); + } else { + console.log("Action failed with error: " + asyncResult.error.message); + } + }); +Office.SessionData#clearAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.clearAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("sessionData.clearAsync succeeded"); + } else { + console.log("Failed to clear sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.SessionData#getAllAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("The sessionData is " + JSON.stringify(asyncResult.value)); + } else { + console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.SessionData#getAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.getAsync( + "Date", + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("The sessionData value is " + JSON.stringify(asyncResult.value)); + } else { + console.log("Failed to get sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.SessionData#removeAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.removeAsync( + "Date", + function callback(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("sessionData.removeAsync succeeded"); + } else { + console.log("Failed to remove sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + } + ); +Office.SessionData#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml + + + Office.context.mailbox.item.sessionData.setAsync( + "Date", + "7/24/2020", + function(asyncResult) { + if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { + console.log("sessionData.setAsync succeeded"); + } else { + console.log("Failed to set sessionData. Error: " + JSON.stringify(asyncResult.error)); + } + }); +Office.SharedProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + + + Office.context.mailbox.item.getSharedPropertiesAsync((result) => { + if (result.status === Office.AsyncResultStatus.Failed) { + console.error("The current folder or mailbox isn't shared."); + return; + } + const sharedProperties = result.value; + console.log(`Owner: ${sharedProperties.owner}`); + console.log(`Permissions: ${sharedProperties.delegatePermissions}`); + console.log(`Target mailbox: ${sharedProperties.targetMailbox}`); + }); +Office.Time#getAsync:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + + + Office.context.mailbox.item.start.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + + const time = result.value; + const localTime = Office.context.mailbox.convertToLocalClientTime(time); + console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`); + }); +Office.Time#setAsync:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + + + const start = new Date(); // Represents current date and time. + + start.setDate(start.getDate() + 2); // Add 2 days to current date. + + Office.context.mailbox.item.start.setAsync(start, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Action failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set start date and time to ${start}`); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + + + Office.context.mailbox.item.start.getAsync((result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Get start date failed with message ${result.error.message}`); + return; + } + + const end = result.value; // Set end to current start date and time. + end.setDate(end.getDate() + 1); // Set end as 1 day later than start date. + Office.context.mailbox.item.end.setAsync(end, (result) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + console.error(`Set end date failed with message ${result.error.message}`); + return; + } + console.log(`Successfully set end date and time to ${end}`); + }); + }); +PowerPoint.AddSlideOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + const chosenMaster = (document.getElementById("master-id") as + HTMLInputElement).value; + + const chosenLayout = (document.getElementById("layout-id") as + HTMLInputElement).value; + + + await PowerPoint.run(async function(context) { + // Create a new slide using an existing master slide and layout. + const newSlideOptions: PowerPoint.AddSlideOptions = { + slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */ + layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */ + }; + context.presentation.slides.add(newSlideOptions); + await context.sync(); + }); +PowerPoint.Binding:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function getShapeForBindingId(bindingId: string): + Promise { + // Gets shape associated with binding ID. + return PowerPoint.run(async (context) => { + const binding = context.presentation.bindings.getItem(bindingId); + const shape = binding.getShape(); + return shape; + }); + } +PowerPoint.Binding#getShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function getShapeForBindingId(bindingId: string): + Promise { + // Gets shape associated with binding ID. + return PowerPoint.run(async (context) => { + const binding = context.presentation.bindings.getItem(bindingId); + const shape = binding.getShape(); + return shape; + }); + } +PowerPoint.BindingCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Loads bindings. + + await PowerPoint.run(async (context) => { + const bindings = context.presentation.bindings; + bindings.load("items"); + await context.sync(); + + const bindingCount = bindings.items.length; + if (bindingCount === 0) { + console.log(`There are no bindings.`); + } else if (bindingCount === 1) { + console.log("There's 1 binding."); + } else { + console.log(`There are ${bindingCount} bindings.`); + } + + bindings.items.forEach((binding) => { + getShapeForBindingId(binding.id).then((shape) => { + if (shape) { + console.log(`Binding ID: ${binding.id} refers to shape ID ${shape.id}`); + } else { + console.log(`Binding ID: ${binding.id} doesn't refers to shape.`); + } + }); + }); + + populateBindingsDropdown(bindings.items); + }); +PowerPoint.BindingCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Inserts an image with binding. + + await PowerPoint.run(async (context) => { + const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value; + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, { + top: 100, + left: 30, + width: 200, + height: 200 + }); + + myShape.fill.setImage(flowerImage); + context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId); + await context.sync(); + + const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement; + + const option = new Option(`Binding ${bindingId}`, bindingId); + + // When a binding ID already exists, the binding is updated to refer to the new shape + // so select the existing item rather than add a new one. + const foundIndex = findDropdownItem(bindingsDropdown, option.text); + if (foundIndex < 0) { + bindingsDropdown.add(option); + bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1; + } else { + bindingsDropdown.selectedIndex = foundIndex; + } + }); +PowerPoint.BindingCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function getShapeForBindingId(bindingId: string): + Promise { + // Gets shape associated with binding ID. + return PowerPoint.run(async (context) => { + const binding = context.presentation.bindings.getItem(bindingId); + const shape = binding.getShape(); + return shape; + }); + } +PowerPoint.BindingType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Inserts an image with binding. + + await PowerPoint.run(async (context) => { + const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value; + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, { + top: 100, + left: 30, + width: 200, + height: 200 + }); + + myShape.fill.setImage(flowerImage); + context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId); + await context.sync(); + + const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement; + + const option = new Option(`Binding ${bindingId}`, bindingId); + + // When a binding ID already exists, the binding is updated to refer to the new shape + // so select the existing item rather than add a new one. + const foundIndex = findDropdownItem(bindingsDropdown, option.text); + if (foundIndex < 0) { + bindingsDropdown.add(option); + bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1; + } else { + bindingsDropdown.selectedIndex = foundIndex; + } + }); +PowerPoint.BorderProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.BorderProperties#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.BorderProperties#dashStyle:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.BorderProperties#weight:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.ConnectorType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a line to the collection, while specifying its + + // start and end points. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + + // For a line, left and top are the coordinates of the start point, + // while height and width are the coordinates of the end point. + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, + { + left: 400, + top: 200, + height: 20, + width: 150 + }); + line.name = "StraightLine"; + + await context.sync(); + }); +PowerPoint.FillProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FillProperties#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#doubleStrikethrough:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#name:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#strikethrough:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#subscript:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.FontProperties#superscript:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.GeometricShapeType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); +PowerPoint.Hyperlink:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml + + + // Gets the hyperlinks found in the first selected slide. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const hyperlinks: PowerPoint.HyperlinkCollection = slide.hyperlinks.load("address,screenTip"); + const hyperlinksCount = hyperlinks.getCount(); + await context.sync(); + + console.log(`${hyperlinksCount.value} hyperlinks found in first selected slide:`); + for (let link of hyperlinks.items) { + console.log(`Address: "${link.address}" (Screen tip: "${link.screenTip}")`); + } + }); +PowerPoint.HyperlinkCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml + + + // Gets the hyperlinks found in the first selected slide. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const hyperlinks: PowerPoint.HyperlinkCollection = slide.hyperlinks.load("address,screenTip"); + const hyperlinksCount = hyperlinks.getCount(); + await context.sync(); + + console.log(`${hyperlinksCount.value} hyperlinks found in first selected slide:`); + for (let link of hyperlinks.items) { + console.log(`Address: "${link.address}" (Screen tip: "${link.screenTip}")`); + } + }); +PowerPoint.InsertSlideFormatting:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml + + + await PowerPoint.run(async function(context) { + // Get the ID of the first selected slide. + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); + selected.load("id"); + await context.sync(); + + // Insert the other presentation after the selected slide. + const insertOptions: PowerPoint.InsertSlideOptions = { + formatting: PowerPoint.InsertSlideFormatting.useDestinationTheme, + targetSlideId: selected.id + }; + presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions); + await context.sync(); + }); +PowerPoint.InsertSlideOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml + + + await PowerPoint.run(async function(context) { + // Get the ID of the first selected slide. + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); + selected.load("id"); + await context.sync(); + + // Insert the other presentation after the selected slide. + const insertOptions: PowerPoint.InsertSlideOptions = { + formatting: PowerPoint.InsertSlideFormatting.useDestinationTheme, + targetSlideId: selected.id + }; + presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions); + await context.sync(); + }); +PowerPoint.ParagraphHorizontalAlignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the horizontal and vertical alignments of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying horizontal and vertical alignment. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify, + verticalAlignment: PowerPoint.TextVerticalAlignment.middle + } + }); + await context.sync(); + }); +PowerPoint.Presentation:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml + + + await PowerPoint.run(async function(context) { + // Get the ID of the first selected slide. + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); + selected.load("id"); + await context.sync(); + + // Insert the other presentation after the selected slide. + const insertOptions: PowerPoint.InsertSlideOptions = { + formatting: PowerPoint.InsertSlideFormatting.useDestinationTheme, + targetSlideId: selected.id + }; + presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions); + await context.sync(); + }); +PowerPoint.Presentation#getSelectedShapes:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Arranges the selected shapes in a line from left to right. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Gets the shapes you selected on the slide and displays their IDs on the + task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
    getSelectedShapes.getCount returned:" + shapeCount.value + "
    "; + finalTable += + "
    "; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
    IndexId
    " + index + "" + shape.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = ""; + outputSpan.innerHTML += finalTable; + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Saves which shapes are selected so that they can be reselected later. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); +PowerPoint.Presentation#getSelectedSlides:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Gets the selected slides and displays their IDs on the task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + context.presentation.load("slides"); + await context.sync(); + const allSlidesList = {}; + const allSlidesCount = context.presentation.slides.getCount(); + context.presentation.slides.load("items"); + await context.sync(); + let allSlideItems: PowerPoint.Slide[] = context.presentation.slides.items; + allSlideItems.map((slide, index) => { + allSlidesList[slide.id] = `Slide ${index + 1}`; + }); + + const checkbox = document.getElementById("id-check-usenative") as HTMLInputElement; + if (checkbox && checkbox.checked) { + context.presentation.load("tags"); + } + + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + finalTable += "
    getSelectedSlides.getCount returned:" + slideCount.value + "
    "; + finalTable += + "
    "; + slides.items.map((slide, index) => { + finalTable += ""; + }); + finalTable += "
    IndexId
    " + index + " - " + allSlidesList[slide.id] + "" + slide.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Saves which slides are currently selected so they can be reselected + later. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + await context.sync(); + finalTable += "
    getSelectedSlides.getCount returned:" + slideCount.value + "
    "; + finalTable += + "
    "; + savedSlideSelection = []; + slides.load("items"); + await context.sync(); + slides.items.map((slide, index) => { + finalTable += ""; + savedSlideSelection.push(slide.id); + }); + finalTable += "
    IndexId
    " + index + "" + slide.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); +PowerPoint.Presentation#getSelectedTextRange:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Gets the selected text range and prints data about the range on the task + pane. + + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + try { + await context.sync(); + } catch (error) { + console.warn("You must select only one range of text for this action to work."); + return; + } + textRange.load("text"); + textRange.load("start"); + textRange.load("length"); + await context.sync(); + let txtHtml = textRange.text; + txtHtml = txtHtml.replace(/\n/g, "
    "); + txtHtml = txtHtml.replace(/\r/g, "
    "); + txtHtml = txtHtml.replace(/\v/g, "
    "); + let txtExplained = textRange.text; + txtExplained = txtExplained.replace(/\n/g, "NL"); + txtExplained = txtExplained.replace(/\r/g, "CR"); + txtExplained = txtExplained.replace(/\v/g, "VV"); + let finalTable = ""; + finalTable += + "
    "; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += ""; + finalTable += "
    IndexId
    Raw" + textRange.text + "
    Html" + txtHtml + "
    Exp" + txtExplained + "
    Start" + textRange.start + "
    Length" + textRange.length + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = "" + outputSpan.innerHTML += finalTable; + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the range selection to the range that was saved previously. + + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]); + const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]); + const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + textRange.setSelected(); + await context.sync(); + }); +PowerPoint.Presentation#insertSlidesFromBase64:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml + + + await PowerPoint.run(async function(context) { + // Get the ID of the first selected slide. + const presentation: PowerPoint.Presentation = context.presentation; + const selected: PowerPoint.Slide = presentation.getSelectedSlides().getItemAt(0); + selected.load("id"); + await context.sync(); + + // Insert the other presentation after the selected slide. + const insertOptions: PowerPoint.InsertSlideOptions = { + formatting: PowerPoint.InsertSlideFormatting.useDestinationTheme, + targetSlideId: selected.id + }; + presentation.insertSlidesFromBase64(chosenFileBase64, insertOptions); + await context.sync(); + }); +PowerPoint.Presentation#setSelectedSlides:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Sets selection to the slides that were saved. + + await PowerPoint.run(async (context) => { + context.presentation.setSelectedSlides(savedSlideSelection); + await context.sync(); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Selects slides 2, 4, and 5. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); + slide2.load("id"); + slide4.load("id"); + slide5.load("id"); + try { + await context.sync(); + } catch (error) { + console.warn("This action requires at least 5 slides in the presentation."); + return; + } + await context.sync(); + context.presentation.setSelectedSlides([slide2.id, slide4.id, slide5.id]); + await context.sync(); + }); +PowerPoint.Presentation#bindings:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Loads bindings. + + await PowerPoint.run(async (context) => { + const bindings = context.presentation.bindings; + bindings.load("items"); + await context.sync(); + + const bindingCount = bindings.items.length; + if (bindingCount === 0) { + console.log(`There are no bindings.`); + } else if (bindingCount === 1) { + console.log("There's 1 binding."); + } else { + console.log(`There are ${bindingCount} bindings.`); + } + + bindings.items.forEach((binding) => { + getShapeForBindingId(binding.id).then((shape) => { + if (shape) { + console.log(`Binding ID: ${binding.id} refers to shape ID ${shape.id}`); + } else { + console.log(`Binding ID: ${binding.id} doesn't refers to shape.`); + } + }); + }); + + populateBindingsDropdown(bindings.items); + }); +PowerPoint.Shape:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.Shape#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and then iterates through them, deleting each one. + + await PowerPoint.run(async (context) => { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shapes: PowerPoint.ShapeCollection = slide.shapes; + + // Load all the shapes in the collection without loading their properties. + shapes.load("items/$none"); + + await context.sync(); + + shapes.items.forEach((shape) => shape.delete()); + + await context.sync(); + }); +PowerPoint.Shape#getTable:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Gets the table from a shape. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + + if (shapeCount.value > 0) { + const shape = shapes.getItemAt(0); + shape.load("type"); + await context.sync(); + + // The shape type can indicate whether the shape is a table. + const isTable = shape.type === PowerPoint.ShapeType.table; + + if (isTable) { + // Get the Table object for the Shape which is a table. + const table = shape.getTable(); + table.load(); + await context.sync(); + + // Get the Table row and column count. + console.log("Table RowCount: " + table.rowCount + " and columnCount: " + table.columnCount); + } else console.log("Selected shape isn't table."); + } else console.log("No shape selected."); + }); +PowerPoint.Shape#setZOrder:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function changeZOrder(operation: PowerPoint.ShapeZOrder) { + // Changes the z-order position of the selected shapes. + return PowerPoint.run(async (context) => { + const selectedShapes = context.presentation.getSelectedShapes(); + selectedShapes.load(); + await context.sync(); + + if (selectedShapes.items.length === 0) { + console.log("No shapes are selected."); + } else { + let direction = 1; // Start with bottom-most (lowest number). + + // Start with top-most when sending to back or bringing forward. + + switch (operation) { + case PowerPoint.ShapeZOrder.bringForward: + + case PowerPoint.ShapeZOrder.sendToBack: + direction = -1; // Reverse direction. + + break; + } + + // Change the z-order position for each of the selected shapes, + + // starting with the bottom-most when bringing to front or sending backward, + + // or top-most when sending to back or bringing forward, + + // so the selected shapes retain their relative z-order positions after they're changed. + + selectedShapes.items + .sort((a, b) => (a.zOrderPosition - b.zOrderPosition) * direction) + .forEach((shape) => { + try { + const originalZOrderPosition = shape.zOrderPosition; + shape.setZOrder(operation); + + console.log(`Changed z-order of shape ${shape.id}.`); + } catch (err) { + console.log(`Unable to change z-order of shape ${shape.id}. ${err.message}`); + } + }); + + await context.sync(); + } + }); + } +PowerPoint.Shape#fill:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Changes the selected shapes fill color to red. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); +PowerPoint.Shape#group:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml + + + await PowerPoint.run(async (context) => { + // Ungroups the first shape group on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); + if (shapeGroups.length === 0) { + console.warn("No shape groups on the current slide, so nothing to ungroup."); + return; + } + + // Ungroup the first grouped shapes. + const firstGroupId = shapeGroups[0].id; + const shapeGroupToUngroup = shapes.getItem(firstGroupId); + shapeGroupToUngroup.group.ungroup(); + await context.sync(); + + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); + }); +PowerPoint.Shape#height:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Arranges the selected shapes in a line from left to right. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); +PowerPoint.Shape#left:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Arranges the selected shapes in a line from left to right. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); +PowerPoint.Shape#top:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Arranges the selected shapes in a line from left to right. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); +PowerPoint.Shape#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.Shape#width:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Arranges the selected shapes in a line from left to right. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + let maxHeight = 0; + shapes.items.map((shape) => { + shape.load("width,height"); + }); + await context.sync(); + shapes.items.map((shape) => { + shape.left = currentLeft; + shape.top = currentTop; + currentLeft += shape.width; + if (shape.height > maxHeight) maxHeight = shape.height; + }); + await context.sync(); + currentLeft = 0; + if (currentTop > slideHeight - 200) currentTop = 0; + }); +PowerPoint.Shape#zOrderPosition:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function changeZOrder(operation: PowerPoint.ShapeZOrder) { + // Changes the z-order position of the selected shapes. + return PowerPoint.run(async (context) => { + const selectedShapes = context.presentation.getSelectedShapes(); + selectedShapes.load(); + await context.sync(); + + if (selectedShapes.items.length === 0) { + console.log("No shapes are selected."); + } else { + let direction = 1; // Start with bottom-most (lowest number). + + // Start with top-most when sending to back or bringing forward. + + switch (operation) { + case PowerPoint.ShapeZOrder.bringForward: + + case PowerPoint.ShapeZOrder.sendToBack: + direction = -1; // Reverse direction. + + break; + } + + // Change the z-order position for each of the selected shapes, + + // starting with the bottom-most when bringing to front or sending backward, + + // or top-most when sending to back or bringing forward, + + // so the selected shapes retain their relative z-order positions after they're changed. + + selectedShapes.items + .sort((a, b) => (a.zOrderPosition - b.zOrderPosition) * direction) + .forEach((shape) => { + try { + const originalZOrderPosition = shape.zOrderPosition; + shape.setZOrder(operation); + + console.log(`Changed z-order of shape ${shape.id}.`); + } catch (err) { + console.log(`Unable to change z-order of shape ${shape.id}. ${err.message}`); + } + }); + + await context.sync(); + } + }); + } +PowerPoint.ShapeAddOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); +PowerPoint.ShapeCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.ShapeCollection#addGeometricShape:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a hexagon shape to the collection, while specifying its + + // location and size. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const shapeOptions: PowerPoint.ShapeAddOptions = { + left: 100, + top: 100, + height: 150, + width: 150 + }; + const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions); + hexagon.name = "Hexagon"; + + await context.sync(); + }); +PowerPoint.ShapeCollection#addGroup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml + + + await PowerPoint.run(async (context) => { + // Groups the geometric shapes on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape); + if (shapesToGroup.length === 0) { + console.warn("No shapes on the current slide, so nothing to group."); + return; + } + + // Group the geometric shapes. + console.log(`Number of shapes to group: ${shapesToGroup.length}`); + const group = shapes.addGroup(shapesToGroup); + group.load("id"); + await context.sync(); + + console.log(`Grouped shapes. Group ID: ${group.id}`); + }); +PowerPoint.ShapeCollection#addLine:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a line to the collection, while specifying its + + // start and end points. Then it names the shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + + // For a line, left and top are the coordinates of the start point, + // while height and width are the coordinates of the end point. + const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, + { + left: 400, + top: 200, + height: 20, + width: 150 + }); + line.name = "StraightLine"; + + await context.sync(); + }); +PowerPoint.ShapeCollection#addTable:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Adds a basic table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a simple table, specifying the row and column count. + shapes.addTable(3, 4); + await context.sync(); + }); +PowerPoint.ShapeCollection#addTextBox:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a text box to the collection, while specifying its text, + + // location, and size. Then it names the text box. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", + { + left: 100, + top: 300, + height: 300, + width: 450 + }); + textbox.name = "Textbox"; + + return context.sync(); + }); +PowerPoint.ShapeCollection#getCount:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Gets the table from a shape. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + + if (shapeCount.value > 0) { + const shape = shapes.getItemAt(0); + shape.load("type"); + await context.sync(); + + // The shape type can indicate whether the shape is a table. + const isTable = shape.type === PowerPoint.ShapeType.table; + + if (isTable) { + // Get the Table object for the Shape which is a table. + const table = shape.getTable(); + table.load(); + await context.sync(); + + // Get the Table row and column count. + console.log("Table RowCount: " + table.rowCount + " and columnCount: " + table.columnCount); + } else console.log("Selected shape isn't table."); + } else console.log("No shape selected."); + }); +PowerPoint.ShapeCollection#getItemAt:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function(context) { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + const shape: PowerPoint.Shape = slide.shapes.getItemAt(0); + shape.tags.add("MOUNTAIN", "Denali"); + + await context.sync(); + + const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN"); + myShapeTag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(myShapeTag.key) + " with value " + JSON.stringify(myShapeTag.value)); + }); +PowerPoint.ShapeCollection#load:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.ShapeFill:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.ShapeFill#setImage:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Inserts an image with binding. + + await PowerPoint.run(async (context) => { + const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value; + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, { + top: 100, + left: 30, + width: 200, + height: 200 + }); + + myShape.fill.setImage(flowerImage); + context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId); + await context.sync(); + + const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement; + + const option = new Option(`Binding ${bindingId}`, bindingId); + + // When a binding ID already exists, the binding is updated to refer to the new shape + // so select the existing item rather than add a new one. + const foundIndex = findDropdownItem(bindingsDropdown, option.text); + if (foundIndex < 0) { + bindingsDropdown.add(option); + bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1; + } else { + bindingsDropdown.selectedIndex = foundIndex; + } + }); +PowerPoint.ShapeFill#setSolidColor:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Changes the selected shapes fill color to red. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); +PowerPoint.ShapeFill#foregroundColor:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Creates random shapes on the selected slide. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + const maxNewShapeWidth = 200; + const maxNewShapeHeight = 200; + const minNewShapeWidth = 50; + const minNewShapeHeight = 50; + for (let i = 0; i < 20; i++) { + const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape( + PowerPoint.GeometricShapeType.rectangle + ); + rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth); + rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight); + rectangle.left = getRandomBetween(0, slideWidth - rectangle.width); + rectangle.top = getRandomBetween(0, slideHeight - rectangle.height); + rectangle.fill.foregroundColor = generateRandomHexColor(); + } + finalTable += "Done
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = ""; + outputSpan.innerHTML += finalTable; + }); +PowerPoint.ShapeFill#transparency:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the transparency of every geometric shape in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the shape transparency to be halfway transparent. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.geometricShape) { + shape.fill.transparency = 0.5; + } + }); + await context.sync(); + }); +PowerPoint.ShapeFont:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the color of the selected text range to green. + + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + textRange.font.color = "green"; + await context.sync(); + }); +PowerPoint.ShapeFont#color:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the color of the selected text range to green. + + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + textRange.font.color = "green"; + await context.sync(); + }); +PowerPoint.ShapeGroup:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml + + + await PowerPoint.run(async (context) => { + // Ungroups the first shape group on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); + if (shapeGroups.length === 0) { + console.warn("No shape groups on the current slide, so nothing to ungroup."); + return; + } + + // Ungroup the first grouped shapes. + const firstGroupId = shapeGroups[0].id; + const shapeGroupToUngroup = shapes.getItem(firstGroupId); + shapeGroupToUngroup.group.ungroup(); + await context.sync(); + + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); + }); +PowerPoint.ShapeGroup#ungroup:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml + + + await PowerPoint.run(async (context) => { + // Ungroups the first shape group on the current slide. + + // Get the shapes on the current slide. + context.presentation.load("slides"); + const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0); + slide.load("shapes/items/type,shapes/items/id"); + await context.sync(); + + const shapes: PowerPoint.ShapeCollection = slide.shapes; + const shapeGroups = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.group); + if (shapeGroups.length === 0) { + console.warn("No shape groups on the current slide, so nothing to ungroup."); + return; + } + + // Ungroup the first grouped shapes. + const firstGroupId = shapeGroups[0].id; + const shapeGroupToUngroup = shapes.getItem(firstGroupId); + shapeGroupToUngroup.group.ungroup(); + await context.sync(); + + console.log(`Ungrouped shapes with group ID: ${firstGroupId}`); + }); +PowerPoint.ShapeLineDashStyle:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the dash style of every line in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the dash style for shapes of the type `line`. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.line) { + shape.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.dashDot; + } + }); + await context.sync(); + }); +PowerPoint.ShapeLineFormat:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the dash style of every line in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the dash style for shapes of the type `line`. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.line) { + shape.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.dashDot; + } + }); + await context.sync(); + }); +PowerPoint.ShapeLineFormat#dashStyle:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the dash style of every line in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the dash style for shapes of the type `line`. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.line) { + shape.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.dashDot; + } + }); + await context.sync(); + }); +PowerPoint.ShapeScopedCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Changes the selected shapes fill color to red. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + shape.fill.setSolidColor("red"); + }); + await context.sync(); + }); +PowerPoint.ShapeScopedCollection#getCount:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Gets the shapes you selected on the slide and displays their IDs on the + task pane. + + await PowerPoint.run(async (context) => { + let finalTable = ""; + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + finalTable += "
    getSelectedShapes.getCount returned:" + shapeCount.value + "
    "; + finalTable += + "
    "; + shapes.load("items"); + await context.sync(); + shapes.items.map((shape, index) => { + finalTable += ""; + }); + finalTable += "
    IndexId
    " + index + "" + shape.id + "
    "; + const outputSpan = document.getElementById("outputSpan"); + outputSpan.innerHTML = ""; + outputSpan.innerHTML += finalTable; + }); +PowerPoint.ShapeType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml + + + // Changes the dash style of every line in the slide. + + await PowerPoint.run(async (context) => { + // Get the type of shape for every shape in the collection. + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + shapes.load("type"); + await context.sync(); + + // Change the dash style for shapes of the type `line`. + shapes.items.forEach((shape) => { + if (shape.type === PowerPoint.ShapeType.line) { + shape.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.dashDot; + } + }); + await context.sync(); + }); +PowerPoint.ShapeZOrder:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + // Sends the shape to the back. + + changeZOrder(PowerPoint.ShapeZOrder.sendToBack); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml + + + async function changeZOrder(operation: PowerPoint.ShapeZOrder) { + // Changes the z-order position of the selected shapes. + return PowerPoint.run(async (context) => { + const selectedShapes = context.presentation.getSelectedShapes(); + selectedShapes.load(); + await context.sync(); + + if (selectedShapes.items.length === 0) { + console.log("No shapes are selected."); + } else { + let direction = 1; // Start with bottom-most (lowest number). + + // Start with top-most when sending to back or bringing forward. + + switch (operation) { + case PowerPoint.ShapeZOrder.bringForward: + + case PowerPoint.ShapeZOrder.sendToBack: + direction = -1; // Reverse direction. + + break; + } + + // Change the z-order position for each of the selected shapes, + + // starting with the bottom-most when bringing to front or sending backward, + + // or top-most when sending to back or bringing forward, + + // so the selected shapes retain their relative z-order positions after they're changed. + + selectedShapes.items + .sort((a, b) => (a.zOrderPosition - b.zOrderPosition) * direction) + .forEach((shape) => { + try { + const originalZOrderPosition = shape.zOrderPosition; + shape.setZOrder(operation); + + console.log(`Changed z-order of shape ${shape.id}.`); + } catch (err) { + console.log(`Unable to change z-order of shape ${shape.id}. ${err.message}`); + } + }); + + await context.sync(); + } + }); + } +PowerPoint.Slide:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Reselects shapes that were saved previously. + + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); + await context.sync(); + slide1.setSelectedShapes(savedShapeSelection); + await context.sync(); + }); +PowerPoint.Slide#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Deletes the selected slides. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + slides.items.map((slide) => { + slide.delete(); + }); + }); +PowerPoint.Slide#exportAsBase64:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/export-import-slide.yaml + + + // Exports current slide. + + await PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const slideBase64DataResult = slide.exportAsBase64(); + const imageBase64DataResult = slide.getImageAsBase64({ height: 300 }); + await context.sync(); + + localStorage.setItem("exportedSlide", slideBase64DataResult.value); + localStorage.setItem("exportedSlideImage", imageBase64DataResult.value); + + updateSlideImage(imageBase64DataResult.value); + + console.log("Slide was exported."); + }); +PowerPoint.Slide#getImageAsBase64:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/export-import-slide.yaml + + + // Exports current slide. + + await PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const slideBase64DataResult = slide.exportAsBase64(); + const imageBase64DataResult = slide.getImageAsBase64({ height: 300 }); + await context.sync(); + + localStorage.setItem("exportedSlide", slideBase64DataResult.value); + localStorage.setItem("exportedSlideImage", imageBase64DataResult.value); + + updateSlideImage(imageBase64DataResult.value); + + console.log("Slide was exported."); + }); +PowerPoint.Slide#setSelectedShapes:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Reselects shapes that were saved previously. + + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]); + await context.sync(); + slide1.setSelectedShapes(savedShapeSelection); + await context.sync(); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Selects the first two shapes on slide 1. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slide1 = context.presentation.slides.getItemAt(0); + slide1.load("shapes/items/type"); + await context.sync(); + + const shapes = slide1.shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape); + const shape1: PowerPoint.Shape = shapes[0]; + const shape2: PowerPoint.Shape = shapes[1]; + shape1.load("id"); + shape2.load("id"); + await context.sync(); + + console.log(`IDs: ${shape1.id}, ${shape2.id}`) + slide1.setSelectedShapes([shape1.id, shape2.id]); + await context.sync(); + }); +PowerPoint.SlideCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + const chosenMaster = (document.getElementById("master-id") as + HTMLInputElement).value; + + const chosenLayout = (document.getElementById("layout-id") as + HTMLInputElement).value; + + + await PowerPoint.run(async function(context) { + // Create a new slide using an existing master slide and layout. + const newSlideOptions: PowerPoint.AddSlideOptions = { + slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */ + layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */ + }; + context.presentation.slides.add(newSlideOptions); + await context.sync(); + }); +PowerPoint.SlideCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + const chosenMaster = (document.getElementById("master-id") as + HTMLInputElement).value; + + const chosenLayout = (document.getElementById("layout-id") as + HTMLInputElement).value; + + + await PowerPoint.run(async function(context) { + // Create a new slide using an existing master slide and layout. + const newSlideOptions: PowerPoint.AddSlideOptions = { + slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */ + layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */ + }; + context.presentation.slides.add(newSlideOptions); + await context.sync(); + }); +PowerPoint.SlideCollection#getItemAt:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml + + + // Selects slides 2, 4, and 5. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1); + const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3); + const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4); + slide2.load("id"); + slide4.load("id"); + slide5.load("id"); + try { + await context.sync(); + } catch (error) { + console.warn("This action requires at least 5 slides in the presentation."); + return; + } + await context.sync(); + context.presentation.setSelectedSlides([slide2.id, slide4.id, slide5.id]); + await context.sync(); + }); +PowerPoint.SlideGetImageOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/export-import-slide.yaml + + + // Exports current slide. + + await PowerPoint.run(async (context) => { + const slide = context.presentation.getSelectedSlides().getItemAt(0); + const slideBase64DataResult = slide.exportAsBase64(); + const imageBase64DataResult = slide.getImageAsBase64({ height: 300 }); + await context.sync(); + + localStorage.setItem("exportedSlide", slideBase64DataResult.value); + localStorage.setItem("exportedSlideImage", imageBase64DataResult.value); + + updateSlideImage(imageBase64DataResult.value); + + console.log("Slide was exported."); + }); +PowerPoint.SlideLayout:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideLayout#id:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideLayoutCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideLayoutCollection#load:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideMaster:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideMaster#id:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideMasterCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideMasterCollection#load:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml + + + await PowerPoint.run(async function(context) { + // Load information about all the slide masters and associated layouts. + const slideMasters: PowerPoint.SlideMasterCollection = context.presentation.slideMasters.load("id, name, layouts/items/name, layouts/items/id"); + await context.sync(); + + // Log the name and ID of each slide master. + for (let i = 0; i < slideMasters.items.length; i++) { + console.log("Master name: " + slideMasters.items[i].name); + console.log("Master ID: " + slideMasters.items[i].id); + + // Log the name and ID of each slide layout in the slide master. + const layoutsInMaster: PowerPoint.SlideLayoutCollection = slideMasters.items[i].layouts; + for (let j = 0; j < layoutsInMaster.items.length; j++) { + console.log(" Layout name: " + layoutsInMaster.items[j].name + " Layout ID: " + layoutsInMaster.items[j].id); + } + } + }); +PowerPoint.SlideScopedCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml + + + // Saves which shapes are selected so that they can be reselected later. + + await PowerPoint.run(async (context) => { + context.presentation.load("slides"); + await context.sync(); + const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides(); + const slideCount = slides.getCount(); + slides.load("items"); + await context.sync(); + savedSlideSelection = []; + slides.items.map((slide) => { + savedSlideSelection.push(slide.id); + }); + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + shapes.load("items"); + await context.sync(); + shapes.items.map((shape) => { + savedShapeSelection.push(shape.id); + }); + }); +PowerPoint.Table:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Updates a table's values. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table (which is a type of Shape). + const shape = shapes.addTable(4, 3); + let table = shape.getTable(); + table.load(); + await context.sync(); + + // Update values in the table. + for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) { + for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) { + const cell = table.getCellOrNullObject(rowIndex, columnIndex); + cell.text = generateRandomString(); + } + } + + await context.sync(); + }); +PowerPoint.Table#getCellOrNullObject:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Updates a table's values. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table (which is a type of Shape). + const shape = shapes.addTable(4, 3); + let table = shape.getTable(); + table.load(); + await context.sync(); + + // Update values in the table. + for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) { + for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) { + const cell = table.getCellOrNullObject(rowIndex, columnIndex); + cell.text = generateRandomString(); + } + } + + await context.sync(); + }); +PowerPoint.TableAddOptions:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the width and height of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the width and height. + shapes.addTable(3, 4, { + width: 600, + height: 400 + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#columns:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#height:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the width and height of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the width and height. + shapes.addTable(3, 4, { + width: 600, + height: 400 + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#mergedAreas:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#rows:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#specificCellProperties:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#uniformCellProperties:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#values:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's values. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying cell values. + const shape = shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ] + }); + await context.sync(); + }); +PowerPoint.TableAddOptions#width:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the width and height of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the width and height. + shapes.addTable(3, 4, { + width: 600, + height: 400 + }); + await context.sync(); + }); +PowerPoint.TableCell:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Updates a table's values. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table (which is a type of Shape). + const shape = shapes.addTable(4, 3); + let table = shape.getTable(); + table.load(); + await context.sync(); + + // Update values in the table. + for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) { + for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) { + const cell = table.getCellOrNullObject(rowIndex, columnIndex); + cell.text = generateRandomString(); + } + } + + await context.sync(); + }); +PowerPoint.TableCell#text:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Updates a table's values. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table (which is a type of Shape). + const shape = shapes.addTable(4, 3); + let table = shape.getTable(); + table.load(); + await context.sync(); + + // Update values in the table. + for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) { + for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) { + const cell = table.getCellOrNullObject(rowIndex, columnIndex); + cell.text = generateRandomString(); + } + } + + await context.sync(); + }); +PowerPoint.TableCellBorders:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellBorders#bottom:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellBorders#left:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellBorders#right:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellBorders#top:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#borders:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies a table's borders. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying border styles. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + borders: { + left: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + right: { color: "blue", dashStyle: PowerPoint.ShapeLineDashStyle.solid, weight: 4 }, + top: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 }, + bottom: { color: "red", dashStyle: PowerPoint.ShapeLineDashStyle.longDashDotDot, weight: 2 } + } + } + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#fill:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#font:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the font formatting and fill colors of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying font formatting and fill colors. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [ + { fill: { color: "red" }, font: { color: "yellow", name: "Calibri" } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", name: "Coolvetica" } }, + { fill: { color: "red" }, font: { color: "yellow", italic: true } }, + { fill: { color: "red" }, font: { color: "#9966cc", strikethrough: true } } + ], + [ + { fill: { color: "#fbceb1" }, font: { color: "yellow", doubleStrikethrough: true } }, + { fill: { color: "red" }, font: { color: "yellow", subscript: true } }, + { fill: { color: "#0048ba" }, font: { color: "yellow", superscript: true } }, + { fill: { color: "red" }, font: { color: "yellow" } } + ], + [ + { fill: { color: "red" }, font: { color: "#b0bf1a" } }, + { fill: { color: "#9966cc" }, font: { color: "yellow" } }, + { fill: { color: "#b0bf1a" }, font: { color: "yellow" } }, + { fill: { color: "red" }, font: { color: "#fbceb1" } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#horizontalAlignment:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the horizontal and vertical alignments of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying horizontal and vertical alignment. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify, + verticalAlignment: PowerPoint.TextVerticalAlignment.middle + } + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#indentLevel:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifying the indents for a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying the indent level for cells. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + specificCellProperties: [ + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }], + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }], + [{ indentLevel: 0 }, { indentLevel: 1 }, { indentLevel: 2 }, { indentLevel: 3 }] + ] + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#textRuns:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the text runs of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying text runs. + shapes.addTable(3, 4, { + specificCellProperties: [ + [ + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } } + ], + [ + { text: "Bold text", font: { bold: true } }, + { + textRuns: [ + { text: "Text runs with " }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.double } }, + { text: " and plain text" } + ] + }, + { text: "Italicized text", font: { italic: true } }, + { text: "Plain text" } + ], + [ + { text: "Bold text", font: { bold: true } }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.dotted } }, + { + font: { bold: true }, + textRuns: [ + { text: "Text runs with " }, + { text: "italicized text", font: { italic: true } }, + { text: " and (inherited) bold text" } + ] + }, + { text: "Italicized text", font: { italic: true } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TableCellProperties#verticalAlignment:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the horizontal and vertical alignments of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying horizontal and vertical alignment. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "GGG", "HHHH"], + ["1", "12", "123", "1234"] + ], + uniformCellProperties: { + horizontalAlignment: PowerPoint.ParagraphHorizontalAlignment.justify, + verticalAlignment: PowerPoint.TextVerticalAlignment.middle + } + }); + await context.sync(); + }); +PowerPoint.TableColumnProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.TableColumnProperties#columnWidth:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.TableMergedAreaProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableMergedAreaProperties#columnCount:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableMergedAreaProperties#columnIndex:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableMergedAreaProperties#rowCount:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableMergedAreaProperties#rowIndex:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the merge areas of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying one 2x2 merged area. + shapes.addTable(3, 4, { + values: [ + ["A", "BB", "CCC", "DDDD"], + ["E", "FF", "", "HHHH"], + ["1", "", "", "1234"] + ], + mergedAreas: [{ rowIndex: 1, columnIndex: 1, rowCount: 2, columnCount: 2 }] + }); + await context.sync(); + }); +PowerPoint.TableRowProperties:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.TableRowProperties#rowHeight:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the column widths and row heights of a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying column widths and row heights. + shapes.addTable(3, 4, { + columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }], + rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }] + }); + await context.sync(); + }); +PowerPoint.Tag:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + presentationTags.add("COLOR", "blue"); + + await context.sync(); + + const tag: PowerPoint.Tag = presentationTags.getItem("COLOR"); + tag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(tag.key) + " with value " + JSON.stringify(tag.value)); + }); +PowerPoint.TagCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function(context) { + let selectedSlideIndex = await getSelectedSlideIndex(); + + // Decrement because the getSelectedSlideByIndex method is 1-based, + // but the getItemAt method is 0-based. + selectedSlideIndex = selectedSlideIndex - 1; + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); + slide.tags.add("CUSTOMER_TYPE", "Premium"); + + await context.sync(); + + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); + audienceTag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(audienceTag.key) + " with value " + JSON.stringify(audienceTag.value)); + }); +PowerPoint.TagCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function(context) { + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0); + slide.tags.add("OCEAN", "Indian"); + slide.tags.add("PLANET", "Jupiter"); + slide.tags.add("CONTINENT", "Antarctica"); + + await context.sync(); + + slide.tags.load("key, value"); + + await context.sync(); + + for (let i = 0; i < slide.tags.items.length; i++) { + console.log("Added key " + JSON.stringify(slide.tags.items[i].key) + " with value " + JSON.stringify(slide.tags.items[i].value)); + } + }); +PowerPoint.TagCollection#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function (context) { + let presentationTags: PowerPoint.TagCollection = context.presentation.tags; + + presentationTags.delete("COLOR"); + + await context.sync(); + + console.log(JSON.stringify(presentationTags)); + }); +PowerPoint.TagCollection#getItem:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml + + + await PowerPoint.run(async function(context) { + let selectedSlideIndex = await getSelectedSlideIndex(); + + // Decrement because the getSelectedSlideByIndex method is 1-based, + // but the getItemAt method is 0-based. + selectedSlideIndex = selectedSlideIndex - 1; + const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(selectedSlideIndex); + slide.tags.add("CUSTOMER_TYPE", "Premium"); + + await context.sync(); + + const audienceTag: PowerPoint.Tag = slide.tags.getItem("CUSTOMER_TYPE"); + audienceTag.load("key, value"); + + await context.sync(); + + console.log("Added key " + JSON.stringify(audienceTag.key) + " with value " + JSON.stringify(audienceTag.value)); + }); +PowerPoint.TextFrame:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); +PowerPoint.TextRange:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the color of the selected text range to green. + + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + textRange.font.color = "green"; + await context.sync(); + }); +PowerPoint.TextRange#font:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the color of the selected text range to green. + + await PowerPoint.run(async (context) => { + const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange(); + textRange.font.color = "green"; + await context.sync(); + }); +PowerPoint.TextRange#setSelected:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Selects the first 10 characters of the selected shape. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes(); + const shapeCount = shapes.getCount(); + await context.sync(); + if (shapeCount.value !== 1) { + console.warn("You must select only one shape with text in it."); + return; + } + const shape: PowerPoint.Shape = shapes.getItemAt(0); + const textFrame: PowerPoint.TextFrame = shape.textFrame.load("textRange,hasText"); + await context.sync(); + if (textFrame.hasText != true) { + console.warn("You must select only one shape with text in it."); + return; + } + const textRange: PowerPoint.TextRange = textFrame.textRange; + textRange.load("text"); + await context.sync(); + if (textRange.text.length < 10) { + console.warn("You must select only one shape with at least 10 characters in it."); + return; + } + const textRange10 = textRange.getSubstring(0, 10); + textRange10.setSelected(); + await context.sync(); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml + + + // Sets the range selection to the range that was saved previously. + + await PowerPoint.run(async (context) => { + const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedTextSlideSelection[0]); + const shape1: PowerPoint.Shape = slide1.shapes.getItem(savedTextShapeSelection[0]); + const textRange: PowerPoint.TextRange = shape1.textFrame.textRange.getSubstring(savedTextTextRangeStart, savedTextTextRangeLength); + textRange.setSelected(); + await context.sync(); + }); +PowerPoint.TextRun:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml + + + // Specifies the text runs of the cells in a table. + + await PowerPoint.run(async (context) => { + const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes; + + // Add a table, specifying text runs. + shapes.addTable(3, 4, { + specificCellProperties: [ + [ + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } }, + { text: "Title text", font: { bold: true } } + ], + [ + { text: "Bold text", font: { bold: true } }, + { + textRuns: [ + { text: "Text runs with " }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.double } }, + { text: " and plain text" } + ] + }, + { text: "Italicized text", font: { italic: true } }, + { text: "Plain text" } + ], + [ + { text: "Bold text", font: { bold: true } }, + { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.dotted } }, + { + font: { bold: true }, + textRuns: [ + { text: "Text runs with " }, + { text: "italicized text", font: { italic: true } }, + { text: " and (inherited) bold text" } + ] + }, + { text: "Italicized text", font: { italic: true } } + ] + ] + }); + await context.sync(); + }); +PowerPoint.TextVerticalAlignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml + + + // This function gets the collection of shapes on the first slide, + + // and adds a brace pair, {}, to the collection, while specifying its + + // location and size. Then it names the shape, sets its text and font + + // color, and centers it inside the braces. + + await PowerPoint.run(async (context) => { + const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; + const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, { + left: 100, + top: 400, + height: 50, + width: 150 + }); + braces.name = "Braces"; + braces.textFrame.textRange.text = "Shape text"; + braces.textFrame.textRange.font.color = "purple"; + braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered; + + return context.sync(); + }); +Word.Alignment:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml + + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + body.paragraphs + .getLast() + .insertText( + "Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.", + "Replace" + ); + body.paragraphs.getFirst().alignment = "Left"; + body.paragraphs.getLast().alignment = Word.Alignment.left; + }); +Word.Annotation:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Accepts the first annotation found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Accepting ID ${annotation.id}...`); + annotation.critiqueAnnotation.accept(); + + await context.sync(); + break; + } + } + }); +Word.Annotation#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Deletes all annotations found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id"); + + await context.sync(); + + const ids = []; + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + ids.push(annotation.id); + annotation.delete(); + } + + await context.sync(); + + console.log("Annotations deleted:", ids); + }); +Word.Annotation#critiqueAnnotation:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Gets annotations found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + console.log("Annotations found:"); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); + } + }); +Word.Annotation#id:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Accepts the first annotation found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Accepting ID ${annotation.id}...`); + annotation.critiqueAnnotation.accept(); + + await context.sync(); + break; + } + } + }); +Word.Annotation#state:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Rejects the last annotation found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = annotations.items.length - 1; i >= 0; i--) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Rejecting ID ${annotation.id}...`); + annotation.critiqueAnnotation.reject(); + + await context.sync(); + break; + } + } + }); +Word.AnnotationClickedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Registers event handlers. + + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + - await Excel.run(async (context) => { - /* - The table is expected to look like this: - Product, Inventory, Price, Current Market Share - Calamansi, 2000, $2.45, 10% - ... + async function onClickedHandler(args: Word.AnnotationClickedEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); - We want each bubble to represent a single row. - */ + await context.sync(); - // Get the worksheet and table data. - const sheet = context.workbook.worksheets.getItem("Sample"); - const table = sheet.tables.getItem("Sales"); - const dataRange = table.getDataBodyRange(); + console.log(`AnnotationClicked: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } +Word.AnnotationCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - // Get the table data without the row names. - const valueRange = dataRange.getOffsetRange(0, 1).getResizedRange(0, -1); - // Create the chart. - const bubbleChart = sheet.charts.add(Excel.ChartType.bubble, valueRange); - bubbleChart.name = "Product Chart"; + // Gets annotations found in the selected paragraph. - // Remove the default series, since we want a unique series for each row. - bubbleChart.series.getItemAt(0).delete(); + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); - // Load the data necessary to make a chart series. - dataRange.load(["rowCount", "values"]); await context.sync(); - // For each row, create a chart series (a bubble). - for (let i = 0; i < dataRange.rowCount; i++) { - const newSeries = bubbleChart.series.add(dataRange.values[i][0], i); - newSeries.setXAxisValues(dataRange.getCell(i, 1)); - newSeries.setValues(dataRange.getCell(i, 2)); - newSeries.setBubbleSizes(dataRange.getCell(i, 3)); + console.log("Annotations found:"); - // Show the product name and market share percentage. - newSeries.dataLabels.showSeriesName = true; - newSeries.dataLabels.showBubbleSize = true; - newSeries.dataLabels.showValue = false; - } + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; - await context.sync(); + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); + } }); -'Excel.ChartSeries#getDimensionValues:member(1)': +Word.AnnotationHoveredEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-bubble-chart.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // The sample chart is of type `Excel.ChartType.bubble`. - const bubbleChart = sheet.charts.getItem("Product Chart"); + // Registers event handlers. - // Get the first series in the chart. - const firstSeries = bubbleChart.series.getItemAt(0); + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); - // Get the values for the dimensions we're interested in. - const bubbleSize = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.bubbleSizes); - const xValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.xvalues); - const yValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.yvalues); - const category = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.categories); + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); await context.sync(); - // Log the information. - console.log(`Series ${category.value} - X:${xValues.value},Y:${yValues.value},Bubble:${bubbleSize.value}`); + console.log("Event handlers registered."); }); -'Excel.ChartSeries#delete:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const seriesCollection = sheet.charts.getItemAt(0).series; - seriesCollection.load("count"); - await context.sync(); - if (seriesCollection.count > 0) { - const series = seriesCollection.getItemAt(0); + async function onHoveredHandler(args: Word.AnnotationHoveredEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); - // Delete the first series. - series.delete(); - } + await context.sync(); - await context.sync(); - }); -'Excel.ChartSeries#setValues:member(1)': + console.log(`AnnotationHovered: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } +Word.AnnotationInsertedEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let seriesCollection = sheet.charts.getItemAt(0); - let rangeSelection = sheet.getRange("C2:C7"); - let xRangeSelection = sheet.getRange("A1:A7"); + // Registers event handlers. - // Add a series. - let newSeries = seriesCollection.series.add("Qtr2"); - newSeries.setValues(rangeSelection); - newSeries.setXAxisValues(xRangeSelection); + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.ChartSeries#markerBackgroundColor:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series-markers.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); - let dataRange = sheet.getRange("A1:E7"); - // Create an XY scatter chart. - let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); - chart.title.text = "Bicycle Parts Quarterly Sales"; - - let series = chart.series; - let series0 = series.getItemAt(0); - let series1 = series.getItemAt(1); - let series2 = series.getItemAt(2); - let series3 = series.getItemAt(3); + async function onInsertedHandler(args: Word.AnnotationInsertedEventArgs) { + await Word.run(async (context) => { + const annotations = []; + for (let i = 0; i < args.ids.length; i++) { + let annotation: Word.Annotation = context.document.getAnnotationById(args.ids[i]); + annotation.load("id,critiqueAnnotation"); - // Set markers. - series0.markerStyle = "Dash"; - series0.markerForegroundColor = "black"; - series1.markerStyle = "Star"; - series1.markerForegroundColor = "black"; - series2.markerStyle = "X"; - series2.markerSize = 12; - series3.markerStyle = "Triangle"; - series3.markerBackgroundColor = "purple"; + annotations.push(annotation); + } await context.sync(); - }); -'Excel.ChartSeries#markerForegroundColor:member': + + for (let annotation of annotations) { + console.log(`AnnotationInserted: ID ${annotation.id}:`, annotation.critiqueAnnotation.critique); + } + }); + } +Word.AnnotationPopupActionEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series-markers.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); - let dataRange = sheet.getRange("A1:E7"); - // Create an XY scatter chart. - let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); - chart.title.text = "Bicycle Parts Quarterly Sales"; - - let series = chart.series; - let series0 = series.getItemAt(0); - let series1 = series.getItemAt(1); - let series2 = series.getItemAt(2); - let series3 = series.getItemAt(3); + // Registers event handlers. - // Set markers. - series0.markerStyle = "Dash"; - series0.markerForegroundColor = "black"; - series1.markerStyle = "Star"; - series1.markerForegroundColor = "black"; - series2.markerStyle = "X"; - series2.markerSize = 12; - series3.markerStyle = "Triangle"; - series3.markerBackgroundColor = "purple"; + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); - await context.sync(); + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.ChartSeries#markerSize:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series-markers.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); - let dataRange = sheet.getRange("A1:E7"); - // Create an XY scatter chart. - let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); - chart.title.text = "Bicycle Parts Quarterly Sales"; - - let series = chart.series; - let series0 = series.getItemAt(0); - let series1 = series.getItemAt(1); - let series2 = series.getItemAt(2); - let series3 = series.getItemAt(3); + async function onPopupActionHandler(args: + Word.AnnotationPopupActionEventArgs) { + await Word.run(async (context) => { + let message = `AnnotationPopupAction: ID ${args.id} = `; + if (args.action === "Accept") { + message += `Accepted: ${args.critiqueSuggestion}`; + } else { + message += "Rejected"; + } - // Set markers. - series0.markerStyle = "Dash"; - series0.markerForegroundColor = "black"; - series1.markerStyle = "Star"; - series1.markerForegroundColor = "black"; - series2.markerStyle = "X"; - series2.markerSize = 12; - series3.markerStyle = "Triangle"; - series3.markerBackgroundColor = "purple"; + console.log(message); + }); + } +Word.AnnotationRemovedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await context.sync(); + + // Registers event handlers. + + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.ChartSeries#markerStyle:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-series-markers.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let salesTable = sheet.tables.getItem("SalesTable"); - let dataRange = sheet.getRange("A1:E7"); - // Create an XY scatter chart. - let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto"); - chart.title.text = "Bicycle Parts Quarterly Sales"; - - let series = chart.series; - let series0 = series.getItemAt(0); - let series1 = series.getItemAt(1); - let series2 = series.getItemAt(2); - let series3 = series.getItemAt(3); + async function onRemovedHandler(args: Word.AnnotationRemovedEventArgs) { + await Word.run(async (context) => { + for (let id of args.ids) { + console.log(`AnnotationRemoved: ID ${id}`); + } + }); + } +Word.AnnotationSet:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - // Set markers. - series0.markerStyle = "Dash"; - series0.markerForegroundColor = "black"; - series1.markerStyle = "Star"; - series1.markerForegroundColor = "black"; - series2.markerStyle = "X"; - series2.markerSize = 12; - series3.markerStyle = "Triangle"; - series3.markerBackgroundColor = "purple"; - await context.sync(); + // Adds annotations to the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; + + const annotationIds = paragraph.insertAnnotations(annotationSet); + + await context.sync(); + + console.log("Annotations inserted:", annotationIds.value); }); -'Excel.ChartTitle#getSubstring:member(1)': +Word.AnnotationState:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-title-format.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - let chart = sheet.charts.getItemAt(0); - // Get first seven characters of the title and color them green. - chart.title.getSubstring(0, 7).font.color = "Yellow"; - await context.sync(); + // Accepts the first annotation found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Accepting ID ${annotation.id}...`); + annotation.critiqueAnnotation.accept(); + + await context.sync(); + break; + } + } }); -'Excel.ChartTitle#textOrientation:member': +Word.Application:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-title-format.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const title = sheet.charts.getItemAt(0).title; - title.textOrientation = -45; - await context.sync(); + // Updates the text of the current document with the text from another + document passed in as a Base64-encoded string. + + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + const externalDoc: Word.DocumentCreated = context.application.createDocument(externalDocument); + await context.sync(); + + if (!Office.context.requirements.isSetSupported("WordApiHiddenDocument", "1.3")) { + console.warn("The WordApiHiddenDocument 1.3 requirement set isn't supported on this client so can't proceed. Try this action on a platform that supports this requirement set."); + return; + } + + const externalDocBody: Word.Body = externalDoc.body; + externalDocBody.load("text"); + await context.sync(); + + // Insert the external document's text at the beginning of the current document's body. + const externalDocBodyText = externalDocBody.text; + const currentDocBody: Word.Body = context.document.body; + currentDocBody.insertText(externalDocBodyText, Word.InsertLocation.start); + await context.sync(); }); -'Excel.ChartTrendline#type:member': +Word.Application#createDocument:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-trendlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let seriesCollection = sheet.charts.getItemAt(0).series; + // Updates the text of the current document with the text from another + document passed in as a Base64-encoded string. - // Get the trendline for series 1 and load its type property. - let trendline = seriesCollection.getItemAt(0).trendlines.getItem(0); - trendline.load("type"); + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + const externalDoc: Word.DocumentCreated = context.application.createDocument(externalDocument); + await context.sync(); - await context.sync(); + if (!Office.context.requirements.isSetSupported("WordApiHiddenDocument", "1.3")) { + console.warn("The WordApiHiddenDocument 1.3 requirement set isn't supported on this client so can't proceed. Try this action on a platform that supports this requirement set."); + return; + } + + const externalDocBody: Word.Body = externalDoc.body; + externalDocBody.load("text"); + await context.sync(); - console.log("The trendline type is:" + trendline.type); + // Insert the external document's text at the beginning of the current document's body. + const externalDocBodyText = externalDocBody.text; + const currentDocBody: Word.Body = context.document.body; + currentDocBody.insertText(externalDocBodyText, Word.InsertLocation.start); + await context.sync(); }); -'Excel.ChartTrendlineCollection#add:member(1)': +Word.Application#retrieveStylesFromBase64:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-trendlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/get-external-styles.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let seriesCollection = sheet.charts.getItemAt(0).series; + // Gets style info from another document passed in as a Base64-encoded + string. - // Add a trendline. - seriesCollection.getItemAt(0).trendlines.add("Linear"); + await Word.run(async (context) => { + const retrievedStyles = context.application.retrieveStylesFromBase64(externalDocument); + await context.sync(); - await context.sync(); + console.log("Styles from the other document:", retrievedStyles.value); }); -'Excel.ChartTrendlineFormat#line:member': +Word.Body#clear:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-trendlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let seriesCollection = sheet.charts.getItemAt(0).series; + // Clears out the content from the document body. - // Get the color of the chart trendline. - let trendline = seriesCollection.getItemAt(0).trendlines.getItem(0); - let line = trendline.format.line; - line.load("color"); + // Run a batch operation against the Word object model. - await context.sync(); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to clear the contents of the body. + body.clear(); - console.log("The trendline color is:" + line.color); + console.log("Cleared the body contents."); }); + + + // The Silly stories add-in sample shows how the clear method can be used to + clear the contents of a document. + + // https://aka.ms/sillystorywordaddin +Word.Body#getComments:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/10-chart/chart-trendlines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - let seriesCollection = sheet.charts.getItemAt(0).series; - let trendline = seriesCollection.getItemAt(0).trendlines.getItem(0); + // Gets the comments in the document body. - // Set format of the trendline to a solid, red line. - let line = trendline.format.line; - line.color = '#FF0000'; + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.body.getComments(); - await context.sync(); + // Load objects to log in the console. + comments.load(); + await context.sync(); - console.log("The trendline color has been set to:" + line.color); + console.log("All comments:", comments); }); -'Excel.ColorScaleConditionalFormat#criteria:member': +Word.Body#getHtml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.colorScale); - const criteria = { - minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, - midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, - maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } - }; - conditionalFormat.colorScale.criteria = criteria; - await context.sync(); - }); -'Excel.Comment#content:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-basics.yaml + // Gets the HTML that represents the content of the body. - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Comments"); - const comment = sheet.comments.getItemAt(0); - comment.content = "PLEASE add headers here."; - await context.sync(); - }); -'Excel.Comment#delete:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-basics.yaml + // Run a batch operation against the Word object model. - await Excel.run(async (context) => { - context.workbook.comments.getItemByCell("Comments!A2").delete(); - await context.sync(); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to get the HTML contents of the body. + const bodyHTML = body.getHtml(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Body contents (HTML): " + bodyHTML.value); }); -'Excel.Comment#load:member(2)': +Word.Body#getOoxml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const comment = context.workbook.comments.getItemByCell("Comments!A2"); - comment.load(["authorEmail", "authorName", "creationDate"]); - await context.sync(); - console.log(`${comment.creationDate.toDateString()}: ${comment.authorName} (${comment.authorEmail})`); - await context.sync(); + // Gets the OOXML that represents the content of the body. + + // Run a batch operation against the Word object model. + + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to get the OOXML contents of the body. + const bodyOOXML = body.getOoxml(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Body contents (OOXML): " + bodyOOXML.value); }); -'Excel.Comment#resolved:member': +Word.Body#getTrackedChanges:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-resolution.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Comments"); - sheet.comments.getItemAt(0).resolved = true; - await context.sync(); + + // Gets all tracked changes. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.load(); + await context.sync(); + + console.log(trackedChanges); }); -'Excel.CommentCollection#add:member(1)': +Word.Body#insertBreak:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Comments"); - // Note that an InvalidArgument error will be thrown if multiple cells passed to `comment.add`. - sheet.comments.add("A2", "TODO: add data."); - await context.sync(); + // Inserts a page break at the beginning of the document. + + // Run a batch operation against the Word object model. + + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert a page break at the start of the document body. + body.insertBreak(Word.BreakType.page, Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added a page break at the start of the document body."); }); -'Excel.CommentCollection#onAdded:member': +Word.Body#insertContentControl:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const comments = context.workbook.worksheets.getActiveWorksheet().comments; - // Register the onAdded, onChanged, and onDeleted comment event handlers. - comments.onAdded.add(commentAdded); - comments.onChanged.add(commentChanged); - comments.onDeleted.add(commentDeleted); + // Creates a content control using the document body. - await context.sync(); + // Run a batch operation against the Word object model. - console.log("Added event handlers for when comments are added, changed, or deleted."); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to wrap the body in a content control. + body.insertContentControl(); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Wrapped the body in a content control."); }); +Word.Body#insertFileFromBase64:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - async function commentAdded(event: Excel.CommentAddedEventArgs) { - await Excel.run(async (context) => { - // Retrieve the added comment using the comment ID. - // Note: This method assumes only a single comment is added at a time. - const addedComment = context.workbook.comments.getItem(event.commentDetails[0].commentId); - // Load the added comment's data. - addedComment.load(["content", "authorName", "creationDate"]); + // Inserts the body from the external document at the beginning of this + document. - await context.sync(); + // Run a batch operation against the Word object model. - // Print out the added comment's data. - console.log(`A comment was added:`); - console.log(` ID: ${event.commentDetails[0].commentId}`); - console.log(` Comment content:${addedComment.content}`); - console.log(` Comment author:${addedComment.authorName}`); - console.log(` Creation date:${addedComment.creationDate}`); - }); - } -'Excel.CommentCollection#onChanged:member': + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert the Base64-encoded string representation of the body of the selected .docx file at the beginning of the current document. + body.insertFileFromBase64(externalDocument, Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added Base64-encoded text to the beginning of the document body."); + }); +Word.Body#insertHtml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const comments = context.workbook.worksheets.getActiveWorksheet().comments; - // Register the onAdded, onChanged, and onDeleted comment event handlers. - comments.onAdded.add(commentAdded); - comments.onChanged.add(commentChanged); - comments.onDeleted.add(commentDeleted); + // Inserts the HTML at the beginning of this document. - await context.sync(); + // Run a batch operation against the Word object model. - console.log("Added event handlers for when comments are added, changed, or deleted."); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert HTML at the beginning of the document. + body.insertHtml("This is text inserted with body.insertHtml()", Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("HTML added to the beginning of the document body."); }); +Word.Body#insertInlinePictureFromBase64:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - async function commentChanged(event: Excel.CommentChangedEventArgs) { - await Excel.run(async (context) => { - // Retrieve the changed comment using the comment ID. - // Note: This method assumes only a single comment is changed at a time. - const changedComment = context.workbook.comments.getItem(event.commentDetails[0].commentId); - // Load the changed comment's data. - changedComment.load(["content", "authorName", "creationDate"]); + // Inserts an image inline at the beginning of this document. - await context.sync(); + // Run a batch operation against the Word object model. - // Print out the changed comment's data. - console.log(`A comment was changed:`); - console.log(` ID: ${event.commentDetails[0].commentId}`); - console.log(` Updated comment content: ${changedComment.content}`); - console.log(` Comment author: ${changedComment.authorName}`); - console.log(` Creation date: ${changedComment.creationDate}`); - }); - } -'Excel.CommentCollection#onDeleted:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; - await Excel.run(async (context) => { - const comments = context.workbook.worksheets.getActiveWorksheet().comments; + // Base64-encoded image to insert inline. + const base64EncodedImg = + "iVBORw0KGgoAAAANSUhEUgAAAB4AAAANCAIAAAAxEEnAAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACFSURBVDhPtY1BEoQwDMP6/0+XgIMTBAeYoTqso9Rkx1zG+tNj1H94jgGzeNSjteO5vtQQuG2seO0av8LzGbe3anzRoJ4ybm/VeKEerAEbAUpW4aWQCmrGFWykRzGBCnYy2ha3oAIq2MloW9yCCqhgJ6NtcQsqoIKdjLbFLaiACnYyf2fODbrjZcXfr2F4AAAAAElFTkSuQmCC"; - // Register the onAdded, onChanged, and onDeleted comment event handlers. - comments.onAdded.add(commentAdded); - comments.onChanged.add(commentChanged); - comments.onDeleted.add(commentDeleted); + // Queue a command to insert a Base64-encoded image at the beginning of the current document. + body.insertInlinePictureFromBase64(base64EncodedImg, Word.InsertLocation.start); - await context.sync(); + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); - console.log("Added event handlers for when comments are added, changed, or deleted."); + console.log("Added a Base64-encoded image to the beginning of the document body."); }); +Word.Body#insertOoxml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-comment-event-handler.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - async function commentDeleted(event: Excel.CommentDeletedEventArgs) { - await Excel.run(async (context) => { - // Print out the deleted comment's ID. - // Note: This method assumes only a single comment is deleted at a time. - console.log(`A comment was deleted:`); - console.log(` ID: ${event.commentDetails[0].commentId}`); - }); - } -'Excel.CommentReply#content:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-replies.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Comments"); - const comment = sheet.comments.getItemAt(0); - const reply = comment.replies.getItemAt(0); - reply.load("content"); - // Sync to load the content of the comment reply. - await context.sync(); + // Inserts OOXML at the beginning of this document. - // Append "Please!" to the end of the comment reply. - reply.content += " Please!"; - await context.sync(); - }); -'Excel.CommentReply#delete:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-replies.yaml + // Run a batch operation against the Word object model. - await Excel.run(async (context) => { - // Remove the first comment reply from this worksheet's first comment. - const sheet = context.workbook.worksheets.getItem("Comments"); - const comment = sheet.comments.getItemAt(0); - comment.replies.getItemAt(0).delete(); - await context.sync(); - }); -'Excel.CommentReplyCollection#add:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-replies.yaml + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; - await Excel.run(async (context) => { - // Adds a reply to the first comment in this worksheet. - const sheet = context.workbook.worksheets.getItem("Comments"); - const comment = sheet.comments.getItemAt(0); - comment.replies.add("Add content to this worksheet."); - await context.sync(); + // Queue a command to insert OOXML at the beginning of the body. + body.insertOoxml( + "This text has formatting directly applied to achieve its font size, color, line spacing, and paragraph spacing.", + Word.InsertLocation.start + ); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Added OOXML to the beginning of the document body."); }); -'Excel.CommentRichContent#mentions:member': + + + // Read "Understand when and how to use Office Open XML in your Word add-in" + for guidance on working with OOXML. + + // + https://learn.microsoft.com/office/dev/add-ins/word/create-better-add-ins-for-word-with-office-open-xml + + + // The Word-Add-in-DocumentAssembly sample shows how you can use this API to + assemble a document. + + // https://github.com/OfficeDev/Word-Add-in-DocumentAssembly +Word.Body#insertParagraph:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/12-comment/comment-mentions.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-formatted-text.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Comments"); - const mention = { - email: "kakri@contoso.com", - id: 0, - name: "Kate Kristensen" - }; - // This will tag the mention's name using the '@' syntax. - // They will be notified via email. - const commentBody = { - mentions: [mention], - richContent: '' + mention.name + " - Can you take a look?" - }; + await Word.run(async (context) => { + // Second sentence, let's insert it as a paragraph after the previously inserted one. + const secondSentence: Word.Paragraph = context.document.body.insertParagraph( + "This is the first text with a custom style.", + "End" + ); + secondSentence.font.set({ + bold: false, + italic: true, + name: "Berlin Sans FB", + color: "blue", + size: 30 + }); - // Note that an InvalidArgument error will be thrown if multiple cells passed to `comment.add`. - sheet.comments.add("A1", commentBody, Excel.ContentType.mention); - await context.sync(); + await context.sync(); }); -'Excel.ConditionalCellValueRule#formula1:member': +Word.Body#insertTable:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B21:E23"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.cellValue); - conditionalFormat.cellValue.format.font.color = "red"; - conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; - await context.sync(); + await Word.run(async (context) => { + // Use a two-dimensional array to hold the initial table values. + const data = [ + ["Tokyo", "Beijing", "Seattle"], + ["Apple", "Orange", "Pineapple"] + ]; + const table: Word.Table = context.document.body.insertTable(2, 3, "Start", data); + table.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2; + table.styleFirstColumn = false; + + await context.sync(); }); -'Excel.ConditionalCellValueRule#operator:member': +Word.Body#insertText:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B21:E23"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.cellValue); - conditionalFormat.cellValue.format.font.color = "red"; - conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; - await context.sync(); + // Inserts text at the beginning of this document. + + // Run a batch operation against the Word object model. + + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to insert text at the beginning of the current document. + body.insertText('This is text inserted with body.insertText()', Word.InsertLocation.start); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + console.log("Text added to the beginning of the document body."); }); -'Excel.ConditionalFormat#cellValue:member': +Word.Body#search:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/search.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B21:E23"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.cellValue); - conditionalFormat.cellValue.format.font.color = "red"; - conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" }; - await context.sync(); + // Does a basic text search and highlights matches in the document. + + await Word.run(async (context) => { + const results : Word.RangeCollection = context.document.body.search("extend"); + results.load("length"); + + await context.sync(); + + // Let's traverse the search results and highlight matches. + for (let i = 0; i < results.items.length; i++) { + results.items[i].font.highlightColor = "yellow"; + } + + await context.sync(); }); -'Excel.ConditionalFormat#colorScale:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/search.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.colorScale); - const criteria = { - minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, - midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, - maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } - }; - conditionalFormat.colorScale.criteria = criteria; - await context.sync(); + // Does a wildcard search and highlights matches in the document. + + await Word.run(async (context) => { + // Construct a wildcard expression and set matchWildcards to true in order to use wildcards. + const results : Word.RangeCollection = context.document.body.search("$*.[0-9][0-9]", { matchWildcards: true }); + results.load("length"); + + await context.sync(); + + // Let's traverse the search results and highlight matches. + for (let i = 0; i < results.items.length; i++) { + results.items[i].font.highlightColor = "red"; + results.items[i].font.color = "white"; + } + + await context.sync(); }); -'Excel.ConditionalFormat#custom:member': +Word.Body#select:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); - conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; - conditionalFormat.custom.format.font.color = "green"; - await context.sync(); + // Selects the entire body. + + // Run a batch operation against the Word object model. + + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + + // Queue a command to select the document body. + // The Word UI will move to the selected document body. + body.select(); + + console.log("Selected the document body."); }); -'Excel.ConditionalFormat#dataBar:member': +Word.Body#fields:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.dataBar); - conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight; + // Gets all fields in the document body. + + await Word.run(async (context) => { + const fields: Word.FieldCollection = context.document.body.fields.load("items"); + + await context.sync(); + + if (fields.items.length === 0) { + console.log("No fields in this document."); + } else { + fields.load(["code", "result"]); await context.sync(); + + for (let i = 0; i < fields.items.length; i++) { + console.log(`Field ${i + 1}'s code: ${fields.items[i].code}`, `Field ${i + 1}'s result: ${JSON.stringify(fields.items[i].result)}`); + } + } }); -'Excel.ConditionalFormat#getRange:member(1)': +Word.Body#font:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const worksheetRange = sheet.getRange(); - worksheetRange.conditionalFormats.load("type"); - await context.sync(); + // Gets the style and the font size, font name, and font color properties on + the body object. - let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; - worksheetRange.conditionalFormats.items.forEach(item => { - cfRangePairs.push({ - cf: item, - range: item.getRange().load("address") - }); - }); + // Run a batch operation against the Word object model. - await context.sync(); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; - if (cfRangePairs.length > 0) { - cfRangePairs.forEach(item => { - console.log(item.cf.type); - }); - } else { - console.log("No conditional formats applied."); - } + // Queue a command to load font and style information for the document body. + body.load("font/size, font/name, font/color, style"); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. + await context.sync(); + + // Show font-related property values on the body object. + const results = + "Font size: " + + body.font.size + + "; Font name: " + + body.font.name + + "; Font color: " + + body.font.color + + "; Body style: " + + body.style; + + console.log(results); }); -'Excel.ConditionalFormat#iconSet:member': +Word.Body#footnotes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + // Gets the footnotes in the document body. - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", - } - ]; + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("length"); + await context.sync(); - await context.sync(); + console.log("Number of footnotes in the document body: " + footnotes.items.length); }); -'Excel.ConditionalFormat#preset:member': +Word.Body#inlinePictures:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.presetCriteria); - conditionalFormat.preset.format.font.color = "white"; - conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; - await context.sync(); + // Gets the first image in the document. + + await Word.run(async (context) => { + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); + + await context.sync(); + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. + const base64 = firstPicture.getBase64ImageSrc(); + + await context.sync(); + console.log(base64.value); }); -'Excel.ConditionalFormat#textComparison:member': +Word.Body#lists:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B16:D18"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.containsText); - conditionalFormat.textComparison.format.font.color = "red"; - conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; - await context.sync(); + // Gets information about the first list in the document. + + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); + + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; + } + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); + + await context.sync(); + + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); + } }); -'Excel.ConditionalFormat#type:member': +Word.Body#onCommentAdded:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const worksheetRange = sheet.getRange(); - worksheetRange.conditionalFormats.load("type"); - await context.sync(); + // Registers event handlers. - let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; - worksheetRange.conditionalFormats.items.forEach(item => { - cfRangePairs.push({ - cf: item, - range: item.getRange().load("address") - }); - }); + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); - await context.sync(); + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); - if (cfRangePairs.length > 0) { - cfRangePairs.forEach(item => { - console.log(item.cf.type); - }); - } else { - console.log("No conditional formats applied."); - } + console.log("Event handlers registered."); }); -'Excel.ConditionalFormatCollection#add:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.colorScale); - const criteria = { - minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" }, - midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" }, - maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" } - }; - conditionalFormat.colorScale.criteria = criteria; - await context.sync(); - }); -'Excel.ConditionalFormatCollection#clearAll:member(1)': + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.Body#onCommentChanged:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange(); - range.conditionalFormats.clearAll(); - await context.sync(); + // Registers event handlers. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); - $(".conditional-formats").hide(); + console.log("Event handlers registered."); }); -'Excel.ConditionalFormatCollection#getItemAt:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const worksheetRange = sheet.getRange(); - worksheetRange.conditionalFormats.load("type"); - await context.sync(); + async function onChangedHandler(event: Word.CommentEventArgs) { + await Word.run(async (context) => { + console.log( + `${event.type} event detected. ${event.changeType} change made. Event source: ${event.source}. Comment info:`, event.commentDetails + ); + }); + } +Word.Body#onCommentDeleted:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = []; - worksheetRange.conditionalFormats.items.forEach(item => { - cfRangePairs.push({ - cf: item, - range: item.getRange().load("address") - }); - }); - await context.sync(); + // Registers event handlers. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); - if (cfRangePairs.length > 0) { - cfRangePairs.forEach(item => { - console.log(item.cf.type); - }); - } else { - console.log("No conditional formats applied."); - } + console.log("Event handlers registered."); }); -'Excel.ConditionalFormatRule#formula:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); - conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; - conditionalFormat.custom.format.font.color = "green"; - await context.sync(); - }); -'Excel.ConditionalIconCriterion#formula:member': + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.Body#onCommentDeselected:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + // Registers event handlers. - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", - } - ]; + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); - await context.sync(); + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.ConditionalIconCriterion#operator:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.Body#onCommentSelected:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", - } - ]; - await context.sync(); + // Registers event handlers. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); }); - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B16:D18"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.containsText); - conditionalFormat.textComparison.format.font.color = "red"; - conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; - await context.sync(); - }); -'Excel.ConditionalIconCriterion#type:member': + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.Body#paragraphs:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-word-count.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + // Counts how many times each term appears in the document. - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("text"); + await context.sync(); + + // Split up the document text using existing spaces as the delimiter. + let text = []; + paragraphs.items.forEach((item) => { + let paragraph = item.text.trim(); + if (paragraph) { + paragraph.split(" ").forEach((term) => { + let currentTerm = term.trim(); + if (currentTerm) { + text.push(currentTerm); } - ]; + }); + } + }); - await context.sync(); + // Determine the list of unique terms. + let makeTextDistinct = new Set(text); + let distinctText = Array.from(makeTextDistinct); + let allSearchResults = []; + + for (let i = 0; i < distinctText.length; i++) { + let results = context.document.body.search(distinctText[i], { matchCase: true, matchWholeWord: true }); + results.load("text"); + + // Map each search term with its results. + let correlatedResults = { + searchTerm: distinctText[i], + hits: results + }; + + allSearchResults.push(correlatedResults); + } + + await context.sync(); + + // Display the count for each search term. + allSearchResults.forEach((result) => { + let length = result.hits.items.length; + + console.log("Search term: " + result.searchTerm + " => Count: " + length); + }); }); -'Excel.ConditionalPresetCriteriaRule#criterion:member': +Word.Body#shapes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.presetCriteria); - conditionalFormat.preset.format.font.color = "white"; - conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; - await context.sync(); + await Word.run(async (context) => { + // Gets text boxes in the main document. + const shapes: Word.ShapeCollection = context.document.body.shapes; + shapes.load(); + await context.sync(); + + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the main document: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the main document has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the main document doesn't have a text box.`); + } + }); + } else { + console.log("No shapes found in the main document."); + } }); -'Excel.ConditionalTextComparisonRule#text:member': +Word.Body#tables:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B16:D18"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.containsText); - conditionalFormat.textComparison.format.font.color = "red"; - conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; - await context.sync(); + // Gets the content of the first cell in the first table. + + await Word.run(async (context) => { + const firstCell: Word.Body = context.document.body.tables.getFirst().getCell(0, 0).body; + firstCell.load("text"); + + await context.sync(); + console.log("First cell's text is: " + firstCell.text); }); -'Excel.CultureInfo#datetimeFormat:member': +Word.Body#text:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/culture-info-date-time.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml - await Excel.run(async (context) => { - context.application.cultureInfo.datetimeFormat.load([ - "longDatePattern", - "shortDatePattern", - "dateSeparator", - "longTimePattern", - "timeSeparator" - ]); - await context.sync(); - // Use the cultural settings API to retrieve the user's system date and time settings. - const systemLongDatePattern = context.application.cultureInfo.datetimeFormat.longDatePattern; - const systemShortDatePattern = context.application.cultureInfo.datetimeFormat.shortDatePattern; - const systemDateSeparator = context.application.cultureInfo.datetimeFormat.dateSeparator; - const systemLongTimePattern = context.application.cultureInfo.datetimeFormat.longTimePattern; - const systemTimeSeparator = context.application.cultureInfo.datetimeFormat.timeSeparator; + // Gets the text content of the body. - // Write the date and time settings in your table. - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const dateTimeData = sheet.getRange("A2:B6"); - dateTimeData.values = [ - ["Long date", systemLongDatePattern], - ["Short date", systemShortDatePattern], - ["Date separator", systemDateSeparator], - ["Long time format", systemLongTimePattern], - ["Time separator", systemTimeSeparator] - ]; + // Run a batch operation against the Word object model. - sheet.tables - .getItemAt(0) - .getRange() - .format.autofitColumns(); + await Word.run(async (context) => { + // Create a proxy object for the document body. + const body: Word.Body = context.document.body; + // Queue a command to load the text in document body. + body.load("text"); + + // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion. await context.sync(); + + console.log("Body contents (text): " + body.text); }); -'Excel.CustomConditionalFormat#format:member': +Word.Body#type:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); - conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; - conditionalFormat.custom.format.font.color = "green"; - await context.sync(); - }); -'Excel.CustomPropertyCollection#add:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/26-document/custom-properties.yaml + // Gets the referenced note's item type and body type, which are both + "Footnote". - await Excel.run(async (context) => { - // Get the key/value pair from the task pane. - const userKey = $("#key").text(); - const userValue = $("#value").text(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); - // Add the custom property. - const customDocProperties = context.workbook.properties.custom; - customDocProperties.add(userKey, userValue); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + console.log(`Note type of footnote ${referenceNumber}: ${item.type}`); + item.body.load("type"); await context.sync(); - console.log(`Successfully set custom document property ${userKey}:${userValue}.`); + console.log(`Body type of note: ${item.body.type}`); }); -'Excel.CustomXmlPart#delete:member(1)': +Word.BodyType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); - await context.sync(); - if (xmlPartIDSetting.value) { - let customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); - const xmlBlob = customXmlPart.getXml(); - customXmlPart.delete(); - customXmlPart = context.workbook.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + // Gets the referenced note's item type and body type, which are both + "Footnote". - await context.sync(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); - if (customXmlPart.isNullObject) { - $("#display-xml").text(`The XML part with the id ${xmlPartIDSetting.value} has been deleted.`); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + console.log(`Note type of footnote ${referenceNumber}: ${item.type}`); - // Delete the unneeded setting too. - xmlPartIDSetting.delete(); - } else { - const readableXml = addLineBreaksToXML(xmlBlob.value); - const strangeMessage = `This is strange. The XML part with the id ${xmlPartIDSetting.value} has not been deleted:\n${readableXml}` - $("#display-xml").text(strangeMessage); - } + item.body.load("type"); + await context.sync(); - await context.sync(); - } + console.log(`Body type of note: ${item.body.type}`); }); -'Excel.CustomXmlPart#getXml:member(1)': +Word.Border:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - // You must have the xmlns attribute to populate the - // CustomXml.namespaceUri property. - const originalXml = "JuanHongSally"; - const customXmlPart = context.workbook.customXmlParts.add(originalXml); - customXmlPart.load("id"); - const xmlBlob = customXmlPart.getXml(); - await context.sync(); + // Updates border properties (e.g., type, width, color) of the specified + style. - const readableXml = addLineBreaksToXML(xmlBlob.value); - $("#display-xml").text(readableXml); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - // Store the XML part's ID in a setting. - const settings = context.workbook.settings; - settings.add("ContosoReviewXmlPartId", customXmlPart.id); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPart#id:member': +Word.BorderCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - // You must have the xmlns attribute to populate the - // CustomXml.namespaceUri property. - const originalXml = "JuanHongSally"; - const customXmlPart = context.workbook.customXmlParts.add(originalXml); - customXmlPart.load("id"); - const xmlBlob = customXmlPart.getXml(); - await context.sync(); + // Updates border properties (e.g., type, width, color) of the specified + style. - const readableXml = addLineBreaksToXML(xmlBlob.value); - $("#display-xml").text(readableXml); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - // Store the XML part's ID in a setting. - const settings = context.workbook.settings; - settings.add("ContosoReviewXmlPartId", customXmlPart.id); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPart#setXml:member(1)': +Word.BorderCollection#outsideBorderColor:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); - await context.sync(); - if (xmlPartIDSetting.value) { - const customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + // Updates border properties (e.g., type, width, color) of the specified + style. - // The setXml method does a whole-for-whole replacement - // of the entire XML. - customXmlPart.setXml("JohnHitomi"); - const xmlBlob = customXmlPart.getXml(); - await context.sync(); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - const readableXml = addLineBreaksToXML(xmlBlob.value); - $("#display-xml").text(readableXml); - await context.sync(); - } + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); + await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPartCollection#add:member(1)': +Word.BorderCollection#outsideBorderType:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - // You must have the xmlns attribute to populate the - // CustomXml.namespaceUri property. - const originalXml = "JuanHongSally"; - const customXmlPart = context.workbook.customXmlParts.add(originalXml); - customXmlPart.load("id"); - const xmlBlob = customXmlPart.getXml(); - await context.sync(); + // Updates border properties (e.g., type, width, color) of the specified + style. - const readableXml = addLineBreaksToXML(xmlBlob.value); - $("#display-xml").text(readableXml); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - // Store the XML part's ID in a setting. - const settings = context.workbook.settings; - settings.add("ContosoReviewXmlPartId", customXmlPart.id); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPartCollection#getItem:member(1)': +Word.BorderCollection#outsideBorderWidth:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); - await context.sync(); - if (xmlPartIDSetting.value) { - const customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); + // Updates border properties (e.g., type, width, color) of the specified + style. - // The setXml method does a whole-for-whole replacement - // of the entire XML. - customXmlPart.setXml("JohnHitomi"); - const xmlBlob = customXmlPart.getXml(); - await context.sync(); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - const readableXml = addLineBreaksToXML(xmlBlob.value); - $("#display-xml").text(readableXml); - await context.sync(); - } + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); + await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPartCollection#getByNamespace:member(1)': +Word.BorderLocation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Excel.run(async (context) => { - $("#display-xml").text(""); - const contosoNamespace = "http://schemas.contoso.com/review/1.0"; - const customXmlParts = context.workbook.customXmlParts; - const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); - const numberOfPartsInNamespace = filteredXmlParts.getCount(); - await context.sync(); + // Gets border details about the first table in the document. - if (numberOfPartsInNamespace.value == 1) { - const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); - const xmlBlob = onlyXmlPartInNamespace.getXml(); + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); - await context.sync(); + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); +Word.BorderType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - // Make it a bit more readable. - const readableXml = xmlBlob.value.replace(/>\n<"); - $("#display-xml").text(`The only XML part in the namespace ${contosoNamespace} is: - ${readableXml}`); + // Gets border details about the first of the first table in the document. - } else { - console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); - } + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstCell: Word.TableCell = firstTable.getCell(0, 0); + const borderLocation = "Left"; + const border: Word.TableBorder = firstCell.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); - await context.sync(); + console.log(`Details about the ${borderLocation} border of the first table's first cell:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); }); -'Excel.CustomXmlPartScopedCollection#getItemOrNullObject:member(1)': +Word.BorderWidth:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - const xmlPartIDSetting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); - await context.sync(); - if (xmlPartIDSetting.value) { - let customXmlPart = context.workbook.customXmlParts.getItem(xmlPartIDSetting.value); - const xmlBlob = customXmlPart.getXml(); - customXmlPart.delete(); - customXmlPart = context.workbook.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); + // Updates border properties (e.g., type, width, color) of the specified + style. - await context.sync(); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); + return; + } - if (customXmlPart.isNullObject) { - $("#display-xml").text(`The XML part with the id ${xmlPartIDSetting.value} has been deleted.`); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); - // Delete the unneeded setting too. - xmlPartIDSetting.delete(); - } else { - const readableXml = addLineBreaksToXML(xmlBlob.value); - const strangeMessage = `This is strange. The XML part with the id ${xmlPartIDSetting.value} has not been deleted:\n${readableXml}` - $("#display-xml").text(strangeMessage); - } + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const borders: Word.BorderCollection = style.borders; + borders.load("items"); + await context.sync(); - await context.sync(); - } + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); + } }); -'Excel.CustomXmlPartScopedCollection#getCount:member(1)': +Word.BreakType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml - - await Excel.run(async (context) => { - $("#display-xml").text(""); - const contosoNamespace = "http://schemas.contoso.com/review/1.0"; - const customXmlParts = context.workbook.customXmlParts; - const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); - const numberOfPartsInNamespace = filteredXmlParts.getCount(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-line-and-page-breaks.yaml - await context.sync(); - if (numberOfPartsInNamespace.value == 1) { - const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); - const xmlBlob = onlyXmlPartInNamespace.getXml(); + await Word.run(async (context) => { + context.document.body.paragraphs.getFirst().insertBreak(Word.BreakType.page, "After"); - await context.sync(); + await context.sync(); + console.log("success"); + }); +Word.BuiltInStyleName:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-formatted-text.yaml - // Make it a bit more readable. - const readableXml = xmlBlob.value.replace(/>\n<"); - $("#display-xml").text(`The only XML part in the namespace ${contosoNamespace} is: - ${readableXml}`); + await Word.run(async (context) => { + const sentence: Word.Paragraph = context.document.body.insertParagraph( + "To be or not to be", + "End" + ); - } else { - console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); - } + // Use styleBuiltIn to use an enumeration of existing styles. If your style is custom make sure to use: range.style = "name of your style"; + sentence.styleBuiltIn = Word.BuiltInStyleName.intenseReference; - await context.sync(); + await context.sync(); }); -'Excel.CustomXmlPartScopedCollection#getOnlyItem:member(1)': +Word.Canvas:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml - - await Excel.run(async (context) => { - $("#display-xml").text(""); - const contosoNamespace = "http://schemas.contoso.com/review/1.0"; - const customXmlParts = context.workbook.customXmlParts; - const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace); - const numberOfPartsInNamespace = filteredXmlParts.getCount(); - - await context.sync(); - - if (numberOfPartsInNamespace.value == 1) { - const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem(); - const xmlBlob = onlyXmlPartInNamespace.getXml(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-canvases.yaml - await context.sync(); - // Make it a bit more readable. - const readableXml = xmlBlob.value.replace(/>\n<"); + await Word.run(async (context) => { + // Inserts a canvas in the document. + const canvasShape: Word.Shape = context.document.getSelection().insertCanvas(); + canvasShape.load(); + await context.sync(); - $("#display-xml").text(`The only XML part in the namespace ${contosoNamespace} is: - ${readableXml}`); + canvasShape.select(); + console.log("Inserted canvas:", canvasShape); - } else { - console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`); - } + const canvas: Word.Canvas = canvasShape.canvas; + canvas.load("shape,shapes"); + await context.sync(); - await context.sync(); + console.log("Canvas object:", canvas); }); -'Excel.DataBarConditionalFormat#barDirection:member': +Word.Canvas#shapes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-canvases.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.dataBar); - conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight; - await context.sync(); + await Word.run(async (context) => { + // Gets the first canvas found in the document body. + const canvasShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.canvas]) + .getFirstOrNullObject(); + canvasShape.load(); + canvasShape.load("canvas/shapes"); + await context.sync(); + + if (canvasShape.isNullObject) { + console.log("No canvases found in the document body."); + return; + } + + console.log("First canvas found in the document body:", canvasShape); + console.log("Shapes associated with the first canvas:", canvasShape.canvas.shapes); + canvasShape.select(); }); -'Excel.DataPivotHierarchy#showAs:member': +Word.CellPaddingLocation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-calculations.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm"); - const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale"); - farmDataHierarchy.load("showAs"); - wholesaleDataHierarchy.load("showAs"); - await context.sync(); + // Gets cell padding details about the first table in the document. - // show the crates of each fruit type sold at the farm as a percentage of the column's total - let farmShowAs = farmDataHierarchy.showAs; - farmShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; - farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); - farmDataHierarchy.showAs = farmShowAs; + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const cellPaddingLocation = Word.CellPaddingLocation.right; + const cellPadding = firstTable.getCellPadding(cellPaddingLocation); + await context.sync(); - let wholesaleShowAs = wholesaleDataHierarchy.showAs; - wholesaleShowAs.calculation = Excel.ShowAsCalculation.percentOfColumnTotal; - wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Type").fields.getItem("Type"); - wholesaleDataHierarchy.showAs = wholesaleShowAs; - await context.sync(); + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table: ${cellPadding.value} points` + ); }); -'Excel.DataPivotHierarchy#name:member': +Word.ChangeTrackingMode:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml - await Excel.run(async (context) => { - const dataHierarchies = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales").dataHierarchies - dataHierarchies.load("no-properties-needed"); - await context.sync(); - dataHierarchies.items[0].name = "Farm Sales"; - dataHierarchies.items[1].name = "Wholesale"; - await context.sync(); + // Gets the current change tracking mode. + + await Word.run(async (context) => { + const document: Word.Document = context.document; + document.load("changeTrackingMode"); + await context.sync(); + + if (document.changeTrackingMode === Word.ChangeTrackingMode.trackMineOnly) { + console.log("Only my changes are being tracked."); + } else if (document.changeTrackingMode === Word.ChangeTrackingMode.trackAll) { + console.log("Everyone's changes are being tracked."); + } else { + console.log("No changes are being tracked."); + } }); -'Excel.DataValidation#prompt:member': +Word.ChangeTrackingState:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/22-data-validation/data-validation.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Decision"); - const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); - - // When you are developing, it is a good practice to - // clear the dataValidation object with each run of your code. - rankingRange.dataValidation.clear(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/get-change-tracking-states.yaml - let greaterThanZeroRule = { - wholeNumber: { - formula1: 0, - operator: Excel.DataValidationOperator.greaterThan - } - }; - rankingRange.dataValidation.rule = greaterThanZeroRule; - rankingRange.dataValidation.prompt = { - message: "Please enter a positive number.", - showPrompt: true, - title: "Positive numbers only." - }; + // Logs the current change tracking states of the content controls. - rankingRange.dataValidation.errorAlert = { - message: "Sorry, only positive numbers are allowed", - showAlert: true, - style: "Stop", - title: "Negative Number Entered" - }; + await Word.run(async (context) => { + let trackAddedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.added]; + let trackDeletedArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.deleted]; + let trackNormalArray: Word.ChangeTrackingState[] = [Word.ChangeTrackingState.normal]; + + let addedContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackAddedArray); + let deletedContentControls = context.document.body + .getContentControls() + .getByChangeTrackingStates(trackDeletedArray); + let normalContentControls = context.document.body.getContentControls().getByChangeTrackingStates(trackNormalArray); + + addedContentControls.load(); + deletedContentControls.load(); + normalContentControls.load(); + await context.sync(); - await context.sync(); + console.log(`Number of content controls in Added state: ${addedContentControls.items.length}`); + console.log(`Number of content controls in Deleted state: ${deletedContentControls.items.length}`); + console.log(`Number of content controls in Normal state: ${normalContentControls.items.length}`); }); -'Excel.DataValidation#rule:member': +Word.ChangeTrackingVersion:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/22-data-validation/data-validation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Decision"); - const nameRange = - sheet.tables.getItem("NameOptionsTable").columns.getItem("Baby Name").getDataBodyRange(); - // When you are developing, it is a good practice to - // clear the dataValidation object with each run of your code. - nameRange.dataValidation.clear(); + // Gets the reviewed text. - const nameSourceRange = context.workbook.worksheets.getItem("Names").getRange("A1:A3"); + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection(); + const before = range.getReviewedText(Word.ChangeTrackingVersion.original); + const after = range.getReviewedText(Word.ChangeTrackingVersion.current); - let approvedListRule = { - list: { - inCellDropDown: true, - source: nameSourceRange - } - }; - nameRange.dataValidation.rule = approvedListRule; + await context.sync(); - await context.sync(); + console.log("Reviewed text (before):", before.value, "Reviewed text (after):", after.value); }); -'Excel.DataValidation#errorAlert:member': +Word.CheckboxContentControl:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/22-data-validation/data-validation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Decision"); - const commentsRange = - sheet.tables.getItem("NameOptionsTable").columns.getItem("Comments").getDataBodyRange(); - // When you are developing, it is a good practice to - // clear the dataValidation object with each run of your code. - commentsRange.dataValidation.clear(); + // Toggles the isChecked property on all checkbox content controls. - // If the value of A2 is contained in the value of C2, then - // SEARCH(A2,C2) returns the number where it begins. Otherwise, - // it does not return a number. - let redundantStringRule = { - custom: { - formula: "=NOT(ISNUMBER(SEARCH(A2,C2)))" - } - }; - commentsRange.dataValidation.rule = redundantStringRule; - commentsRange.dataValidation.errorAlert = { - message: "It is redundant to include the baby name in the comment.", - showAlert: true, - style: "Information", - title: "Baby Name in Comment" - }; + await Word.run(async (context) => { + let contentControls = context.document.getContentControls({ + types: [Word.ContentControlType.checkBox] + }); + contentControls.load("items"); - await context.sync(); - }); -'Excel.DataValidationRule#list:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/22-data-validation/data-validation.yaml + await context.sync(); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Decision"); - const nameRange = - sheet.tables.getItem("NameOptionsTable").columns.getItem("Baby Name").getDataBodyRange(); + const length = contentControls.items.length; + console.log(`Number of checkbox content controls: ${length}`); - // When you are developing, it is a good practice to - // clear the dataValidation object with each run of your code. - nameRange.dataValidation.clear(); + if (length <= 0) { + return; + } - const nameSourceRange = context.workbook.worksheets.getItem("Names").getRange("A1:A3"); + const checkboxContentControls = []; + for (let i = 0; i < length; i++) { + let contentControl = contentControls.items[i]; + contentControl.load("id,checkboxContentControl/isChecked"); + checkboxContentControls.push(contentControl); + } - let approvedListRule = { - list: { - inCellDropDown: true, - source: nameSourceRange - } - }; - nameRange.dataValidation.rule = approvedListRule; + await context.sync(); - await context.sync(); + console.log("isChecked state before:"); + const updatedCheckboxContentControls = []; + for (let i = 0; i < checkboxContentControls.length; i++) { + const currentCheckboxContentControl = checkboxContentControls[i]; + const isCheckedBefore = currentCheckboxContentControl.checkboxContentControl.isChecked; + console.log(`id: ${currentCheckboxContentControl.id} ... isChecked: ${isCheckedBefore}`); + + currentCheckboxContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + currentCheckboxContentControl.load("id,checkboxContentControl/isChecked"); + updatedCheckboxContentControls.push(currentCheckboxContentControl); + } + + await context.sync(); + + console.log("isChecked state after:"); + for (let i = 0; i < updatedCheckboxContentControls.length; i++) { + const currentCheckboxContentControl = updatedCheckboxContentControls[i]; + console.log( + `id: ${currentCheckboxContentControl.id} ... isChecked: ${currentCheckboxContentControl.checkboxContentControl.isChecked}` + ); + } }); -'Excel.DataValidationRule#wholeNumber:member': +Word.CloseBehavior:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/22-data-validation/data-validation.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Decision"); - const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange(); - // When you are developing, it is a good practice to - // clear the dataValidation object with each run of your code. - rankingRange.dataValidation.clear(); + // Closes the document after saving. - let greaterThanZeroRule = { - wholeNumber: { - formula1: 0, - operator: Excel.DataValidationOperator.greaterThan - } - }; - rankingRange.dataValidation.rule = greaterThanZeroRule; + await Word.run(async (context) => { + context.document.close(Word.CloseBehavior.save); + }); +Word.ComboBoxContentControl:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - rankingRange.dataValidation.prompt = { - message: "Please enter a positive number.", - showPrompt: true, - title: "Positive numbers only." - }; - rankingRange.dataValidation.errorAlert = { - message: "Sorry, only positive numbers are allowed", - showAlert: true, - style: "Stop", - title: "Negative Number Entered" - }; + // Places a combo box content control at the end of the selection. - await context.sync(); + await Word.run(async (context) => { + let selection = context.document.getSelection(); + selection.getRange(Word.RangeLocation.end).insertContentControl(Word.ContentControlType.comboBox); + await context.sync(); + + console.log("Combo box content control inserted at the end of the selection."); }); -'Excel.DocumentProperties#custom:member': +Word.ComboBoxContentControl#addListItem:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/26-document/custom-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - // Load the keys and values of all custom properties. - const customDocProperties = context.workbook.properties.custom; - customDocProperties.load(["key", "value"]); + + // Adds the provided list item to the first combo box content control in the + selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-add") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); await context.sync(); - // Log each custom property to the console. - // Note that your document may have more properties than those you have set using this snippet. - customDocProperties.items.forEach((property) => { - console.log(`${property.key}:${property.value}`); - }); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + selectedContentControl.comboBoxContentControl.addListItem(listItemText); + await context.sync(); + + console.log(`List item added to control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.IconSetConditionalFormat#criteria:member': +Word.ComboBoxContentControl#deleteAllListItems:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + // Deletes the list items from first combo box content control found in the + selection. - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", - } - ]; + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + console.log(`About to delete the list from the combo box content control with ID ${selectedContentControl.id}`); + selectedContentControl.comboBoxContentControl.deleteAllListItems(); + await context.sync(); + + console.log("Deleted the list from the combo box content control."); }); -'Excel.IconSetConditionalFormat#style:member': +Word.ComboBoxContentControl#listItems:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.iconSet); - const iconSetCF = conditionalFormat.iconSet; - iconSetCF.style = Excel.IconSet.threeTriangles; - /* - The iconSetCF.criteria array is automatically prepopulated with - criterion elements whose properties have been given default settings. - You can't write to each property of a criterion directly. Instead, - replace the whole criteria object. + // Deletes the provided list item from the first combo box content control + in the selection. - With a "three*" icon set style, such as "threeTriangles", the third - element in the criteria array (criteria[2]) defines the "top" icon; - e.g., a green triangle. The second (criteria[1]) defines the "middle" - icon, The first (criteria[0]) defines the "low" icon, but it - can often be left empty as this method does below, because every - cell that does not match the other two criteria always gets the low - icon. - */ - iconSetCF.criteria = [ - {} as any, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=700" - }, - { - type: Excel.ConditionalFormatIconRuleType.number, - operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual, - formula: "=1000", - } - ]; + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + let selectedComboBox: Word.ComboBoxContentControl = selectedContentControl.comboBoxContentControl; + selectedComboBox.listItems.load("items/*"); + await context.sync(); - await context.sync(); - }); -'Excel.Image#format:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-images.yaml + let listItems: Word.ContentControlListItemCollection = selectedContentControl.comboBoxContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`); + return; + } - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const image = sheet.shapes.getItem("Image").image; - image.load("format"); - await context.sync(); + itemToDelete.delete(); + await context.sync(); - console.log("The image's format is: " + image.format); - await context.sync(); + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.Line#connectBeginShape:member(1)': +Word.Comment:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.getItem("StraightLine").line; - line.connectBeginShape(shapes.getItem("Left"), 2); - line.connectEndShape(shapes.getItem("Right"), 0); - await context.sync(); - }); -'Excel.Line#connectEndShape:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.getItem("StraightLine").line; - line.connectBeginShape(shapes.getItem("Left"), 2); - line.connectEndShape(shapes.getItem("Right"), 0); - await context.sync(); + // Sets a comment on the selected content. + + await Word.run(async (context) => { + const text = (document.getElementById("comment-text") as HTMLInputElement).value; + const comment: Word.Comment = context.document.getSelection().insertComment(text); + + // Load object to log in the console. + comment.load(); + await context.sync(); + + console.log("Comment inserted:", comment); }); -'Excel.Line#disconnectBeginShape:member(1)': +Word.Comment#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.getItem("StraightLine").line; - line.disconnectBeginShape(); - line.disconnectEndShape(); - await context.sync(); + + // Deletes the first comment in the selected content. + + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.delete(); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to delete."); + return; + } + + console.log("Comment deleted."); }); -'Excel.Line#disconnectEndShape:member(1)': +Word.Comment#getRange:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.getItem("StraightLine").line; - line.disconnectBeginShape(); - line.disconnectEndShape(); - await context.sync(); + + // Gets the range of the first comment in the selected content. + + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); }); -'Excel.NamedItem#delete:member(1)': +Word.Comment#reply:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/34-named-item/create-and-remove-named-item.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const totalName = sheet.names.getItemOrNullObject("TotalAmount"); - totalName.load(); - await context.sync(); - if (totalName.value) { - totalName.delete(); + // Replies to the first active comment in the selected content. - // Replace the named item (TotalAmount) with the actual formula for TotalAmount to avoid displaying #NAME in the cell. - sheet.getRange("D11").values = [["=SUM(ExpensesTable[AMOUNT])"]]; - } else { - console.log("No named item created for the formula."); - } + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); - await context.sync(); + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } }); -'Excel.NamedItem#formula:member': +Word.Comment#content:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/34-named-item/update-named-item.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Get the named item - const myNamedItem = sheet.names.getItemOrNullObject("MyRange"); - myNamedItem.load("name, formula"); - await context.sync(); + // Edits the first active comment in the selected content. - if (myNamedItem.isNullObject) { - console.log(`There is no named item. Create it with "Add named item for a range" first.`); - } else { - // Update named item to point to the second range - myNamedItem.formula = "=Sample!$B$10:$D$14"; - sheet.getRange("B10:D14").select(); - await context.sync(); + await Word.run(async (context) => { + const text = (document.getElementById("edit-comment-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); - console.log(`Just updated the named item "${myNamedItem.name}" -- it's now located here: ${myNamedItem.formula}`); - } + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (!firstActiveComment) { + console.warn("No active comment was found in the selection, so couldn't edit."); + return; + } + + firstActiveComment.content = text; + + // Load object to log in the console. + firstActiveComment.load(); + await context.sync(); + + console.log("Comment content changed:", firstActiveComment); }); -'Excel.NamedItemCollection#add:member(1)': +Word.Comment#contentRange:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/34-named-item/create-and-remove-named-item.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const headerRange = sheet.getRange("A1:D1"); - sheet.names.add("ExpensesHeader", headerRange); - const namedItems = sheet.names.load("name, type"); + // Gets the range of the first comment in the selected content. - await context.sync(); + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); }); -'Excel.NumberFormatInfo#numberDecimalSeparator:member': +Word.Comment#replies:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/culture-info.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - // This will convert a number like "14,37" to "14.37" - // (assuming the system decimal separator is "."). - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); + // Gets the replies to the first comment in the selected content. - const decimalSource = sheet.getRange("B2"); + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("replies"); + await context.sync(); - decimalSource.load("values"); + if (comment.isNullObject) { + console.warn("No comments in the selection, so no replies to get."); + return; + } - context.application.cultureInfo.numberFormat.load("numberDecimalSeparator"); + const replies: Word.CommentReplyCollection = comment.replies; + console.log("Replies to the first comment:", replies); + }); +Word.Comment#resolved:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await context.sync(); + // Toggles Resolved status of the first comment in the selected content. - const systemDecimalSeparator = - context.application.cultureInfo.numberFormat.numberDecimalSeparator; + await Word.run(async (context) => { + const comment: Word.Comment = context.document + .getSelection() + .getComments() + .getFirstOrNullObject(); + comment.load("resolved"); + await context.sync(); - const oldDecimalString: string = decimalSource.values[0][0]; + if (comment.isNullObject) { + console.warn("No comments in the selection, so nothing to toggle."); + return; + } + // Toggle resolved status. + // If the comment is active, set as resolved. + // If it's resolved, set resolved to false. + const resolvedBefore = comment.resolved; + console.log(`Comment Resolved status (before): ${resolvedBefore}`); + comment.resolved = !resolvedBefore; + comment.load("resolved"); + await context.sync(); - // This assumes the input column is standardized to use "," as the decimal - separator. + console.log(`Comment Resolved status (after): ${comment.resolved}`); + }); +Word.CommentChangeType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - const newDecimalString = oldDecimalString.replace(",", - systemDecimalSeparator); + // Registers event handlers. - const resultRange = sheet.getRange("C2"); + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); - resultRange.values = [[newDecimalString]]; + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); - resultRange.format.autofitColumns(); + console.log("Event handlers registered."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await context.sync(); + + async function onChangedHandler(event: Word.CommentEventArgs) { + await Word.run(async (context) => { + console.log( + `${event.type} event detected. ${event.changeType} change made. Event source: ${event.source}. Comment info:`, event.commentDetails + ); }); -'Excel.NumberFormatInfo#numberGroupSeparator:member': + } +Word.CommentCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/culture-info.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - // This will convert a number like "123-456-789" to "123,456,789" - // (assuming the system thousands separator is ","). - const sheet = context.workbook.worksheets.getItem("Sample"); - const bigNumberSource = sheet.getRange("B3"); - bigNumberSource.load("values"); - context.application.cultureInfo.numberFormat.load("numberGroupSeparator"); - await context.sync(); - const systemThousandsSeparator = context.application.cultureInfo.numberFormat.numberGroupSeparator; - const oldBigNumberString: string = bigNumberSource.values[0][0]; - - // This assumes the input column is standardized to use "-" as the number group separator. - const newBigNumberString = oldBigNumberString.replace(/-/g, systemThousandsSeparator); + // Replies to the first active comment in the selected content. - const resultRange = sheet.getRange("C3"); - resultRange.values = [[newBigNumberString]]; - resultRange.format.autofitColumns(); + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } }); -'Excel.PageBreakCollection#add:member(1)': +Word.CommentCollection#getFirstOrNullObject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.horizontalPageBreaks.add("A21:E21"); - await context.sync(); + + // Gets the range of the first comment in the selected content. + + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); }); -'Excel.PageLayout#centerHorizontally:member': +Word.CommentCollection#items:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.centerHorizontally = true; - farmSheet.pageLayout.centerVertically = true; - await context.sync(); + + // Replies to the first active comment in the selected content. + + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); + await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } }); -'Excel.PageLayout#centerVertically:member': +Word.CommentContentRange:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.centerHorizontally = true; - farmSheet.pageLayout.centerVertically = true; - await context.sync(); + + // Gets the range of the first comment in the selected content. + + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); + + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } + + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); }); -'Excel.PageLayout#orientation:member': +Word.CommentDetail:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.orientation = Excel.PageOrientation.landscape; - await context.sync(); + + // Registers event handlers. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.PageLayout#setPrintArea:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.setPrintArea("A1:D41"); - await context.sync(); - }); -'Excel.PageLayout#setPrintTitleRows:member(1)': + + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.CommentEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.setPrintTitleRows("$1:$1"); - await context.sync(); + + // Registers event handlers. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); + + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.PageLayout#zoom:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-page-layout.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - const farmSheet = context.workbook.worksheets.getItem("Print"); - farmSheet.pageLayout.zoom = { scale: 200 }; - await context.sync(); - }); -'Excel.PivotField#clearAllFilters:member(1)': + + async function onChangedHandler(event: Word.CommentEventArgs) { + await Word.run(async (context) => { + console.log( + `${event.type} event detected. ${event.changeType} change made. Event source: ${event.source}. Comment info:`, event.commentDetails + ); + }); + } +Word.CommentReply:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - // Clear all the PivotFilters. - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - pivotTable.hierarchies.load("name"); - await context.sync(); + // Replies to the first active comment in the selected content. - // Clear the filters on each PivotField. - pivotTable.hierarchies.items.forEach((hierarchy) => { - hierarchy.fields.getItem(hierarchy.name).clearAllFilters(); - }); + await Word.run(async (context) => { + const text = (document.getElementById("reply-text") as HTMLInputElement).value; + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + comments.load("items"); await context.sync(); + + const firstActiveComment: Word.Comment = comments.items.find((item) => item.resolved !== true); + if (firstActiveComment) { + const reply: Word.CommentReply = firstActiveComment.reply(text); + console.log("Reply added."); + } else { + console.warn("No active comment was found in the selection, so couldn't reply."); + } }); -'Excel.PivotFilters#dateFilter:member': +Word.CommentReplyCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - await Excel.run(async (context) => { - // Add a date-based PivotFilter. - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + // Gets the replies to the first comment in the selected content. - // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. - // If it's not already there, add "Date Updated" to the hierarchies. - let dateHierarchy = pivotTable.rowHierarchies.getItemOrNullObject("Date Updated"); + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("replies"); await context.sync(); - if (dateHierarchy.isNullObject) { - dateHierarchy = pivotTable.rowHierarchies.add(pivotTable.hierarchies.getItem("Date Updated")); - } - // Apply a date filter to filter out anything logged before August. - const filterField = dateHierarchy.fields.getItem("Date Updated"); - const dateFilter = { - condition: Excel.DateFilterCondition.afterOrEqualTo, - comparator: { - date: "2020-08-01", - specificity: Excel.FilterDatetimeSpecificity.month - } - }; - filterField.applyFilter({ dateFilter: dateFilter }); + if (comment.isNullObject) { + console.warn("No comments in the selection, so no replies to get."); + return; + } - await context.sync(); + const replies: Word.CommentReplyCollection = comment.replies; + console.log("Replies to the first comment:", replies); }); -'Excel.PivotFilters#labelFilter:member': +Word.CompareTarget:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/compare-documents.yaml - await Excel.run(async (context) => { - // Add a PivotFilter to filter based on the strings of item labels. - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + // Compares the current document with a specified external document. - // Get the "Type" field. - const field = pivotTable.hierarchies.getItem("Type").fields.getItem("Type"); + await Word.run(async (context) => { + // Absolute path of an online or local document. + const filePath = (document.getElementById("filePath") as HTMLInputElement).value; + // Options that configure the compare operation. + const options: Word.DocumentCompareOptions = { + compareTarget: Word.CompareTarget.compareTargetCurrent, + detectFormatChanges: false + // Other options you choose... + }; + context.document.compare(filePath, options); - // Filter out any types that start with "L" ("Lemons" and "Limes" in this case). - const filter: Excel.PivotLabelFilter = { - condition: Excel.LabelFilterCondition.beginsWith, - substring: "L", - exclusive: true - }; + await context.sync(); - // Apply the label filter to the field. - field.applyFilter({ labelFilter: filter }); + console.log("Differences shown in the current document."); + }); +Word.ContentControl#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml + + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("forTesting"); + contentControls.load("items"); await context.sync(); + + if (contentControls.items.length === 0) { + console.log("There are no content controls in this document."); + } else { + console.log("Control to be deleted:", contentControls.items[0]); + contentControls.items[0].delete(false); + await context.sync(); + } }); -'Excel.PivotFilters#manualFilter:member': +Word.ContentControl#resetState:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml - await Excel.run(async (context) => { - // Add a PivotFilter to filter on manually-selected items. - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + // Resets the state of the first content control. - // PivotFilters can only be applied to PivotHierarchies that are being used for pivoting. - // If it's not already there, add "Classification" to the hierarchies. - let classHierarchy = pivotTable.filterHierarchies.getItemOrNullObject("Classification"); + await Word.run(async (context) => { + let firstContentControl = context.document.contentControls.getFirstOrNullObject(); await context.sync(); - if (classHierarchy.isNullObject) { - classHierarchy = pivotTable.filterHierarchies.add(pivotTable.hierarchies.getItem("Classification")); - } - // Apply a manual filter to include only a specific PivotItem (the string "Organic"). - const filterField = classHierarchy.fields.getItem("Classification"); - const manualFilter = { selectedItems: ["Organic"]}; - filterField.applyFilter({ manualFilter: manualFilter }); + if (firstContentControl.isNullObject) { + console.warn("There are no content controls in this document."); + return; + } + firstContentControl.resetState(); + firstContentControl.load("id"); await context.sync(); + + console.log(`Reset state of first content control with ID: ${firstContentControl.id}`); }); -'Excel.PivotFilters#valueFilter:member': +Word.ContentControl#set:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml - await Excel.run(async (context) => { - // Add a PivotFilter to filter on the values correlated with a row. - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + // Adds title and colors to odd and even content controls and changes their + appearance. - // Get the "Farm" field. - const field = pivotTable.hierarchies.getItem("Farm").fields.getItem("Farm"); + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + let evenContentControls = context.document.contentControls.getByTag("even"); + let oddContentControls = context.document.contentControls.getByTag("odd"); + evenContentControls.load("length"); + oddContentControls.load("length"); - // Filter to only include rows with more than 500 wholesale crates sold. - const filter: Excel.PivotValueFilter = { - condition: Excel.ValueFilterCondition.greaterThan, - comparator: 500, - value: "Sum of Crates Sold Wholesale" - }; + await context.sync(); - // Apply the value filter to the field. - field.applyFilter({ valueFilter: filter }); + for (let i = 0; i < evenContentControls.items.length; i++) { + // Change a few properties and append a paragraph. + evenContentControls.items[i].set({ + color: "red", + title: "Odd ContentControl #" + (i + 1), + appearance: Word.ContentControlAppearance.tags + }); + evenContentControls.items[i].insertParagraph("This is an odd content control", "End"); + } + + for (let j = 0; j < oddContentControls.items.length; j++) { + // Change a few properties and append a paragraph. + oddContentControls.items[j].set({ + color: "green", + title: "Even ContentControl #" + (j + 1), + appearance: "Tags" + }); + oddContentControls.items[j].insertHtml("This is an even content control", "End"); + } await context.sync(); }); -'Excel.PivotHierarchy#fields:member': +Word.ContentControl#setState:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-pivotfilters.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml - await Excel.run(async (context) => { - // Add a PivotFilter to filter on the values correlated with a row. - - // Get the PivotTable. - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - // Get the "Farm" field. - const field = pivotTable.hierarchies.getItem("Farm").fields.getItem("Farm"); + // Sets the state of the first content control. - // Filter to only include rows with more than 500 wholesale crates sold. - const filter: Excel.PivotValueFilter = { - condition: Excel.ValueFilterCondition.greaterThan, - comparator: 500, - value: "Sum of Crates Sold Wholesale" - }; + await Word.run(async (context) => { + const state = ((document.getElementById("state-to-set") as HTMLSelectElement) + .value as unknown) as Word.ContentControlState; + let firstContentControl = context.document.contentControls.getFirstOrNullObject(); + await context.sync(); - // Apply the value filter to the field. - field.applyFilter({ valueFilter: filter }); + if (firstContentControl.isNullObject) { + console.warn("There are no content controls in this document."); + return; + } + firstContentControl.setState(state); + firstContentControl.load("id"); await context.sync(); + + console.log(`Set state of first content control with ID ${firstContentControl.id} to ${state}.`); }); -'Excel.PivotLayout#getDataBodyRange:member(1)': +Word.ContentControl#checkboxContentControl:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - // the layout controls the ranges used by the PivotTable - const range = pivotTable.layout.getDataBodyRange(); + // Toggles the isChecked property of the first checkbox content control + found in the selection. - // get all the data hierarchy totals - const grandTotalRange = range.getLastRow(); - grandTotalRange.load("address"); - await context.sync(); - - // use the wholesale and farm sale totals to make a final sum - const masterTotalRange = context.workbook.worksheets.getActiveWorksheet().getRange("B27:C27"); - masterTotalRange.formulas = [["All Crates", "=SUM(" + grandTotalRange.address + ")"]]; - await context.sync(); - }); -'Excel.PivotTable#columnHierarchies:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,checkboxContentControl/isChecked"); - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); + await context.sync(); - // check if the PivotTable already has a column - const column = pivotTable.columnHierarchies.getItemOrNullObject("Farm"); - column.load("id"); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,checkboxContentControl/isChecked"); await context.sync(); - if (column.isNullObject) { - // ading the farm column to the column hierarchy automatically removes it from the row hierarchy - pivotTable.columnHierarchies.add(pivotTable.hierarchies.getItem("Farm")); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; } else { - pivotTable.columnHierarchies.remove(column); + selectedContentControl = parentContentControl; } + } - await context.sync(); + const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked; + console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`); + selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + selectedContentControl.load("id,checkboxContentControl/isChecked"); + await context.sync(); + + console.log( + "isChecked state after:", + `id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}` + ); }); -'Excel.PivotTable#dataHierarchies:member': +Word.ContentControl#comboBoxContentControl:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold at Farm")); - pivotTable.dataHierarchies.add(pivotTable.hierarchies.getItem("Crates Sold Wholesale")); + // Adds the provided list item to the first combo box content control in the + selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-add") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + selectedContentControl.comboBoxContentControl.addListItem(listItemText); + await context.sync(); + + console.log(`List item added to control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.PivotTable#delete:member(1)': +Word.ContentControl#dropDownListContentControl:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - await Excel.run(async (context) => { - context.workbook.worksheets.getItem("Pivot").pivotTables.getItem("Farm Sales").delete(); + // Adds the provided list item to the first dropdown list content control in + the selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-add") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + selectedContentControl.dropDownListContentControl.addListItem(listItemText); + await context.sync(); + + console.log(`List item added to control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.PivotTable#layout:member': +Word.ContentControl#onDataChanged:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - pivotTable.layout.load("layoutType"); - await context.sync(); - // cycle between the three layout types - if (pivotTable.layout.layoutType === "Compact") { - pivotTable.layout.layoutType = "Outline"; - } else if (pivotTable.layout.layoutType === "Outline") { - pivotTable.layout.layoutType = "Tabular"; - } else { - pivotTable.layout.layoutType = "Compact"; + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onDataChanged event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDataChanged.add(contentControlDataChanged); + contentControls.items[i].track(); } + await context.sync(); - console.log("Pivot layout is now " + pivotTable.layout.layoutType); + + console.log("Added event handlers for when data is changed in content controls."); + } }); -'Excel.PivotTable#filterHierarchies:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml - async function filter(functionType: Excel.AggregationFunction) { - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - const filters = pivotTable.filterHierarchies; - const filter = filters.getItemOrNullObject("Classification"); - filter.load(); - await context.sync(); - // add the Classification hierarchy to the filter, if it's not already there - if (filter.isNullObject) { - filters.add(pivotTable.hierarchies.getItem("Classification")); - await context.sync(); - } - }); + async function contentControlDataChanged(event: + Word.ContentControlDataChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where data was changed:`, event.ids); + }); } -'Excel.PivotTableCollection#add:member(1)': +Word.ContentControl#onDeleted:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-create-and-modify.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml - await Excel.run(async (context) => { - const rangeToAnalyze = context.workbook.worksheets.getItem("Data").getRange("A1:E21"); - const rangeToPlacePivot = context.workbook.worksheets.getItem("Pivot").getRange("A2"); - context.workbook.worksheets.getItem("Pivot").pivotTables.add("Farm Sales", rangeToAnalyze, rangeToPlacePivot); - await context.sync(); - }); -'Excel.PresetCriteriaConditionalFormat#rule:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:M5"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.presetCriteria); - conditionalFormat.preset.format.font.color = "white"; - conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage }; + // Register the onDeleted event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDeleted.add(contentControlDeleted); + contentControls.items[i].track(); + } await context.sync(); + + console.log("Added event handlers for when content controls are deleted."); + } }); - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B8:E13"); - const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom); - conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)'; - conditionalFormat.custom.format.font.color = "green"; - await context.sync(); - }); -'Excel.Range#getDirectPrecedents:member(1)': + async function contentControlDeleted(event: + Word.ContentControlDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were deleted:`, event.ids); + }); + } +Word.ContentControl#onEntered:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/direct-precedents.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml - await Excel.run(async (context) => { - // Precedents are cells referenced by the formula in a cell. - let range = context.workbook.getActiveCell(); - let directPrecedents = range.getDirectPrecedents(); - range.load("address"); - directPrecedents.areas.load("address"); + + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); await context.sync(); - console.log(`Direct precedent cells of ${range.address}:`); + // Register the onEntered event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onEntered.add(contentControlEntered); + contentControls.items[i].track(); + } - // Use the direct precedents API to loop through precedents of the active cell. - for (var i = 0; i < directPrecedents.areas.items.length; i++) { - // Highlight and console the address of each precedent cell. - directPrecedents.areas.items[i].format.fill.color = "Yellow"; - console.log(` ${directPrecedents.areas.items[i].address}`); + await context.sync(); + + console.log("Added event handlers for when the cursor is placed in content controls."); } - await context.sync(); }); -'Excel.Range#sort:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/event-column-and-row-sort.yaml - - async function sortTopToBottom(criteria: string) { - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const range = sheet.getRange("A1:E5"); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml - // Find the column header that provides the sort criteria. - const header = range.find(criteria, {}); - header.load("columnIndex"); - await context.sync(); - range.sort.apply( - [ - { - key: header.columnIndex, - sortOn: Excel.SortOn.value - } - ], - false /*matchCase*/, - true /*hasHeaders*/, - Excel.SortOrientation.rows - ); - await context.sync(); - }); + async function contentControlEntered(event: + Word.ContentControlEnteredEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was entered: ${event.ids[0]}`); + }); } -'Excel.Range#group:member(1)': +Word.ContentControl#onExited:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/outline.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml - Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - - // Group the larger, main level. Note that the outline controls - // will be on row 10, meaning 4-9 will collapse and expand. - sheet.getRange("4:9").group(Excel.GroupOption.byRows); - // Group the smaller, sublevels. Note that the outline controls - // will be on rows 6 and 9, meaning 4-5 and 7-8 will collapse and expand. - sheet.getRange("4:5").group(Excel.GroupOption.byRows); - sheet.getRange("7:8").group(Excel.GroupOption.byRows); - await context.sync(); - }); -'Excel.Range#ungroup:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/outline.yaml + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onExited event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onExited.add(contentControlExited); + contentControls.items[i].track(); + } - Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - - // This removes two levels of groups from the "A1-R10" range. - // Any groups at the same level on the same dimension will be removed by a single call. - sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byRows); - sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byRows); - sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byColumns); - sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byColumns); await context.sync(); + + console.log("Added event handlers for when the cursor is removed from within content controls."); + } }); -'Excel.Range#getPivotTables:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-get-pivottables.yaml - - await Excel.run(async (context) => { - const activeRange = context.workbook.getSelectedRange(); - - // Get all the PivotTables that intersect with this range. - const partiallyContainedPivotTables = activeRange.getPivotTables(); - // Get all the PivotTables that are completely contained within this range. - const fullyContainedPivotTables = activeRange.getPivotTables(true); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml - partiallyContainedPivotTables.load("name"); - fullyContainedPivotTables.load("name"); - await context.sync(); - // Display the names in the console. - console.log("PivotTables in the current range:") - partiallyContainedPivotTables.items.forEach((pivotTable) => { - console.log(`\t${pivotTable.name}`); - }); - console.log("PivotTables completely contained in the current range:") - fullyContainedPivotTables.items.forEach((pivotTable) => { - console.log(`\t${pivotTable.name}`); + async function contentControlExited(event: + Word.ContentControlExitedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was exited: ${event.ids[0]}`); }); - }); -'Excel.Range#getSpecialCells:member(1)': + } +Word.ContentControl#onSelectionChanged:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-areas.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const usedRange = sheet.getUsedRange(); + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - // Find the ranges with either text or logical (boolean) values. - const formulaRanges = usedRange.getSpecialCells("Constants", "LogicalText"); - formulaRanges.format.fill.color = "orange"; + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onSelectionChanged.add(contentControlSelectionChanged); + contentControls.items[i].track(); + } - return context.sync(); + await context.sync(); + + console.log("Added event handlers for when selections are changed in content controls."); + } }); -'Excel.Range#autoFill:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-auto-fill.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const sumCell = sheet.getRange("P4"); - - // Copy everything. The formulas will be contextually updated based on their new locations. - sumCell.autoFill("P4:P7", Excel.AutoFillType.fillCopy); - sumCell.format.autofitColumns(); - await context.sync(); - }); -'Excel.Range#setCellProperties:member(1)': + + async function contentControlSelectionChanged(event: + Word.ContentControlSelectionChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where selection was changed:`, event.ids); + }); + } +Word.ContentControl#tag:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - // Creating the SettableCellProperties objects to use for the range. - // In your add-in, these should be created once, outside the function. - const topHeaderProps: Excel.SettableCellProperties = { - // The style property takes a string matching the name of an Excel style. - // Built-in style names are listed in the `BuiltInStyle` enum. - // Note that a style will overwrite any formatting, - // so do not use the format property with the style property. - style: "Heading1" - }; + // Traverses each paragraph of the document and wraps a content control on + each with either a even or odd tags. - const headerProps: Excel.SettableCellProperties = { - // Any subproperties of format that are not set will not be changed when these cell properties are set. - format: { - fill: { - color: "Blue" - }, - font: { - color: "White", - bold: true - } - } - }; + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. - const nonApplicableProps: Excel.SettableCellProperties = { - format: { - fill: { - pattern: Excel.FillPattern.gray25 - }, - font: { - color: "Gray", - italic: true - } - } - }; + await context.sync(); - const matchupScoreProps: Excel.SettableCellProperties = { - format: { - borders: { - bottom: { - style: Excel.BorderLineStyle.continuous - }, - left: { - style: Excel.BorderLineStyle.continuous - }, - right: { - style: Excel.BorderLineStyle.continuous - }, - top: { - style: Excel.BorderLineStyle.continuous - } - } - } - }; + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + // For even, tag "even". + if (i % 2 === 0) { + contentControl.tag = "even"; + } else { + contentControl.tag = "odd"; + } + } + console.log("Content controls inserted: " + paragraphs.items.length); - const range = sheet.getRange("A1:E5"); + await context.sync(); + }); +Word.ContentControlAddedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml - // You can use empty JSON objects to avoid changing a cell's properties. - range.setCellProperties([ - [topHeaderProps, {}, {}, {}, {}], - [{}, {}, headerProps, headerProps, headerProps], - [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], - [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], - [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] - ]); - sheet.getUsedRange().format.autofitColumns(); - await context.sync(); + // Registers the onAdded event handler on the document. + + await Word.run(async (context) => { + eventContext = context.document.onContentControlAdded.add(contentControlAdded); + await context.sync(); + + console.log("Added event handler for when content controls are added."); }); -'Excel.Range#getCellProperties:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml - await Excel.run(async (context) => { - const cell = context.workbook.getActiveCell(); - // Define the cell properties to get by setting the matching LoadOptions to true. - const propertiesToGet = cell.getCellProperties({ - address: true, - format: { - fill: { - color: true - }, - font: { - color: true - } - }, - style: true + async function contentControlAdded(event: Word.ContentControlAddedEventArgs) + { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were added:`, event.ids); + }); + } +Word.ContentControlAppearance:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml + + + // Adds title and colors to odd and even content controls and changes their + appearance. + + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + let evenContentControls = context.document.contentControls.getByTag("even"); + let oddContentControls = context.document.contentControls.getByTag("odd"); + evenContentControls.load("length"); + oddContentControls.load("length"); + + await context.sync(); + + for (let i = 0; i < evenContentControls.items.length; i++) { + // Change a few properties and append a paragraph. + evenContentControls.items[i].set({ + color: "red", + title: "Odd ContentControl #" + (i + 1), + appearance: Word.ContentControlAppearance.tags + }); + evenContentControls.items[i].insertParagraph("This is an odd content control", "End"); + } + + for (let j = 0; j < oddContentControls.items.length; j++) { + // Change a few properties and append a paragraph. + oddContentControls.items[j].set({ + color: "green", + title: "Even ContentControl #" + (j + 1), + appearance: "Tags" }); + oddContentControls.items[j].insertHtml("This is an even content control", "End"); + } - // Sync to get the data from the workbook. - await context.sync(); - const cellProperties = propertiesToGet.value[0][0]; - console.log( - `Address: ${cellProperties.address}\nStyle: ${cellProperties.style}\nFill Color: ${cellProperties.format.fill.color}\nFont Color: ${cellProperties.format.font.color}`); + await context.sync(); }); -'Excel.Range#copyFrom:member(1)': +Word.ContentControlCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-copyfrom.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Place a label in front of the copied data. - sheet.getRange("F2").values = [["Copied Formula"]]; - // Copy a range preserving the formulas. - // Note: non-formula values are copied over as is. - sheet.getRange("G2").copyFrom("A1:E1", Excel.RangeCopyType.formulas); + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("customer"); + contentControls.load("text"); + await context.sync(); - }); -'Excel.Range#moveTo:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-copyfrom.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Place a label in front of the moved data. - sheet.getRange("F12").values = [["Moved Range:"]]; + for (let i = 0; i < contentControls.items.length; i++) { + contentControls.items[i].insertText("Fabrikam", "Replace"); + } - // Move the range from A1:E1 to G12:K12. - sheet.getRange("A1:E1").moveTo("G12"); await context.sync(); }); -'Excel.Range#getSpillingToRange:member(1)': +Word.ContentControlCollection#getByTag:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/dynamic-arrays.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Set G4 to a formula that returns a dynamic array. - const targetCell = sheet.getRange("G4"); - targetCell.formulas = [["=A4:D4"]]; + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("customer"); + contentControls.load("text"); - // Get the address of the cells that the dynamic array spilled into. - const spillRange = targetCell.getSpillingToRange(); - spillRange.load("address"); + await context.sync(); - // Fit the columns for readability. - sheet.getUsedRange().format.autofitColumns(); - await context.sync(); + for (let i = 0; i < contentControls.items.length; i++) { + contentControls.items[i].insertText("Fabrikam", "Replace"); + } - console.log(`Copying the table headers spilled into ${spillRange.address}.`); + await context.sync(); }); -'Excel.Range#find:member(1)': +Word.ContentControlCollection#getFirstOrNullObject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-find.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const table = sheet.tables.getItem("ExpensesTable"); - const searchRange = table.getRange(); - // NOTE: If no match is found, an ItemNotFound error - // is thrown when Range.find is evaluated. - const foundRange = searchRange.find($("#searchText").text(), { - completeMatch: isCompleteMatchToggle, - matchCase: isMatchCaseToggle, - searchDirection: searchDirectionToggle - }); - - foundRange.load("address"); + // Toggles the isChecked property of the first checkbox content control + found in the selection. + + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,checkboxContentControl/isChecked"); + + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,checkboxContentControl/isChecked"); await context.sync(); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked; + console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`); + selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + selectedContentControl.load("id,checkboxContentControl/isChecked"); + await context.sync(); - console.log(foundRange.address); + console.log( + "isChecked state after:", + `id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}` + ); }); -'Excel.Range#findOrNullObject:member(1)': +Word.ContentControlDataChangedEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-find.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const table = sheet.tables.getItem("ExpensesTable"); - const searchRange = table.getRange(); - const foundRange = searchRange.findOrNullObject($("#searchText").text(), { - completeMatch: isCompleteMatchToggle, - matchCase: isMatchCaseToggle, - searchDirection: searchDirectionToggle - }); - - foundRange.load("address"); - await context.sync(); - if (foundRange.isNullObject) { - console.log("Text not found"); - } else { - console.log(foundRange.address); + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); + + // Register the onDataChanged event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDataChanged.add(contentControlDataChanged); + contentControls.items[i].track(); } + + await context.sync(); + + console.log("Added event handlers for when data is changed in content controls."); + } }); -'Excel.Range#hyperlink:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-hyperlink.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Orders"); - let productsRange = sheet.getRange("A3:A5"); - productsRange.load("values"); + async function contentControlDataChanged(event: + Word.ContentControlDataChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where data was changed:`, event.ids); + }); + } +Word.ContentControlDeletedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml - await context.sync(); - // Create a hyperlink to a URL - // for each product name in the first table. - for (let i = 0; i < productsRange.values.length; i++) { - let cellRange = productsRange.getCell(i, 0); - let cellText = productsRange.values[i][0]; + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - let hyperlink = { - textToDisplay: cellText, - screenTip: "Search Bing for '" + cellText + "'", - address: "https://www.bing.com/?q=" + cellText - } - cellRange.hyperlink = hyperlink; + // Register the onDeleted event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onDeleted.add(contentControlDeleted); + contentControls.items[i].track(); } await context.sync(); + + console.log("Added event handlers for when content controls are deleted."); + } }); -'Excel.Range#getIntersectionOrNullObject:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-relationships.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - // We want the most recent quarter that has data, so - // exclude quarters without data and get the last of - // the remaining columns. - const usedDataRange = dataRange.getUsedRange(true /* valuesOnly */); - const currentQuarterRange = usedDataRange.getLastColumn(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml - // Asian and European teams have separate contests. - const asianSalesRange = sheet.getRange("A2:E4"); - const europeanSalesRange = sheet.getRange("A5:E7"); - // The data for each chart is the intersection of the - // current quarter column and the rows for the continent. - const asianContestRange = asianSalesRange.getIntersectionOrNullObject(currentQuarterRange); - const europeanContestRange = europeanSalesRange.getIntersectionOrNullObject(currentQuarterRange); + async function contentControlDeleted(event: + Word.ContentControlDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were deleted:`, event.ids); + }); + } +Word.ContentControlEnteredEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml - // Must sync before you can test the output of *OrNullObject - // method/property. - await context.sync(); - if (asianContestRange.isNullObject) { - // See the declaration of this method for how to - // test this code path. - reportMissingData("Asian"); - } else { - createContinentChart( - sheet, - "Asian", - asianContestRange, - "A9", - "F24" - ); - } + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - if (europeanContestRange.isNullObject) { - // See the declaration of this method for how to - // test this code path. - reportMissingData("European"); - } else { - createContinentChart( - sheet, - "European", - europeanContestRange, - "A25", - "F40" - ); + // Register the onEntered event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onEntered.add(contentControlEntered); + contentControls.items[i].track(); } await context.sync(); + + console.log("Added event handlers for when the cursor is placed in content controls."); + } }); -'Excel.Range#getUsedRange:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-relationships.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - - // We want the most recent quarter that has data, so - // exclude quarters without data and get the last of - // the remaining columns. - const usedDataRange = dataRange.getUsedRange(true /* valuesOnly */); - const currentQuarterRange = usedDataRange.getLastColumn(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml - // Asian and European teams have separate contests. - const asianSalesRange = sheet.getRange("A2:E4"); - const europeanSalesRange = sheet.getRange("A5:E7"); - // The data for each chart is the intersection of the - // current quarter column and the rows for the continent. - const asianContestRange = asianSalesRange.getIntersectionOrNullObject(currentQuarterRange); - const europeanContestRange = europeanSalesRange.getIntersectionOrNullObject(currentQuarterRange); + async function contentControlEntered(event: + Word.ContentControlEnteredEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was entered: ${event.ids[0]}`); + }); + } +Word.ContentControlExitedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml - // Must sync before you can test the output of *OrNullObject - // method/property. - await context.sync(); - if (asianContestRange.isNullObject) { - // See the declaration of this method for how to - // test this code path. - reportMissingData("Asian"); - } else { - createContinentChart( - sheet, - "Asian", - asianContestRange, - "A9", - "F24" - ); - } + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - if (europeanContestRange.isNullObject) { - // See the declaration of this method for how to - // test this code path. - reportMissingData("European"); - } else { - createContinentChart( - sheet, - "European", - europeanContestRange, - "A25", - "F40" - ); + // Register the onExited event handler on each content control. + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onExited.add(contentControlExited); + contentControls.items[i].track(); } await context.sync(); + + console.log("Added event handlers for when the cursor is removed from within content controls."); + } }); -'Excel.Range#removeDuplicates:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-remove-duplicates.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:D11"); - const deleteResult = range.removeDuplicates([0],true); - deleteResult.load(); + async function contentControlExited(event: + Word.ContentControlExitedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. ID of content control that was exited: ${event.ids[0]}`); + }); + } +Word.ContentControlListItem:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml + + + // Deletes the provided list item from the first dropdown list content + control in the selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); - console.log(deleteResult.removed + " entries with duplicate names removed."); - console.log(deleteResult.uniqueRemaining + " entries with unique names remain in the range."); - }); -'Excel.Range#style:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } - await Excel.run(async (context) => { - let worksheet = context.workbook.worksheets.getItem("Sample"); - let range = worksheet.getRange("A1:E1"); + let selectedDropdownList: Word.DropDownListContentControl = selectedContentControl.dropDownListContentControl; + selectedDropdownList.listItems.load("items/*"); + await context.sync(); - // Apply built-in style. - // Styles are in the Home tab ribbon. - range.style = Excel.BuiltInStyle.neutral; - range.format.horizontalAlignment = "Right"; + let listItems: Word.ContentControlListItemCollection = selectedContentControl.dropDownListContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`) + return; + } + + itemToDelete.delete(); + await context.sync(); - await context.sync(); + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.Range#getUsedRangeOrNullObject:member(1)': +Word.ContentControlListItem#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/used-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const salesTable = sheet.tables.getItem("SalesTable"); - const dataRange = salesTable.getDataBodyRange(); - // Pass true so only cells with values count as used - const usedDataRange = dataRange.getUsedRangeOrNullObject( - true /* valuesOnly */ - ); + // Deletes the provided list item from the first combo box content control + in the selection. - //Must sync before reading value returned from *OrNullObject method/property. + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); await context.sync(); - if (usedDataRange.isNullObject) { - console.log("Need Data to Make Chart"); - console.log("To create a meaningful chart, press 'Fill the table' (or add names to the Product column and numbers to some of the other cells). Then press 'Try to create chart' again."); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; } else { - const chart = sheet.charts.add( - Excel.ChartType.columnClustered, - dataRange, - "Columns" - ); - chart.setPosition("A15", "F30"); - chart.title.text = "Quarterly sales chart"; - chart.legend.position = "Right"; - chart.legend.format.fill.setSolidColor("white"); - chart.dataLabels.format.font.size = 15; - chart.dataLabels.format.font.color = "black"; + selectedContentControl = parentContentControl; } + } - await context.sync(); + let selectedComboBox: Word.ComboBoxContentControl = selectedContentControl.comboBoxContentControl; + selectedComboBox.listItems.load("items/*"); + await context.sync(); + + let listItems: Word.ContentControlListItemCollection = selectedContentControl.comboBoxContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`); + return; + } + + itemToDelete.delete(); + await context.sync(); + + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.Range#set:member(1)': +Word.ContentControlListItem#displayText:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/90-scenarios/multiple-property-set.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:E2"); - range.set({ - format: { - fill: { - color: "#4472C4" - }, - font: { - name: "Verdana", - color: "white" - } - } + // Deletes the provided list item from the first dropdown list content + control in the selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] }) - range.format.autofitColumns(); + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); - }); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/90-scenarios/multiple-property-set.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } - const sourceRange = sheet.getRange("B2:E2"); - sourceRange.load("format/fill/color, format/font/name, format/font/color"); - await context.sync(); + let selectedDropdownList: Word.DropDownListContentControl = selectedContentControl.dropDownListContentControl; + selectedDropdownList.listItems.load("items/*"); + await context.sync(); - // Set properties based on the loaded and synced - // source range. - const targetRange = sheet.getRange("B7:E7"); - targetRange.set(sourceRange); - targetRange.format.autofitColumns(); - await context.sync(); + let listItems: Word.ContentControlListItemCollection = selectedContentControl.dropDownListContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`) + return; + } + + itemToDelete.delete(); + await context.sync(); + + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.RangeAreas#format:member': +Word.ContentControlListItemCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-areas.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const usedRange = sheet.getUsedRange(); + // Gets the list items from the first combo box content control found in the + selection. - // Find the ranges with formulas. - const formulaRanges = usedRange.getSpecialCells("Formulas"); - formulaRanges.format.fill.color = "lightgreen"; + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.comboBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,comboBoxContentControl"); + await context.sync(); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,comboBoxContentControl"); await context.sync(); - }); -'Excel.RangeFormat#textOrientation:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-text-orientation.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:E2"); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.comboBox) { + console.warn("No combo box content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } - // Set textOrientation to either an integer between -90 and 90 - // or to 180 for vertically-oriented text. - range.format.textOrientation = 90; + let selectedComboBox: Word.ComboBoxContentControl = selectedContentControl.comboBoxContentControl; + selectedComboBox.listItems.load("items"); + await context.sync(); - await context.sync(); + const currentItems: Word.ContentControlListItemCollection = selectedComboBox.listItems; + console.log(`The list from the combo box content control with ID ${selectedContentControl.id}:`, currentItems); }); -'Excel.RangeHyperlink#address:member': +Word.ContentControlOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-hyperlink.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Orders"); - let productsRange = sheet.getRange("A3:A5"); - productsRange.load("values"); + // Toggles the isChecked property of the first checkbox content control + found in the selection. - await context.sync(); + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,checkboxContentControl/isChecked"); - // Create a hyperlink to a URL - // for each product name in the first table. - for (let i = 0; i < productsRange.values.length; i++) { - let cellRange = productsRange.getCell(i, 0); - let cellText = productsRange.values[i][0]; + await context.sync(); - let hyperlink = { - textToDisplay: cellText, - screenTip: "Search Bing for '" + cellText + "'", - address: "https://www.bing.com/?q=" + cellText - } - cellRange.hyperlink = hyperlink; + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,checkboxContentControl/isChecked"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; } + } - await context.sync(); + const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked; + console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`); + selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + selectedContentControl.load("id,checkboxContentControl/isChecked"); + await context.sync(); + + console.log( + "isChecked state after:", + `id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}` + ); }); -'Excel.RangeHyperlink#documentReference:member': +Word.ContentControlSelectionChangedEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-hyperlink.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Orders"); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml - let productsRange = sheet.getRange("A9:A11"); - productsRange.load("values"); - - await context.sync(); - // Create a hyperlink to a location within the workbook - // for each product name in the second table. - for (let i = 0; i < productsRange.values.length; i++) { - let cellRange = productsRange.getCell(i, 0); - let cellText = productsRange.values[i][0]; + await Word.run(async (context) => { + const contentControls: Word.ContentControlCollection = context.document.contentControls; + contentControls.load("items"); + await context.sync(); - let hyperlink = { - textToDisplay: cellText, - screenTip: "Navigate to the '" + cellText + "' worksheet", - documentReference: cellText + "!A1" - } - cellRange.hyperlink = hyperlink; + if (contentControls.items.length === 0) { + console.log("There aren't any content controls in this document so can't register event handlers."); + } else { + for (let i = 0; i < contentControls.items.length; i++) { + eventContexts[i] = contentControls.items[i].onSelectionChanged.add(contentControlSelectionChanged); + contentControls.items[i].track(); } await context.sync(); + + console.log("Added event handlers for when selections are changed in content controls."); + } }); -'Excel.RangeHyperlink#screenTip:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-hyperlink.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Orders"); - let productsRange = sheet.getRange("A3:A5"); - productsRange.load("values"); + async function contentControlSelectionChanged(event: + Word.ContentControlSelectionChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls where selection was changed:`, event.ids); + }); + } +Word.ContentControlState:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml - await context.sync(); - // Create a hyperlink to a URL - // for each product name in the first table. - for (let i = 0; i < productsRange.values.length; i++) { - let cellRange = productsRange.getCell(i, 0); - let cellText = productsRange.values[i][0]; + // Sets the state of the first content control. - let hyperlink = { - textToDisplay: cellText, - screenTip: "Search Bing for '" + cellText + "'", - address: "https://www.bing.com/?q=" + cellText - } - cellRange.hyperlink = hyperlink; - } + await Word.run(async (context) => { + const state = ((document.getElementById("state-to-set") as HTMLSelectElement) + .value as unknown) as Word.ContentControlState; + let firstContentControl = context.document.contentControls.getFirstOrNullObject(); + await context.sync(); - await context.sync(); + if (firstContentControl.isNullObject) { + console.warn("There are no content controls in this document."); + return; + } + + firstContentControl.setState(state); + firstContentControl.load("id"); + await context.sync(); + + console.log(`Set state of first content control with ID ${firstContentControl.id} to ${state}.`); }); -'Excel.RangeHyperlink#textToDisplay:member': +Word.ContentControlType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-hyperlink.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Orders"); - let productsRange = sheet.getRange("A3:A5"); - productsRange.load("values"); + // Traverses each paragraph of the document and places a checkbox content + control at the beginning of each. - await context.sync(); + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just start each paragraph with a content control. - // Create a hyperlink to a URL - // for each product name in the first table. - for (let i = 0; i < productsRange.values.length; i++) { - let cellRange = productsRange.getCell(i, 0); - let cellText = productsRange.values[i][0]; + await context.sync(); - let hyperlink = { - textToDisplay: cellText, - screenTip: "Search Bing for '" + cellText + "'", - address: "https://www.bing.com/?q=" + cellText - } - cellRange.hyperlink = hyperlink; - } + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i] + .getRange(Word.RangeLocation.start) + .insertContentControl(Word.ContentControlType.checkBox); + } + console.log("Checkbox content controls inserted: " + paragraphs.items.length); - await context.sync(); + await context.sync(); }); -'Excel.RemoveDuplicatesResult#uniqueRemaining:member': +Word.Critique:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-remove-duplicates.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B2:D11"); - const deleteResult = range.removeDuplicates([0],true); - deleteResult.load(); - await context.sync(); + // Adds annotations to the selected paragraph. - console.log(deleteResult.removed + " entries with duplicate names removed."); - console.log(deleteResult.uniqueRemaining + " entries with unique names remain in the range."); - }); -'Excel.Runtime#enableEvents:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-disable-events.yaml + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; - await Excel.run(async (context) => { - context.runtime.load("enableEvents"); - await context.sync(); + const annotationIds = paragraph.insertAnnotations(annotationSet); - // check if events are enabled and toggle accordingly - const eventBoolean = !context.runtime.enableEvents - context.runtime.enableEvents = eventBoolean; - if (eventBoolean) { - console.log("Events are currently on."); - } else { - console.log("Events are currently off."); - } + await context.sync(); - await context.sync(); + console.log("Annotations inserted:", annotationIds.value); }); -'Excel.SettableCellProperties#style:member': +Word.CritiqueAnnotation:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/cell-properties.yaml - - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - // Creating the SettableCellProperties objects to use for the range. - // In your add-in, these should be created once, outside the function. - const topHeaderProps: Excel.SettableCellProperties = { - // The style property takes a string matching the name of an Excel style. - // Built-in style names are listed in the `BuiltInStyle` enum. - // Note that a style will overwrite any formatting, - // so do not use the format property with the style property. - style: "Heading1" - }; - const headerProps: Excel.SettableCellProperties = { - // Any subproperties of format that are not set will not be changed when these cell properties are set. - format: { - fill: { - color: "Blue" - }, - font: { - color: "White", - bold: true - } - } - }; + // Gets annotations found in the selected paragraph. - const nonApplicableProps: Excel.SettableCellProperties = { - format: { - fill: { - pattern: Excel.FillPattern.gray25 - }, - font: { - color: "Gray", - italic: true - } - } - }; + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); - const matchupScoreProps: Excel.SettableCellProperties = { - format: { - borders: { - bottom: { - style: Excel.BorderLineStyle.continuous - }, - left: { - style: Excel.BorderLineStyle.continuous - }, - right: { - style: Excel.BorderLineStyle.continuous - }, - top: { - style: Excel.BorderLineStyle.continuous - } - } - } - }; + await context.sync(); - const range = sheet.getRange("A1:E5"); + console.log("Annotations found:"); - // You can use empty JSON objects to avoid changing a cell's properties. - range.setCellProperties([ - [topHeaderProps, {}, {}, {}, {}], - [{}, {}, headerProps, headerProps, headerProps], - [{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps], - [{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps], - [{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps] - ]); + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; - sheet.getUsedRange().format.autofitColumns(); - await context.sync(); + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); + } }); -'Excel.Setting#delete:member(1)': +Word.CritiqueAnnotation#accept:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/create-get-change-delete-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - let needsReview = settings.getItem("NeedsReview"); - needsReview.delete(); - needsReview = settings.getItemOrNullObject("NeedsReview"); - await context.sync(); + // Accepts the first annotation found in the selected paragraph. - if (needsReview.isNullObject) { - console.log("The setting has been deleted"); - } else { - console.log("The setting was not deleted"); - } + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); - await context.sync(); + await context.sync(); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Accepting ID ${annotation.id}...`); + annotation.critiqueAnnotation.accept(); + + await context.sync(); + break; + } + } }); -'Excel.SettingCollection#add:member(1)': +Word.CritiqueAnnotation#reject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - settings.onSettingsChanged.add(onChangedSetting); - await context.sync(); - console.log("Settings changed handler registered."); + // Rejects the last annotation found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + for (let i = annotations.items.length - 1; i >= 0; i--) { + const annotation: Word.Annotation = annotations.items[i]; + + if (annotation.state === Word.AnnotationState.created) { + console.log(`Rejecting ID ${annotation.id}...`); + annotation.critiqueAnnotation.reject(); + + await context.sync(); + break; + } + } }); -'Excel.SettingCollection#onSettingsChanged:member': +Word.CritiqueAnnotation#critique:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - settings.onSettingsChanged.add(onChangedSetting); - await context.sync(); - console.log("Settings changed handler registered."); + // Gets annotations found in the selected paragraph. + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + console.log("Annotations found:"); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); + } }); -'Excel.SettingCollection#getItemOrNullObject:member(1)': +Word.CritiqueColorScheme:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/create-get-change-delete-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const settings = context.workbook.settings; - let needsReview = settings.getItem("NeedsReview"); - needsReview.delete(); - needsReview = settings.getItemOrNullObject("NeedsReview"); - await context.sync(); + // Adds annotations to the selected paragraph. - if (needsReview.isNullObject) { - console.log("The setting has been deleted"); - } else { - console.log("The setting was not deleted"); - } + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; - await context.sync(); + const annotationIds = paragraph.insertAnnotations(annotationSet); + + await context.sync(); + + console.log("Annotations inserted:", annotationIds.value); }); -'Excel.Shape#delete:member(1)': +Word.CritiquePopupOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-create-and-delete.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - context.workbook.worksheets.getItemOrNullObject("Shapes").delete(); - const sheet = context.workbook.worksheets.add("Shapes"); - const shapes = sheet.shapes; + // Adds annotations to the selected paragraph. - // load all the shapes in the collection without loading their properties - shapes.load("items/$none"); - await context.sync(); + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; - shapes.items.forEach((shape) => shape.delete()); - await context.sync(); + const annotationIds = paragraph.insertAnnotations(annotationSet); + + await context.sync(); + + console.log("Annotations inserted:", annotationIds.value); }); -'Excel.Shape#fill:member': +Word.CustomProperty:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-create-and-delete.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml + + + await Word.run(async (context) => { + const properties: Word.CustomPropertyCollection = context.document.properties.customProperties; + properties.load("key,type,value"); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.smileyFace); - shape.left = 300; - shape.top = 100; - shape.height = 100; - shape.width = 100; - shape.fill.foregroundColor = "yellow" await context.sync(); + for (let i = 0; i < properties.items.length; i++) + console.log("Property Name:" + properties.items[i].key + "; Type=" + properties.items[i].type + "; Property Value=" + properties.items[i].value); }); -'Excel.Shape#rotation:member': +Word.CustomPropertyCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-create-and-delete.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml + + + await Word.run(async (context) => { + const properties: Word.CustomPropertyCollection = context.document.properties.customProperties; + properties.load("key,type,value"); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.triangle); - shape.left = 100; - shape.top = 300; - shape.height = 150; - shape.width = 200; - shape.rotation = 45; - shape.fill.clear(); await context.sync(); + for (let i = 0; i < properties.items.length; i++) + console.log("Property Name:" + properties.items[i].key + "; Type=" + properties.items[i].type + "; Property Value=" + properties.items[i].value); }); -'Excel.Shape#group:member': +Word.CustomPropertyCollection#add:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-groups.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shapeGroup = sheet.shapes.getItem("Group").group; - shapeGroup.ungroup(); - console.log("Shapes ungrouped"); + await Word.run(async (context) => { + context.document.properties.customProperties.add("Numeric Property", 1234); await context.sync(); + console.log("Property added"); }); -'Excel.Shape#getAsImage:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-images.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Image"); - const result = shape.getAsImage(Excel.PictureFormat.png); - await context.sync(); - const imageString = result.value; - // Your add-in would save this string as a .png file. - console.log("The image's base64-encoded string: " + imageString); - }); -'Excel.Shape#incrementRotation:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-images.yaml + await Word.run(async (context) => { + context.document.properties.customProperties.add("String Property", "Hello World!"); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Image"); - shape.incrementRotation(180); await context.sync(); + console.log("Property added"); }); -'Excel.Shape#line:member': +Word.CustomPropertyCollection#items:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.getItem("StraightLine").line; - line.beginArrowheadLength = Excel.ArrowheadLength.long; - line.beginArrowheadWidth = Excel.ArrowheadWidth.wide; - line.beginArrowheadStyle = Excel.ArrowheadStyle.oval; - line.endArrowheadLength = Excel.ArrowheadLength.long; - line.endArrowheadWidth = Excel.ArrowheadWidth.wide; - line.endArrowheadStyle = Excel.ArrowheadStyle.triangle; + await Word.run(async (context) => { + const properties: Word.CustomPropertyCollection = context.document.properties.customProperties; + properties.load("key,type,value"); await context.sync(); + for (let i = 0; i < properties.items.length; i++) + console.log("Property Name:" + properties.items[i].key + "; Type=" + properties.items[i].type + "; Property Value=" + properties.items[i].value); }); -'Excel.Shape#incrementLeft:member(1)': +Word.CustomXmlPart:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Square") - shape.incrementLeft(-25); - await context.sync(); + + // Adds a custom XML part. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Added custom XML part:", readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); }); -'Excel.Shape#incrementTop:member(1)': +Word.CustomXmlPart#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml + + + // Original XML: + JuanHongSally + + + // Deletes a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.document.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Pentagon") - shape.incrementTop(25); await context.sync(); + + if (customXmlPart.isNullObject) { + console.log(`The XML part with the ID ${xmlPartIDSetting.value} has been deleted.`); + + // Delete the associated setting too. + xmlPartIDSetting.delete(); + + await context.sync(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.error(`This is strange. The XML part with the id ${xmlPartIDSetting.value} wasn't deleted:`, readableXml); + } + } else { + console.warn("Didn't find custom XML part to delete."); + } }); -'Excel.Shape#scaleHeight:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml + + + // Original XML: JuanHongSally + + + // Deletes a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + let customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xmlBlob = customXmlPart.getXml(); + customXmlPart.delete(); + customXmlPart = context.document.customXmlParts.getItemOrNullObject(xmlPartIDSetting.value); - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Octagon") - shape.lockAspectRatio = true; - shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize); await context.sync(); + + if (customXmlPart.isNullObject) { + console.log(`The XML part with the ID ${xmlPartIDSetting.value} has been deleted.`); + + // Delete the associated setting too. + xmlPartIDSetting.delete(); + + await context.sync(); + } else { + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.error( + `This is strange. The XML part with the id ${xmlPartIDSetting.value} wasn't deleted:`, + readableXml + ); + } + } else { + console.warn("Didn't find custom XML part to delete."); + } }); -'Excel.Shape#lockAspectRatio:member': +Word.CustomXmlPart#getXml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Octagon") - shape.lockAspectRatio = true; - shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize); - await context.sync(); + + // Adds a custom XML part. + + // If you want to populate the CustomXml.namespaceUri property, you must + include the xmlns attribute. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load(["id", "namespaceUri"]); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log(`Added custom XML part with namespace URI ${customXmlPart.namespaceUri}:`, readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartIdNS", customXmlPart.id); + + await context.sync(); }); -'Excel.Shape#setZOrder:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-move-and-order.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.getItem("Octagon") - shape.setZOrder(Excel.ShapeZOrder.sendBackward); - await context.sync(); + + // Adds a custom XML part. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Added custom XML part:", readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); }); -'Excel.ShapeCollection#addGeometricShape:member(1)': +Word.CustomXmlPart#insertAttribute:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-create-and-delete.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.hexagon); - shape.left = 5; - shape.top = 5; - shape.height = 175; - shape.width = 200; + + // Original XML: JuanHongSally + + + // Inserts an attribute into a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertAttribute method inserts an attribute with the given name and value into the element identified by the xpath parameter. + customXmlPart.insertAttribute( + "/contoso:Reviewers", + { contoso: "http://schemas.contoso.com/review/1.0" }, + "Nation", + "US" + ); + const xmlBlob = customXmlPart.getXml(); await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted attribute:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert attribute into."); + } }); -'Excel.ShapeCollection#addGroup:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-groups.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const square = sheet.shapes.getItem("Square"); - const pentagon = sheet.shapes.getItem("Pentagon"); - const octagon = sheet.shapes.getItem("Octagon"); - const shapeGroup = sheet.shapes.addGroup([square, pentagon, octagon]); - shapeGroup.name = "Group"; - console.log("Shapes grouped"); + // Original XML: + JuanHongSally + + + // Inserts an attribute into a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertAttribute method inserts an attribute with the given name and value into the element identified by the xpath parameter. + customXmlPart.insertAttribute("/Reviewers", { contoso: "http://schemas.contoso.com/review/1.0" }, "Nation", "US"); + const xmlBlob = customXmlPart.getXml(); await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted attribute:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert attribute into."); + } }); -'Excel.ShapeCollection#addImage:member(1)': +Word.CustomXmlPart#insertElement:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-images.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - const myFile = document.getElementById("selectedFile"); - - const reader = new FileReader(); + // Original XML: JuanHongSally - reader.onload = (event) => { - Excel.run((context) => { - const startIndex = reader.result.toString().indexOf("base64,"); - const mybase64 = reader.result.toString().substr(startIndex + 7); - const sheet = context.workbook.worksheets.getItem("Shapes"); - const image = sheet.shapes.addImage(mybase64); - image.name = "Image"; - return context.sync(); - }); - }; + // Inserts an element into a custom XML part. - // Read in the image file as a data URL. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); - reader.readAsDataURL(myFile.files[0]); -'Excel.ShapeCollection#addLine:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-lines.yaml + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const line = shapes.addLine(200, 50, 300, 150, Excel.ConnectorType.straight); - line.name = "StraightLine"; + // The insertElement method inserts the given XML under the parent element identified by the xpath parameter at the provided child position index. + customXmlPart.insertElement( + "/contoso:Reviewers", + "Mark", + { contoso: "http://schemas.contoso.com/review/1.0" }, + 0 + ); + const xmlBlob = customXmlPart.getXml(); await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted element:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert element into."); + } }); -'Excel.ShapeCollection#addTextBox:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-textboxes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const textbox = shapes.addTextBox("A box with text"); - textbox.left = 100; - textbox.top = 100; - textbox.height = 20; - textbox.width = 175; - textbox.name = "Textbox"; + + // Original XML: + JuanHongSally + + + // Inserts an element into a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + + // The insertElement method inserts the given XML under the parent element identified by the xpath parameter at the provided child position index. + customXmlPart.insertElement( + "/Reviewers", + "Mark", + { contoso: "http://schemas.contoso.com/review/1.0" }, + 0 + ); + const xmlBlob = customXmlPart.getXml(); await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Successfully inserted element:", readableXml); + } else { + console.warn("Didn't find custom XML part to insert element into."); + } }); -'Excel.ShapeGroup#ungroup:member(1)': +Word.CustomXmlPart#query:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-groups.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Shapes"); - const shapeGroup = sheet.shapes.getItem("Group").group; - shapeGroup.ungroup(); - console.log("Shapes ungrouped"); + // Original XML: JuanHongSally + + + // Queries a custom XML part for elements matching the search terms. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/contoso:Reviewers"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); await context.sync(); + + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } }); -'Excel.ShowAsRule#baseItem:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-calculations.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales"); - const farmDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold at Farm"); - const wholesaleDataHierarchy: Excel.DataPivotHierarchy = pivotTable.dataHierarchies.getItem("Sum of Crates Sold Wholesale"); - farmDataHierarchy.load("showAs"); - wholesaleDataHierarchy.load("showAs"); - await context.sync(); + // Original XML: + JuanHongSally - // show the difference between crate sales of the "A Farms" and the other farms - // this difference is both aggregated and shown for individual fruit types (where applicable) - let farmShowAs = farmDataHierarchy.showAs; - farmShowAs.calculation = Excel.ShowAsCalculation.differenceFrom; - farmShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm"); - farmShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms"); - farmDataHierarchy.showAs = farmShowAs; - let wholesaleShowAs = wholesaleDataHierarchy.showAs; - wholesaleShowAs.calculation = Excel.ShowAsCalculation.differenceFrom; - wholesaleShowAs.baseField = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm"); - wholesaleShowAs.baseItem = pivotTable.rowHierarchies.getItem("Farm").fields.getItem("Farm").items.getItem("A Farms"); - wholesaleDataHierarchy.showAs = wholesaleShowAs; + // Queries a custom XML part for elements matching the search terms. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/Reviewers/Reviewer"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); + await context.sync(); + + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } }); -'Excel.Slicer#style:member': +Word.CustomXmlPart#setXml:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const slicer = context.workbook.slicers.getItem("Fruit Slicer"); - slicer.style = "SlicerStyleLight6"; + + // Original XML: JuanHongSally + + + // Replaces a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const originalXmlBlob = customXmlPart.getXml(); + await context.sync(); + + let readableXml = addLineBreaksToXML(originalXmlBlob.value); + console.log("Original custom XML part:", readableXml); + + // The setXml method replaces the entire XML part. + customXmlPart.setXml( + "JohnHitomi" + ); + const updatedXmlBlob = customXmlPart.getXml(); await context.sync(); + + readableXml = addLineBreaksToXML(updatedXmlBlob.value); + console.log("Replaced custom XML part:", readableXml); + } else { + console.warn("Didn't find custom XML part to replace."); + } }); -'Excel.Slicer#selectItems:member(1)': +Word.CustomXmlPart#id:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const slicer = context.workbook.slicers.getItem("Fruit Slicer"); - slicer.selectItems(["Lemon", "Lime", "Orange"]); - await context.sync(); + + // Adds a custom XML part. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Added custom XML part:", readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); }); -'Excel.Slicer#clearFilters:member(1)': +Word.CustomXmlPart#namespaceUri:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const slicer = context.workbook.slicers.getItem("Fruit Slicer"); - slicer.clearFilters(); + + // Original XML: JuanHongSally + + + // Gets the namespace URI from a custom XML part. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + customXmlPart.load("namespaceUri"); await context.sync(); + + const namespaceUri = customXmlPart.namespaceUri; + console.log(`Namespace URI: ${JSON.stringify(namespaceUri)}`); + } else { + console.warn("Didn't find custom XML part."); + } }); -'Excel.Slicer#delete:member(1)': +Word.CustomXmlPartCollection#add:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - sheet.slicers.getItemAt(0).delete(); - await context.sync(); + + // Adds a custom XML part. + + // If you want to populate the CustomXml.namespaceUri property, you must + include the xmlns attribute. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load(["id", "namespaceUri"]); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log(`Added custom XML part with namespace URI ${customXmlPart.namespaceUri}:`, readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartIdNS", customXmlPart.id); + + await context.sync(); }); -'Excel.SlicerCollection#add:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Pivot"); - const slicer = sheet.slicers.add( - "Farm Sales", /* The slicer data source. For PivotTables, this can be the PivotTable object reference or name. */ - "Type" /* The field in the data source to filter by. For PivotTables, this can be a PivotField object reference or ID. */ - ); - slicer.name = "Fruit Slicer"; - await context.sync(); + + // Adds a custom XML part. + + await Word.run(async (context) => { + const originalXml = + "JuanHongSally"; + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.add(originalXml); + customXmlPart.load("id"); + const xmlBlob = customXmlPart.getXml(); + + await context.sync(); + + const readableXml = addLineBreaksToXML(xmlBlob.value); + console.log("Added custom XML part:", readableXml); + + // Store the XML part's ID in a setting so the ID is available to other functions. + const settings: Word.SettingCollection = context.document.settings; + settings.add("ContosoReviewXmlPartId", customXmlPart.id); + + await context.sync(); }); -'Excel.SlicerCollection#getItem:member(1)': +Word.CustomXmlPartCollection#getByNamespace:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - const slicer = context.workbook.slicers.getItem("Fruit Slicer"); - slicer.caption = "Fruit Types"; - slicer.left = 395; - slicer.top = 15; - slicer.height = 135; - slicer.width = 150; - await context.sync(); + + // Original XML: JuanHongSally + + + // Gets the custom XML parts with the specified namespace URI. + + await Word.run(async (context) => { + const namespaceUri = "http://schemas.contoso.com/review/1.0"; + console.log(`Specified namespace URI: ${namespaceUri}`); + const scopedCustomXmlParts: Word.CustomXmlPartScopedCollection = + context.document.customXmlParts.getByNamespace(namespaceUri); + scopedCustomXmlParts.load("items"); + await context.sync(); + + console.log(`Number of custom XML parts found with this namespace: ${!scopedCustomXmlParts.items ? 0 : scopedCustomXmlParts.items.length}`); }); -'Excel.Style#delete:member(1)': +Word.CustomXmlPartCollection#getItem:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - let style = context.workbook.styles.getItem("Diagonal Orientation Style"); - // Delete the diagonal orientation style from the style collection. - // Styles are in the Home tab ribbon. - style.delete(); + // Original XML: JuanHongSally + + + // Queries a custom XML part for elements matching the search terms. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartIdNS").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/contoso:Reviewers"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); await context.sync(); - console.log("Successfully deleted the diagonal orientation style from the Home tab ribbon."); + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } }); -'Excel.Style#font:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml - await Excel.run(async (context) => { - let style = context.workbook.styles.getItem("Normal"); - style.font.load("bold, color, italic, name, size"); - style.fill.load("color"); + + // Original XML: + JuanHongSally + + + // Queries a custom XML part for elements matching the search terms. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + const xmlPartIDSetting: Word.Setting = settings.getItemOrNullObject("ContosoReviewXmlPartId").load("value"); + + await context.sync(); + + if (xmlPartIDSetting.value) { + const customXmlPart: Word.CustomXmlPart = context.document.customXmlParts.getItem(xmlPartIDSetting.value); + const xpathToQueryFor = "/Reviewers/Reviewer"; + const clientResult = customXmlPart.query(xpathToQueryFor, { + contoso: "http://schemas.contoso.com/review/1.0" + }); await context.sync(); - console.log("Bold: " + style.font.bold); - console.log("Font color: " + style.font.color); - console.log("Italic: " + style.font.italic); - console.log("Name: " + style.font.name); - console.log("Size: " + style.font.size); - console.log("Fill color: " + style.fill.color); + console.log(`Queried custom XML part for ${xpathToQueryFor} and found ${clientResult.value.length} matches:`); + for (let i = 0; i < clientResult.value.length; i++) { + console.log(clientResult.value[i]); + } + } else { + console.warn("Didn't find custom XML part to query."); + } }); -'Excel.Style#horizontalAlignment:member': +Word.CustomXmlPartScopedCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml - await Excel.run(async (context) => { - let worksheet = context.workbook.worksheets.getItem("Sample"); - let range = worksheet.getRange("A1:E1"); - // Apply built-in style. - // Styles are in the Home tab ribbon. - range.style = Excel.BuiltInStyle.neutral; - range.format.horizontalAlignment = "Right"; + // Original XML: JuanHongSally - await context.sync(); + + // Gets the custom XML parts with the specified namespace URI. + + await Word.run(async (context) => { + const namespaceUri = "http://schemas.contoso.com/review/1.0"; + console.log(`Specified namespace URI: ${namespaceUri}`); + const scopedCustomXmlParts: Word.CustomXmlPartScopedCollection = + context.document.customXmlParts.getByNamespace(namespaceUri); + scopedCustomXmlParts.load("items"); + await context.sync(); + + console.log(`Number of custom XML parts found with this namespace: ${!scopedCustomXmlParts.items ? 0 : scopedCustomXmlParts.items.length}`); }); -'Excel.Style#load:member(1)': +Word.Document:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml - await Excel.run(async (context) => { - let style = context.workbook.styles.getItem("Diagonal Orientation Style"); - style.load("textOrientation, horizontalAlignment, autoIndent, readingOrder, wrapText, includeProtection, shrinkToFit, locked"); - await context.sync(); + // Gets the current change tracking mode. - console.log("Orientation: " + style.textOrientation); - console.log("Horizontal alignment: " + style.horizontalAlignment); - console.log("Add indent: " + style.autoIndent); - console.log("Reading order: " + style.readingOrder); - console.log("Wrap text: " + style.wrapText); - console.log("Include protection: " + style.includeProtection); - console.log("Shrink to fit: " + style.shrinkToFit); - console.log("Style locked: " + style.locked); + await Word.run(async (context) => { + const document: Word.Document = context.document; + document.load("changeTrackingMode"); + await context.sync(); + + if (document.changeTrackingMode === Word.ChangeTrackingMode.trackMineOnly) { + console.log("Only my changes are being tracked."); + } else if (document.changeTrackingMode === Word.ChangeTrackingMode.trackAll) { + console.log("Everyone's changes are being tracked."); + } else { + console.log("No changes are being tracked."); + } }); -'Excel.StyleCollection#add:member(1)': +Word.Document#addStyle:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - await Excel.run(async (context) => { - let styles = context.workbook.styles; - // Add a new style to the style collection. - // Styles is in the Home tab ribbon. - styles.add("Diagonal Orientation Style"); - - let newStyle = styles.getItem("Diagonal Orientation Style"); - - // The "Diagonal Orientation Style" properties. - newStyle.textOrientation = 38; - newStyle.autoIndent = true; - newStyle.includeProtection = true; - newStyle.shrinkToFit = true; - newStyle.locked = false; - - await context.sync(); + // Adds a new style. - console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + await Word.run(async (context) => { + const newStyleName = (document.getElementById("new-style-name") as HTMLInputElement).value; + if (newStyleName == "") { + console.warn("Enter a style name to add."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(newStyleName); + style.load(); + await context.sync(); + + if (!style.isNullObject) { + console.warn( + `There's an existing style with the same name '${newStyleName}'! Please provide another style name.` + ); + return; + } + + const newStyleType = ((document.getElementById("new-style-type") as HTMLSelectElement).value as unknown) as Word.StyleType; + context.document.addStyle(newStyleName, newStyleType); + await context.sync(); + + console.log(newStyleName + " has been added to the style list."); }); -'Excel.StyleCollection#getItem:member(1)': +Word.Document#close:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml - await Excel.run(async (context) => { - let styles = context.workbook.styles; - // Add a new style to the style collection. - // Styles is in the Home tab ribbon. - styles.add("Diagonal Orientation Style"); - - let newStyle = styles.getItem("Diagonal Orientation Style"); - - // The "Diagonal Orientation Style" properties. - newStyle.textOrientation = 38; - newStyle.autoIndent = true; - newStyle.includeProtection = true; - newStyle.shrinkToFit = true; - newStyle.locked = false; - - await context.sync(); + // Closes the document with default behavior - console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + // for current state of the document. + + await Word.run(async (context) => { + context.document.close(); }); -'Excel.Table#onChanged:member': +Word.Document#compare:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-table-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/compare-documents.yaml - await Excel.run(async (context) => { - let table = context.workbook.tables.getItemAt(0); - table.onChanged.add(onChange); - await context.sync(); - console.log("A handler has been registered for the onChanged event"); + // Compares the current document with a specified external document. + + await Word.run(async (context) => { + // Absolute path of an online or local document. + const filePath = (document.getElementById("filePath") as HTMLInputElement).value; + // Options that configure the compare operation. + const options: Word.DocumentCompareOptions = { + compareTarget: Word.CompareTarget.compareTargetCurrent, + detectFormatChanges: false + // Other options you choose... + }; + context.document.compare(filePath, options); + + await context.sync(); + + console.log("Differences shown in the current document."); }); -'Excel.Table#onSelectionChanged:member': +Word.Document#getContentControls:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-table-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - await Excel.run(async (context) => { - let table = context.workbook.tables.getItemAt(0); - table.onSelectionChanged.add(onSelectionChange); - await context.sync(); - console.log("A handler has been registered for table onSelectionChanged event"); + // Toggles the isChecked property on all checkbox content controls. + + await Word.run(async (context) => { + let contentControls = context.document.getContentControls({ + types: [Word.ContentControlType.checkBox] + }); + contentControls.load("items"); + + await context.sync(); + + const length = contentControls.items.length; + console.log(`Number of checkbox content controls: ${length}`); + + if (length <= 0) { + return; + } + + const checkboxContentControls = []; + for (let i = 0; i < length; i++) { + let contentControl = contentControls.items[i]; + contentControl.load("id,checkboxContentControl/isChecked"); + checkboxContentControls.push(contentControl); + } + + await context.sync(); + + console.log("isChecked state before:"); + const updatedCheckboxContentControls = []; + for (let i = 0; i < checkboxContentControls.length; i++) { + const currentCheckboxContentControl = checkboxContentControls[i]; + const isCheckedBefore = currentCheckboxContentControl.checkboxContentControl.isChecked; + console.log(`id: ${currentCheckboxContentControl.id} ... isChecked: ${isCheckedBefore}`); + + currentCheckboxContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + currentCheckboxContentControl.load("id,checkboxContentControl/isChecked"); + updatedCheckboxContentControls.push(currentCheckboxContentControl); + } + + await context.sync(); + + console.log("isChecked state after:"); + for (let i = 0; i < updatedCheckboxContentControls.length; i++) { + const currentCheckboxContentControl = updatedCheckboxContentControls[i]; + console.log( + `id: ${currentCheckboxContentControl.id} ... isChecked: ${currentCheckboxContentControl.checkboxContentControl.isChecked}` + ); + } }); -'Excel.TableChangedEventArgs#details:member': +Word.Document#getParagraphByUniqueLocalId:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/data-change-event-details.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml - async function onTableChanged(eventArgs: Excel.TableChangedEventArgs) { - await Excel.run(async (context) => { - const details = eventArgs.details; - const address = eventArgs.address; - console.log(`Change at ${address}: was ${details.valueBefore}(${details.valueTypeBefore}),` - + ` now is ${details.valueAfter}(${details.valueTypeAfter})`); - }); - } -'Excel.TableChangedEventArgs#tableId:member': + await Word.run(async (context) => { + const paragraphId = (document.getElementById("paragraph-id") as HTMLInputElement).value; + const paragraph: Word.Paragraph = context.document.getParagraphByUniqueLocalId(paragraphId); + paragraph.load(); + await paragraph.context.sync(); + + console.log(paragraph); + }); +Word.Document#getStyles:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-tablecollection-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - async function onChange(event) { - await Excel.run(async (context) => { - let table = context.workbook.tables.getItem(event.tableId); - let worksheet = context.workbook.worksheets.getItem(event.worksheetId); - worksheet.load("name"); - await context.sync(); + // Gets the number of available styles stored with the document. - console.log("Handler for table collection onChanged event has been triggered. Data changed address: " + event.address); - console.log("Table Id : " + event.tableId); - console.log("Worksheet Id : " + worksheet.name); - }); - } -'Excel.TableChangedEventArgs#worksheetId:member': + await Word.run(async (context) => { + const styles: Word.StyleCollection = context.document.getStyles(); + const count = styles.getCount(); + await context.sync(); + + console.log(`Number of styles: ${count.value}`); + }); +Word.Document#importStylesFromJson:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-tablecollection-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml - async function onChange(event) { - await Excel.run(async (context) => { - let table = context.workbook.tables.getItem(event.tableId); - let worksheet = context.workbook.worksheets.getItem(event.worksheetId); - worksheet.load("name"); - await context.sync(); + // Imports styles from JSON. - console.log("Handler for table collection onChanged event has been triggered. Data changed address: " + event.address); - console.log("Table Id : " + event.tableId); - console.log("Worksheet Id : " + worksheet.name); - }); - } -'Excel.TableCollection#onChanged:member': + await Word.run(async (context) => { + const str = + '{"styles":[{"baseStyle":"Default Paragraph Font","builtIn":false,"inUse":true,"linked":false,"nameLocal":"NewCharStyle","priority":2,"quickStyle":true,"type":"Character","unhideWhenUsed":false,"visibility":false,"paragraphFormat":null,"font":{"name":"DengXian Light","size":16.0,"bold":true,"italic":false,"color":"#F1A983","underline":"None","subscript":false,"superscript":true,"strikeThrough":true,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#FF0000"}},{"baseStyle":"Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewParaStyle","nameLocal":"NewParaStyle","priority":1,"quickStyle":true,"type":"Paragraph","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Centered","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":72.0,"lineSpacing":18.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":72.0,"spaceAfter":30.0,"spaceBefore":30.0,"widowControl":true},"font":{"name":"DengXian","size":14.0,"bold":true,"italic":true,"color":"#8DD873","underline":"Single","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":true,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#00FF00"}},{"baseStyle":"Table Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewTableStyle","nameLocal":"NewTableStyle","priority":100,"type":"Table","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Left","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":0.0,"lineSpacing":12.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":0.0,"spaceAfter":0.0,"spaceBefore":0.0,"widowControl":true},"font":{"name":"DengXian","size":20.0,"bold":false,"italic":true,"color":"#D86DCB","underline":"None","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"tableStyle":{"allowBreakAcrossPage":true,"alignment":"Left","bottomCellMargin":0.0,"leftCellMargin":0.08,"rightCellMargin":0.08,"topCellMargin":0.0,"cellSpacing":0.0},"shading":{"backgroundPatternColor":"#60CAF3"}}]}'; + const styles = context.document.importStylesFromJson(str); + + // If you'd like to set how conflicting styles are handled, use the importedStylesConflictBehavior parameter that was introduced in the Desktop 1.1 requirement set. "Ignore" is the default. + ////const styles = context.document.importStylesFromJson(str, Word.ImportedStylesConflictBehavior.Ignore); + + await context.sync(); + console.log("Styles imported from JSON:", styles); + }); +Word.Document#insertFileFromBase64:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-tablecollection-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml - await Excel.run(async (context) => { - let tables = context.workbook.tables; - tables.onChanged.add(onChange); - await context.sync(); - console.log("A handler has been registered for the table collection onChanged event"); + // Inserts content (applying selected settings) from another document passed + in as a Base64-encoded string. + + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + context.document.insertFileFromBase64(externalDocument, "Replace", { + importTheme: true, + importStyles: true, + importParagraphSpacing: true, + importPageColor: true, + importChangeTrackingMode: true, + importCustomProperties: true, + importCustomXmlParts: true, + importDifferentOddEvenPages: true + }); + await context.sync(); }); -'Excel.TableSelectionChangedEventArgs#address:member': +Word.Document#save:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-table-changed.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml - async function onSelectionChange(args) { - await Excel.run(async (context) => { - console.log("Handler for table onSelectionChanged event has been triggered. The new selection is: " + args.address); - }); - } -'Excel.TextConditionalFormat#format:member': + + // Saves the document with default behavior + + // for current state of the document. + + await Word.run(async (context) => { + context.document.save(); + await context.sync(); + }); +Word.Document#activeWindow:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B16:D18"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.containsText); - conditionalFormat.textComparison.format.font.color = "red"; - conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; - await context.sync(); + await Word.run(async (context) => { + // Gets the first paragraph of each page. + console.log("Getting first paragraph of each page..."); + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get all pages. + const pages: Word.PageCollection = activePane.pages; + pages.load(); + + await context.sync(); + + // Get page index and paragraphs of each page. + const pagesIndexes = []; + const pagesNumberOfParagraphs = []; + const pagesFirstParagraphText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const paragraphs = page.getRange().paragraphs; + paragraphs.load("items/length"); + pagesNumberOfParagraphs.push(paragraphs); + + const firstParagraph = paragraphs.getFirst(); + firstParagraph.load("text"); + pagesFirstParagraphText.push(firstParagraph); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + console.log(`Number of paragraphs: ${pagesNumberOfParagraphs[i].items.length}`); + console.log("First paragraph's text:", pagesFirstParagraphText[i].text); + } }); -'Excel.TextConditionalFormat#rule:member': +Word.Document#changeTrackingMode:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const range = sheet.getRange("B16:D18"); - const conditionalFormat = range.conditionalFormats - .add(Excel.ConditionalFormatType.containsText); - conditionalFormat.textComparison.format.font.color = "red"; - conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" }; - await context.sync(); + // Gets the current change tracking mode. + + await Word.run(async (context) => { + const document: Word.Document = context.document; + document.load("changeTrackingMode"); + await context.sync(); + + if (document.changeTrackingMode === Word.ChangeTrackingMode.trackMineOnly) { + console.log("Only my changes are being tracked."); + } else if (document.changeTrackingMode === Word.ChangeTrackingMode.trackAll) { + console.log("Everyone's changes are being tracked."); + } else { + console.log("No changes are being tracked."); + } }); -'Excel.TextFrame#deleteText:member(1)': +Word.Document#onAnnotationClicked:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/44-shape/shape-textboxes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const shapes = context.workbook.worksheets.getItem("Shapes").shapes; - const textbox = shapes.getItem("Textbox"); - textbox.textFrame.deleteText(); - await context.sync(); + + // Registers event handlers. + + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.Workbook#properties:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/26-document/properties.yaml - - await Excel.run(async (context) => { - let titleValue = "Excel document properties API"; - let subjectValue = "Set and get document properties"; - let keywordsValue = "Set and get operations"; - let commentsValue = "This is an Excel document properties API code sample"; - let categoryValue = "Office Add-ins"; - let managerValue = "John"; - let companyValue = "Microsoft"; + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - let docProperties = context.workbook.properties; - // Set the writeable document properties. - docProperties.title = titleValue; - docProperties.subject = subjectValue; - docProperties.keywords = keywordsValue; - docProperties.comments = commentsValue; - docProperties.category = categoryValue; - docProperties.manager = managerValue; - docProperties.company = companyValue; + async function onClickedHandler(args: Word.AnnotationClickedEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); await context.sync(); - console.log("Set the following document properties: title, subject, keywords, comments, category, manager, company."); - }); -'Excel.Workbook#pivotTables:member': + console.log(`AnnotationClicked: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } +Word.Document#onAnnotationHovered:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml + + + // Registers event handlers. + + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); - await Excel.run(async (context) => { - // Get the names of all the PivotTables in the workbook. - const pivotTables = context.workbook.pivotTables; - pivotTables.load("name"); await context.sync(); - // Display the names in the console. - console.log("PivotTables in the workbook:") - pivotTables.items.forEach((pivotTable) => { - console.log(`\t${pivotTable.name}`); - }); + console.log("Event handlers registered."); }); -'Excel.Workbook#getSelectedRanges:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-areas.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - const selectedRanges = context.workbook.getSelectedRanges(); - selectedRanges.format.fill.color = "lightblue"; + async function onHoveredHandler(args: Word.AnnotationHoveredEventArgs) { + await Word.run(async (context) => { + const annotation: Word.Annotation = context.document.getAnnotationById(args.id); + annotation.load("critiqueAnnotation"); await context.sync(); - }) -'Excel.Workbook#styles:member': + + console.log(`AnnotationHovered: ID ${args.id}:`, annotation.critiqueAnnotation.critique); + }); + } +Word.Document#onAnnotationInserted:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/style.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let styles = context.workbook.styles; - // Add a new style to the style collection. - // Styles is in the Home tab ribbon. - styles.add("Diagonal Orientation Style"); - - let newStyle = styles.getItem("Diagonal Orientation Style"); - - // The "Diagonal Orientation Style" properties. - newStyle.textOrientation = 38; - newStyle.autoIndent = true; - newStyle.includeProtection = true; - newStyle.shrinkToFit = true; - newStyle.locked = false; - - await context.sync(); + // Registers event handlers. - console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon."); + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.Workbook#getActiveCell:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/workbook-get-active-cell.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let myWorkbook = context.workbook; - let activeCell = myWorkbook.getActiveCell(); - activeCell.load("address"); + async function onInsertedHandler(args: Word.AnnotationInsertedEventArgs) { + await Word.run(async (context) => { + const annotations = []; + for (let i = 0; i < args.ids.length; i++) { + let annotation: Word.Annotation = context.document.getAnnotationById(args.ids[i]); + annotation.load("id,critiqueAnnotation"); + + annotations.push(annotation); + } await context.sync(); - - console.log("The active cell is " + activeCell.address); - }); -'Excel.Workbook#close:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/workbook-save-and-close.yaml - await Excel.run(async (context) => { - context.workbook.close(Excel.CloseBehavior.save); - }); -'Excel.Workbook#save:member(1)': + for (let annotation of annotations) { + console.log(`AnnotationInserted: ID ${annotation.id}:`, annotation.critiqueAnnotation.critique); + } + }); + } +Word.Document#onAnnotationPopupAction:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/workbook-save-and-close.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - context.workbook.save(Excel.SaveBehavior.save); + + // Registers event handlers. + + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); + + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); + + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.WorkbookProtection#protect:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml - - await Excel.run(async (context) => { - let workbook = context.workbook; - workbook.load("protection/protected"); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await context.sync(); - if (!workbook.protection.protected) { - workbook.protection.protect(); + async function onPopupActionHandler(args: + Word.AnnotationPopupActionEventArgs) { + await Word.run(async (context) => { + let message = `AnnotationPopupAction: ID ${args.id} = `; + if (args.action === "Accept") { + message += `Accepted: ${args.critiqueSuggestion}`; + } else { + message += "Rejected"; } - }); + + console.log(message); + }); + } +Word.Document#onAnnotationRemoved:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - let password = await passwordHandler(); - passwordHelper(password); + // Registers event handlers. - await Excel.run(async (context) => { - let workbook = context.workbook; - workbook.load("protection/protected"); + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); - await context.sync(); + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); - if (!workbook.protection.protected) { - workbook.protection.protect(password); - } + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.WorkbookProtection#unprotect:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - await Excel.run(async (context) => { - let workbook = context.workbook; - workbook.protection.unprotect(); - }); + + async function onRemovedHandler(args: Word.AnnotationRemovedEventArgs) { + await Word.run(async (context) => { + for (let id of args.ids) { + console.log(`AnnotationRemoved: ID ${id}`); + } + }); + } +Word.Document#onContentControlAdded:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml - let password = await passwordHandler(); - passwordHelper(password); + // Registers the onAdded event handler on the document. - await Excel.run(async (context) => { - let workbook = context.workbook; - workbook.protection.unprotect(password); + await Word.run(async (context) => { + eventContext = context.document.onContentControlAdded.add(contentControlAdded); + await context.sync(); + + console.log("Added event handler for when content controls are added."); }); -'Excel.WorkbookRangeAreas#areas:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/direct-precedents.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml - await Excel.run(async (context) => { - // Precedents are cells referenced by the formula in a cell. - let range = context.workbook.getActiveCell(); - let directPrecedents = range.getDirectPrecedents(); - range.load("address"); - directPrecedents.areas.load("address"); - await context.sync(); - console.log(`Direct precedent cells of ${range.address}:`); + async function contentControlAdded(event: Word.ContentControlAddedEventArgs) + { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were added:`, event.ids); + }); + } +Word.Document#onParagraphAdded:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml - // Use the direct precedents API to loop through precedents of the active cell. - for (var i = 0; i < directPrecedents.areas.items.length; i++) { - // Highlight and console the address of each precedent cell. - directPrecedents.areas.items[i].format.fill.color = "Yellow"; - console.log(` ${directPrecedents.areas.items[i].address}`); - } + + // Registers the onParagraphAdded event handler on the document. + + await Word.run(async (context) => { + eventContext = context.document.onParagraphAdded.add(paragraphAdded); await context.sync(); + + console.log("Added event handler for when paragraphs are added."); }); -'Excel.Worksheet#customProperties:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/26-document/custom-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml - await Excel.run(async (context) => { - // Load the keys and values of all custom properties in the current worksheet. - const customWorksheetProperties = context.workbook.worksheets.getActiveWorksheet().customProperties; - customWorksheetProperties.load(["key", "value"]); - await context.sync(); - // Log each custom property to the console. - // Note that your document may have more properties than those you have set using this snippet. - customWorksheetProperties.items.forEach((property) => { - console.log(`${property.key}:${property.value}`); + async function paragraphAdded(event: Word.ParagraphAddedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs that were added:`, event.uniqueLocalIds); }); - }); -'Excel.Worksheet#onRowSorted:member': + } +Word.Document#onParagraphChanged:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/event-column-and-row-sort.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml - await Excel.run(async (context) => { - console.log("Adding row handler"); - const sheet = context.workbook.worksheets.getActiveWorksheet(); - // This will fire whenever a row has been moved as the result of a sort action. - sheet.onRowSorted.add((event) => { - return Excel.run((context) => { - console.log("Row sorted: " + event.address); - const sheet = context.workbook.worksheets.getActiveWorksheet(); + // Registers the onParagraphChanged event handler on the document. - // Clear formatting for section, then highlight the sorted area. - sheet.getRange("A1:E5").format.fill.clear(); - if (event.address !== "") { - sheet.getRanges(event.address).format.fill.color = "yellow"; - } + await Word.run(async (context) => { + eventContext = context.document.onParagraphChanged.add(paragraphChanged); + await context.sync(); - return context.sync(); - }); - }); + console.log("Added event handler for when content is changed in paragraphs."); }); -'Excel.Worksheet#onColumnSorted:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/event-column-and-row-sort.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml - await Excel.run(async (context) => { - console.log("Adding column handler"); - const sheet = context.workbook.worksheets.getActiveWorksheet(); - // This will fire whenever a column has been moved as the result of a sort action. - sheet.onColumnSorted.add((event) => { - return Excel.run((context) => { - console.log("Column sorted: " + event.address); - const sheet = context.workbook.worksheets.getActiveWorksheet(); + async function paragraphChanged(event: Word.ParagraphChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs where content was changed:`, event.uniqueLocalIds); + }); + } +Word.Document#onParagraphDeleted:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml - // Clear formatting for section, then highlight the sorted area. - sheet.getRange("A1:E5").format.fill.clear(); - if (event.address !== "") { - sheet.getRanges(event.address).format.fill.color = "yellow"; - } - return context.sync(); - }); - }); + // Registers the onParagraphDeleted event handler on the document. + + await Word.run(async (context) => { + eventContext = context.document.onParagraphDeleted.add(paragraphDeleted); + await context.sync(); + + console.log("Added event handlers for when paragraphs are deleted."); }); -'Excel.Worksheet#onChanged:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-worksheet.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets.getItem("Sample"); - sheet.onChanged.add(onChange); - await context.sync(); - console.log("Added a worksheet-level data-changed event handler."); - }); -'Excel.Worksheet#onSingleClicked:member': + async function paragraphDeleted(event: Word.ParagraphDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs that were deleted:`, event.uniqueLocalIds); + }); + } +Word.Document#properties:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/event-worksheet-single-click.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/get-built-in-properties.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - sheet.onSingleClicked.add((event) => { - return Excel.run((context) => { - console.log(`Click detected at ${event.address} (pixel offset from upper-left cell corner: ${event.offsetX}, ${event.offsetY})`); - return context.sync(); - }); - }); - console.log("The worksheet click handler is registered."); + await Word.run(async (context) => { + const builtInProperties: Word.DocumentProperties = context.document.properties; + builtInProperties.load("*"); // Let's get all! await context.sync(); + console.log(JSON.stringify(builtInProperties, null, 4)); }); -'Excel.Worksheet#showOutlineLevels:member(1)': +Word.Document#settings:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/outline.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - // This collapses the entire outline. - sheet.showOutlineLevels(1, 1); - await context.sync(); + // Gets all custom settings this add-in set on this document. + + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + settings.load("items"); + await context.sync(); + + if (settings.items.length == 0) { + console.log("There are no settings."); + } else { + console.log("All settings:"); + for (let i = 0; i < settings.items.length; i++) { + console.log(settings.items[i]); + } + } }); +Word.Document#windows:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/outline.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - // This shows the top 3 outline levels; collapsing any additional sublevels. - sheet.showOutlineLevels(3, 3); - await context.sync(); + await Word.run(async (context) => { + // Gets the document windows. + const windows: Word.WindowCollection = context.document.windows; + windows.load("windows/items/length"); + + await context.sync(); + + console.log(`Number of windows for this document: ${windows.items.length}`); }); -'Excel.Worksheet#pivotTables:member': +Word.DocumentCompareOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-get-pivottables.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/compare-documents.yaml + + + // Compares the current document with a specified external document. + + await Word.run(async (context) => { + // Absolute path of an online or local document. + const filePath = (document.getElementById("filePath") as HTMLInputElement).value; + // Options that configure the compare operation. + const options: Word.DocumentCompareOptions = { + compareTarget: Word.CompareTarget.compareTargetCurrent, + detectFormatChanges: false + // Other options you choose... + }; + context.document.compare(filePath, options); - await Excel.run(async (context) => { - // Get the names of all the PivotTables in the current worksheet. - const pivotTables = context.workbook.worksheets.getActiveWorksheet().pivotTables; - pivotTables.load("name"); await context.sync(); - // Display the names in the console. - console.log("PivotTables in the current worksheet:") - pivotTables.items.forEach((pivotTable) => { - console.log(`\t${pivotTable.name}`); - }); + console.log("Differences shown in the current document."); }); -'Excel.Worksheet#slicers:member': +Word.DocumentCreated:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/38-pivottable/pivottable-slicer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Pivot"); - const slicer = sheet.slicers.add( - "Farm Sales", /* The slicer data source. For PivotTables, this can be the PivotTable object reference or name. */ - "Type" /* The field in the data source to filter by. For PivotTables, this can be a PivotField object reference or ID. */ - ); - slicer.name = "Fruit Slicer"; - await context.sync(); + + // Updates the text of the current document with the text from another + document passed in as a Base64-encoded string. + + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + const externalDoc: Word.DocumentCreated = context.application.createDocument(externalDocument); + await context.sync(); + + if (!Office.context.requirements.isSetSupported("WordApiHiddenDocument", "1.3")) { + console.warn("The WordApiHiddenDocument 1.3 requirement set isn't supported on this client so can't proceed. Try this action on a platform that supports this requirement set."); + return; + } + + const externalDocBody: Word.Body = externalDoc.body; + externalDocBody.load("text"); + await context.sync(); + + // Insert the external document's text at the beginning of the current document's body. + const externalDocBodyText = externalDocBody.text; + const currentDocBody: Word.Body = context.document.body; + currentDocBody.insertText(externalDocBodyText, Word.InsertLocation.start); + await context.sync(); }); -'Excel.Worksheet#getRanges:member(1)': +Word.DocumentProperties:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/42-range/range-areas.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/get-built-in-properties.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const specifiedRanges = sheet.getRanges("D3:D5, G3:G5"); - specifiedRanges.format.fill.color = "pink"; + await Word.run(async (context) => { + const builtInProperties: Word.DocumentProperties = context.document.properties; + builtInProperties.load("*"); // Let's get all! await context.sync(); - }) -'Excel.Worksheet#autoFilter:member': + console.log(JSON.stringify(builtInProperties, null, 4)); + }); +Word.DocumentPropertyType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-auto-filter.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - const farmData = sheet.getUsedRange(); - // This filter will only show the rows with the top 25% of values in column 3. - sheet.autoFilter.apply(farmData, 3, { criterion1: "25", filterOn: Excel.FilterOn.topPercent }); + await Word.run(async (context) => { + const properties: Word.CustomPropertyCollection = context.document.properties.customProperties; + properties.load("key,type,value"); + await context.sync(); + for (let i = 0; i < properties.items.length; i++) + console.log("Property Name:" + properties.items[i].key + "; Type=" + properties.items[i].type + "; Property Value=" + properties.items[i].value); }); -'Excel.Worksheet#copy:member(1)': +Word.DropDownListContentControl:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-copy.yaml - - await Excel.run(async (context) => { + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - let myWorkbook = context.workbook; - let sampleSheet = myWorkbook.worksheets.getActiveWorksheet(); - let copiedSheet = sampleSheet.copy("End") - sampleSheet.load("name"); - copiedSheet.load("name"); + // Places a dropdown list content control at the end of the selection. - await context.sync(); + await Word.run(async (context) => { + let selection = context.document.getSelection(); + selection.getRange(Word.RangeLocation.end).insertContentControl(Word.ContentControlType.dropDownList); + await context.sync(); - console.log("'" + sampleSheet.name + "' was copied to '" + copiedSheet.name + "'") + console.log("Dropdown list content control inserted at the end of the selection."); }); -'Excel.Worksheet#findAllOrNullObject:member(1)': +Word.DropDownListContentControl#addListItem:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-find-all.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const foundRanges = sheet.findAllOrNullObject("Complete", { - completeMatch: true, - matchCase: false - }); + // Adds the provided list item to the first dropdown list content control in + the selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-add") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); - if (foundRanges.isNullObject) { - console.log("No complete projects"); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; } else { - foundRanges.format.fill.color = "green" + selectedContentControl = parentContentControl; } - }); -'Excel.Worksheet#showGridlines:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/gridlines.yaml + } - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - sheet.showGridlines = true; + selectedContentControl.dropDownListContentControl.addListItem(listItemText); + await context.sync(); - await context.sync(); + console.log(`List item added to control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.Worksheet#getNext:member(1)': +Word.DropDownListContentControl#deleteAllListItems:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - await Excel.run(async (context) => { - const sheets = context.workbook.worksheets; - // We don't want to include the default worksheet that was created - // when the workbook was created, so our "firstSheet" will be the one - // after the literal first. Note chaining of navigation methods. - const firstSheet = sheets.getFirst().getNext(); - const lastSheet = sheets.getLast(); - const firstTaxRateRange = firstSheet.getRange("B2"); - const lastTaxRateRange = lastSheet.getRange("B2"); + // Deletes the list items from first dropdown list content control found in + the selection. - firstSheet.load("name"); - lastSheet.load("name"); - firstTaxRateRange.load("text"); - lastTaxRateRange.load("text"); + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); - let firstYear = firstSheet.name.substr(5, 4); - let lastYear = lastSheet.name.substr(5, 4); - console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } - await context.sync(); + console.log( + `About to delete the list from the dropdown list content control with ID ${selectedContentControl.id}` + ); + selectedContentControl.dropDownListContentControl.deleteAllListItems(); + await context.sync(); + + console.log("Deleted the list from the dropdown list content control."); }); -'Excel.Worksheet#getPrevious:member(1)': +Word.DropDownListContentControl#listItems:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - await Excel.run(async (context) => { - const sheets = context.workbook.worksheets; - const currentSheet = sheets.getActiveWorksheet(); - const previousYearSheet = currentSheet.getPrevious(); - const currentTaxDueRange = currentSheet.getRange("C2"); - const previousTaxDueRange = previousYearSheet.getRange("C2"); - currentSheet.load("name"); - previousYearSheet.load("name"); - currentTaxDueRange.load("text"); - previousTaxDueRange.load("text"); + // Deletes the provided list item from the first dropdown list content + control in the selection. + + await Word.run(async (context) => { + const listItemText = (document.getElementById("item-to-delete") as HTMLInputElement).value.trim(); + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.dropDownList] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,dropDownListContentControl"); + await context.sync(); + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,dropDownListContentControl"); await context.sync(); - let currentYear = currentSheet.name.substr(5, 4); - let previousYear = previousYearSheet.name.substr(5, 4); - console.log("Two Year Tax Due Comparison", `Tax due for ${currentYear} was ${currentTaxDueRange.text[0][0]}\nTax due for ${previousYear} was ${previousTaxDueRange.text[0][0]}`) + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.dropDownList) { + console.warn("No dropdown list content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } - await context.sync(); - }); -'Excel.Worksheet#tabColor:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/tab-color.yaml + let selectedDropdownList: Word.DropDownListContentControl = selectedContentControl.dropDownListContentControl; + selectedDropdownList.listItems.load("items/*"); + await context.sync(); - await Excel.run(async (context) => { - const activeSheet = context.workbook.worksheets.getActiveWorksheet(); - activeSheet.tabColor = "#FF0000"; + let listItems: Word.ContentControlListItemCollection = selectedContentControl.dropDownListContentControl.listItems; + let itemToDelete: Word.ContentControlListItem = listItems.items.find((item) => item.displayText === listItemText); + if (!itemToDelete) { + console.warn(`List item doesn't exist in control with ID ${selectedContentControl.id}: ${listItemText}`) + return; + } + + itemToDelete.delete(); + await context.sync(); - await context.sync(); + console.log(`List item deleted from control with ID ${selectedContentControl.id}: ${listItemText}`); }); -'Excel.WorksheetAddedEventArgs#worksheetId:member': +Word.ErrorCodes:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - async function onWorksheetAdd(event) { - await Excel.run(async (context) => { - console.log( - "Handler for worksheet onAdded event has been triggered. Newly added worksheet Id : " + - event.worksheetId - ); - }); + + 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. + if (error.code === Word.ErrorCodes.itemNotFound) { + console.warn("No checkbox content control is currently selected."); + } else { + console.error(error); + } + } } -'Excel.WorksheetCollection#onActivated:member': +Word.EventSource:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - let sheets = context.workbook.worksheets; - sheets.onActivated.add(onActivate); - await context.sync(); - console.log("A handler has been registered for the OnActivate event."); - }); -'Excel.WorksheetCollection#onAdded:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + // Registers event handlers. - await Excel.run(async (context) => { - let sheet = context.workbook.worksheets; - sheet.onAdded.add(onWorksheetAdd); + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.track(); + await context.sync(); - await context.sync(); - console.log("A handler has been registered for the OnAdded event."); + eventContexts[0] = body.onCommentAdded.add(onEventHandler); + eventContexts[1] = body.onCommentChanged.add(onChangedHandler); + eventContexts[2] = body.onCommentDeleted.add(onEventHandler); + eventContexts[3] = body.onCommentDeselected.add(onEventHandler); + eventContexts[4] = body.onCommentSelected.add(onEventHandler); + await context.sync(); + + console.log("Event handlers registered."); }); -'Excel.WorksheetCollection#onDeactivated:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml - await Excel.run(async (context) => { - let sheets = context.workbook.worksheets; - sheets.onDeactivated.add(onDeactivate); - await context.sync(); - console.log("A handler has been registered for the OnDeactivate event."); - }); -'Excel.WorksheetCollection#addFromBase64:member(1)': + async function onEventHandler(event: Word.CommentEventArgs) { + // Handler for all events except onCommentChanged. + await Word.run(async (context) => { + console.log(`${event.type} event detected. Event source: ${event.source}. Comment info:`, event.commentDetails); + }); + } +Word.EventType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml - const myFile = document.getElementById("file"); - const reader = new FileReader(); + async function contentControlDeleted(event: + Word.ContentControlDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.eventType} event detected. IDs of content controls that were deleted:`, event.ids); + }); + } +Word.Field:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - reader.onload = (event) => { - Excel.run((context) => { - // strip off the metadata before the base64-encoded string - const startIndex = reader.result.toString().indexOf("base64,"); - const workbookContents = reader.result.toString().substr(startIndex + 7); - - const sheets = context.workbook.worksheets; - sheets.addFromBase64( - workbookContents, - null, // get all the worksheets - Excel.WorksheetPositionType.end // insert them after the current workbook's worksheets - ); - return context.sync(); - }); - }; + // Gets the first field in the document. + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); - // read in the file as a data URL so we can parse the base64-encoded string + await context.sync(); - reader.readAsDataURL(myFile.files[0]); -'Excel.WorksheetCollection#getFirst:member(1)': + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } + }); +Word.Field#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml - - await Excel.run(async (context) => { - const sheets = context.workbook.worksheets; + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - // We don't want to include the default worksheet that was created - // when the workbook was created, so our "firstSheet" will be the one - // after the literal first. Note chaining of navigation methods. - const firstSheet = sheets.getFirst().getNext(); - const lastSheet = sheets.getLast(); - const firstTaxRateRange = firstSheet.getRange("B2"); - const lastTaxRateRange = lastSheet.getRange("B2"); - firstSheet.load("name"); - lastSheet.load("name"); - firstTaxRateRange.load("text"); - lastTaxRateRange.load("text"); + // Deletes the first field in the document. - await context.sync(); + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(); - let firstYear = firstSheet.name.substr(5, 4); - let lastYear = lastSheet.name.substr(5, 4); - console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + await context.sync(); + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + field.delete(); await context.sync(); + + console.log("The first field in the document was deleted."); + } }); -'Excel.WorksheetCollection#getLast:member(1)': +Word.Field#select:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheets = context.workbook.worksheets; - // We don't want to include the default worksheet that was created - // when the workbook was created, so our "firstSheet" will be the one - // after the literal first. Note chaining of navigation methods. - const firstSheet = sheets.getFirst().getNext(); - const lastSheet = sheets.getLast(); - const firstTaxRateRange = firstSheet.getRange("B2"); - const lastTaxRateRange = lastSheet.getRange("B2"); + // Gets and updates the first field in the selection. - firstSheet.load("name"); - lastSheet.load("name"); - firstTaxRateRange.load("text"); - lastTaxRateRange.load("text"); + await Word.run(async (context) => { + let field = context.document.getSelection().fields.getFirstOrNullObject(); + field.load(["code", "result", "type", "locked"]); - await context.sync(); + await context.sync(); - let firstYear = firstSheet.name.substr(5, 4); - let lastYear = lastSheet.name.substr(5, 4); - console.log(`Tax Rate change from ${firstYear} to ${lastYear}`, `Tax rate for ${firstYear}: ${firstTaxRateRange.text[0][0]}\nTax rate for ${lastYear}: ${lastTaxRateRange.text[0][0]}`) + if (field.isNullObject) { + console.log("No field in selection."); + } else { + console.log("Before updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + + field.updateResult(); + field.select(); + await context.sync(); + field.load(["code", "result"]); await context.sync(); + + console.log("After updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + } }); -'Excel.WorksheetCustomPropertyCollection#add:member(1)': +Word.Field#updateResult:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/26-document/custom-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - // Get the key/value pair from the task pane. - const userKey = $("#key").text(); - const userValue = $("#value").text(); - // Add the custom property. - const customWorksheetProperties = context.workbook.worksheets.getActiveWorksheet().customProperties; - customWorksheetProperties.add(userKey, userValue); + // Gets and updates the first field in the selection. + + await Word.run(async (context) => { + let field = context.document.getSelection().fields.getFirstOrNullObject(); + field.load(["code", "result", "type", "locked"]); await context.sync(); - console.log(`Successfully set custom worksheet property ${userKey}:${userValue}.`); + if (field.isNullObject) { + console.log("No field in selection."); + } else { + console.log("Before updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + + field.updateResult(); + field.select(); + await context.sync(); + + field.load(["code", "result"]); + await context.sync(); + + console.log("After updating:", "Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result)); + } }); -'Excel.WorksheetFreezePanes#freezeAt:member(1)': +Word.Field#code:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Freeze the specified range in top-and-left-most pane of the worksheet. - sheet.freezePanes.freezeAt(sheet.getRange("H2:K5")); + // Gets the first field in the document. - await context.sync(); + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } }); -'Excel.WorksheetFreezePanes#freezeColumns:member(1)': +Word.Field#kind:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Freeze the first two columns in the worksheet. - sheet.freezePanes.freezeColumns(2); + // Gets the first field in the document. - await context.sync(); + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } }); -'Excel.WorksheetFreezePanes#freezeRows:member(1)': +Word.Field#locked:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - // Freeze the top two rows in the worksheet. - sheet.freezePanes.freezeRows(2); + // Gets the first field in the selection and toggles between setting it to + locked or unlocked. + + await Word.run(async (context) => { + let field = context.document.getSelection().fields.getFirstOrNullObject(); + field.load(["code", "result", "type", "locked"]); + await context.sync(); + if (field.isNullObject) { + console.log("The selection has no fields."); + } else { + console.log(`The first field in the selection is currently ${field.locked ? "locked" : "unlocked"}.`); + field.locked = !field.locked; await context.sync(); + + console.log(`The first field in the selection is now ${field.locked ? "locked" : "unlocked"}.`); + } }); -'Excel.WorksheetFreezePanes#getLocationOrNullObject:member(1)': +Word.Field#parentBody:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - const frozenRange = sheet.freezePanes.getLocationOrNullObject(); - frozenRange.load("address"); - await context.sync(); + // Gets the parent body of the first field in the document. - if (frozenRange.isNullObject) { - console.log(`The worksheet does not contain a frozen pane.`); - } else { - console.log(`The address of the frozen range (cells that are frozen in the top-and-left-most pane) is "${frozenRange.address}"`); - } + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load("parentBody/text"); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + const parentBody: Word.Body = field.parentBody; + console.log("Text of first field's parent body: " + JSON.stringify(parentBody.text)); + } }); -'Excel.WorksheetFreezePanes#unfreeze:member(1)': +Word.Field#result:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/54-worksheet/worksheet-freeze-panes.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getItem("Sample"); - sheet.freezePanes.unfreeze(); - await context.sync(); + // Gets the first field in the document. + + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } }); -'Excel.WorksheetProtection#protect:member(1)': +Word.Field#type:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - let activeSheet = context.workbook.worksheets.getActiveWorksheet(); - activeSheet.load("protection/protected"); - await context.sync(); + // Gets the first field in the document. - if (!activeSheet.protection.protected) { - activeSheet.protection.protect(); - } + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); + + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } }); +Word.FieldCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - let password = await passwordHandler(); - passwordHelper(password); + // Gets all fields in the document body. - await Excel.run(async (context) => { - let activeSheet = context.workbook.worksheets.getActiveWorksheet(); - activeSheet.load("protection/protected"); + await Word.run(async (context) => { + const fields: Word.FieldCollection = context.document.body.fields.load("items"); + + await context.sync(); + if (fields.items.length === 0) { + console.log("No fields in this document."); + } else { + fields.load(["code", "result"]); await context.sync(); - if (!activeSheet.protection.protected) { - activeSheet.protection.protect(null, password); + for (let i = 0; i < fields.items.length; i++) { + console.log(`Field ${i + 1}'s code: ${fields.items[i].code}`, `Field ${i + 1}'s result: ${JSON.stringify(fields.items[i].result)}`); } + } }); -'Excel.WorksheetProtection#unprotect:member(1)': +Word.FieldCollection#getFirstOrNullObject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - let activeSheet = context.workbook.worksheets.getActiveWorksheet(); - activeSheet.protection.unprotect(); - }); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/50-workbook/data-protection.yaml - let password = await passwordHandler(); + // Gets the first field in the document. - passwordHelper(password); + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); - await Excel.run(async (context) => { - let activeSheet = context.workbook.worksheets.getActiveWorksheet(); - activeSheet.protection.unprotect(password); + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } }); -'Excel.WorksheetSingleClickedEventArgs#address:member': +Word.FieldCollection#items:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/excel/30-events/event-worksheet-single-click.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - await Excel.run(async (context) => { - const sheet = context.workbook.worksheets.getActiveWorksheet(); - sheet.onSingleClicked.add((event) => { - return Excel.run((context) => { - console.log(`Click detected at ${event.address} (pixel offset from upper-left cell corner: ${event.offsetX}, ${event.offsetY})`); - return context.sync(); - }); - }); - console.log("The worksheet click handler is registered."); + // Gets all fields in the document body. + + await Word.run(async (context) => { + const fields: Word.FieldCollection = context.document.body.fields.load("items"); + + await context.sync(); + if (fields.items.length === 0) { + console.log("No fields in this document."); + } else { + fields.load(["code", "result"]); await context.sync(); + + for (let i = 0; i < fields.items.length; i++) { + console.log(`Field ${i + 1}'s code: ${fields.items[i].code}`, `Field ${i + 1}'s result: ${JSON.stringify(fields.items[i].result)}`); + } + } }); -'Office.RoamingSettings#get:member(1)': +Word.FieldKind:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/10-roaming-settings/roaming-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - var settingName = $("#settingName").val(); - var settingValue = Office.context.roamingSettings.get(settingName); + // Gets the first field in the document. - $("#settingValue").val(settingValue); + await Word.run(async (context) => { + const field: Word.Field = context.document.body.fields.getFirstOrNullObject(); + field.load(["code", "result", "locked", "type", "data", "kind"]); - console.log(`The value of setting "${settingName}" is "${settingValue}".`); -'Office.RoamingSettings#set:member(1)': + await context.sync(); + + if (field.isNullObject) { + console.log("This document has no fields."); + } else { + console.log("Code of first field: " + field.code, "Result of first field: " + JSON.stringify(field.result), "Type of first field: " + field.type, "Is the first field locked? " + field.locked, "Kind of the first field: " + field.kind); + } + }); +Word.FieldType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/10-roaming-settings/roaming-settings.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - var settingName = $("#settingName").val(); - var settingValue = $("#settingValue").val(); + // Inserts a Date field before selection. - Office.context.roamingSettings.set(settingName, settingValue); + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection().getRange(); - console.log(`Setting "${settingName}" set to value "${settingValue}".`); -'Office.RoamingSettings#saveAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/10-roaming-settings/roaming-settings.yaml + const field: Word.Field = range.insertField(Word.InsertLocation.before, Word.FieldType.date, '\\@ "M/d/yyyy h:mm am/pm"', true); - // Save settings in the mailbox to make it available in future sessions. + field.load("result,code"); + await context.sync(); - Office.context.roamingSettings.saveAsync(function(result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + if (field.isNullObject) { + console.log("There are no fields in this document."); } else { - console.log(`Settings saved with status: ${result.status}`); + console.log("Code of the field: " + field.code, "Result of the field: " + JSON.stringify(field.result)); } }); -'Office.CustomProperties#get:member(1)': +Word.GeometricShapeType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - var propertyName = $("#propertyName").val(); - var propertyValue = customProps.get(propertyName); - - $("#propertyValue").val(propertyValue); + await Word.run(async (context) => { + // Inserts a heptagon geometric shape at the beginning of the selection. + const selection: Word.Range = context.document.getSelection(); + const shapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + }; + selection.insertGeometricShape(Word.GeometricShapeType.heptagon, shapeOptions); + await context.sync(); - console.log(`The value of custom property "${propertyName}" is - "${propertyValue}".`); -'Office.CustomProperties#set:member(1)': + console.log("Inserted a heptagon."); + }); +Word.GetTextOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-text.yaml - var propertyName = $("#propertyName").val(); - var propertyValue = $("#propertyValue").val(); + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); - customProps.set(propertyName, propertyValue); + const text = paragraph.getText(); + const textIncludingHidden = paragraph.getText({ IncludeHiddenText: true }); + const textIncludingDeleted = paragraph.getText({ IncludeTextMarkedAsDeleted: true }); - console.log(`Custom property "${propertyName}" set to value - "${propertyValue}".`); -'Office.CustomProperties#remove:member(1)': + await context.sync(); + + console.log("Text:- " + text.value, "Including hidden text:- " + textIncludingHidden.value, "Including text marked as deleted:- " + textIncludingDeleted.value); + }); +Word.HeaderFooterType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-header-and-footer.yaml - var propertyName = $("#propertyName").val(); - customProps.remove(propertyName); - - console.log(`Custom property "${propertyName}" removed.`); -'Office.AppointmentCompose#loadCustomPropertiesAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + await Word.run(async (context) => { + context.document.sections + .getFirst() + .getHeader(Word.HeaderFooterType.primary) + .insertParagraph("This is a primary header.", "End"); - Office.context.mailbox.item.loadCustomPropertiesAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log("Loaded following custom properties:"); - customProps = result.value; - var dataKey = Object.keys(customProps)[0]; - var data = customProps[dataKey]; - for (var propertyName in data) - { - var propertyValue = data[propertyName]; - console.log(`${propertyName}: ${propertyValue}`); - } - } - else { - console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); - } + await context.sync(); }); -'Office.AppointmentRead#loadCustomPropertiesAsync:member(1)': +Word.ImageFormat:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.loadCustomPropertiesAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log("Loaded following custom properties:"); - customProps = result.value; - var dataKey = Object.keys(customProps)[0]; - var data = customProps[dataKey]; - for (var propertyName in data) - { - var propertyValue = data[propertyName]; - console.log(`${propertyName}: ${propertyValue}`); - } - } - else { - console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); - } - }); -'Office.MessageCompose#loadCustomPropertiesAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml - Office.context.mailbox.item.loadCustomPropertiesAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log("Loaded following custom properties:"); - customProps = result.value; - var dataKey = Object.keys(customProps)[0]; - var data = customProps[dataKey]; - for (var propertyName in data) - { - var propertyValue = data[propertyName]; - console.log(`${propertyName}: ${propertyValue}`); - } - } - else { - console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); - } - }); -'Office.MessageRead#loadCustomPropertiesAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/15-item-custom-properties/load-set-get-save.yaml + // Gets the first image in the document. - Office.context.mailbox.item.loadCustomPropertiesAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log("Loaded following custom properties:"); - customProps = result.value; - var dataKey = Object.keys(customProps)[0]; - var data = customProps[dataKey]; - for (var propertyName in data) - { - var propertyValue = data[propertyName]; - console.log(`${propertyName}: ${propertyValue}`); - } - } - else { - console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`); - } - }); -'Office.AppointmentCompose#getSelectedDataAsync:member(2)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/20-item-body/get-selected-data.yaml + await Word.run(async (context) => { + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); - Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var text = asyncResult.value.data; - var prop = asyncResult.value.sourceProperty; - console.log("Selected text in " + prop + ": " + text); - } else { - console.error(asyncResult.error); - } + await context.sync(); + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. + const base64 = firstPicture.getBase64ImageSrc(); + + await context.sync(); + console.log(base64.value); }); -'Office.MessageCompose#getSelectedDataAsync:member(2)': +Word.ImportedStylesConflictBehavior:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/20-item-body/get-selected-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml - Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var text = asyncResult.value.data; - var prop = asyncResult.value.sourceProperty; - console.log("Selected text in " + prop + ": " + text); - } else { - console.error(asyncResult.error); - } + + // Imports styles from JSON. + + await Word.run(async (context) => { + const str = + '{"styles":[{"baseStyle":"Default Paragraph Font","builtIn":false,"inUse":true,"linked":false,"nameLocal":"NewCharStyle","priority":2,"quickStyle":true,"type":"Character","unhideWhenUsed":false,"visibility":false,"paragraphFormat":null,"font":{"name":"DengXian Light","size":16.0,"bold":true,"italic":false,"color":"#F1A983","underline":"None","subscript":false,"superscript":true,"strikeThrough":true,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#FF0000"}},{"baseStyle":"Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewParaStyle","nameLocal":"NewParaStyle","priority":1,"quickStyle":true,"type":"Paragraph","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Centered","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":72.0,"lineSpacing":18.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":72.0,"spaceAfter":30.0,"spaceBefore":30.0,"widowControl":true},"font":{"name":"DengXian","size":14.0,"bold":true,"italic":true,"color":"#8DD873","underline":"Single","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":true,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#00FF00"}},{"baseStyle":"Table Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewTableStyle","nameLocal":"NewTableStyle","priority":100,"type":"Table","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Left","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":0.0,"lineSpacing":12.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":0.0,"spaceAfter":0.0,"spaceBefore":0.0,"widowControl":true},"font":{"name":"DengXian","size":20.0,"bold":false,"italic":true,"color":"#D86DCB","underline":"None","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"tableStyle":{"allowBreakAcrossPage":true,"alignment":"Left","bottomCellMargin":0.0,"leftCellMargin":0.08,"rightCellMargin":0.08,"topCellMargin":0.0,"cellSpacing":0.0},"shading":{"backgroundPatternColor":"#60CAF3"}}]}'; + const styles = context.document.importStylesFromJson(str); + + // If you'd like to set how conflicting styles are handled, use the importedStylesConflictBehavior parameter that was introduced in the Desktop 1.1 requirement set. "Ignore" is the default. + ////const styles = context.document.importStylesFromJson(str, Word.ImportedStylesConflictBehavior.Ignore); + + await context.sync(); + console.log("Styles imported from JSON:", styles); }); -'Office.AppointmentCompose#setSelectedDataAsync:member(1)': +Word.InlinePicture#getBase64ImageSrc:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/20-item-body/set-selected-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.setSelectedDataAsync("Replaced", - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Selected text has been updated successfully."); - } else { - console.error(asyncResult.error); - } + + // Gets the first image in the document. + + await Word.run(async (context) => { + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); + + await context.sync(); + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. + const base64 = firstPicture.getBase64ImageSrc(); + + await context.sync(); + console.log(base64.value); }); -'Office.MessageCompose#setSelectedDataAsync:member(1)': +Word.InlinePicture:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/20-item-body/set-selected-data.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.setSelectedDataAsync("Replaced", - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Selected text has been updated successfully."); - } else { - console.error(asyncResult.error); - } + + // Inserts an image anchored to the last paragraph. + + await Word.run(async (context) => { + context.document.body.paragraphs + .getLast() + .insertParagraph("", "After") + .insertInlinePictureFromBase64(base64Image, "End"); + + await context.sync(); }); -'Office.AppointmentCompose#close:member(1)': +Word.InlinePicture#imageFormat:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/25-item-save-and-close/close.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.close(); -'Office.MessageCompose#close:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/25-item-save-and-close/close.yaml - Office.context.mailbox.item.close(); -'Office.AppointmentCompose#saveAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/25-item-save-and-close/save.yaml + // Gets the first image in the document. - Office.context.mailbox.item.saveAsync(function (result) { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log(`saveAsync succeeded, itemId is ${result.value}`); - } - else { - console.error(`saveAsync failed with message ${result.error.message}`); - } + await Word.run(async (context) => { + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); + + await context.sync(); + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. + const base64 = firstPicture.getBase64ImageSrc(); + + await context.sync(); + console.log(base64.value); }); -'Office.MessageCompose#bcc:member': +Word.InlinePictureCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.bcc.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgBcc = asyncResult.value; - console.log("Message being blind-copied to:"); - for (var i = 0; i < msgBcc.length; i++) { - console.log(msgBcc[i].displayName + " (" + msgBcc[i].emailAddress + ")"); - } - } else { - console.error(asyncResult.error); - } + + // Gets the first image in the document. + + await Word.run(async (context) => { + const firstPicture: Word.InlinePicture = context.document.body.inlinePictures.getFirst(); + firstPicture.load("width, height, imageFormat"); + + await context.sync(); + console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`, `Image format: ${firstPicture.imageFormat}`); + // Get the image encoded as Base64. + const base64 = firstPicture.getBase64ImageSrc(); + + await context.sync(); + console.log(base64.value); }); +Word.InsertFileOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml - var email = $("#emailBcc") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.bcc.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting Bcc field."); - } else { - console.error(asyncResult.error); - } + // Inserts content (applying selected settings) from another document passed + in as a Base64-encoded string. + + await Word.run(async (context) => { + // Use the Base64-encoded string representation of the selected .docx file. + context.document.insertFileFromBase64(externalDocument, "Replace", { + importTheme: true, + importStyles: true, + importParagraphSpacing: true, + importPageColor: true, + importChangeTrackingMode: true, + importCustomProperties: true, + importCustomXmlParts: true, + importDifferentOddEvenPages: true + }); + await context.sync(); }); -'Office.Recipients#getAsync:member(2)': +Word.InsertLocation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-section-breaks.yaml - Office.context.mailbox.item.bcc.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgBcc = asyncResult.value; - console.log("Message being blind-copied to:"); - for (var i = 0; i < msgBcc.length; i++) { - console.log(msgBcc[i].displayName + " (" + msgBcc[i].emailAddress + ")"); - } - } else { - console.error(asyncResult.error); - } + + // Inserts a section without an associated page break. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionContinuous, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section without an associated page break."); }); +Word.InsertShapeOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.cc.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgCc = asyncResult.value; - console.log("Message being copied to:"); - for (var i = 0; i < msgCc.length; i++) { - console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // Inserts a text box at the beginning of the selection. + const range: Word.Range = context.document.getSelection(); + const insertShapeOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100 + }; + + const newTextBox: Word.Shape = range.insertTextBox("placeholder text", insertShapeOptions); + await context.sync(); + + console.log("Inserted a text box at the beginning of the current selection."); }); +Word.List:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - Office.context.mailbox.item.optionalAttendees.getAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptOptionalAttendees = asyncResult.value; - for (var i = 0; i < apptOptionalAttendees.length; i++) { - console.log( - "Optional attendees: " + - apptOptionalAttendees[i].displayName + - " (" + - apptOptionalAttendees[i].emailAddress + - ") - response: " + - apptOptionalAttendees[i].appointmentResponse - ); - } - } else { - console.error(asyncResult.error); - } + + // This example starts a new list with the second paragraph. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set up list level for the list item. + paragraph.listItem.level = 4; + + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + + await context.sync(); }); +Word.List#insertParagraph:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - Office.context.mailbox.item.requiredAttendees.getAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptRequiredAttendees = asyncResult.value; - for (var i = 0; i < apptRequiredAttendees.length; i++) { - console.log( - "Required attendees: " + - apptRequiredAttendees[i].displayName + - " (" + - apptRequiredAttendees[i].emailAddress + - ") - response: " + - apptRequiredAttendees[i].appointmentResponse - ); - } - } else { - console.error(asyncResult.error); - } + + // This example starts a new list with the second paragraph. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set up list level for the list item. + paragraph.listItem.level = 4; + + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + + await context.sync(); }); +Word.List#setLevelBullet:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - Office.context.mailbox.item.to.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgTo = asyncResult.value; - console.log("Message being sent to:"); - for (var i = 0; i < msgTo.length; i++) { - console.log(msgTo[i].displayName + " (" + msgTo[i].emailAddress + ")"); - } - } else { - console.error(asyncResult.error); - } + + // Inserts a list starting with the first paragraph then set numbering and + bullet types of the list items. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Use the first paragraph to start a new list. + const list: Word.List = paragraphs.items[0].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set numbering for list level 1. + list.setLevelNumbering(0, Word.ListNumbering.arabic); + + // Set bullet type for list level 5. + list.setLevelBullet(4, Word.ListBullet.arrow); + + // Set list level for the last item in this list. + paragraph.listItem.level = 4; + + list.load("levelTypes"); + + await context.sync(); }); -'Office.Recipients#setAsync:member(2)': +Word.List#setLevelNumbering:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var email = $("#emailBcc") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.bcc.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting Bcc field."); - } else { - console.error(asyncResult.error); - } + // Inserts a list starting with the first paragraph then set numbering and + bullet types of the list items. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Use the first paragraph to start a new list. + const list: Word.List = paragraphs.items[0].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set numbering for list level 1. + list.setLevelNumbering(0, Word.ListNumbering.arabic); + + // Set bullet type for list level 5. + list.setLevelBullet(4, Word.ListBullet.arrow); + + // Set list level for the last item in this list. + paragraph.listItem.level = 4; + + list.load("levelTypes"); + + await context.sync(); }); +Word.List#levelExistences:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var email = $("#emailCc") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.cc.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting Cc field."); - } else { - console.error(asyncResult.error); + // Gets information about the first list in the document. + + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); + + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; } - }); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); - var email = $("#emailOptional") - .val() - .toString(); - var emailArray = [email]; + await context.sync(); - Office.context.mailbox.item.optionalAttendees.setAsync(emailArray, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting optional attendees field."); - } else { - console.error(asyncResult.error); + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); } }); +Word.List#levelTypes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var email = $("#emailRequired") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.requiredAttendees.setAsync(emailArray, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting required attendees field."); - } else { - console.error(asyncResult.error); + // Gets information about the first list in the document. + + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); + + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; } - }); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); - var email = $("#emailTo") - .val() - .toString(); - var emailArray = [email]; + await context.sync(); - Office.context.mailbox.item.to.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting To field."); - } else { - console.error(asyncResult.error); + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); } }); -'Office.MessageCompose#cc:member': +Word.ListBuiltInNumberStyle:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml - Office.context.mailbox.item.cc.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgCc = asyncResult.value; - console.log("Message being copied to:"); - for (var i = 0; i < msgCc.length; i++) { - console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); - } + + // Gets the properties of the specified style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); } else { - console.error(asyncResult.error); + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); } }); +Word.ListBullet:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml + + + // Inserts a list starting with the first paragraph then set numbering and + bullet types of the list items. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Use the first paragraph to start a new list. + const list: Word.List = paragraphs.items[0].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set numbering for list level 1. + list.setLevelNumbering(0, Word.ListNumbering.arabic); - var email = $("#emailCc") - .val() - .toString(); - var emailArray = [email]; + // Set bullet type for list level 5. + list.setLevelBullet(4, Word.ListBullet.arrow); - Office.context.mailbox.item.cc.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting Cc field."); - } else { - console.error(asyncResult.error); - } + // Set list level for the last item in this list. + paragraph.listItem.level = 4; + + list.load("levelTypes"); + + await context.sync(); }); -'Office.MessageRead#cc:member': +Word.ListCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var msgCc = Office.context.mailbox.item.cc; - console.log("Message copied to:"); + // Gets information about the first list in the document. - for (var i = 0; i < msgCc.length; i++) { - console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")"); - } -'Office.MessageCompose#from:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); - Office.context.mailbox.item.from.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgFrom = asyncResult.value; - console.log("Message from: " + msgFrom.displayName + " (" + msgFrom.emailAddress + ")"); - } else { - console.error(asyncResult.error); + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; } - }); -'Office.From#getAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); - Office.context.mailbox.item.from.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgFrom = asyncResult.value; - console.log("Message from: " + msgFrom.displayName + " (" + msgFrom.emailAddress + ")"); - } else { - console.error(asyncResult.error); + await context.sync(); + + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); } }); -'Office.MessageRead#from:member': +Word.ListItem:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - var msgFrom = Office.context.mailbox.item.from; - console.log("Message received from: " + msgFrom.displayName + " (" + - msgFrom.emailAddress + ")"); -'Office.AppointmentRead#optionalAttendees:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml + // This example starts a new list with the second paragraph. - var apptOptionalAttendees = Office.context.mailbox.item.optionalAttendees; + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); - console.log("Optional attendees:"); + await context.sync(); - for (var i = 0; i < apptOptionalAttendees.length; i++) { - console.log( - apptOptionalAttendees[i].displayName + - " (" + - apptOptionalAttendees[i].emailAddress + - ") - response: " + - apptOptionalAttendees[i].appointmentResponse - ); - } -'Office.AppointmentCompose#optionalAttendees:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); - Office.context.mailbox.item.optionalAttendees.getAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptOptionalAttendees = asyncResult.value; - for (var i = 0; i < apptOptionalAttendees.length; i++) { - console.log( - "Optional attendees: " + - apptOptionalAttendees[i].displayName + - " (" + - apptOptionalAttendees[i].emailAddress + - ") - response: " + - apptOptionalAttendees[i].appointmentResponse - ); - } - } else { - console.error(asyncResult.error); - } + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set up list level for the list item. + paragraph.listItem.level = 4; + + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + + await context.sync(); }); +Word.ListItem#level:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - var email = $("#emailOptional") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.optionalAttendees.setAsync(emailArray, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting optional attendees field."); - } else { - console.error(asyncResult.error); - } + // This example starts a new list with the second paragraph. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set up list level for the list item. + paragraph.listItem.level = 4; + + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + + await context.sync(); }); -'Office.AppointmentRead#organizer:member': +Word.ListLevel:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml - var apptOrganizer = Office.context.mailbox.item.organizer; - console.log("Organizer: " + apptOrganizer.displayName + " (" + - apptOrganizer.emailAddress + ")"); -'Office.AppointmentCompose#organizer:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml + // Gets the properties of the specified style. - Office.context.mailbox.item.organizer.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptOrganizer = asyncResult.value; - console.log("Organizer: " + apptOrganizer.displayName + " (" + apptOrganizer.emailAddress + ")"); - } else { - console.error(asyncResult.error); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; } - }); -'Office.Organizer#getAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml - Office.context.mailbox.item.organizer.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptOrganizer = asyncResult.value; - console.log("Organizer: " + apptOrganizer.displayName + " (" + apptOrganizer.emailAddress + ")"); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); } else { - console.error(asyncResult.error); + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); } }); -'Office.AppointmentRead#requiredAttendees:member': +Word.ListLevelCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml - var apptRequiredAttendees = Office.context.mailbox.item.requiredAttendees; - console.log("Required attendees:"); + // Gets the properties of the specified style. - for (var i = 0; i < apptRequiredAttendees.length; i++) { - console.log( - apptRequiredAttendees[i].displayName + - " (" + - apptRequiredAttendees[i].emailAddress + - ") - response: " + - apptRequiredAttendees[i].appointmentResponse - ); - } -'Office.AppointmentCompose#requiredAttendees:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } - Office.context.mailbox.item.requiredAttendees.getAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var apptRequiredAttendees = asyncResult.value; - for (var i = 0; i < apptRequiredAttendees.length; i++) { - console.log( - "Required attendees: " + - apptRequiredAttendees[i].displayName + - " (" + - apptRequiredAttendees[i].emailAddress + - ") - response: " + - apptRequiredAttendees[i].appointmentResponse - ); - } + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); } else { - console.error(asyncResult.error); + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); } }); +Word.ListLevelType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var email = $("#emailRequired") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.requiredAttendees.setAsync(emailArray, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting required attendees field."); - } else { - console.error(asyncResult.error); + // Gets information about the first list in the document. + + await Word.run(async (context) => { + const lists: Word.ListCollection = context.document.body.lists; + lists.load("items"); + + await context.sync(); + + if (lists.items.length === 0) { + console.warn("There are no lists in this document."); + return; + } + + // Get the first list. + const list: Word.List = lists.getFirst(); + list.load("levelTypes,levelExistences"); + + await context.sync(); + + const levelTypes = list.levelTypes; + console.log("Level types of the first list:"); + for (let i = 0; i < levelTypes.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`); + } + + const levelExistences = list.levelExistences; + console.log("Level existences of the first list:"); + for (let i = 0; i < levelExistences.length; i++) { + console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`); } }); -'Office.MessageRead#sender:member': +Word.ListNumbering:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml - var msgSender = Office.context.mailbox.item.sender; - console.log("Sender: " + msgSender.displayName + " (" + - msgSender.emailAddress + ")"); -'Office.MessageCompose#to:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + // Inserts a list starting with the first paragraph then set numbering and + bullet types of the list items. - Office.context.mailbox.item.to.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var msgTo = asyncResult.value; - console.log("Message being sent to:"); - for (var i = 0; i < msgTo.length; i++) { - console.log(msgTo[i].displayName + " (" + msgTo[i].emailAddress + ")"); - } - } else { - console.error(asyncResult.error); - } + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Use the first paragraph to start a new list. + const list: Word.List = paragraphs.items[0].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set numbering for list level 1. + list.setLevelNumbering(0, Word.ListNumbering.arabic); + + // Set bullet type for list level 5. + list.setLevelBullet(4, Word.ListBullet.arrow); + + // Set list level for the last item in this list. + paragraph.listItem.level = 4; + + list.load("levelTypes"); + + await context.sync(); }); +Word.ListTemplate:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml - var email = $("#emailTo") - .val() - .toString(); - var emailArray = [email]; - Office.context.mailbox.item.to.setAsync(emailArray, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Succeeded in setting To field."); + // Gets the properties of the specified style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); } else { - console.error(asyncResult.error); + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); } }); -'Office.MessageRead#to:member': +Word.LocationRelation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/compare-location.yaml - var msgTo = Office.context.mailbox.item.to; - console.log("Message sent to:"); + // Compares the location of one paragraph in relation to another paragraph. - for (var i = 0; i < msgTo.length; i++) { - console.log(msgTo[i].displayName + " (" + msgTo[i].emailAddress + ")"); - } -'Office.AppointmentCompose#notificationMessages:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("items"); - var id = $("#notificationId").val(); + await context.sync(); - var details = - { - type: "progressIndicator", - message: "Progress indicator with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + const firstParagraphAsRange: Word.Range = paragraphs.items[0].getRange(); + const secondParagraphAsRange: Word.Range = paragraphs.items[1].getRange(); - var id = $("#notificationId").val(); + const comparedLocation = firstParagraphAsRange.compareLocationWith(secondParagraphAsRange); - var details = - { - type: "informationalMessage", - message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", - persistent: false - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + await context.sync(); + + const locationValue: Word.LocationRelation = comparedLocation.value; + console.log(`Location of the first paragraph in relation to the second paragraph: ${locationValue}`); + }); +Word.NoteItem:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "informationalMessage", - message: "Persistent informational notification message with id = " + id, - icon: "icon1", - persistent: true - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Gets the text of the referenced footnote. - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/body"); + await context.sync(); - var id = $("#notificationId").val(); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const footnoteBody: Word.Range = footnotes.items[mark].body.getRange(); + footnoteBody.load("text"); + await context.sync(); - Office.context.mailbox.item.notificationMessages.replaceAsync( - id, - { - type: "informationalMessage", - message: "Notification message with id = " + id + " has been replaced with an informational message.", - icon: "icon2", - persistent: false - }, - handleResult); + console.log(`Text of footnote ${referenceNumber}: ${footnoteBody.text}`); + }); +Word.NoteItem#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - Office.context.mailbox.item.notificationMessages.removeAsync(id, - handleResult); -'Office.AppointmentRead#notificationMessages:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Deletes this referenced footnote. - var id = $("#notificationId").val(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); - var details = - { - type: "progressIndicator", - message: "Progress indicator with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + footnotes.items[mark].delete(); + await context.sync(); + + console.log("Footnote deleted."); + }); +Word.NoteItem#getNext:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "informationalMessage", - message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", - persistent: false - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Selects the next footnote in the document body. - var id = $("#notificationId").val(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/reference"); + await context.sync(); - var details = - { - type: "informationalMessage", - message: "Persistent informational notification message with id = " + id, - icon: "icon1", - persistent: true - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const reference: Word.Range = footnotes.items[mark].getNext().reference; + reference.select(); + console.log("Selected is the next footnote: " + (mark + 2)); + }); +Word.NoteItem#body:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml - var id = $("#notificationId").val(); + // Gets the text of the referenced footnote. - Office.context.mailbox.item.notificationMessages.replaceAsync( - id, - { - type: "informationalMessage", - message: "Notification message with id = " + id + " has been replaced with an informational message.", - icon: "icon2", - persistent: false - }, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/body"); + await context.sync(); - var id = $("#notificationId").val(); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const footnoteBody: Word.Range = footnotes.items[mark].body.getRange(); + footnoteBody.load("text"); + await context.sync(); - Office.context.mailbox.item.notificationMessages.removeAsync(id, - handleResult); -'Office.MessageCompose#notificationMessages:member': + console.log(`Text of footnote ${referenceNumber}: ${footnoteBody.text}`); + }); +Word.NoteItem#reference:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "progressIndicator", - message: "Progress indicator with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Selects the footnote's reference mark in the document body. - var id = $("#notificationId").val(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items/reference"); + await context.sync(); - var details = - { - type: "informationalMessage", - message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", - persistent: false - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + const reference: Word.Range = item.reference; + reference.select(); + await context.sync(); + + console.log(`Reference ${referenceNumber} is selected.`); + }); +Word.NoteItem#type:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "informationalMessage", - message: "Persistent informational notification message with id = " + id, - icon: "icon1", - persistent: true - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Gets the referenced note's item type and body type, which are both + "Footnote". - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); - var id = $("#notificationId").val(); + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + console.log(`Note type of footnote ${referenceNumber}: ${item.type}`); - Office.context.mailbox.item.notificationMessages.replaceAsync( - id, - { - type: "informationalMessage", - message: "Notification message with id = " + id + " has been replaced with an informational message.", - icon: "icon2", - persistent: false - }, - handleResult); + item.body.load("type"); + await context.sync(); + + console.log(`Body type of note: ${item.body.type}`); + }); +Word.NoteItemCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - Office.context.mailbox.item.notificationMessages.removeAsync(id, - handleResult); -'Office.MessageRead#notificationMessages:member': + // Gets the first footnote in the document body and select its reference + mark. + + await Word.run(async (context) => { + const reference: Word.Range = context.document.body.footnotes.getFirst().reference; + reference.select(); + console.log("The first footnote is selected."); + }); +Word.NoteItemCollection#getFirst:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "progressIndicator", - message: "Progress indicator with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + // Gets the first footnote in the document body and select its reference + mark. + + await Word.run(async (context) => { + const reference: Word.Range = context.document.body.footnotes.getFirst().reference; + reference.select(); + console.log("The first footnote is selected."); + }); +Word.NoteItemType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var id = $("#notificationId").val(); - var details = - { - type: "informationalMessage", - message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", - persistent: false - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Gets the referenced note's item type and body type, which are both + "Footnote". - var id = $("#notificationId").val(); + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.body.footnotes; + footnotes.load("items"); + await context.sync(); - var details = - { - type: "informationalMessage", - message: "Persistent informational notification message with id = " + id, - icon: "icon1", - persistent: true - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + const referenceNumber = (document.getElementById("input-reference") as HTMLInputElement).value; + const mark = (referenceNumber as number) - 1; + const item: Word.NoteItem = footnotes.items[mark]; + console.log(`Note type of footnote ${referenceNumber}: ${item.type}`); + + item.body.load("type"); + await context.sync(); - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); + console.log(`Body type of note: ${item.body.type}`); + }); +Word.OutlineLevel:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml - var id = $("#notificationId").val(); - Office.context.mailbox.item.notificationMessages.replaceAsync( - id, - { - type: "informationalMessage", - message: "Notification message with id = " + id + " has been replaced with an informational message.", - icon: "icon2", - persistent: false - }, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + // Imports styles from JSON. + + await Word.run(async (context) => { + const str = + '{"styles":[{"baseStyle":"Default Paragraph Font","builtIn":false,"inUse":true,"linked":false,"nameLocal":"NewCharStyle","priority":2,"quickStyle":true,"type":"Character","unhideWhenUsed":false,"visibility":false,"paragraphFormat":null,"font":{"name":"DengXian Light","size":16.0,"bold":true,"italic":false,"color":"#F1A983","underline":"None","subscript":false,"superscript":true,"strikeThrough":true,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#FF0000"}},{"baseStyle":"Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewParaStyle","nameLocal":"NewParaStyle","priority":1,"quickStyle":true,"type":"Paragraph","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Centered","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":72.0,"lineSpacing":18.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":72.0,"spaceAfter":30.0,"spaceBefore":30.0,"widowControl":true},"font":{"name":"DengXian","size":14.0,"bold":true,"italic":true,"color":"#8DD873","underline":"Single","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":true,"highlightColor":null,"hidden":false},"shading":{"backgroundPatternColor":"#00FF00"}},{"baseStyle":"Table Normal","builtIn":false,"inUse":true,"linked":false,"nextParagraphStyle":"NewTableStyle","nameLocal":"NewTableStyle","priority":100,"type":"Table","unhideWhenUsed":false,"visibility":false,"paragraphFormat":{"alignment":"Left","firstLineIndent":0.0,"keepTogether":false,"keepWithNext":false,"leftIndent":0.0,"lineSpacing":12.0,"lineUnitAfter":0.0,"lineUnitBefore":0.0,"mirrorIndents":false,"outlineLevel":"OutlineLevelBodyText","rightIndent":0.0,"spaceAfter":0.0,"spaceBefore":0.0,"widowControl":true},"font":{"name":"DengXian","size":20.0,"bold":false,"italic":true,"color":"#D86DCB","underline":"None","subscript":false,"superscript":false,"strikeThrough":false,"doubleStrikeThrough":false,"highlightColor":null,"hidden":false},"tableStyle":{"allowBreakAcrossPage":true,"alignment":"Left","bottomCellMargin":0.0,"leftCellMargin":0.08,"rightCellMargin":0.08,"topCellMargin":0.0,"cellSpacing":0.0},"shading":{"backgroundPatternColor":"#60CAF3"}}]}'; + const styles = context.document.importStylesFromJson(str); - var id = $("#notificationId").val(); + // If you'd like to set how conflicting styles are handled, use the importedStylesConflictBehavior parameter that was introduced in the Desktop 1.1 requirement set. "Ignore" is the default. + ////const styles = context.document.importStylesFromJson(str, Word.ImportedStylesConflictBehavior.Ignore); - Office.context.mailbox.item.notificationMessages.removeAsync(id, - handleResult); -'Office.NotificationMessages#addAsync:member(1)': + await context.sync(); + console.log("Styles imported from JSON:", styles); + }); +Word.Page:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - var id = $("#notificationId").val(); - var details = - { - type: "progressIndicator", - message: "Progress indicator with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + // Gets pages of the selection. + const pages: Word.PageCollection = context.document.getSelection().pages; + pages.load(); + await context.sync(); - var id = $("#notificationId").val(); + // Log info for pages included in selection. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } - var details = - { - type: "informationalMessage", - message: "Non-persistent informational notification message with id = " + id, - icon: "icon1", - persistent: false - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index info for page ${i + 1} in the selection: ${pagesIndexes[i].index}`); + console.log("Text of that page in the selection:", pagesText[i].text); + } + }); +Word.Page#getRange:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - var id = $("#notificationId").val(); - var details = - { - type: "informationalMessage", - message: "Persistent informational notification message with id = " + id, - icon: "icon1", - persistent: true - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + // Gets pages of the selection. + const pages: Word.PageCollection = context.document.getSelection().pages; + pages.load(); + await context.sync(); - var id = $("#notificationId").val(); + // Log info for pages included in selection. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } - var details = - { - type: "errorMessage", - message: "Error notification message with id = " + id - }; - Office.context.mailbox.item.notificationMessages.addAsync(id, details, - handleResult); -'Office.NotificationMessages#getAllAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await context.sync(); - Office.context.mailbox.item.notificationMessages.getAllAsync(handleResult); -'Office.NotificationMessages#replaceAsync:member(1)': + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index info for page ${i + 1} in the selection: ${pagesIndexes[i].index}`); + console.log("Text of that page in the selection:", pagesText[i].text); + } + }); +Word.Page#index:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - var id = $("#notificationId").val(); - Office.context.mailbox.item.notificationMessages.replaceAsync( - id, - { - type: "informationalMessage", - message: "Notification message with id = " + id + " has been replaced with an informational message.", - icon: "icon2", - persistent: false - }, - handleResult); -'Office.NotificationMessages#removeAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/35-notifications/add-getall-remove.yaml + await Word.run(async (context) => { + // Gets the pages that contain the third paragraph. + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load(); + await context.sync(); - var id = $("#notificationId").val(); + const paraThree = paragraphs.items[2]; + const rangeOfParagraph = paraThree.getRange(); + const pages: Word.PageCollection = rangeOfParagraph.pages; + pages.load(); + await context.sync(); - Office.context.mailbox.item.notificationMessages.removeAsync(id, - handleResult); -'Office.AppointmentCompose#addFileAttachmentAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + // Log info for pages in range. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } - var attachmentUrl = $("#attachmentUrl").val(); + await context.sync(); - Office.context.mailbox.item.addFileAttachmentAsync( - attachmentUrl, - getFileName(attachmentUrl), - { "asyncContext" : { var1: 1, var2: true } }, - function(result) { console.log(result); }); -'Office.MessageCompose#addFileAttachmentAsync:member(1)': + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index of page ${i + 1} that contains the third paragraph: ${pagesIndexes[i].index}`); + console.log("Text of that page:", pagesText[i].text); + } + }); +Word.PageCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - var attachmentUrl = $("#attachmentUrl").val(); - Office.context.mailbox.item.addFileAttachmentAsync( - attachmentUrl, - getFileName(attachmentUrl), - { "asyncContext" : { var1: 1, var2: true } }, - function(result) { console.log(result); }); -'Office.AppointmentCompose#addItemAttachmentAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + await Word.run(async (context) => { + // Gets pages of the selection. + const pages: Word.PageCollection = context.document.getSelection().pages; + pages.load(); + await context.sync(); + + // Log info for pages included in selection. + console.log(pages); + const pagesIndexes = []; + const pagesText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const range = page.getRange(); + range.load("text"); + pagesText.push(range); + } - var attachmentItemId = $("#attachmentItemId").val(); + await context.sync(); - Office.context.mailbox.item.addItemAttachmentAsync( - attachmentItemId, - "My attachment", - { "asyncContext" : { var3: 3, var4: false } }, - function(result) { console.log(result); }); -'Office.MessageCompose#addItemAttachmentAsync:member(1)': + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Index info for page ${i + 1} in the selection: ${pagesIndexes[i].index}`); + console.log("Text of that page in the selection:", pagesText[i].text); + } + }); +Word.Pane:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - var attachmentItemId = $("#attachmentItemId").val(); - Office.context.mailbox.item.addItemAttachmentAsync( - attachmentItemId, - "My attachment", - { "asyncContext" : { var3: 3, var4: false } }, - function(result) { console.log(result); }); -'Office.AppointmentCompose#addFileAttachmentFromBase64Async:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + await Word.run(async (context) => { + // Gets the first paragraph of each page. + console.log("Getting first paragraph of each page..."); - base64String = - "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - base64String, - "logo.png", - { isInline: false }, - function(result) { console.log(result); }); + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get all pages. + const pages: Word.PageCollection = activePane.pages; + pages.load(); + + await context.sync(); + + // Get page index and paragraphs of each page. + const pagesIndexes = []; + const pagesNumberOfParagraphs = []; + const pagesFirstParagraphText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const paragraphs = page.getRange().paragraphs; + paragraphs.load("items/length"); + pagesNumberOfParagraphs.push(paragraphs); + + const firstParagraph = paragraphs.getFirst(); + firstParagraph.load("text"); + pagesFirstParagraphText.push(firstParagraph); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + console.log(`Number of paragraphs: ${pagesNumberOfParagraphs[i].items.length}`); + console.log("First paragraph's text:", pagesFirstParagraphText[i].text); + } + }); +Word.Pane#pages:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - // Set the signature for the current item with inline image. - var modIcon1Base64 = - "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + await Word.run(async (context) => { + // Gets the first paragraph of each page. + console.log("Getting first paragraph of each page..."); - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - modIcon1Base64, - "myImage.png", - { isInline: true }, - function(result) { - if (result.status == Office.AsyncResultStatus.Succeeded) { - var signature = $("#signature").val() + ""; - console.log(`Setting signature to "${signature}".`); - // Important: setSignatureAsync is currently in preview. - Office.context.mailbox.item.body.setSignatureAsync( - signature, - { coercionType: "html" }, - function(asyncResult) { - console.log(`setSignatureAsync: ${asyncResult.status}`); - } - ); - } else { - console.error(`addFileAttachmentFromBase64Async: ${result.error}`); - } + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get all pages. + const pages: Word.PageCollection = activePane.pages; + pages.load(); + + await context.sync(); + + // Get page index and paragraphs of each page. + const pagesIndexes = []; + const pagesNumberOfParagraphs = []; + const pagesFirstParagraphText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const paragraphs = page.getRange().paragraphs; + paragraphs.load("items/length"); + pagesNumberOfParagraphs.push(paragraphs); + + const firstParagraph = paragraphs.getFirst(); + firstParagraph.load("text"); + pagesFirstParagraphText.push(firstParagraph); + } + + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + console.log(`Number of paragraphs: ${pagesNumberOfParagraphs[i].items.length}`); + console.log("First paragraph's text:", pagesFirstParagraphText[i].text); } - ); -'Office.MessageCompose#addFileAttachmentFromBase64Async:member(1)': + }); +Word.Pane#pagesEnclosingViewport:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - base64String = - "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVRYw82XzXHbMBCFP2F8tzsQc8Ixyh0zoiuIXIGdCsxUYKqC0B04FdiuwMoM7mGOOIXqQGoAymXhgSX+itJM9kIRFLAP+3YXD5Pdbscx5oxaAIW8Ztr6l2PWmQwF4IyaieP53qdfAqQ8CwBn1JU4vpWhrbxXQA5MZfynANmcDIAzKgcy4FKGXsVJFf3nLgKyBQptfT4KQMRz2N0fcbxqmRMDWXflx0VPnrdArq0vekQ1Dv0UeHZGNebHhwjU8AzwKM43RyZnbAf58Q6ghudeWd0Aus0+5EcMIIRi3beua0D3Nm39BEAx3i7HTK4DEBJn5YxKOnaRA5+ErpMBWMpzDvx1RuXCcxOISlufAjfC7zgAsqsvUvMAD0ApPaEtGi9AIlUzKgJo60tt/SyKRkzLrAXERluf7W1gOICWaMyB386oooOWsIHvXbSoHuUSFovtHqicUVnH3EJoeT0aQEf5/XBGlc6otIOWBXAtPeZkAIJ9Bt6cUU9tZautX2nrk3MACHYr1ZKProKRtDw4o8pzAPjWo+NtpXTTvoteDDg8noDAcwbcRedAkGdFXyk2GEDcegVAFp2gyVDHjRQ4o6q2smoqtR5Hd+qMqtoALCWUUymr1m43QMZfOaMK4C0SrMsDANJ2E5FNcbdbjHC+ENl+H0myJFbLtaq4Rt8dyPBYRQV1E40nMv9rl7xrOw3DGb+Whcqu3i/OM6CUOWvgRlufNmnLYy4m77uJI7AXtdNcTDrU71LEyv7v01/N/ovL6bmu5/8A1tNWZldH0W4AAAAASUVORK5CYII="; - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - base64String, - "logo.png", - { isInline: false }, - function(result) { console.log(result); }); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + await Word.run(async (context) => { + // Gets the pages enclosing the viewport. - // Set the signature for the current item with inline image. + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); - var modIcon1Base64 = - "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - modIcon1Base64, - "myImage.png", - { isInline: true }, - function(result) { - if (result.status == Office.AsyncResultStatus.Succeeded) { - var signature = $("#signature").val() + ""; - console.log(`Setting signature to "${signature}".`); - // Important: setSignatureAsync is currently in preview. - Office.context.mailbox.item.body.setSignatureAsync( - signature, - { coercionType: "html" }, - function(asyncResult) { - console.log(`setSignatureAsync: ${asyncResult.status}`); - } - ); - } else { - console.error(`addFileAttachmentFromBase64Async: ${result.error}`); - } + // Get pages enclosing the viewport. + const pages: Word.PageCollection = activePane.pagesEnclosingViewport; + pages.load(); + + await context.sync(); + + // Log the number of pages. + const pageCount = pages.items.length; + console.log(`Number of pages enclosing the viewport: ${pageCount}`); + + // Log index info of these pages. + const pagesIndexes = []; + for (let i = 0; i < pageCount; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); } - ); -'Office.AppointmentCompose#getAttachmentsAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml - Office.context.mailbox.item.getAttachmentsAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(result.error.message); - } else { - if (result.value.length > 0) { - for (var i = 0; i < result.value.length; i++) { - var attachment = result.value[i]; - console.log(`${attachment.id}. Name: ${attachment.name}, size: ${attachment.size}, isInline: ${attachment.isInline}`); - } - } - else { - console.log("No attachments on this message."); - } - } + await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + } }); -'Office.MessageCompose#getAttachmentsAsync:member(1)': +Word.PaneCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml - Office.context.mailbox.item.getAttachmentsAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(result.error.message); - } else { - if (result.value.length > 0) { - for (var i = 0; i < result.value.length; i++) { - var attachment = result.value[i]; - console.log(`${attachment.id}. Name: ${attachment.name}, size: ${attachment.size}, isInline: ${attachment.isInline}`); - } - } - else { - console.log("No attachments on this message."); - } - } + + await Word.run(async (context) => { + // Gets all the panes in the active document window. + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load("panes/items/length"); + + await context.sync(); + + const panes: Word.PaneCollection = activeWindow.panes; + console.log(`Number of panes in the current document window: ${panes.items.length}`); }); -'Office.AppointmentCompose#removeAttachmentAsync:member(1)': +Word.Paragraph:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml - Office.context.mailbox.item.removeAttachmentAsync( - $("#attachmentId").val(), - { asyncContext : null }, - function(result) - { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`${result.error.message}`); - } else { - console.log(`Attachment removed successfully.`); - } - } - ); -'Office.MessageCompose#removeAttachmentAsync:member(1)': + + await Word.run(async (context) => { + // The collection of paragraphs of the current selection returns the full paragraphs contained in it. + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + paragraph.load("text"); + + await context.sync(); + console.log(paragraph.text); + }); +Word.Paragraph#getRange:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/attachments-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml - Office.context.mailbox.item.removeAttachmentAsync( - $("#attachmentId").val(), - { asyncContext : null }, - function(result) - { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`${result.error.message}`); - } else { - console.log(`Attachment removed successfully.`); - } - } - ); -'Office.AppointmentCompose#getAttachmentContentAsync:member(1)': + + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + const sentences: Word.RangeCollection = context.document + .getSelection() + .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); + sentences.load("$none"); + await context.sync(); + + // Expand the range to the end of the paragraph to get all the complete sentences. + const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0] + .getRange() + .expandTo( + context.document + .getSelection() + .paragraphs.getFirst() + .getRange(Word.RangeLocation.end) + ) + .getTextRanges(["."], false /* Don't trim spaces*/); + sentencesToTheEndOfParagraph.load("text"); + await context.sync(); + + for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) { + console.log(sentencesToTheEndOfParagraph.items[i].text); + } + }); +Word.Paragraph#insertAnnotations:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachment-content.yaml - - var item = Office.context.mailbox.item; + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - var options = {asyncContext: {currentItem: item}}; - item.getAttachmentsAsync(options, callback); + // Adds annotations to the selected paragraph. + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const options: Word.CritiquePopupOptions = { + brandingTextResourceId: "PG.TabLabel", + subtitleResourceId: "PG.HelpCommand.TipTitle", + titleResourceId: "PG.HelpCommand.Label", + suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"] + }; + const critique1: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.red, + start: 1, + length: 3, + popupOptions: options + }; + const critique2: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.green, + start: 6, + length: 1, + popupOptions: options + }; + const critique3: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.blue, + start: 10, + length: 3, + popupOptions: options + }; + const critique4: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.lavender, + start: 14, + length: 3, + popupOptions: options + }; + const critique5: Word.Critique = { + colorScheme: Word.CritiqueColorScheme.berry, + start: 18, + length: 10, + popupOptions: options + }; + const annotationSet: Word.AnnotationSet = { + critiques: [critique1, critique2, critique3, critique4, critique5] + }; - function callback(result) { - if (result.value.length > 0) { - for (i = 0 ; i < result.value.length ; i++) { - result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); - } - } - } + const annotationIds = paragraph.insertAnnotations(annotationSet); + await context.sync(); - function handleAttachmentsCallback(result) { - // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file. - switch (result.value.format) { - case Office.MailboxEnums.AttachmentContentFormat.Base64: - // Handle file attachment. - console.log(result.value.content); - break; - case Office.MailboxEnums.AttachmentContentFormat.Eml: - // Handle email item attachment. - console.log("Attachment is a message."); - break; - case Office.MailboxEnums.AttachmentContentFormat.ICalendar: - // Handle .icalender attachment. - console.log("Attachment is a calendar item."); - break; - case Office.MailboxEnums.AttachmentContentFormat.Url: - // Handle cloud attachment. - console.log("Attachment is a cloud attachment."); - break; - default: - // Handle attachment formats that are not supported. - } - } -'Office.AppointmentRead#getAttachmentContentAsync:member(1)': + console.log("Annotations inserted:", annotationIds.value); + }); +Word.Paragraph#insertBreak:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachment-content.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-line-and-page-breaks.yaml - var item = Office.context.mailbox.item; - var options = {asyncContext: {currentItem: item}}; + Word.run(async (context) => { + context.document.body.paragraphs.getFirst().insertBreak(Word.BreakType.line, "After"); + + await context.sync(); + console.log("success"); + }); +Word.Paragraph#insertContentControl:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml - item.getAttachmentsAsync(options, callback); + // Traverses each paragraph of the document and wraps a content control on + each with either a even or odd tags. - function callback(result) { - if (result.value.length > 0) { - for (i = 0 ; i < result.value.length ; i++) { - result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); - } - } - } + await Word.run(async (context) => { + let paragraphs = context.document.body.paragraphs; + paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + await context.sync(); - function handleAttachmentsCallback(result) { - // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file. - switch (result.value.format) { - case Office.MailboxEnums.AttachmentContentFormat.Base64: - // Handle file attachment. - console.log(result.value.content); - break; - case Office.MailboxEnums.AttachmentContentFormat.Eml: - // Handle email item attachment. - console.log("Attachment is a message."); - break; - case Office.MailboxEnums.AttachmentContentFormat.ICalendar: - // Handle .icalender attachment. - console.log("Attachment is a calendar item."); - break; - case Office.MailboxEnums.AttachmentContentFormat.Url: - // Handle cloud attachment. - console.log("Attachment is a cloud attachment."); - break; - default: - // Handle attachment formats that are not supported. + for (let i = 0; i < paragraphs.items.length; i++) { + let contentControl = paragraphs.items[i].insertContentControl(); + // For even, tag "even". + if (i % 2 === 0) { + contentControl.tag = "even"; + } else { + contentControl.tag = "odd"; } - } -'Office.MessageCompose#getAttachmentContentAsync:member(1)': + } + console.log("Content controls inserted: " + paragraphs.items.length); + + await context.sync(); + }); +Word.Paragraph#insertGeometricShape:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachment-content.yaml - - var item = Office.context.mailbox.item; - - var options = {asyncContext: {currentItem: item}}; - - item.getAttachmentsAsync(options, callback); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - function callback(result) { - if (result.value.length > 0) { - for (i = 0 ; i < result.value.length ; i++) { - result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); - } - } - } + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.clear(); + const lastParagraph: Word.Paragraph = body.paragraphs.getLast(); + + // Inserts a text box. + const textBoxOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100, + }; + lastParagraph.insertTextBox("placeholder text", textBoxOptions); + // Inserts a geometric shape. + const geometricShapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + left: 120, + }; + lastParagraph.insertGeometricShape(Word.GeometricShapeType.star24, geometricShapeOptions); + + // Inserts a picture. + const pictureOptions: Word.InsertShapeOptions = { + top: 120, + left: 60, + height: 150, + width: 150, + }; + lastParagraph.insertPictureFromBase64(getPictureBase64(), pictureOptions); - function handleAttachmentsCallback(result) { - // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file. - switch (result.value.format) { - case Office.MailboxEnums.AttachmentContentFormat.Base64: - // Handle file attachment. - console.log(result.value.content); - break; - case Office.MailboxEnums.AttachmentContentFormat.Eml: - // Handle email item attachment. - console.log("Attachment is a message."); - break; - case Office.MailboxEnums.AttachmentContentFormat.ICalendar: - // Handle .icalender attachment. - console.log("Attachment is a calendar item."); - break; - case Office.MailboxEnums.AttachmentContentFormat.Url: - // Handle cloud attachment. - console.log("Attachment is a cloud attachment."); - break; - default: - // Handle attachment formats that are not supported. - } - } -'Office.MessageRead#getAttachmentContentAsync:member(1)': + await context.sync(); + }); +Word.Paragraph#insertText:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachment-content.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-in-different-locations.yaml - var item = Office.context.mailbox.item; - var options = {asyncContext: {currentItem: item}}; - - item.getAttachmentsAsync(options, callback); + await Word.run(async (context) => { + // Replace the last paragraph. + const range: Word.Range = context.document.body.paragraphs.getLast().insertText("Just replaced the last paragraph!", "Replace"); + range.font.highlightColor = "black"; + range.font.color = "white"; + await context.sync(); + }); +Word.Paragraph#insertTextBox:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - function callback(result) { - if (result.value.length > 0) { - for (i = 0 ; i < result.value.length ; i++) { - result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback); - } - } - } + await Word.run(async (context) => { + // Inserts a text box at the beginning of the first paragraph in the header. + const headerFooterBody: Word.Body = context.document.sections.getFirst().getHeader(Word.HeaderFooterType.primary); + headerFooterBody.load("paragraphs"); + const firstParagraph: Word.Paragraph = headerFooterBody.paragraphs.getFirst(); + const insertShapeOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100 + }; + const newTextBox: Word.Shape = firstParagraph.insertTextBox("placeholder text", insertShapeOptions); + newTextBox.select(); + await context.sync(); - function handleAttachmentsCallback(result) { - // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file. - switch (result.value.format) { - case Office.MailboxEnums.AttachmentContentFormat.Base64: - // Handle file attachment. - console.log(result.value.content); - break; - case Office.MailboxEnums.AttachmentContentFormat.Eml: - // Handle email item attachment. - console.log("Attachment is a message."); - break; - case Office.MailboxEnums.AttachmentContentFormat.ICalendar: - // Handle .icalender attachment. - console.log("Attachment is a calendar item."); - break; - case Office.MailboxEnums.AttachmentContentFormat.Url: - // Handle cloud attachment. - console.log("Attachment is a cloud attachment."); - break; - default: - // Handle attachment formats that are not supported. - } - } -'Office.AppointmentRead#attachments:member': + console.log("Inserted a text box at the beginning of the first paragraph in the header."); + }); +Word.Paragraph#select:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachments-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml + - var attachments = Office.context.mailbox.item.attachments; + await Word.run(async (context) => { + // If select is called with no parameters, it selects the object. + context.document.body.paragraphs.getLast().select(); - console.log(attachments); -'Office.MessageRead#attachments:member': + await context.sync(); + }); - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/40-attachments/get-attachments-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml + - var attachments = Office.context.mailbox.item.attachments; + await Word.run(async (context) => { + // Select can be at the start or end of a range; this by definition moves the insertion point without selecting the range. + context.document.body.paragraphs.getLast().select(Word.SelectionMode.end); - console.log(attachments); -'Office.AppointmentCompose#categories:member': + await context.sync(); + }); +Word.Paragraph#set:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/multiple-property-set.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Categories assigned to this item:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories assigned to this item."); + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.body.paragraphs.getFirst(); + paragraph.set({ + leftIndent: 30, + font: { + bold: true, + color: "red" } - } else { - console.error(asyncResult.error); - } + }); + + await context.sync(); }); - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/multiple-property-set.yaml - // Note: In order for you to successfully add a category, - // it must be in the mailbox categories master list. + await Word.run(async (context) => { + const firstParagraph: Word.Paragraph = context.document.body.paragraphs.getFirst(); + const secondParagraph: Word.Paragraph = firstParagraph.getNext(); + firstParagraph.load("text, font/color, font/bold, leftIndent"); + await context.sync(); - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; - if (masterCategories && masterCategories.length > 0) { - // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; - Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully assigned category '${categoryToAdd}' to item.`); - } else { - console.log("categories.addAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); - } - } else { - console.error(asyncResult.error); - } + secondParagraph.set(firstParagraph); + + await context.sync(); }); +Word.Paragraph#split:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/split-words-of-first-paragraph.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; - Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); - } else { - console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories assigned to this item."); + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.body.paragraphs.getFirst(); + const words = paragraph.split([" "], true /* trimDelimiters*/, true /* trimSpaces */); + words.load("text"); + + await context.sync(); + + for (let i = 0; i < words.items.length; i++) { + if (i >= 1) { + words.items[i - 1].font.highlightColor = "#FFFFFF"; } - } else { - console.error(asyncResult.error); + words.items[i].font.highlightColor = "#FFFF00"; + + await context.sync(); + await pause(200); } }); -'Office.AppointmentRead#categories:member': +Word.Paragraph#startNewList:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Categories assigned to this item:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + // This example starts a new list with the second paragraph. + + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); + + await context.sync(); + + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); + + await context.sync(); + + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); + + // Set up list level for the list item. + paragraph.listItem.level = 4; + + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + + await context.sync(); }); +Word.Paragraph#alignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - // Note: In order for you to successfully add a category, - - // it must be in the mailbox categories master list. + await Word.run(async (context) => { + // Center last paragraph alignment. + context.document.body.paragraphs.getLast().alignment = "Centered"; - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; - if (masterCategories && masterCategories.length > 0) { - // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; - Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully assigned category '${categoryToAdd}' to item.`); - } else { - console.log("categories.addAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); - } - } else { - console.error(asyncResult.error); - } + await context.sync(); }); +Word.Paragraph#leftIndent:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; - Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); - } else { - console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // Indent the first paragraph. + context.document.body.paragraphs.getFirst().leftIndent = 75; //units = points + + return context.sync(); }); -'Office.MessageCompose#categories:member': +Word.Paragraph#lineSpacing:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Categories assigned to this item:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // Adjust line spacing. + context.document.body.paragraphs.getFirst().lineSpacing = 20; + + await context.sync(); }); +Word.Paragraph#lineUnitAfter:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml - - // Note: In order for you to successfully add a category, + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - // it must be in the mailbox categories master list. + await Word.run(async (context) => { + // Set the space (in line units) after the first paragraph. + context.document.body.paragraphs.getFirst().lineUnitAfter = 1; - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; - if (masterCategories && masterCategories.length > 0) { - // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; - Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully assigned category '${categoryToAdd}' to item.`); - } else { - console.log("categories.addAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); - } - } else { - console.error(asyncResult.error); - } + await context.sync(); }); +Word.Paragraph#lineUnitBefore:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; - Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); - } else { - console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // Set the space (in line units) before the first paragraph. + context.document.body.paragraphs.getFirst().lineUnitBefore = 1; + + await context.sync(); }); -'Office.MessageRead#categories:member': +Word.Paragraph#spaceAfter:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Categories assigned to this item:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // Set the space (in points) after the first paragraph. + context.document.body.paragraphs.getFirst().spaceAfter = 20; + + await context.sync(); }); +Word.Paragraph#style:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - // Note: In order for you to successfully add a category, - // it must be in the mailbox categories master list. + // Applies the specified style to a paragraph. + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to apply."); + return; + } - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; - if (masterCategories && masterCategories.length > 0) { - // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; - Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully assigned category '${categoryToAdd}' to item.`); - } else { - console.log("categories.addAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); - } + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else if (style.type != Word.StyleType.paragraph) { + console.log(`The '${styleName}' style isn't a paragraph style.`); } else { - console.error(asyncResult.error); + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + const paragraph: Word.Paragraph = body.paragraphs.getFirst(); + paragraph.style = style.nameLocal; + console.log(`'${styleName}' style applied to first paragraph.`); } }); +Word.Paragraph#styleBuiltIn:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; - Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); - } else { - console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.body.insertParagraph("Timeline", "End"); + paragraph.styleBuiltIn = "Heading2"; + const paragraph2: Word.Paragraph = context.document.body.insertParagraph("The Services shall commence on July 31, 2015, and shall continue through July 29, 2015.", "End"); + paragraph2.styleBuiltIn = "Normal"; + const paragraph3: Word.Paragraph = context.document.body.insertParagraph("Project Costs by Phase", "End"); + paragraph3.styleBuiltIn = "Heading2"; + // Note a content control with the title of "ProjectCosts" is added. Content will be replaced later. + const paragraph4: Word.Paragraph = context.document.body.insertParagraph("", "End"); + paragraph4.styleBuiltIn = "Normal"; + paragraph4.font.highlightColor = "#FFFF00"; + const contentControl: Word.ContentControl = paragraph4.insertContentControl(); + contentControl.title = "ProjectCosts"; + const paragraph5: Word.Paragraph = context.document.body.insertParagraph("Project Team", "End"); + paragraph5.styleBuiltIn = "Heading2"; + paragraph5.font.highlightColor = "#FFFFFF"; + const paragraph6: Word.Paragraph = context.document.body.insertParagraph("Terms of Work", "End"); + paragraph6.styleBuiltIn = "Heading1"; + const paragraph7: Word.Paragraph = context.document.body.insertParagraph("Contractor shall provide the Services and Deliverable(s) as follows:", "End"); + paragraph7.styleBuiltIn = "Normal"; + const paragraph8: Word.Paragraph = context.document.body.insertParagraph("Out-of-Pocket Expenses / Invoice Procedures", "End"); + paragraph8.styleBuiltIn = "Heading2"; + const paragraph9 : Word.Paragraph= context.document.body.insertParagraph("Client will be invoiced monthly for the consulting services and T&L expenses. Standard Contractor invoicing is assumed to be acceptable. Invoices are due upon receipt. client will be invoiced all costs associated with out-of-pocket expenses (including, without limitation, costs and expenses associated with meals, lodging, local transportation and any other applicable business expenses) listed on the invoice as a separate line item. Reimbursement for out-of-pocket expenses in connection with performance of this SOW, when authorized and up to the limits set forth in this SOW, shall be in accordance with Client's then-current published policies governing travel and associated business expenses, which information shall be provided by the Client Project Manager.", "End"); + paragraph9.styleBuiltIn = "Normal"; + // Insert a page break at the end of the document. + context.document.body.insertBreak("Page", "End"); + + await context.sync(); }); -'Office.Categories#getAsync:member(2)': +Word.Paragraph#text:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Categories assigned to this item:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + + await Word.run(async (context) => { + // The collection of paragraphs of the current selection returns the full paragraphs contained in it. + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + paragraph.load("text"); + + await context.sync(); + console.log(paragraph.text); }); -'Office.Categories#addAsync:member(1)': +Word.Paragraph#uniqueLocalId:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - // Note: In order for you to successfully add a category, - // it must be in the mailbox categories master list. + // Registers event handlers. + await Word.run(async (context) => { + eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged); + eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged); - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var masterCategories = asyncResult.value; - if (masterCategories && masterCategories.length > 0) { - // Grab the first category from the master list. - var categoryToAdd = [masterCategories[0].displayName]; - Office.context.mailbox.item.categories.addAsync(categoryToAdd, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully assigned category '${categoryToAdd}' to item.`); - } else { - console.log("categories.addAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories in the master list on this mailbox. You can add categories using Office.context.mailbox.masterCategories.addAsync."); - } - } else { - console.error(asyncResult.error); - } - }); -'Office.Categories#removeAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-categories.yaml + eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler); + eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler); + eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler); + eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler); + eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler); - Office.context.mailbox.item.categories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - // Grab the first category assigned to this item. - var categoryToRemove = [categories[0].displayName]; - Office.context.mailbox.item.categories.removeAsync(categoryToRemove, function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully unassigned category '${categoryToRemove}' from this item.`); - } else { - console.log("categories.removeAsync call failed with error: " + asyncResult.error.message); - } - }); - } else { - console.log("There are no categories assigned to this item."); - } - } else { - console.error(asyncResult.error); - } + await context.sync(); + + console.log("Event handlers registered."); }); -'Office.Mailbox#masterCategories:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Master categories:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories in the master list."); + + async function paragraphChanged(args: Word.ParagraphChangedEventArgs) { + await Word.run(async (context) => { + const results = []; + for (let id of args.uniqueLocalIds) { + let para = context.document.getParagraphByUniqueLocalId(id); + para.load("uniqueLocalId"); + + results.push({ para: para, text: para.getText() }); } - } else { - console.error(asyncResult.error); - } - }); + + await context.sync(); + + for (let result of results) { + console.log(`${args.type}: ID ${result.para.uniqueLocalId}:-`, result.text.value); + } + }); + } +Word.ParagraphAddedEventArgs:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml - var masterCategoriesToAdd = [ - { - displayName: "TestCategory", - color: Office.MailboxEnums.CategoryColor.Preset0 - } - ]; + // Registers the onParagraphAdded event handler on the document. - Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Successfully added categories to master list"); - } else { - console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message); - } + await Word.run(async (context) => { + eventContext = context.document.onParagraphAdded.add(paragraphAdded); + await context.sync(); + + console.log("Added event handler for when paragraphs are added."); }); - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml - var masterCategoriesToRemove = ["TestCategory"]; + async function paragraphAdded(event: Word.ParagraphAddedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs that were added:`, event.uniqueLocalIds); + }); + } +Word.ParagraphChangedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml - Office.context.mailbox.masterCategories.removeAsync(masterCategoriesToRemove, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Successfully removed categories from master list"); - } else { - console.log("masterCategories.removeAsync call failed with error: " + asyncResult.error.message); - } + + // Registers the onParagraphChanged event handler on the document. + + await Word.run(async (context) => { + eventContext = context.document.onParagraphChanged.add(paragraphChanged); + await context.sync(); + + console.log("Added event handler for when content is changed in paragraphs."); }); -'Office.MasterCategories#getAsync:member(2)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml - Office.context.mailbox.masterCategories.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var categories = asyncResult.value; - if (categories && categories.length > 0) { - console.log("Master categories:"); - console.log(JSON.stringify(categories)); - } else { - console.log("There are no categories in the master list."); - } - } else { - console.error(asyncResult.error); - } - }); -'Office.MasterCategories#addAsync:member(1)': + + async function paragraphChanged(event: Word.ParagraphChangedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs where content was changed:`, event.uniqueLocalIds); + }); + } +Word.ParagraphCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - var masterCategoriesToAdd = [ - { - displayName: "TestCategory", - color: Office.MailboxEnums.CategoryColor.Preset0 - } - ]; + // Inserts an image anchored to the last paragraph. - Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Successfully added categories to master list"); - } else { - console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message); - } + await Word.run(async (context) => { + context.document.body.paragraphs + .getLast() + .insertParagraph("", "After") + .insertInlinePictureFromBase64(base64Image, "End"); + + await context.sync(); }); -'Office.MasterCategories#removeAsync:member(1)': +Word.ParagraphCollection#getFirst:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/45-categories/work-with-master-categories.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml - var masterCategoriesToRemove = ["TestCategory"]; + // Gets annotations found in the selected paragraph. - Office.context.mailbox.masterCategories.removeAsync(masterCategoriesToRemove, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Successfully removed categories from master list"); - } else { - console.log("masterCategories.removeAsync call failed with error: " + asyncResult.error.message); + await Word.run(async (context) => { + const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst(); + const annotations: Word.AnnotationCollection = paragraph.getAnnotations(); + annotations.load("id,state,critiqueAnnotation"); + + await context.sync(); + + console.log("Annotations found:"); + + for (let i = 0; i < annotations.items.length; i++) { + const annotation: Word.Annotation = annotations.items[i]; + + console.log(`ID ${annotation.id} - state '${annotation.state}':`, annotation.critiqueAnnotation.critique); } }); -'Office.AppointmentCompose#recurrence:member': +Word.ParagraphCollection#getLast:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml - Office.context.mailbox.item.recurrence.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var recurrence = asyncResult.value; - if (recurrence === null) { - console.log("This is a single appointment."); - } else { - console.log(`Recurrence pattern: ${JSON.stringify(recurrence)}`); - } - } else { - console.error(asyncResult.error); - } + + // Inserts an image anchored to the last paragraph. + + await Word.run(async (context) => { + context.document.body.paragraphs + .getLast() + .insertParagraph("", "After") + .insertInlinePictureFromBase64(base64Image, "End"); + + await context.sync(); }); +Word.ParagraphCollection#items:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml - // Important: Can only set the recurrence pattern of an appointment series. + // This example starts a new list with the second paragraph. - var currentDate = new Date(); + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("$none"); - let seriesTimeObject : Office.SeriesTime; + await context.sync(); - // Set series start date to tomorrow. + // Start new list using the second paragraph. + const list: Word.List = paragraphs.items[1].startNewList(); + list.load("$none"); - seriesTimeObject.setStartDate( - currentDate.getFullYear(), - currentDate.getMonth(), - currentDate.getDay() + 1 - ); + await context.sync(); - // Set series end date to 1 month from now. + // To add new items to the list, use Start or End on the insertLocation parameter. + list.insertParagraph("New list item at the start of the list", "Start"); + const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End"); - seriesTimeObject.setEndDate( - currentDate.getFullYear(), - currentDate.getMonth() + 1, - currentDate.getDay() - ); + // Set up list level for the list item. + paragraph.listItem.level = 4; - // Set start time to 1:30 PM. + // To add paragraphs outside the list, use Before or After. + list.insertParagraph("New paragraph goes after (not part of the list)", "After"); - seriesTimeObject.setStartTime(13, 30); + await context.sync(); + }); +Word.ParagraphDeletedEventArgs:interface: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml - // Set duration to 30 minutes. - seriesTimeObject.setDuration(30); + // Registers the onParagraphDeleted event handler on the document. + await Word.run(async (context) => { + eventContext = context.document.onParagraphDeleted.add(paragraphDeleted); + await context.sync(); - let pattern : Office.Recurrence = { - seriesTime: seriesTimeObject, - recurrenceType: "weekly", - recurrenceProperties: { interval: 1, days: ["tue", "thu"], firstDayOfWeek: "sun" }, - recurrenceTimeZone: { name: "Pacific Standard Time" } - }; + console.log("Added event handlers for when paragraphs are deleted."); + }); + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml - Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { - if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); + async function paragraphDeleted(event: Word.ParagraphDeletedEventArgs) { + await Word.run(async (context) => { + console.log(`${event.type} event detected. IDs of paragraphs that were deleted:`, event.uniqueLocalIds); + }); + } +Word.ParagraphFormat:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml + + + // Sets certain aspects of the specified style's paragraph format e.g., the + left indent size and the alignment. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update its paragraph format."); return; } - console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + style.paragraphFormat.leftIndent = 30; + style.paragraphFormat.alignment = Word.Alignment.centered; + console.log(`Successfully the paragraph format of the '${styleName}' style.`); + } }); -'Office.Recurrence#getAsync:member(1)': +Word.ParagraphFormat#alignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.recurrence.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - var recurrence = asyncResult.value; - if (recurrence === null) { - console.log("This is a single appointment."); - } else { - console.log(`Recurrence pattern: ${JSON.stringify(recurrence)}`); - } + + // Sets certain aspects of the specified style's paragraph format e.g., the + left indent size and the alignment. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update its paragraph format."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.error(asyncResult.error); + style.paragraphFormat.leftIndent = 30; + style.paragraphFormat.alignment = Word.Alignment.centered; + console.log(`Successfully the paragraph format of the '${styleName}' style.`); } }); -'Office.Recurrence#setAsync:member(1)': +Word.ParagraphFormat#leftIndent:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - // Important: Can only set the recurrence pattern of an appointment series. + // Sets certain aspects of the specified style's paragraph format e.g., the + left indent size and the alignment. - var currentDate = new Date(); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update its paragraph format."); + return; + } - let seriesTimeObject : Office.SeriesTime; + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); - // Set series start date to tomorrow. + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + style.paragraphFormat.leftIndent = 30; + style.paragraphFormat.alignment = Word.Alignment.centered; + console.log(`Successfully the paragraph format of the '${styleName}' style.`); + } + }); +Word.Range:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - seriesTimeObject.setStartDate( - currentDate.getFullYear(), - currentDate.getMonth(), - currentDate.getDay() + 1 - ); - // Set series end date to 1 month from now. + // Gets the range of the first comment in the selected content. - seriesTimeObject.setEndDate( - currentDate.getFullYear(), - currentDate.getMonth() + 1, - currentDate.getDay() - ); + await Word.run(async (context) => { + const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject(); + comment.load("contentRange"); + const range: Word.Range = comment.getRange(); + range.load("text"); + await context.sync(); - // Set start time to 1:30 PM. + if (comment.isNullObject) { + console.warn("No comments in the selection, so no range to get."); + return; + } - seriesTimeObject.setStartTime(13, 30); + console.log(`Comment location: ${range.text}`); + const contentRange: Word.CommentContentRange = comment.contentRange; + console.log("Comment content range:", contentRange); + }); +Word.Range#compareLocationWith:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/compare-location.yaml - // Set duration to 30 minutes. - seriesTimeObject.setDuration(30); + // Compares the location of one paragraph in relation to another paragraph. + await Word.run(async (context) => { + const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs; + paragraphs.load("items"); - let pattern : Office.Recurrence = { - seriesTime: seriesTimeObject, - recurrenceType: "weekly", - recurrenceProperties: { interval: 1, days: ["tue", "thu"], firstDayOfWeek: "sun" }, - recurrenceTimeZone: { name: "Pacific Standard Time" } - }; + await context.sync(); + const firstParagraphAsRange: Word.Range = paragraphs.items[0].getRange(); + const secondParagraphAsRange: Word.Range = paragraphs.items[1].getRange(); - Office.context.mailbox.item.recurrence.setAsync(pattern, (asyncResult) => { - if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Failed to set recurrence. Error: ${asyncResult.error.message}`); - return; + const comparedLocation = firstParagraphAsRange.compareLocationWith(secondParagraphAsRange); + + await context.sync(); + + const locationValue: Word.LocationRelation = comparedLocation.value; + console.log(`Location of the first paragraph in relation to the second paragraph: ${locationValue}`); + }); +Word.Range#expandTo:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml + + + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + const sentences: Word.RangeCollection = context.document + .getSelection() + .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); + sentences.load("$none"); + await context.sync(); + + // Expand the range to the end of the paragraph to get all the complete sentences. + const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0] + .getRange() + .expandTo( + context.document + .getSelection() + .paragraphs.getFirst() + .getRange(Word.RangeLocation.end) + ) + .getTextRanges(["."], false /* Don't trim spaces*/); + sentencesToTheEndOfParagraph.load("text"); + await context.sync(); + + for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) { + console.log(sentencesToTheEndOfParagraph.items[i].text); } - console.log(`Succeeded in setting recurrence pattern ${JSON.stringify(pattern)}`); }); -'Office.AppointmentRead#recurrence:member': +Word.Range#getComments:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-recurrence-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - var recurrence = Office.context.mailbox.item.recurrence; + // Gets the comments in the selected content. - if (recurrence === undefined) { - console.log("This item is a message but not a meeting request."); - } else if (recurrence === null) { - console.log("This is a single appointment."); - } else { - console.log(JSON.stringify(recurrence)); - } -'Office.MessageRead#recurrence:member': + await Word.run(async (context) => { + const comments: Word.CommentCollection = context.document.getSelection().getComments(); + + // Load objects to log in the console. + comments.load(); + await context.sync(); + + console.log("Comments:", comments); + }); +Word.Range#getContentControls:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-recurrence-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - var recurrence = Office.context.mailbox.item.recurrence; + // Deletes the first checkbox content control found in the selection. - if (recurrence === undefined) { - console.log("This item is a message but not a meeting request."); - } else if (recurrence === null) { - console.log("This is a single appointment."); - } else { - console.log(JSON.stringify(recurrence)); - } -'Office.AppointmentCompose#seriesId:member': + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id"); + + await context.sync(); + + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type"); + await context.sync(); + + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } + } + + console.log(`About to delete checkbox content control with id: ${selectedContentControl.id}`); + selectedContentControl.delete(false); + await context.sync(); + + console.log("Deleted checkbox content control."); + }); +Word.Range#getRange:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-series-id.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml - var seriesId = Office.context.mailbox.item.seriesId; + // Places a dropdown list content control at the end of the selection. - if (seriesId === undefined) { - console.log("This is a message that's not a meeting request."); - } else if (seriesId === null) { - console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); - } else { - console.log("This is an instance belonging to series with ID " + seriesId); - } -'Office.AppointmentRead#seriesId:member': + await Word.run(async (context) => { + let selection = context.document.getSelection(); + selection.getRange(Word.RangeLocation.end).insertContentControl(Word.ContentControlType.dropDownList); + await context.sync(); + + console.log("Dropdown list content control inserted at the end of the selection."); + }); +Word.Range#getReviewedText:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-series-id.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml - var seriesId = Office.context.mailbox.item.seriesId; + // Gets the reviewed text. - if (seriesId === undefined) { - console.log("This is a message that's not a meeting request."); - } else if (seriesId === null) { - console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); - } else { - console.log("This is an instance belonging to series with ID " + seriesId); - } -'Office.MessageCompose#seriesId:member': + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection(); + const before = range.getReviewedText(Word.ChangeTrackingVersion.original); + const after = range.getReviewedText(Word.ChangeTrackingVersion.current); + + await context.sync(); + + console.log("Reviewed text (before):", before.value, "Reviewed text (after):", after.value); + }); +Word.Range#getTextRanges:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-series-id.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml - var seriesId = Office.context.mailbox.item.seriesId; + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + const sentences: Word.RangeCollection = context.document + .getSelection() + .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); + sentences.load("$none"); + await context.sync(); - if (seriesId === undefined) { - console.log("This is a message that's not a meeting request."); - } else if (seriesId === null) { - console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); - } else { - console.log("This is an instance belonging to series with ID " + seriesId); - } -'Office.MessageRead#seriesId:member': + // Expand the range to the end of the paragraph to get all the complete sentences. + const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0] + .getRange() + .expandTo( + context.document + .getSelection() + .paragraphs.getFirst() + .getRange(Word.RangeLocation.end) + ) + .getTextRanges(["."], false /* Don't trim spaces*/); + sentencesToTheEndOfParagraph.load("text"); + await context.sync(); + + for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) { + console.log(sentencesToTheEndOfParagraph.items[i].text); + } + }); +Word.Range#insertComment:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/50-recurrence/get-series-id.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml - var seriesId = Office.context.mailbox.item.seriesId; + // Sets a comment on the selected content. - if (seriesId === undefined) { - console.log("This is a message that's not a meeting request."); - } else if (seriesId === null) { - console.log("This is a single appointment, a parent series, or a meeting request for a series or single meeting."); - } else { - console.log("This is an instance belonging to series with ID " + seriesId); - } -'Office.Mailbox#displayAppointmentForm:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-existing-appointment.yaml + await Word.run(async (context) => { + const text = (document.getElementById("comment-text") as HTMLInputElement).value; + const comment: Word.Comment = context.document.getSelection().insertComment(text); - var itemId = $("#itemId").val(); + // Load object to log in the console. + comment.load(); + await context.sync(); - Office.context.mailbox.displayAppointmentForm(itemId); -'Office.Mailbox#displayMessageForm:member(1)': + console.log("Comment inserted:", comment); + }); +Word.Range#insertContentControl:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-existing-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml - var itemId = $("#itemId").val(); - Office.context.mailbox.displayMessageForm(itemId); -'Office.Mailbox#displayNewAppointmentForm:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-new-appointment.yaml + // Simulates creation of a template. First searches the document for + instances of the string "Contractor", - var start = new Date(); + // then changes the format of each search result, - var end = new Date(); + // then wraps each search result within a content control, - end.setHours(start.getHours() + 1); + // finally sets a tag and title property on each content control. + await Word.run(async (context) => { + const results: Word.RangeCollection = context.document.body.search("Contractor"); + results.load("font/bold"); - Office.context.mailbox.displayNewAppointmentForm({ - requiredAttendees: ["bob@contoso.com"], - optionalAttendees: ["sam@contoso.com"], - start: start, - end: end, - location: "Home", - subject: "meeting", - resources: ["projector@contoso.com"], - body: "Hello World!" - }); -'Office.Mailbox#displayNewMessageForm:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-new-message.yaml + // Check to make sure these content controls haven't been added yet. + const customerContentControls: Word.ContentControlCollection = context.document.contentControls.getByTag("customer"); + customerContentControls.load("text"); + await context.sync(); - Office.context.mailbox.displayNewMessageForm({ - toRecipients: Office.context.mailbox.item.to, // Copies the To line from current item - ccRecipients: ["sam@contoso.com"], - subject: "Outlook add-ins are cool!", - htmlBody: 'Hello World!
    ', - attachments: [ - { - type: "file", - name: "image.png", - url: "http://www.cutestpaw.com/wp-content/uploads/2011/11/Cute-Black-Dogs-s.jpg", - isInline: true + if (customerContentControls.items.length === 0) { + for (let i = 0; i < results.items.length; i++) { + results.items[i].font.bold = true; + let cc: Word.ContentControl = results.items[i].insertContentControl(); + cc.tag = "customer"; // This value is used in the next step of this sample. + cc.title = "Customer Name " + i; } - ] + } + await context.sync(); }); -'Office.AppointmentRead#displayReplyForm:member(1)': +Word.Range#insertField:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml - Office.context.mailbox.item.displayReplyForm("This is a reply with some - text in italics."); - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-with-attachments.yaml - Office.context.mailbox.item.displayReplyForm({ - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
    ", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ], - options: { asyncContext: null }, - callback: function(result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); - } + // Inserts a Date field before selection. + + await Word.run(async (context) => { + const range: Word.Range = context.document.getSelection().getRange(); + + const field: Word.Field = range.insertField(Word.InsertLocation.before, Word.FieldType.date, '\\@ "M/d/yyyy h:mm am/pm"', true); + + field.load("result,code"); + await context.sync(); + + if (field.isNullObject) { + console.log("There are no fields in this document."); + } else { + console.log("Code of the field: " + field.code, "Result of the field: " + JSON.stringify(field.result)); } }); -'Office.MessageRead#displayReplyForm:member(1)': +Word.Range#insertFootnote:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - Office.context.mailbox.item.displayReplyForm("This is a reply with some - text in italics."); + + // Sets a footnote on the selected content. + + await Word.run(async (context) => { + const text = (document.getElementById("input-footnote") as HTMLInputElement).value; + const footnote: Word.NoteItem = context.document.getSelection().insertFootnote(text); + await context.sync(); + + console.log("Inserted footnote."); + }); +Word.Range#insertInlinePictureFromBase64:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-with-attachments.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.displayReplyForm({ - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
    ", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ], - options: { asyncContext: null }, - callback: function(result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); - } - } + + await Word.run(async (context) => { + // Inserts a picture at the start of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const startRange: Word.Range = firstShapeWithTextBox.body.getRange(Word.RangeLocation.start); + const newPic: Word.InlinePicture = startRange.insertInlinePictureFromBase64( + getPictureBase64(), + Word.InsertLocation.start + ); + newPic.load(); + await context.sync(); + + console.log("New inline picture properties:", newPic); }); -'Office.AppointmentRead#displayReplyAllForm:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.displayReplyAllForm("This is a reply ALL with - some bold text."); -'Office.MessageRead#displayReplyAllForm:member(1)': + + // Returns Base64-encoded image data for a sample picture. + + const pictureBase64 = + "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"; + return pictureBase64; +Word.Range#insertGeometricShape:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - Office.context.mailbox.item.displayReplyAllForm("This is a reply ALL with - some bold text."); -'Office.Mailbox#displayAppointmentFormAsync:member(1)': + + await Word.run(async (context) => { + // Inserts a moon geometric shape at the beginning of the selection. + const selection: Word.Range = context.document.getSelection(); + const shapeOptions: Word.InsertShapeOptions = { + height: 120, + width: 120, + left: 120, + }; + selection.insertGeometricShape(Word.GeometricShapeType.moon, shapeOptions); + await context.sync(); + + console.log("Inserted a moon."); + }); +Word.Range#insertTextBox:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-existing-appointment.yaml - - var itemId = $("#itemId").val(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // The async version will return error 9049 if the item is not found. + await Word.run(async (context) => { + // Inserts a text box at the beginning of the selection. + const range: Word.Range = context.document.getSelection(); + const insertShapeOptions: Word.InsertShapeOptions = { + top: 0, + left: 0, + height: 100, + width: 100 + }; - // The async version is only available starting with requirement set 1.9. + const newTextBox: Word.Shape = range.insertTextBox("placeholder text", insertShapeOptions); + await context.sync(); - Office.context.mailbox.displayAppointmentFormAsync(itemId, - function(asyncResult) { - console.log("Result: " + JSON.stringify(asyncResult)); + console.log("Inserted a text box at the beginning of the current selection."); }); -'Office.Mailbox#displayMessageFormAsync:member(1)': +Word.Range#footnotes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-existing-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml - var itemId = $("#itemId").val(); + // Gets the footnotes in the selected document range. - // The async version will return error 9049 if the item is not found. - - // The async version is only available starting with requirement set 1.9. + await Word.run(async (context) => { + const footnotes: Word.NoteItemCollection = context.document.getSelection().footnotes; + footnotes.load("length"); + await context.sync(); - Office.context.mailbox.displayMessageFormAsync(itemId, function - (asyncResult) { - console.log("Result: " + JSON.stringify(asyncResult)); + console.log("Number of footnotes in the selected range: " + footnotes.items.length); }); -'Office.Mailbox#displayNewAppointmentFormAsync:member(1)': +Word.Range#parentContentControl:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-new-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml - var start = new Date(); - var end = new Date(); - - end.setHours(start.getHours() + 1); + // Toggles the isChecked property of the first checkbox content control + found in the selection. + await Word.run(async (context) => { + const selectedRange: Word.Range = context.document.getSelection(); + let selectedContentControl = selectedRange + .getContentControls({ + types: [Word.ContentControlType.checkBox] + }) + .getFirstOrNullObject(); + selectedContentControl.load("id,checkboxContentControl/isChecked"); - // The async version is only available starting with requirement set 1.9, + await context.sync(); - // and provides a callback when the new appointment form has been created. + if (selectedContentControl.isNullObject) { + const parentContentControl: Word.ContentControl = selectedRange.parentContentControl; + parentContentControl.load("id,type,checkboxContentControl/isChecked"); + await context.sync(); - Office.context.mailbox.displayNewAppointmentFormAsync( - { - requiredAttendees: ["bob@contoso.com"], - optionalAttendees: ["sam@contoso.com"], - start: start, - end: end, - location: "Home", - subject: "meeting", - resources: ["projector@contoso.com"], - body: "Hello World!" - }, - function(asyncResult) { - console.log(JSON.stringify(asyncResult)); + if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) { + console.warn("No checkbox content control is currently selected."); + return; + } else { + selectedContentControl = parentContentControl; + } } - ); -'Office.Mailbox#displayNewMessageFormAsync:member(1)': + + const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked; + console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`); + selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore; + selectedContentControl.load("id,checkboxContentControl/isChecked"); + await context.sync(); + + console.log( + "isChecked state after:", + `id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}` + ); + }); +Word.Range#styleBuiltIn:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-new-message.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml - // The async version is only available starting with requirement set 1.9, - // and provides a callback when the new message form has been created. + await Word.run(async (context) => { + const header: Word.Range = context.document.body.insertText("This is a sample Heading 1 Title!!\n", + "Start" /*this means at the beginning of the body */); + header.styleBuiltIn = Word.BuiltInStyleName.heading1; - Office.context.mailbox.displayNewMessageFormAsync( - { - toRecipients: Office.context.mailbox.item.to, // Copies the To line from current item - ccRecipients: ["sam@contoso.com"], - subject: "Outlook add-ins are cool!", - htmlBody: 'Hello World!
    ', - attachments: [ - { - type: "file", - name: "image.png", - url: "http://www.cutestpaw.com/wp-content/uploads/2011/11/Cute-Black-Dogs-s.jpg", - isInline: true - } - ] - }, - function(asyncResult) { - console.log(JSON.stringify(asyncResult)); + await context.sync(); + }); +Word.RangeCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/search.yaml + + + // Does a basic text search and highlights matches in the document. + + await Word.run(async (context) => { + const results : Word.RangeCollection = context.document.body.search("extend"); + results.load("length"); + + await context.sync(); + + // Let's traverse the search results and highlight matches. + for (let i = 0; i < results.items.length; i++) { + results.items[i].font.highlightColor = "yellow"; } - ); -'Office.AppointmentRead#displayReplyFormAsync:member(1)': + + await context.sync(); + }); +Word.RangeLocation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml - Office.context.mailbox.item.displayReplyFormAsync("This is a reply with - some text in italics.", function( - asyncResult - ) { - console.log(JSON.stringify(asyncResult)); + + await Word.run(async (context) => { + // Get the complete sentence (as range) associated with the insertion point. + const sentences: Word.RangeCollection = context.document + .getSelection() + .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); + sentences.load("$none"); + await context.sync(); + + // Expand the range to the end of the paragraph to get all the complete sentences. + const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0] + .getRange() + .expandTo( + context.document + .getSelection() + .paragraphs.getFirst() + .getRange(Word.RangeLocation.end) + ) + .getTextRanges(["."], false /* Don't trim spaces*/); + sentencesToTheEndOfParagraph.load("text"); + await context.sync(); + + for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) { + console.log(sentencesToTheEndOfParagraph.items[i].text); + } }); +Word.RelativeHorizontalPosition:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-with-attachments.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - // The async version is only available starting with requirement set 1.9, - // and provides a callback when the new appointment form has been created. + await Word.run(async (context) => { + // Changes the position of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - Office.context.mailbox.item.displayReplyFormAsync( - { - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
    ", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ] - }, - function(asyncResult) { - console.log(JSON.stringify(asyncResult)); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; } - ); -'Office.MessageRead#displayReplyFormAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml - Office.context.mailbox.item.displayReplyFormAsync("This is a reply with - some text in italics.", function( - asyncResult - ) { - console.log(JSON.stringify(asyncResult)); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes); + firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin; + firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin; + + console.log("Changed the position of the first shape group."); }); +Word.RelativeSize:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-with-attachments.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - // The async version is only available starting with requirement set 1.9, - // and provides a callback when the new appointment form has been created. + await Word.run(async (context) => { + // Changes the relative size of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - Office.context.mailbox.item.displayReplyFormAsync( - { - htmlBody: "This is a reply with a couple of attachments - an inline image and an item
    ", - attachments: [ - { type: "file", url: "http://i.imgur.com/9S36xvA.jpg", name: "dog.jpg", isInline: true }, - { type: "item", itemId: Office.context.mailbox.item.itemId, name: "test_email.msg" } - ] - }, - function(asyncResult) { - console.log(JSON.stringify(asyncResult)); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; } - ); -'Office.AppointmentRead#displayReplyAllFormAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml - Office.context.mailbox.item.displayReplyAllFormAsync("This is a reply ALL - with some bold text.", function( - asyncResult - ) { - console.log(JSON.stringify(asyncResult)); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log( + "About to change the relative size of the first shape group found in the document body:", + shapeGroup.shapes, + ); + firstShapeGroup.relativeHorizontalSize = Word.RelativeSize.insideMargin; + firstShapeGroup.relativeVerticalSize = Word.RelativeSize.bottomMargin; + firstShapeGroup.heightRelative = 50; + + console.log("Changed the relative size of the first shape group."); }); -'Office.MessageRead#displayReplyAllFormAsync:member(1)': +Word.RelativeVerticalPosition:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/55-display-items/display-reply-forms.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - Office.context.mailbox.item.displayReplyAllFormAsync("This is a reply ALL - with some bold text.", function( - asyncResult - ) { - console.log(JSON.stringify(asyncResult)); + + await Word.run(async (context) => { + // Changes the position of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes); + firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin; + firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin; + + console.log("Changed the position of the first shape group."); }); -'Office.AppointmentCompose#getSharedPropertiesAsync:member(2)': +Word.SaveBehavior:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an item from a shared folder."); - return; - } + // If the document hasn't been saved before, prompts - Office.context.mailbox.item.getSharedPropertiesAsync(function(result) { - console.log(result.value); + // user with options for if or how they want to save. + + await Word.run(async (context) => { + context.document.save(Word.SaveBehavior.prompt); + await context.sync(); }); -'Office.AppointmentRead#getSharedPropertiesAsync:member(2)': +Word.SaveConfiguration:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml - - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an item from a shared folder."); - return; - } + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/close-document-window.yaml - Office.context.mailbox.item.getSharedPropertiesAsync(function(result) { - console.log(result.value); + await Word.run(async (context) => { + // Closes the document window, prompting to save if this is a new document. + const window: Word.Window = context.document.activeWindow; + const closeOptions: Word.WindowCloseOptions = { saveChanges: Word.SaveConfiguration.promptToSaveChanges }; + console.log("About to close the document window..."); + window.close(closeOptions); }); -'Office.MessageCompose#getSharedPropertiesAsync:member(2)': +Word.Section#getFooter:member(2): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-header-and-footer.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an item from a shared folder."); - return; - } + await Word.run(async (context) => { + context.document.sections + .getFirst() + .getFooter("Primary") + .insertParagraph("This is a primary footer.", "End"); - Office.context.mailbox.item.getSharedPropertiesAsync(function(result) { - console.log(result.value); + await context.sync(); }); -'Office.MessageRead#getSharedPropertiesAsync:member(2)': +Word.Section#getHeader:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-header-and-footer.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an item from a shared folder."); - return; - } + await Word.run(async (context) => { + context.document.sections + .getFirst() + .getHeader(Word.HeaderFooterType.primary) + .insertParagraph("This is a primary header.", "End"); - Office.context.mailbox.item.getSharedPropertiesAsync(function(result) { - console.log(result.value); + await context.sync(); }); -'Office.AppointmentCompose#getSharedPropertiesAsync:member(1)': +Word.Section:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-section-breaks.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an appointment from a shared folder."); - return; - } + // Inserts a section break on the next page. - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, - function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/events/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); - } + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionNext, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section break on next page."); }); -'Office.AppointmentRead#getSharedPropertiesAsync:member(1)': +Word.SectionCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-section-breaks.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on an appointment from a shared folder."); - return; - } + // Inserts a section break on the next even page. - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, - function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/events/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); - } + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + body.insertBreak(Word.BreakType.sectionEven, Word.InsertLocation.end); + + await context.sync(); + + console.log("Inserted section break on next even page."); }); -'Office.MessageCompose#getSharedPropertiesAsync:member(1)': +Word.SelectionMode:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on a message from a shared folder."); - return; - } + await Word.run(async (context) => { + // Select can be at the start or end of a range; this by definition moves the insertion point without selecting the range. + context.document.body.paragraphs.getLast().select(Word.SelectionMode.end); - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, - function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/messages/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); - } + await context.sync(); }); -'Office.MessageRead#getSharedPropertiesAsync:member(1)': +Word.Setting:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - if (!Office.context.mailbox.item.getSharedPropertiesAsync) { - console.error("Try this sample on a message from a shared folder."); - return; - } + // Adds a new custom setting or - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, - function(result) { - if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") { - Office.context.mailbox.item.getSharedPropertiesAsync( - { - // Pass auth token along. - asyncContext: result.value - }, - function(result2) { - let sharedProperties = result2.value; - let delegatePermissions = sharedProperties.delegatePermissions; - - // Determine if user has the appropriate permission to do the operation. - if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) { - var ewsId = Office.context.mailbox.item.itemId; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - let rest_url = - sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/messages/" + restId; - - $.ajax({ - url: rest_url, - dataType: "json", - headers: { Authorization: "Bearer " + result2.asyncContext } - }) - .done(function(response) { - console.log(response); - }) - .fail(function(error) { - console.error(error); - }); - } - } - ); + // edits the value of an existing one. + + await Word.run(async (context) => { + const key = (document.getElementById("key") as HTMLInputElement).value; + if (key == "") { + console.error("Key shouldn't be empty."); + return; } + + const value = (document.getElementById("value") as HTMLInputElement).value; + const settings: Word.SettingCollection = context.document.settings; + const setting: Word.Setting = settings.add(key, value); + setting.load(); + await context.sync(); + + console.log("Setting added or edited:", setting); }); -'Office.AppointmentRead#getEntities:member(1)': +Word.Setting#key:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - var entities = Office.context.mailbox.item.getEntities(); - var entityTypesFound = 0; + // Adds a new custom setting or - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } + // edits the value of an existing one. - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } + await Word.run(async (context) => { + const key = (document.getElementById("key") as HTMLInputElement).value; + if (key == "") { + console.error("Key shouldn't be empty."); + return; + } - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } + const value = (document.getElementById("value") as HTMLInputElement).value; + const settings: Word.SettingCollection = context.document.settings; + const setting: Word.Setting = settings.add(key, value); + setting.load(); + await context.sync(); - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } + console.log("Setting added or edited:", setting); + }); +Word.Setting#value:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } + // Adds a new custom setting or - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } + // edits the value of an existing one. - if (entityTypesFound == 0) + await Word.run(async (context) => { + const key = (document.getElementById("key") as HTMLInputElement).value; + if (key == "") { + console.error("Key shouldn't be empty."); + return; + } - { - console.log("No entities found on this item."); - } -'Office.MessageRead#getEntities:member(1)': + const value = (document.getElementById("value") as HTMLInputElement).value; + const settings: Word.SettingCollection = context.document.settings; + const setting: Word.Setting = settings.add(key, value); + setting.load(); + await context.sync(); + + console.log("Setting added or edited:", setting); + }); +Word.SettingCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml - - var entities = Office.context.mailbox.item.getEntities(); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - var entityTypesFound = 0; - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } - - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } + // Deletes all custom settings this add-in had set on this document. - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + settings.deleteAll(); + await context.sync(); + console.log("All settings deleted."); + }); +Word.SettingCollection#add:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } + // Adds a new custom setting or - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } + // edits the value of an existing one. - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } + await Word.run(async (context) => { + const key = (document.getElementById("key") as HTMLInputElement).value; + if (key == "") { + console.error("Key shouldn't be empty."); + return; + } - if (entityTypesFound == 0) + const value = (document.getElementById("value") as HTMLInputElement).value; + const settings: Word.SettingCollection = context.document.settings; + const setting: Word.Setting = settings.add(key, value); + setting.load(); + await context.sync(); - { - console.log("No entities found on this item."); - } -'Office.AppointmentRead#getEntitiesByType:member(1)': + console.log("Setting added or edited:", setting); + }); +Word.SettingCollection#items:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml - console.log(Office.context.mailbox.item.getEntitiesByType(Office.MailboxEnums.EntityType.Address)); -'Office.MessageRead#getEntitiesByType:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml - console.log(Office.context.mailbox.item.getEntitiesByType(Office.MailboxEnums.EntityType.Address)); -'Office.AppointmentRead#getFilteredEntitiesByName:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml + // Gets all custom settings this add-in set on this document. - // This API would only work when you click on highlighted physical address - that has the word "Way" in it. + await Word.run(async (context) => { + const settings: Word.SettingCollection = context.document.settings; + settings.load("items"); + await context.sync(); - console.log(Office.context.mailbox.item.getFilteredEntitiesByName("sampleFilterName")); -'Office.MessageRead#getFilteredEntitiesByName:member(1)': + if (settings.items.length == 0) { + console.log("There are no settings."); + } else { + console.log("All settings:"); + for (let i = 0; i < settings.items.length; i++) { + console.log(settings.items[i]); + } + } + }); +Word.Shading:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - // This API would only work when you click on highlighted physical address - that has the word "Way" in it. - - console.log(Office.context.mailbox.item.getFilteredEntitiesByName("sampleFilterName")); -'Office.AppointmentRead#getRegExMatches:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml - // This API would only work when you click on highlighted word "ScriptLab". + // Updates shading properties (e.g., texture, pattern colors) of the + specified style. - console.log(Office.context.mailbox.item.getRegExMatches()); -'Office.MessageRead#getRegExMatches:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update shading properties."); + return; + } - // This API would only work when you click on highlighted word "ScriptLab". + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); - console.log(Office.context.mailbox.item.getRegExMatches()); -'Office.AppointmentRead#getRegExMatchesByName:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const shading: Word.Shading = style.shading; + shading.load(); + await context.sync(); - // This API would only work when you click on highlighted word "ScriptLab". + shading.backgroundPatternColor = "blue"; + shading.foregroundPatternColor = "yellow"; + shading.texture = Word.ShadingTextureType.darkTrellis; - console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); -'Office.MessageRead#getRegExMatchesByName:member(1)': + console.log("Updated shading."); + } + }); +Word.ShadingTextureType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/contextual.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - // This API would only work when you click on highlighted word "ScriptLab". - console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName")); -'Office.AppointmentRead#getSelectedEntities:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/selected.yaml + // Updates shading properties (e.g., texture, pattern colors) of the + specified style. - var entities = Office.context.mailbox.item.getSelectedEntities(); + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update shading properties."); + return; + } - var entityTypesFound = 0; + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else { + const shading: Word.Shading = style.shading; + shading.load(); + await context.sync(); - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } + shading.backgroundPatternColor = "blue"; + shading.foregroundPatternColor = "yellow"; + shading.texture = Word.ShadingTextureType.darkTrellis; - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } + console.log("Updated shading."); + } + }); +Word.Shape:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } + await Word.run(async (context) => { + // Sets the properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.top = 115; + firstShapeWithTextBox.left = 0; + firstShapeWithTextBox.width = 50; + firstShapeWithTextBox.height = 50; + await context.sync(); - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } + console.log("The first text box's properties were updated:", firstShapeWithTextBox); + }); +Word.Shape#delete:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } - if (entityTypesFound == 0) + await Word.run(async (context) => { + // Deletes the first text box. + context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirst().delete(); + await context.sync(); - { - console.error("Open add-in by clicking on a highlighted entity, for this API to return something useful."); - } -'Office.MessageRead#getSelectedEntities:member(1)': + console.log("The first text box in document was deleted."); + }); +Word.Shape#group:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/selected.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var entities = Office.context.mailbox.item.getSelectedEntities(); - var entityTypesFound = 0; + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); - if (entities.addresses.length > 0) { - console.warn("physical addresses: "); - console.log(entities.addresses); - entityTypesFound++; - } + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); + return; + } - if (entities.contacts.length > 0) { - console.warn("contacts: "); - entities.contacts.forEach(function (contact) { console.log(contact.personName); }) - entityTypesFound++; - } + console.log(`Number of shapes to group: ${numShapes}`); - if (entities.emailAddresses.length > 0) { - console.warn("email addresses: "); - console.log(entities.emailAddresses); - entityTypesFound++; - } + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); - if (entities.meetingSuggestions.length > 0) { - console.warn("meetings suggestions: "); - entities.meetingSuggestions.forEach(function (meetingSuggestion) { console.log(meetingSuggestion.meetingString); }) - entityTypesFound++; - } + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); + }); +Word.Shape#moveHorizontally:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - if (entities.phoneNumbers.length > 0) { - console.warn("phone numbers: "); - entities.phoneNumbers.forEach(function (phoneNumber) { console.log(phoneNumber.originalPhoneString); }) - entityTypesFound++; - } - if (entities.taskSuggestions.length > 0) { - console.warn("task suggestions: "); - entities.taskSuggestions.forEach(function (taskSuggestion) { console.log(taskSuggestion.taskString); }) - entityTypesFound++; - } + await Word.run(async (context) => { + // Moves the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - if (entities.urls.length > 0) { - console.warn("URLs: "); - console.log(entities.urls); - entityTypesFound++; - } + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - if (entityTypesFound == 0) + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to move the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.moveHorizontally(-10); + firstShapeGroup.moveVertically(50); - { - console.error("Open add-in by clicking on a highlighted entity, for this API to return something useful."); - } -'Office.AppointmentRead#getSelectedRegExMatches:member(1)': + console.log("Moved the first shape group."); + }); +Word.Shape#moveVertically:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/selected.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var matches = Office.context.mailbox.item.getSelectedRegExMatches(); - if (matches) { - console.log(matches); - } + await Word.run(async (context) => { + // Moves the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - else { - console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); - } -'Office.MessageRead#getSelectedRegExMatches:member(1)': + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to move the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.moveHorizontally(-10); + firstShapeGroup.moveVertically(50); + + console.log("Moved the first shape group."); + }); +Word.Shape#scaleHeight:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/75-entities-and-regex-matches/selected.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var matches = Office.context.mailbox.item.getSelectedRegExMatches(); - if (matches) { - console.log(matches); - } + await Word.run(async (context) => { + // Scales the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - else { - console.error("Open add-in by clicking on a highlighted regex match, for this API to return something useful."); - } -'Office.Mailbox#convertToRestId:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function - (result) { - var ewsId = Office.context.mailbox.item.itemId; - var token = result.value; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + restId; - - var xhr = new XMLHttpRequest(); - xhr.open('GET', getMessageUrl); - xhr.setRequestHeader("Authorization", "Bearer " + token); - xhr.onload = function (e) { - console.log(this.response); - } - xhr.send(); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize); + firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight); + + console.log("Scaled the first shape group."); }); +Word.Shape#scaleWidth:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - console.log("EWS URL: " + Office.context.mailbox.ewsUrl); - var ewsId = Office.context.mailbox.item.itemId; + await Word.run(async (context) => { + // Scales the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize); + firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight); - console.log("REST URL: " + Office.context.mailbox.restUrl); + console.log("Scaled the first shape group."); + }); +Word.Shape#select:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var restId = Office.context.mailbox.convertToRestId(ewsId, - Office.MailboxEnums.RestVersion.v2_0); - console.log("REST item ID: " + restId); + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); + return; + } - var ewsId2 = Office.context.mailbox.convertToEwsId(restId, - Office.MailboxEnums.RestVersion.v2_0); + console.log(`Number of shapes to group: ${numShapes}`); - console.log("EWS ID (from REST ID): " + ewsId2); -'Office.Mailbox#restUrl:member': + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); + + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); + }); +Word.Shape#body:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function - (result) { - var ewsId = Office.context.mailbox.item.itemId; - var token = result.value; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + restId; - - var xhr = new XMLHttpRequest(); - xhr.open('GET', getMessageUrl); - xhr.setRequestHeader("Authorization", "Bearer " + token); - xhr.onload = function (e) { - console.log(this.response); - } - xhr.send(); + + await Word.run(async (context) => { + // Inserts a content control into the first paragraph in the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const firstParagraphInTextBox: Word.Paragraph = firstShapeWithTextBox.body.paragraphs.getFirst(); + const newControl: Word.ContentControl = firstParagraphInTextBox.insertContentControl(); + newControl.load(); + await context.sync(); + + console.log("New content control properties:", newControl); }); +Word.Shape#canvas:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-canvases.yaml - console.log("EWS URL: " + Office.context.mailbox.ewsUrl); - var ewsId = Office.context.mailbox.item.itemId; + await Word.run(async (context) => { + // Inserts a canvas in the document. + const canvasShape: Word.Shape = context.document.getSelection().insertCanvas(); + canvasShape.load(); + await context.sync(); - console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + canvasShape.select(); + console.log("Inserted canvas:", canvasShape); + const canvas: Word.Canvas = canvasShape.canvas; + canvas.load("shape,shapes"); + await context.sync(); - console.log("REST URL: " + Office.context.mailbox.restUrl); + console.log("Canvas object:", canvas); + }); +Word.Shape#fill:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - var restId = Office.context.mailbox.convertToRestId(ewsId, - Office.MailboxEnums.RestVersion.v2_0); - console.log("REST item ID: " + restId); + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } - var ewsId2 = Office.context.mailbox.convertToEwsId(restId, - Office.MailboxEnums.RestVersion.v2_0); + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; - console.log("EWS ID (from REST ID): " + ewsId2); -'Office.Mailbox#getCallbackTokenAsync:member(1)': + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); + }); +Word.Shape#geometricShapeType:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function - (result) { - var ewsId = Office.context.mailbox.item.itemId; - var token = result.value; - var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0); - var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + restId; - - var xhr = new XMLHttpRequest(); - xhr.open('GET', getMessageUrl); - xhr.setRequestHeader("Authorization", "Bearer " + token); - xhr.onload = function (e) { - console.log(this.response); - } - xhr.send(); + + await Word.run(async (context) => { + // Gets the first geometric shape found in the document body. + const geometricShape: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.geometricShape]) + .getFirstOrNullObject(); + geometricShape.load(); + await context.sync(); + + if (geometricShape.isNullObject) { + console.log("No geometric shapes found in the document body."); + return; + } + + console.log( + `First geometric shape found in the document body is of type ${geometricShape.geometricShapeType}:`, + geometricShape, + ); }); -'Office.Mailbox#ewsUrl:member': +Word.Shape#heightRelative:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - console.log("EWS URL: " + Office.context.mailbox.ewsUrl); - var ewsId = Office.context.mailbox.item.itemId; + await Word.run(async (context) => { + // Changes the relative size of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log( + "About to change the relative size of the first shape group found in the document body:", + shapeGroup.shapes, + ); + firstShapeGroup.relativeHorizontalSize = Word.RelativeSize.insideMargin; + firstShapeGroup.relativeVerticalSize = Word.RelativeSize.bottomMargin; + firstShapeGroup.heightRelative = 50; - console.log("REST URL: " + Office.context.mailbox.restUrl); + console.log("Changed the relative size of the first shape group."); + }); +Word.Shape#relativeHorizontalPosition:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var restId = Office.context.mailbox.convertToRestId(ewsId, - Office.MailboxEnums.RestVersion.v2_0); - console.log("REST item ID: " + restId); + await Word.run(async (context) => { + // Changes the position of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - var ewsId2 = Office.context.mailbox.convertToEwsId(restId, - Office.MailboxEnums.RestVersion.v2_0); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes); + firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin; + firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin; - console.log("EWS ID (from REST ID): " + ewsId2); -'Office.Mailbox#convertToEwsId:member(1)': + console.log("Changed the position of the first shape group."); + }); +Word.Shape#relativeHorizontalSize:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml - - console.log("EWS URL: " + Office.context.mailbox.ewsUrl); + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var ewsId = Office.context.mailbox.item.itemId; - console.log("EWS item ID: " + Office.context.mailbox.item.itemId); + await Word.run(async (context) => { + // Changes the relative size of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - console.log("REST URL: " + Office.context.mailbox.restUrl); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log( + "About to change the relative size of the first shape group found in the document body:", + shapeGroup.shapes, + ); + firstShapeGroup.relativeHorizontalSize = Word.RelativeSize.insideMargin; + firstShapeGroup.relativeVerticalSize = Word.RelativeSize.bottomMargin; + firstShapeGroup.heightRelative = 50; - var restId = Office.context.mailbox.convertToRestId(ewsId, - Office.MailboxEnums.RestVersion.v2_0); + console.log("Changed the relative size of the first shape group."); + }); +Word.Shape#relativeVerticalPosition:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - console.log("REST item ID: " + restId); + await Word.run(async (context) => { + // Changes the position of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - var ewsId2 = Office.context.mailbox.convertToEwsId(restId, - Office.MailboxEnums.RestVersion.v2_0); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - console.log("EWS ID (from REST ID): " + ewsId2); -'Office.AppointmentCompose#getItemIdAsync:member(2)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes); + firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin; + firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin; - Office.context.mailbox.item.getItemIdAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`getItemIdAsync failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } + console.log("Changed the position of the first shape group."); }); -'Office.MessageCompose#getItemIdAsync:member(2)': +Word.Shape#relativeVerticalSize:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - Office.context.mailbox.item.getItemIdAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`getItemIdAsync failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } - }); -'Office.Mailbox#makeEwsRequestAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml - var ewsId = Office.context.mailbox.item.itemId; + await Word.run(async (context) => { + // Changes the relative size of the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - var request = '' + - ' ' + - ' ' + - ' ' + - ' ' + - ' IdOnly' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ''; + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log( + "About to change the relative size of the first shape group found in the document body:", + shapeGroup.shapes, + ); + firstShapeGroup.relativeHorizontalSize = Word.RelativeSize.insideMargin; + firstShapeGroup.relativeVerticalSize = Word.RelativeSize.bottomMargin; + firstShapeGroup.heightRelative = 50; - Office.context.mailbox.makeEwsRequestAsync(request, function (result) { - console.log(result); + console.log("Changed the relative size of the first shape group."); }); +Word.Shape#shapeGroup:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var request = ''+ - ' '+ - ' '+ - ' '+ - ' '+ - ' '+ - ' '+ - ' Hello, Outlook!'+ - ' This message was sent from a ScriptLab code sample, used from ' + Office.context.mailbox.diagnostics.hostName + ', version ' + Office.context.mailbox.diagnostics.hostVersion + '!'+ - ' '+ - ' ' + Office.context.mailbox.userProfile.emailAddress + ''+ - ' '+ - ' '+ - ' '+ - ' '+ - ' '+ - ''; - Office.context.mailbox.makeEwsRequestAsync(request, function (result) { - console.log(result); - }); -'Office.Mailbox#getCallbackTokenAsync:member(2)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); - Office.context.mailbox.getCallbackTokenAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Token retrieval failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } - }); -'Office.Mailbox#getUserIdentityTokenAsync:member(1)': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); + return; + } - Office.context.mailbox.getUserIdentityTokenAsync(function (result) { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Token retrieval failed with message: ${result.error.message}`); - } else { - console.log(result.value); - } + console.log(`Number of shapes to group: ${numShapes}`); + + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); + + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); }); -'Office.MessageCompose#getComposeTypeAsync:member(2)': +Word.Shape#textFrame:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // Get the compose type of the current item (mail only). - Office.context.mailbox.item.getComposeTypeAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log( - "getComposeTypeAsync succeeded with composeType: " + - asyncResult.value.composeType + - " and coercionType: " + - asyncResult.value.coercionType - ); - } else { - console.error(asyncResult.error); + await Word.run(async (context) => { + // Gets the text frame of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; } + + console.log("Text frame of first text box:", shape.textFrame); }); -'Office.Body#setSignatureAsync:member(1)': +Word.Shape#textWrap:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // Set the signature for the current item with inline image. - var modIcon1Base64 = - "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpDRDMxMDg1MjBCNDZFMTExODE2MkM1RUI2M0M4MDYxRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFMTUxQjgyRjQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMTUxQjgyRTQ2MEQxMUUxODlFMkQwNTYzQ0YwMTUxMiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkQxMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNEMzEwODUyMEI0NkUxMTE4MTYyQzVFQjYzQzgwNjFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uC/WfAAAAehJREFUeNpilCzfwEAEkAbiECA2A2J1IOaHin8E4ptAfBaIVwLxU0IGMRKw0B6IW4DYhoE4cASIK6E0VsCEQ1wUiNcB8QESLGOAqj0MxBuhZhBloS4QnwHiQAbygR/UDF1CFupCXSjHQDmQg5qli8tCUBBsQUoQ1AD8UDNFsVk4n0o+w+bT+egWglKjNymmeGhLkqLcG2oHAwtUoIuQDj5OVgZPLUmwRe5aEmAxqYqNpFgKssOcCeplM0KqdST5GfpDDRm0JfkYrj3/SE7QguyQY4ImYYLgCtAS10kHGMw6dzNsv/qC7OwCClJXYlR++v6b4er3j5QmIFcmaNlIL6AOslCIjhYKMTHQGTBBqxh6gXcgC6/R0cKbIAv30dHCfaAKGJTxHxJSqS3Fz9DkowNmywpyMcgA8fF7b8D8VWcfM6w8+4gYC+VB+RCk8hSh0gaUD4/dewvlvUWRe/z+GzGWgex4BGtiOAHxXhoHpzMoSGHZAhSPW2lo2VZYWkHOh4nEtLrIAE+hZmNUwK+B2BOIv1PRsu9QM1/jatNcBtVZ0IREKXgENesyoVYbzNIdFFi2A5tl+NqlL6BB4QBNzsSCU1A9nlAzMAALAQMOQl0qB23qWwKxIlIrDBQ394H4OBCvISYqAAIMACVibHDqsO7zAAAAAElFTkSuQmCC"; + await Word.run(async (context) => { + // Gets text wrap properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textWrap"); + await context.sync(); - Office.context.mailbox.item.addFileAttachmentFromBase64Async( - modIcon1Base64, - "myImage.png", - { isInline: true }, - function(result) { - if (result.status == Office.AsyncResultStatus.Succeeded) { - var signature = $("#signature").val() + ""; - console.log(`Setting signature to "${signature}".`); - // Important: setSignatureAsync is currently in preview. - Office.context.mailbox.item.body.setSignatureAsync( - signature, - { coercionType: "html" }, - function(asyncResult) { - console.log(`setSignatureAsync: ${asyncResult.status}`); - } - ); - } else { - console.error(`addFileAttachmentFromBase64Async: ${result.error}`); - } + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; } - ); + + console.log("Text wrap properties of first text box:", shape.textWrap); + }); +Word.Shape#type:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml - - // Set the signature for the current item. + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - var signature = $("#signature").val(); - console.log(`Setting signature to "${signature}".`); + await Word.run(async (context) => { + // Gets text boxes in the main document. + const shapes: Word.ShapeCollection = context.document.body.shapes; + shapes.load(); + await context.sync(); - Office.context.mailbox.item.body.setSignatureAsync(signature, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("setSignatureAsync succeeded"); + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the main document: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the main document has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the main document doesn't have a text box.`); + } + }); } else { - console.error(asyncResult.error); + console.log("No shapes found in the main document."); } }); -'Office.AppointmentCompose#disableClientSignatureAsync:member(1)': +Word.ShapeAutoSize:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // Disable the client signature. - Office.context.mailbox.item.disableClientSignatureAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("disableClientSignatureAsync succeeded"); - } else { - console.error(asyncResult.error); + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; } + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); }); -'Office.MessageCompose#disableClientSignatureAsync:member(1)': +Word.ShapeCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // Disable the client signature. - Office.context.mailbox.item.disableClientSignatureAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("disableClientSignatureAsync succeeded"); + await Word.run(async (context) => { + // Gets text boxes in the main document. + const shapes: Word.ShapeCollection = context.document.body.shapes; + shapes.load(); + await context.sync(); + + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the main document: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the main document has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the main document doesn't have a text box.`); + } + }); } else { - console.error(asyncResult.error); + console.log("No shapes found in the main document."); } }); -'Office.AppointmentCompose#isClientSignatureEnabledAsync:member(1)': +Word.ShapeCollection#getByGeometricTypes:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - // Check if the client signature is currently enabled. - Office.context.mailbox.item.isClientSignatureEnabledAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("isClientSignatureEnabledAsync succeeded with result: " + asyncResult.value); - } else { - console.error(asyncResult.error); - } + await Word.run(async (context) => { + // Gets the moon geometric shapes from the document body. + const moons: Word.ShapeCollection = context.document.body.shapes.getByGeometricTypes([ + Word.GeometricShapeType.moon, + ]); + moons.load(); + await context.sync(); + + console.log("Moons found in the document body:", moons); }); -'Office.MessageCompose#isClientSignatureEnabledAsync:member(1)': +Word.ShapeCollection#getByTypes:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/work-with-client-signatures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - // Check if the client signature is currently enabled. - Office.context.mailbox.item.isClientSignatureEnabledAsync(function(asyncResult) - { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("isClientSignatureEnabledAsync succeeded with result: " + asyncResult.value); - } else { - console.error(asyncResult.error); - } + await Word.run(async (context) => { + // Sets the properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.top = 115; + firstShapeWithTextBox.left = 0; + firstShapeWithTextBox.width = 50; + firstShapeWithTextBox.height = 50; + await context.sync(); + + console.log("The first text box's properties were updated:", firstShapeWithTextBox); }); -'Office.AppointmentRead#subject:member': +Word.ShapeCollection#getFirst:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-subject-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - console.log(`Subject: ${Office.context.mailbox.item.subject}`); -'Office.MessageRead#subject:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-subject-read.yaml - console.log(`Subject: ${Office.context.mailbox.item.subject}`); -'Office.AppointmentCompose#subject:member': + await Word.run(async (context) => { + // Inserts a content control into the first paragraph in the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirst(); + firstShapeWithTextBox.load("type/body"); + await context.sync(); + + const firstParagraphInTextBox: Word.Paragraph = firstShapeWithTextBox.body.paragraphs.getFirst(); + const newControl: Word.ContentControl = firstParagraphInTextBox.insertContentControl(); + newControl.load(); + await context.sync(); + + console.log("New content control properties:", newControl); + }); +Word.ShapeCollection#getFirstOrNullObject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.subject.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); - return; - } - console.log(`Subject: ${result.value}`); + + await Word.run(async (context) => { + // Gets text from the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("body/text"); + await context.sync(); + + console.log( + shape.isNullObject + ? "No shapes with text boxes found in the main document." + : `Text in first text box: ${shape.body.text}` + ); }); +Word.ShapeCollection#group:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - let subject = "Hello World!"; - Office.context.mailbox.item.subject.setAsync(subject, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); + + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); return; } - console.log(`Successfully set subject to ${subject}`); + + console.log(`Number of shapes to group: ${numShapes}`); + + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); + + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); }); -'Office.MessageCompose#subject:member': +Word.ShapeFill:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - Office.context.mailbox.item.subject.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); return; } - console.log(`Subject: ${result.value}`); + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); }); +Word.ShapeFill#clear:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - let subject = "Hello World!"; - Office.context.mailbox.item.subject.setAsync(subject, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); return; } - console.log(`Successfully set subject to ${subject}`); - }); -'Office.MessageRead#internetMessageId:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml - console.log(`Internet message ID: - ${Office.context.mailbox.item.internetMessageId}`); -'Office.AppointmentRead#itemClass:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-class-read.yaml + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); - console.log(`Item class: ${Office.context.mailbox.item.itemClass}`); -'Office.MessageRead#itemClass:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-class-read.yaml + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); - console.log(`Item class: ${Office.context.mailbox.item.itemClass}`); -'Office.AppointmentCompose#itemType:member': + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); +Word.ShapeFill#setSolidColor:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-type.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - console.log(`Item type: ${Office.context.mailbox.item.itemType}`); -'Office.AppointmentRead#itemType:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-type.yaml - console.log(`Item type: ${Office.context.mailbox.item.itemType}`); -'Office.MessageCompose#itemType:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-type.yaml + await Word.run(async (context) => { + // Sets color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); - console.log(`Item type: ${Office.context.mailbox.item.itemType}`); -'Office.MessageRead#itemType:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-item-type.yaml + if (moon.isNullObject) { + console.log("No moons found in the document body."); + return; + } - console.log(`Item type: ${Office.context.mailbox.item.itemType}`); -'Office.AppointmentRead#start:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-start-read.yaml + const moonFill: Word.ShapeFill = moon.fill; + console.log("Current fill properties of the first moon found in the document body:", moonFill); - console.log(`Appointment starts: ${Office.context.mailbox.item.start}`); -'Office.MessageRead#start:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-start-read.yaml + moonFill.setSolidColor("green"); + moonFill.load(); + await context.sync(); - console.log(`Appointment starts: ${Office.context.mailbox.item.start}`); -'Office.AppointmentCompose#start:member': + console.log("Updated color fill properties of the first moon found in the document body:", moonFill); + }); +Word.ShapeFillType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml - Office.context.mailbox.item.start.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Gets the color fill properties of the first moon found in the document body. + const moon: Word.Shape = context.document.body.shapes + .getByGeometricTypes([Word.GeometricShapeType.moon]) + .getFirstOrNullObject(); + moon.load("fill"); + await context.sync(); + + if (moon.isNullObject) { + console.log("No moons found in the document body."); return; } - console.log(`Appointment starts: ${result.value}`); + + const moonFill: Word.ShapeFill = moon.fill; + const moonFillType = moonFill.type as Word.ShapeFillType; + + console.log("Color fill properties of the first moon found in the document body:"); + console.log(`\tForeground color: ${moonFill.foregroundColor}`); + console.log(`\tBackground color: ${moonFill.backgroundColor}`); + console.log(`\tTransparency: ${moonFill.transparency}`); + console.log(`\tFill type: ${moonFillType}`); }); +Word.ShapeGroup:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var start = new Date(); // Represents current date and time. - start.setDate(start.getDate() + 2); // Add 2 days to current date. + await Word.run(async (context) => { + // Groups the shapes (including text boxes and pictures) found in the document body. + const shapes: Word.ShapeCollection = context.document.body.shapes.getByTypes([ + Word.ShapeType.geometricShape, + Word.ShapeType.textBox, + Word.ShapeType.picture, + ]); + shapes.load("items"); + await context.sync(); - Office.context.mailbox.item.start.setAsync(start, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + const numShapes = shapes.items.length; + if (numShapes === 0) { + console.log("No shapes found in the document body."); return; } - console.log(`Successfully set start date and time to ${start}`); + + console.log(`Number of shapes to group: ${numShapes}`); + + const groupedShape: Word.Shape = shapes.group(); + groupedShape.load("shapeGroup/shapes"); + await context.sync(); + + const shapeGroup: Word.ShapeGroup = groupedShape.shapeGroup; + console.log("Shapes grouped:", shapeGroup.shapes); + groupedShape.select(); }); -'Office.Time#getAsync:member(2)': +Word.ShapeGroup#ungroup:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - Office.context.mailbox.item.start.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Ungroups the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); return; } - console.log(`Appointment starts: ${result.value}`); + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to ungroup the first shape group found in the document body:", shapeGroup.shapes); + shapeGroup.ungroup(); + + console.log("Ungrouped the first shape group."); }); -'Office.Time#setAsync:member(1)': +Word.ShapeGroup#shapes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - var start = new Date(); // Represents current date and time. - start.setDate(start.getDate() + 2); // Add 2 days to current date. + await Word.run(async (context) => { + // Moves the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - Office.context.mailbox.item.start.setAsync(start, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); return; } - console.log(`Successfully set start date and time to ${start}`); + + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to move the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.moveHorizontally(-10); + firstShapeGroup.moveVertically(50); + + console.log("Moved the first shape group."); }); +Word.ShapeScaleFrom:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - Office.context.mailbox.item.start.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Get start date failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Scales the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); + + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); return; } - var end = result.value; // Set end to current start date and time. - end.setDate(end.getDate() + 1); // Set end as 1 day later than start date. - Office.context.mailbox.item.end.setAsync(end, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Set end date failed with message ${result.error.message}`); - return; - } - console.log(`Successfully set end date and time to ${end}`); - }); + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize); + firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight); + + console.log("Scaled the first shape group."); }); -'Office.AppointmentRead#normalizedSubject:member': +Word.ShapeScaleType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml - console.log(`Normalized subject: - ${Office.context.mailbox.item.normalizedSubject}`); -'Office.MessageRead#normalizedSubject:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml - console.log(`Normalized subject: - ${Office.context.mailbox.item.normalizedSubject}`); -'Office.MessageCompose#conversationId:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + await Word.run(async (context) => { + // Scales the first set of grouped shapes (including text boxes) found in the document body. + const firstShapeGroup: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.group]) + .getFirstOrNullObject(); + firstShapeGroup.load("shapeGroup/shapes"); + await context.sync(); - console.log(`Conversation ID: - ${Office.context.mailbox.item.conversationId}`); -'Office.MessageRead#conversationId:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml + if (firstShapeGroup.isNullObject) { + console.log("No shape groups found in the document body."); + return; + } - console.log(`Conversation ID: - ${Office.context.mailbox.item.conversationId}`); -'Office.AppointmentRead#dateTimeCreated:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup; + console.log("About to scale the first shape group found in the document body:", shapeGroup.shapes); + firstShapeGroup.scaleHeight(0.75, Word.ShapeScaleType.currentSize); + firstShapeGroup.scaleWidth(0.5, Word.ShapeScaleType.currentSize, Word.ShapeScaleFrom.scaleFromBottomRight); - console.log(`Creation date and time: - ${Office.context.mailbox.item.dateTimeCreated}`); -'Office.MessageRead#dateTimeCreated:member': + console.log("Scaled the first shape group."); + }); +Word.ShapeTextOrientation:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - console.log(`Creation date and time: - ${Office.context.mailbox.item.dateTimeCreated}`); -'Office.AppointmentRead#dateTimeModified:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml - console.log(`Date and time item last modified: - ${Office.context.mailbox.item.dateTimeModified}`); -'Office.MessageRead#dateTimeModified:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); - console.log(`Date and time item last modified: - ${Office.context.mailbox.item.dateTimeModified}`); -'Office.AppointmentRead#end:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-end-read.yaml + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } - console.log(`Appointment ends: ${Office.context.mailbox.item.end}`); -'Office.MessageRead#end:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-end-read.yaml + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; - console.log(`Appointment ends: ${Office.context.mailbox.item.end}`); -'Office.AppointmentCompose#end:member': + console.log("The first text box's text frame properties were updated:", textFrame); + }); +Word.ShapeTextVerticalAlignment:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.end.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); return; } - console.log(`Appointment ends: ${result.value}`); + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); }); +Word.ShapeTextWrap:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.start.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Get start date failed with message ${result.error.message}`); + + await Word.run(async (context) => { + // Gets text wrap properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textWrap"); + await context.sync(); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); return; } - var end = result.value; // Set end to current start date and time. - end.setDate(end.getDate() + 1); // Set end as 1 day later than start date. - Office.context.mailbox.item.end.setAsync(end, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Set end date failed with message ${result.error.message}`); - return; - } - console.log(`Successfully set end date and time to ${end}`); - }); + console.log("Text wrap properties of first text box:", shape.textWrap); }); -'Office.AppointmentRead#location:member': +Word.ShapeTextWrap#side:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-location-read.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - console.log(`Appointment location: - ${Office.context.mailbox.item.location}`); -'Office.MessageRead#location:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-location-read.yaml - console.log(`Appointment location: - ${Office.context.mailbox.item.location}`); -'Office.AppointmentCompose#location:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + await Word.run(async (context) => { + // Sets text wrap properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirstOrNullObject(); + firstShapeWithTextBox.load("textWrap"); + await context.sync(); - Office.context.mailbox.item.location.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + if (firstShapeWithTextBox.isNullObject) { + console.log("No shapes with text boxes found in main document."); return; } - console.log(`Appointment location: ${result.value}`); + + const textWrap: Word.ShapeTextWrap = firstShapeWithTextBox.textWrap; + textWrap.type = Word.ShapeTextWrapType.square; + textWrap.side = Word.ShapeTextWrapSide.both; + + console.log("The first text box's text wrap properties were updated:", textWrap); }); +Word.ShapeTextWrap#type:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - var location = "my office"; - Office.context.mailbox.item.location.setAsync(location, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + await Word.run(async (context) => { + // Sets text wrap properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirstOrNullObject(); + firstShapeWithTextBox.load("textWrap"); + await context.sync(); + + if (firstShapeWithTextBox.isNullObject) { + console.log("No shapes with text boxes found in main document."); return; } - console.log(`Successfully set location to ${location}`); + + const textWrap: Word.ShapeTextWrap = firstShapeWithTextBox.textWrap; + textWrap.type = Word.ShapeTextWrapType.square; + textWrap.side = Word.ShapeTextWrapSide.both; + + console.log("The first text box's text wrap properties were updated:", textWrap); }); -'Office.Location#getAsync:member(2)': +Word.ShapeTextWrapSide:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml + + + await Word.run(async (context) => { + // Sets text wrap properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirstOrNullObject(); + firstShapeWithTextBox.load("textWrap"); + await context.sync(); - Office.context.mailbox.item.location.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + if (firstShapeWithTextBox.isNullObject) { + console.log("No shapes with text boxes found in main document."); return; } - console.log(`Appointment location: ${result.value}`); + + const textWrap: Word.ShapeTextWrap = firstShapeWithTextBox.textWrap; + textWrap.type = Word.ShapeTextWrapType.square; + textWrap.side = Word.ShapeTextWrapSide.both; + + console.log("The first text box's text wrap properties were updated:", textWrap); }); -'Office.Location#setAsync:member(1)': +Word.ShapeTextWrapType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - var location = "my office"; - Office.context.mailbox.item.location.setAsync(location, (result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Action failed with message ${result.error.message}`); + await Word.run(async (context) => { + // Sets text wrap properties of the first text box. + const firstShapeWithTextBox: Word.Shape = context.document.body.shapes + .getByTypes([Word.ShapeType.textBox]) + .getFirstOrNullObject(); + firstShapeWithTextBox.load("textWrap"); + await context.sync(); + + if (firstShapeWithTextBox.isNullObject) { + console.log("No shapes with text boxes found in main document."); return; } - console.log(`Successfully set location to ${location}`); + + const textWrap: Word.ShapeTextWrap = firstShapeWithTextBox.textWrap; + textWrap.type = Word.ShapeTextWrapType.square; + textWrap.side = Word.ShapeTextWrapSide.both; + + console.log("The first text box's text wrap properties were updated:", textWrap); }); -'Office.AppointmentCompose#enhancedLocation:member': +Word.ShapeType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Office.context.mailbox.item.enhancedLocation.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Failed to get locations. Error message: ${result.error.message}`); - return; - } - var places = result.value; - if (places && places.length > 0) { - result.value.forEach(function(place) { - console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); - if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { - console.log("Email address: " + place.emailAddress); + + await Word.run(async (context) => { + // Gets text boxes in the main document. + const shapes: Word.ShapeCollection = context.document.body.shapes; + shapes.load(); + await context.sync(); + + if (shapes.items.length > 0) { + console.log(`Number of shapes found in the main document: ${shapes.items.length}`); + shapes.items.forEach(function (shape, index) { + if (shape.type === Word.ShapeType.textBox) { + console.log(`Shape ${index} in the main document has a text box. Properties:`, shape); + } else { + console.log(`Shape ${index} in the main document doesn't have a text box.`); } }); } else { - console.log("There are no locations."); + console.log("No shapes found in the main document."); } }); +Word.Style:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - var locations = [ - { - id: "Contoso", - type: Office.MailboxEnums.LocationType.Custom - }, - { - id: "room500@test.com", - type: Office.MailboxEnums.LocationType.Room + + // Applies the specified style to a paragraph. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to apply."); + return; } - ]; - Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => - { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully added locations ${JSON.stringify(locations)}`); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else if (style.type != Word.StyleType.paragraph) { + console.log(`The '${styleName}' style isn't a paragraph style.`); } else { - console.error(`Failed to add locations. Error message: ${result.error.message}`); + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + const paragraph: Word.Paragraph = body.paragraphs.getFirst(); + paragraph.style = style.nameLocal; + console.log(`'${styleName}' style applied to first paragraph.`); } }); +Word.Style#delete:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - var locations = [ - { - id: "Contoso", - type: Office.MailboxEnums.LocationType.Custom - }, - { - id: "room500@test.com", - type: Office.MailboxEnums.LocationType.Room + + // Deletes the custom style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to delete."); + return; } - ]; - Office.context.mailbox.item.enhancedLocation.removeAsync(locations, (result) - => { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully removed locations ${JSON.stringify(locations)}`); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.error(`Failed to remove locations. Error message: ${result.error.message}`); + style.delete(); + console.log(`Successfully deleted custom style '${styleName}'.`); } }); -'Office.AppointmentRead#enhancedLocation:member': +Word.Style#borders:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.enhancedLocation.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Failed to get locations. Error message: ${result.error.message}`); + + // Updates border properties (e.g., type, width, color) of the specified + style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update border properties."); return; } - var places = result.value; - if (places && places.length > 0) { - result.value.forEach(function(place) { - console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); - if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { - console.log("Email address: " + place.emailAddress); - } - }); + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.log("There are no locations."); + const borders: Word.BorderCollection = style.borders; + borders.load("items"); + await context.sync(); + + borders.outsideBorderType = Word.BorderType.dashed; + borders.outsideBorderWidth = Word.BorderWidth.pt025; + borders.outsideBorderColor = "green"; + console.log("Updated outside borders."); } }); -'Office.EnhancedLocation#getAsync:member(1)': +Word.Style#font:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.enhancedLocation.getAsync((result) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - console.error(`Failed to get locations. Error message: ${result.error.message}`); + + // Updates font properties (e.g., color, size) of the specified style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update font properties."); return; } - var places = result.value; - if (places && places.length > 0) { - result.value.forEach(function(place) { - console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`); - if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) { - console.log("Email address: " + place.emailAddress); - } - }); + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.log("There are no locations."); + const font: Word.Font = style.font; + font.color = "#FF0000"; + font.size = 20; + console.log(`Successfully updated font properties of the '${styleName}' style.`); } }); -'Office.EnhancedLocation#addAsync:member(1)': +Word.Style#listTemplate:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml - var locations = [ - { - id: "Contoso", - type: Office.MailboxEnums.LocationType.Custom - }, - { - id: "room500@test.com", - type: Office.MailboxEnums.LocationType.Room + + // Gets the properties of the specified style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; } - ]; - Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => - { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully added locations ${JSON.stringify(locations)}`); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); + await context.sync(); + + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); } else { - console.error(`Failed to add locations. Error message: ${result.error.message}`); + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); + + console.log(`Properties of the '${styleName}' style:`, style); + + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); + + console.log(`List levels of the '${styleName}' style:`, listLevels); } }); -'Office.EnhancedLocation#removeAsync:member(1)': +Word.Style#nameLocal:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - var locations = [ - { - id: "Contoso", - type: Office.MailboxEnums.LocationType.Custom - }, - { - id: "room500@test.com", - type: Office.MailboxEnums.LocationType.Room + + // Applies the specified style to a paragraph. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to apply."); + return; } - ]; - Office.context.mailbox.item.enhancedLocation.removeAsync(locations, (result) - => { - if (result.status === Office.AsyncResultStatus.Succeeded) { - console.log(`Successfully removed locations ${JSON.stringify(locations)}`); + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else if (style.type != Word.StyleType.paragraph) { + console.log(`The '${styleName}' style isn't a paragraph style.`); } else { - console.error(`Failed to remove locations. Error message: ${result.error.message}`); + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + const paragraph: Word.Paragraph = body.paragraphs.getFirst(); + paragraph.style = style.nameLocal; + console.log(`'${styleName}' style applied to first paragraph.`); } }); -'Office.AppointmentCompose#isAllDayEvent:member': +Word.Style#paragraphFormat:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Is this an all-day event? " + asyncResult.value); + + // Sets certain aspects of the specified style's paragraph format e.g., the + left indent size and the alignment. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update its paragraph format."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); + style.paragraphFormat.leftIndent = 30; + style.paragraphFormat.alignment = Word.Alignment.centered; + console.log(`Successfully the paragraph format of the '${styleName}' style.`); } }); +Word.Style#shading:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.isAllDayEvent.setAsync(true, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); + + // Updates shading properties (e.g., texture, pattern colors) of the + specified style. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to update shading properties."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); } else { - console.log("Appointment set to all-day event."); + const shading: Word.Shading = style.shading; + shading.load(); + await context.sync(); + + shading.backgroundPatternColor = "blue"; + shading.foregroundPatternColor = "yellow"; + shading.texture = Word.ShadingTextureType.darkTrellis; + + console.log("Updated shading."); } }); -'Office.IsAllDayEvent#getAsync:member(2)': +Word.StyleCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.isAllDayEvent.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Is this an all-day event? " + asyncResult.value); - } else { - console.log("Failed to get if this is an all-day event. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets the number of available styles stored with the document. + + await Word.run(async (context) => { + const styles: Word.StyleCollection = context.document.getStyles(); + const count = styles.getCount(); + await context.sync(); + + console.log(`Number of styles: ${count.value}`); }); -'Office.IsAllDayEvent#setAsync:member(1)': +Word.StyleCollection#getByNameOrNullObject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.isAllDayEvent.setAsync(true, - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set all-day event: " + JSON.stringify(asyncResult.error)); - } else { - console.log("Appointment set to all-day event."); + + // Adds a new style. + + await Word.run(async (context) => { + const newStyleName = (document.getElementById("new-style-name") as HTMLInputElement).value; + if (newStyleName == "") { + console.warn("Enter a style name to add."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(newStyleName); + style.load(); + await context.sync(); + + if (!style.isNullObject) { + console.warn( + `There's an existing style with the same name '${newStyleName}'! Please provide another style name.` + ); + return; } + + const newStyleType = ((document.getElementById("new-style-type") as HTMLSelectElement).value as unknown) as Word.StyleType; + context.document.addStyle(newStyleName, newStyleType); + await context.sync(); + + console.log(newStyleName + " has been added to the style list."); }); -'Office.AppointmentCompose#sensitivity:member': +Word.StyleCollection#getCount:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml - Office.context.mailbox.item.sensitivity.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Sensitivity: " + asyncResult.value); + + // Gets the number of available styles stored with the document. + + await Word.run(async (context) => { + const styles: Word.StyleCollection = context.document.getStyles(); + const count = styles.getCount(); + await context.sync(); + + console.log(`Number of styles: ${count.value}`); + }); +Word.StyleType:enum: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml + + + // Applies the specified style to a paragraph. + + await Word.run(async (context) => { + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to apply."); + return; + } + + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load(); + await context.sync(); + + if (style.isNullObject) { + console.warn(`There's no existing style with the name '${styleName}'.`); + } else if (style.type != Word.StyleType.paragraph) { + console.log(`The '${styleName}' style isn't a paragraph style.`); } else { - console.log("Failed to get sensitivity: " + JSON.stringify(asyncResult.error)); + const body: Word.Body = context.document.body; + body.clear(); + body.insertParagraph( + "Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.", + "Start" + ); + const paragraph: Word.Paragraph = body.paragraphs.getFirst(); + paragraph.style = style.nameLocal; + console.log(`'${styleName}' style applied to first paragraph.`); } }); +Word.Table#getBorder:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sensitivity.setAsync( - Office.MailboxEnums.AppointmentSensitivityType.Confidential, - function callback(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); - } else { - console.log("Successfully set appointment sensitivity."); - } - } - ); -'Office.Sensitivity#getAsync:member(2)': + + // Gets border details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); +Word.Table#getCell:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml - Office.context.mailbox.item.sensitivity.getAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("Sensitivity: " + asyncResult.value); - } else { - console.log("Failed to get sensitivity: " + JSON.stringify(asyncResult.error)); - } + + // Gets the content of the first cell in the first table. + + await Word.run(async (context) => { + const firstCell: Word.Body = context.document.body.tables.getFirst().getCell(0, 0).body; + firstCell.load("text"); + + await context.sync(); + console.log("First cell's text is: " + firstCell.text); }); -'Office.Sensitivity#setAsync:member(1)': +Word.Table#getCellPadding:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/calendar-properties-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sensitivity.setAsync( - Office.MailboxEnums.AppointmentSensitivityType.Confidential, - function callback(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Failed) { - console.log("Failed to set appointment sensitivity: " + JSON.stringify(asyncResult.error)); - } else { - console.log("Successfully set appointment sensitivity."); - } - } - ); -'Office.AppointmentCompose#sessionData:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml - Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("The sessionData is " + JSON.stringify(asyncResult.value)); - } else { - console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + // Gets cell padding details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const cellPaddingLocation = Word.CellPaddingLocation.right; + const cellPadding = firstTable.getCellPadding(cellPaddingLocation); + await context.sync(); + + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table: ${cellPadding.value} points` + ); }); -'Office.MessageCompose#sessionData:member': +Word.Table#alignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("The sessionData is " + JSON.stringify(asyncResult.value)); - } else { - console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets alignment details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table:`, `- Alignment of the table within the containing page column: ${firstTable.alignment}`, `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`, `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`); }); -'Office.SessionData#setAsync:member(1)': +Word.Table#horizontalAlignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sessionData.setAsync( - "Date", - "7/24/2020", - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("sessionData.setAsync succeeded"); - } else { - console.log("Failed to set sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets alignment details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table:`, `- Alignment of the table within the containing page column: ${firstTable.alignment}`, `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`, `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`); }); -'Office.SessionData#getAsync:member(1)': +Word.Table#rows:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sessionData.getAsync( - "Date", - function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("The sessionData value is " + JSON.stringify(asyncResult.value)); - } else { - console.log("Failed to get sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets content alignment details about the first row of the first table in + the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + firstTableRow.load(["horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table's first row:`, `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`, `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`); }); -'Office.SessionData#getAllAsync:member(1)': +Word.Table#verticalAlignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sessionData.getAllAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("The sessionData is " + JSON.stringify(asyncResult.value)); - } else { - console.log("Failed to get all sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets alignment details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table:`, `- Alignment of the table within the containing page column: ${firstTable.alignment}`, `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`, `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`); }); -'Office.SessionData#removeAsync:member(1)': +Word.Table:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml - Office.context.mailbox.item.sessionData.removeAsync( - "Date", - function callback(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("sessionData.removeAsync succeeded"); - } else { - console.log("Failed to remove sessionData. Error: " + JSON.stringify(asyncResult.error)); - } - } - ); -'Office.SessionData#clearAsync:member(1)': + + await Word.run(async (context) => { + // Use a two-dimensional array to hold the initial table values. + const data = [ + ["Tokyo", "Beijing", "Seattle"], + ["Apple", "Orange", "Pineapple"] + ]; + const table: Word.Table = context.document.body.insertTable(2, 3, "Start", data); + table.styleBuiltIn = Word.BuiltInStyleName.gridTable5Dark_Accent2; + table.styleFirstColumn = false; + + await context.sync(); + }); +Word.TableBorder:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/outlook/99-preview-apis/session-data-apis.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - Office.context.mailbox.item.sessionData.clearAsync(function(asyncResult) { - if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { - console.log("sessionData.clearAsync succeeded"); - } else { - console.log("Failed to clear sessionData. Error: " + JSON.stringify(asyncResult.error)); - } + + // Gets border details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); }); -'Word.Body#search:member(1)': +Word.TableBorder#color:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/search.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Word.run(async (context) => { - let results = context.document.body.search("Online"); - results.load("length"); + // Gets border details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); await context.sync(); - // Let's traverse the search results... and highlight... - for (let i = 0; i < results.items.length; i++) { - results.items[i].font.highlightColor = "yellow"; - } + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); +Word.TableBorder#type:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + + // Gets border details about the first table in the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); }); +Word.TableBorder#width:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/search.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Word.run(async (context) => { - // Check out how wildcard expression are built, also use the second parameter of the search method to include search modes - // (i.e. use wildcards). - let results = context.document.body.search("$*.[0-9][0-9]", { matchWildcards: true }); - results.load("length"); + // Gets border details about the first table in the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const borderLocation = Word.BorderLocation.top; + const border: Word.TableBorder = firstTable.getBorder(borderLocation); + border.load(["type", "color", "width"]); await context.sync(); - // Let's traverse the search results... and highlight... - for (let i = 0; i < results.items.length; i++) { - results.items[i].font.highlightColor = "red"; - results.items[i].font.color = "white"; - } + console.log(`Details about the ${borderLocation} border of the first table:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); +Word.TableCell:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + // Gets content alignment details about the first cell of the first table in + the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); + + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); }); +Word.TableCell#getBorder:member(2): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/get-word-count.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + + // Gets border details about the first of the first table in the document. await Word.run(async (context) => { - let paragraphs = context.document.body.paragraphs; - paragraphs.load("text"); + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstCell: Word.TableCell = firstTable.getCell(0, 0); + const borderLocation = "Left"; + const border: Word.TableBorder = firstCell.getBorder(borderLocation); + border.load(["type", "color", "width"]); await context.sync(); - let text = []; - paragraphs.items.forEach((item) => { - let paragraph = item.text.trim(); - if (paragraph) { - paragraph.split(" ").forEach((term) => { - let currentTerm = term.trim(); - if (currentTerm) { - text.push(currentTerm); - } - }); - } - }); + console.log(`Details about the ${borderLocation} border of the first table's first cell:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); + }); +Word.TableCell#getCellPadding:member(2): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - let makeTextDistinct = new Set(text); - let distinctText = Array.from(makeTextDistinct); - let allSearchResults = []; - for (let i = 0; i < distinctText.length; i++) { - let results = context.document.body.search(distinctText[i], { matchCase: true, matchWholeWord: true }); - results.load("text"); + // Gets cell padding details about the first cell of the first table in the + document. - // Map search term with its results. - let correlatedResults = { - searchTerm: distinctText[i], - hits: results - }; + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstCell: Word.TableCell = firstTable.getCell(0, 0); + const cellPaddingLocation = "Left"; + const cellPadding = firstCell.getCellPadding(cellPaddingLocation); + await context.sync(); - allSearchResults.push(correlatedResults); - } + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table's first cell: ${cellPadding.value} points` + ); + }); +Word.TableCell#horizontalAlignment:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await context.sync(); - // Display counts. - allSearchResults.forEach((result) => { - let length = result.hits.items.length; + // Gets content alignment details about the first cell of the first table in + the document. - console.log("Search term: " + result.searchTerm + " => Count: " + length); - }); + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); + await context.sync(); + + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); }); -'Word.Body#insertTable:member(1)': +Word.TableCell#verticalAlignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/40-tables/table-cell-access.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Word.run(async (context) => { - // Use a two-dimensional array to hold the initial table values. - let data = [ - ["Tokyo", "Beijing", "Seattle"], - ["Apple", "Orange", "Pineapple"] - ]; - let table = context.document.body.insertTable(2, 3, "Start", data); - table.styleBuiltIn = Word.Style.gridTable5Dark_Accent2; - table.styleFirstColumn = false; + // Gets content alignment details about the first cell of the first table in + the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); + + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); }); -'Word.Body#paragraphs:member': +Word.TableCellCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/get-word-count.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + + // Gets content alignment details about the first cell of the first table in + the document. await Word.run(async (context) => { - let paragraphs = context.document.body.paragraphs; - paragraphs.load("text"); + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); - let text = []; - paragraphs.items.forEach((item) => { - let paragraph = item.text.trim(); - if (paragraph) { - paragraph.split(" ").forEach((term) => { - let currentTerm = term.trim(); - if (currentTerm) { - text.push(currentTerm); - } - }); - } - }); + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); + }); +Word.TableCollection:class: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - let makeTextDistinct = new Set(text); - let distinctText = Array.from(makeTextDistinct); - let allSearchResults = []; - for (let i = 0; i < distinctText.length; i++) { - let results = context.document.body.search(distinctText[i], { matchCase: true, matchWholeWord: true }); - results.load("text"); + // Gets alignment details about the first table in the document. - // Map search term with its results. - let correlatedResults = { - searchTerm: distinctText[i], - hits: results - }; + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + firstTable.load(["alignment", "horizontalAlignment", "verticalAlignment"]); + await context.sync(); - allSearchResults.push(correlatedResults); - } + console.log(`Details about the alignment of the first table:`, `- Alignment of the table within the containing page column: ${firstTable.alignment}`, `- Horizontal alignment of every cell in the table: ${firstTable.horizontalAlignment}`, `- Vertical alignment of every cell in the table: ${firstTable.verticalAlignment}`); + }); +Word.TableCollection#getFirst:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml - await context.sync(); - // Display counts. - allSearchResults.forEach((result) => { - let length = result.hits.items.length; + // Gets the content of the first cell in the first table. - console.log("Search term: " + result.searchTerm + " => Count: " + length); - }); + await Word.run(async (context) => { + const firstCell: Word.Body = context.document.body.tables.getFirst().getCell(0, 0).body; + firstCell.load("text"); + + await context.sync(); + console.log("First cell's text is: " + firstCell.text); }); -'Word.ContentControl#tag:member': +Word.TableRow:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/10-content-controls/insert-and-change-content-controls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - // Traverses each paragraph of the document and wraps a content control on - each with either a even or odd tags. - await Word.run(async (context) => { - let paragraphs = context.document.body.paragraphs; - paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control. + // Gets content alignment details about the first cell of the first table in + the document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); - for (let i = 0; i < paragraphs.items.length; i++) { - let contentControl = paragraphs.items[i].insertContentControl(); - // For even, tag "even". - if (i % 2 === 0) { - contentControl.tag = "even"; - } else { - contentControl.tag = "odd"; - } - } - console.log("Content controls inserted: " + paragraphs.items.length); + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); + }); +Word.TableRow#getBorder:member(1): + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + // Gets border details about the first row of the first table in the + document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const borderLocation = Word.BorderLocation.bottom; + const border: Word.TableBorder = firstTableRow.getBorder(borderLocation); + border.load(["type", "color", "width"]); await context.sync(); + + console.log(`Details about the ${borderLocation} border of the first table's first row:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); }); -'Word.ContentControl#set:member(1)': +Word.TableRow#getCellPadding:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/10-content-controls/insert-and-change-content-controls.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - // Adds title and colors to odd and even content controls and changes their - appearance. - await Word.run(async (context) => { - // Gets the complete sentence (as range) associated with the insertion point. - let evenContentControls = context.document.contentControls.getByTag("even"); - let oddContentControls = context.document.contentControls.getByTag("odd"); - evenContentControls.load("length"); - oddContentControls.load("length"); + // Gets cell padding details about the first row of the first table in the + document. + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const cellPaddingLocation = Word.CellPaddingLocation.bottom; + const cellPadding = firstTableRow.getCellPadding(cellPaddingLocation); await context.sync(); - for (let i = 0; i < evenContentControls.items.length; i++) { - // Change a few properties and append a paragraph - evenContentControls.items[i].set({ - color: "red", - title: "Odd ContentControl #" + (i + 1), - appearance: "Tags" - }); - evenContentControls.items[i].insertParagraph("This is an odd content control", "End"); - } + console.log( + `Cell padding details about the ${cellPaddingLocation} border of the first table's first row: ${cellPadding.value} points` + ); + }); +Word.TableRow#cells:member: + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - for (let j = 0; j < oddContentControls.items.length; j++) { - // Change a few properties and append a paragraph - oddContentControls.items[j].set({ - color: "green", - title: "Even ContentControl #" + (j + 1), - appearance: "Tags" - }); - oddContentControls.items[j].insertHtml("This is an even content control", "End"); - } + // Gets content alignment details about the first cell of the first table in + the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const firstCell: Word.TableCell = firstTableRow.cells.getFirst(); + firstCell.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); + + console.log(`Details about the alignment of the first table's first cell:`, `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`, `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`); }); -'Word.ContentControlCollection#getByTag:member(1)': +Word.TableRowCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/90-scenarios/doc-assembly.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Word.run(async (context) => { - let contentControls = context.document.contentControls.getByTag("customer"); - contentControls.load("text"); - await context.sync(); + // Gets content alignment details about the first row of the first table in + the document. - for (let i = 0; i < contentControls.items.length; i++) { - contentControls.items[i].insertText("Fabrikam", "Replace"); - } + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + firstTableRow.load(["horizontalAlignment", "verticalAlignment"]); + await context.sync(); - await context.sync(); + console.log(`Details about the alignment of the first table's first row:`, `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`, `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`); }); -'Word.CustomPropertyCollection#add:member(1)': +Word.TableRowCollection#getFirst:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/30-properties/read-write-custom-document-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml + + + // Gets border details about the first row of the first table in the + document. await Word.run(async (context) => { - context.document.properties.customProperties.add("Numeric Property", 1234); + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + const borderLocation = Word.BorderLocation.bottom; + const border: Word.TableBorder = firstTableRow.getBorder(borderLocation); + border.load(["type", "color", "width"]); + await context.sync(); - await context.sync(); - console.log("Property added"); + console.log(`Details about the ${borderLocation} border of the first table's first row:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`); }); +Word.TableStyle:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/30-properties/read-write-custom-document-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml + + + // Gets the table style properties and displays them in the form. + + const styleName = (document.getElementById("style-name") as + HTMLInputElement).value; + + if (styleName == "") { + console.warn("Please input a table style name."); + return; + } + await Word.run(async (context) => { - context.document.properties.customProperties.add("String Property", "Hello World!"); + const tableStyle: Word.TableStyle = context.document.getStyles().getByName(styleName).tableStyle; + tableStyle.load(); + await context.sync(); - await context.sync(); - console.log("Property added"); + if (tableStyle.isNullObject) { + console.warn(`There's no existing table style with the name '${styleName}'.`); + return; + } + + console.log(tableStyle); + (document.getElementById("alignment") as HTMLInputElement).value = tableStyle.alignment; + (document.getElementById("allow-break-across-page") as HTMLInputElement).value = tableStyle.allowBreakAcrossPage.toString(); + (document.getElementById("top-cell-margin") as HTMLInputElement).value = tableStyle.topCellMargin; + (document.getElementById("bottom-cell-margin") as HTMLInputElement).value = tableStyle.bottomCellMargin; + (document.getElementById("left-cell-margin") as HTMLInputElement).value = tableStyle.leftCellMargin; + (document.getElementById("right-cell-margin") as HTMLInputElement).value = tableStyle.rightCellMargin; + (document.getElementById("cell-spacing") as HTMLInputElement).value = tableStyle.cellSpacing; }); -'Word.CustomPropertyCollection#items:member': +Word.TextFrame:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/30-properties/read-write-custom-document-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml + await Word.run(async (context) => { - let properties = context.document.properties.customProperties; - properties.load("key,type,value"); + // Gets the text frame of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); - await context.sync(); - for (var i = 0; i < properties.items.length; i++) - console.log("Property Name:" + properties.items[i].key + "; Type=" + properties.items[i].type + "; Property Value=" + properties.items[i].value); + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + console.log("Text frame of first text box:", shape.textFrame); }); -'Word.Document#properties:member': +Word.TextFrame#autoSizeSetting:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/30-properties/get-built-in-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml + await Word.run(async (context) => { - let builtInProperties = context.document.properties; - builtInProperties.load("*"); // Let's get all! + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); + await context.sync(); - await context.sync(); - console.log(JSON.stringify(builtInProperties, null, 4)); + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); }); -'Word.InlinePicture#getBase64ImageSrc:member(1)': +Word.TextFrame#orientation:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/15-images/insert-and-get-pictures.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - await Word.run(async (context) => { - const firstPicture = context.document.body.inlinePictures.getFirst(); - firstPicture.load("width, height"); + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); await context.sync(); - console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`); - // Get the image encoded as base64. - const base64 = firstPicture.getBase64ImageSrc(); - await context.sync(); - console.log(base64.value); + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); }); -'Word.Paragraph#insertBreak:member(1)': +Word.TextFrame#verticalAlignment:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/insert-line-and-page-breaks.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml - Word.run(async (context) => { - context.document.body.paragraphs.getFirst().insertBreak(Word.BreakType.line, "After"); + await Word.run(async (context) => { + // Sets text frame properties of the first text box in the main document. + const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject(); + shape.load("textFrame"); await context.sync(); - console.log("success"); + + if (shape.isNullObject) { + console.log("No shapes with text boxes found in the main document."); + return; + } + + const textFrame: Word.TextFrame = shape.textFrame; + textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom; + textFrame.orientation = Word.ShapeTextOrientation.vertical270; + textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText; + + console.log("The first text box's text frame properties were updated:", textFrame); }); -'Word.Paragraph#insertParagraph:member(1)': +Word.TrackedChange:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/insert-formatted-text.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the next (second) tracked change. await Word.run(async (context) => { - // Second sentence, let's insert it as a paragraph after the previously inserted one. - let secondSentence = context.document.body.insertParagraph( - "This is the first text with a custom style.", - "End" - ); - secondSentence.font.set({ - bold: false, - italic: true, - name: "Berlin Sans FB", - color: "blue", - size: 30 - }); + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + await context.sync(); + + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + const nextTrackedChange: Word.TrackedChange = trackedChange.getNext(); await context.sync(); + + nextTrackedChange.load(["author", "date", "text", "type"]); + await context.sync(); + + console.log(nextTrackedChange); }); -'Word.Paragraph#text:member': +Word.TrackedChange#accept:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml - await Word.run(async (context) => { - // The collection of paragraphs of the current selection returns the full paragraphs contained in it. - let paragraph = context.document.getSelection().paragraphs.getFirst(); - paragraph.load("text"); + // Accepts the first tracked change. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + trackedChange.load(); await context.sync(); - console.log(paragraph.text); + + console.log("First tracked change:", trackedChange); + trackedChange.accept(); + console.log("Accepted the first tracked change."); }); -'Word.Paragraph#leftIndent:member': +Word.TrackedChange#getNext:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/paragraph-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the next (second) tracked change. await Word.run(async (context) => { - // Indents the first paragraph. - context.document.body.paragraphs.getFirst().leftIndent = 75; //units = points + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + await context.sync(); - return context.sync(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + + const nextTrackedChange: Word.TrackedChange = trackedChange.getNext(); + await context.sync(); + + nextTrackedChange.load(["author", "date", "text", "type"]); + await context.sync(); + + console.log(nextTrackedChange); }); -'Word.Paragraph#lineSpacing:member': +Word.TrackedChange#getRange:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/paragraph-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the range of the first tracked change. await Word.run(async (context) => { - // Adjusts line spacing. - context.document.body.paragraphs.getFirst().lineSpacing = 20; + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + const range: Word.Range = trackedChange.getRange(); + range.load(); await context.sync(); + + console.log("range.text: " + range.text); }); -'Word.Paragraph#spaceAfter:member': +Word.TrackedChange#reject:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/paragraph-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml - await Word.run(async (context) => { - // Adjust space between paragraphs. - context.document.body.paragraphs.getFirst().spaceAfter = 20; + // Rejects the first tracked change. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + trackedChange.load(); await context.sync(); + + console.log("First tracked change:", trackedChange); + trackedChange.reject(); + console.log("Rejected the first tracked change."); }); -'Word.Paragraph#alignment:member': +Word.TrackedChangeCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/paragraph-properties.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the range of the first tracked change. await Word.run(async (context) => { - // Centers last paragraph alignment. - context.document.body.paragraphs.getLast().alignment = "Centered"; + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + const range: Word.Range = trackedChange.getRange(); + range.load(); await context.sync(); + + console.log("range.text: " + range.text); }); -'Word.Paragraph#insertText:member(1)': +Word.TrackedChangeCollection#acceptAll:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/insert-in-different-locations.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml - await Word.run(async (context) => { - // Replace the last paragraph. - let range = context.document.body.paragraphs.getLast().insertText("Just replaced the last paragraph!", "Replace"); - range.font.highlightColor = "black"; - range.font.color = "white"; - await context.sync(); + // Accepts all tracked changes. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.acceptAll(); + console.log("Accepted all tracked changes."); }); -'Word.Paragraph#select:member(1)': +Word.TrackedChangeCollection#getFirst:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/35-ranges/scroll-to-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the range of the first tracked change. await Word.run(async (context) => { - // If select is called with no parameters, it selects the object. - context.document.body.paragraphs.getLast().select(); + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); + await context.sync(); + const range: Word.Range = trackedChange.getRange(); + range.load(); await context.sync(); + + console.log("range.text: " + range.text); }); +Word.TrackedChangeCollection#rejectAll:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/35-ranges/scroll-to-range.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml - await Word.run(async (context) => { - // Select can be at the start or end of a range; this by definition moves the insertion point without selecting the range. - context.document.body.paragraphs.getLast().select("End"); - await context.sync(); + // Rejects all tracked changes. + + await Word.run(async (context) => { + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + trackedChanges.rejectAll(); + console.log("Rejected all tracked changes."); }); -'Word.Paragraph#split:member(1)': +Word.TrackedChangeType:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/35-ranges/split-words-of-first-paragraph.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml + + + // Gets the next (second) tracked change. await Word.run(async (context) => { - let paragraph = context.document.body.paragraphs.getFirst(); - let words = paragraph.split([" "], true /* trimDelimiters*/, true /* trimSpaces */); - words.load("text"); + const body: Word.Body = context.document.body; + const trackedChanges: Word.TrackedChangeCollection = body.getTrackedChanges(); + await context.sync(); + const trackedChange: Word.TrackedChange = trackedChanges.getFirst(); await context.sync(); - for (let i = 0; i < words.items.length; i++) { - if (i >= 1) { - words.items[i - 1].font.highlightColor = "#FFFFFF"; - } - words.items[i].font.highlightColor = "#FFFF00"; + const nextTrackedChange: Word.TrackedChange = trackedChange.getNext(); + await context.sync(); - await context.sync(); - await pause(200); - } + nextTrackedChange.load(["author", "date", "text", "type"]); + await context.sync(); + + console.log(nextTrackedChange); }); -'Word.Paragraph#startNewList:member(1)': +Word.TrailingCharacter:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/20-lists/insert-list.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml + - // This example starts a new list stating with the second paragraph. + // Gets the properties of the specified style. await Word.run(async (context) => { - let paragraphs = context.document.body.paragraphs; - paragraphs.load("$none"); // No properties needed. + const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value; + if (styleName == "") { + console.warn("Enter a style name to get properties."); + return; + } + const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName); + style.load("type"); await context.sync(); - var list = paragraphs.items[1].startNewList(); // Indicates new list to be started in the second paragraph. - list.load("$none"); // No properties needed. + if (style.isNullObject || style.type != Word.StyleType.list) { + console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`); + } else { + // Load objects to log properties and their values in the console. + style.load(); + style.listTemplate.load(); + await context.sync(); - await context.sync(); + console.log(`Properties of the '${styleName}' style:`, style); - // To add new items to the list use start/end on the insert location parameter. - list.insertParagraph("New list item on top of the list", "Start"); - let paragraph = list.insertParagraph("New list item at the end of the list (4th level)", "End"); - paragraph.listItem.level = 4; // Sets up list level for the lsit item. - // To add paragraphs outside the list use before/after: - list.insertParagraph("New paragraph goes after (not part of the list)", "After"); + const listLevels = style.listTemplate.listLevels; + listLevels.load("items"); + await context.sync(); - await context.sync(); + console.log(`List levels of the '${styleName}' style:`, listLevels); + } }); -'Word.Paragraph#set:member(1)': +Word.VerticalAlignment:enum: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/90-scenarios/multiple-property-set.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml - await Word.run(async (context) => { - const paragraph = context.document.body.paragraphs.getFirst(); - paragraph.set({ - leftIndent: 30, - font: { - bold: true, - color: "red" - } - }); + // Gets content alignment details about the first row of the first table in + the document. + + await Word.run(async (context) => { + const firstTable: Word.Table = context.document.body.tables.getFirst(); + const firstTableRow: Word.TableRow = firstTable.rows.getFirst(); + firstTableRow.load(["horizontalAlignment", "verticalAlignment"]); await context.sync(); + + console.log(`Details about the alignment of the first table's first row:`, `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`, `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`); }); +Word.Window:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/90-scenarios/multiple-property-set.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml + await Word.run(async (context) => { - const firstParagraph = context.document.body.paragraphs.getFirst(); - const secondParagraph = firstParagraph.getNext(); - firstParagraph.load("text, font/color, font/bold, leftIndent"); + // Gets the first paragraph of each page. + console.log("Getting first paragraph of each page..."); + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get all pages. + const pages: Word.PageCollection = activePane.pages; + pages.load(); await context.sync(); - secondParagraph.set(firstParagraph); + // Get page index and paragraphs of each page. + const pagesIndexes = []; + const pagesNumberOfParagraphs = []; + const pagesFirstParagraphText = []; + for (let i = 0; i < pages.items.length; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + + const paragraphs = page.getRange().paragraphs; + paragraphs.load("items/length"); + pagesNumberOfParagraphs.push(paragraphs); + + const firstParagraph = paragraphs.getFirst(); + firstParagraph.load("text"); + pagesFirstParagraphText.push(firstParagraph); + } await context.sync(); + + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); + console.log(`Number of paragraphs: ${pagesNumberOfParagraphs[i].items.length}`); + console.log("First paragraph's text:", pagesFirstParagraphText[i].text); + } }); -'Word.Range#insertContentControl:member(1)': +Word.Window#close:member(1): - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/90-scenarios/doc-assembly.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/close-document-window.yaml - await Word.run(async (context) => { - let results = context.document.body.search("Contractor"); - results.load("font/bold"); - - // Check to make sure these content controls haven't been added yet. - let customerContentControls = context.document.contentControls.getByTag("customer"); - customerContentControls.load("text"); - await context.sync(); - if (customerContentControls.items.length === 0) { - for (var i = 0; i < results.items.length; i++) { - results.items[i].font.bold = true; - var cc = results.items[i].insertContentControl(); - cc.tag = "customer"; // This value is used in the next step of this sample. - cc.title = "Customer Name " + i; - } - } - await context.sync(); + await Word.run(async (context) => { + // Closes the document window, prompting to save if this is a new document. + const window: Word.Window = context.document.activeWindow; + const closeOptions: Word.WindowCloseOptions = { saveChanges: Word.SaveConfiguration.promptToSaveChanges }; + console.log("About to close the document window..."); + window.close(closeOptions); }); -'Word.Range#getTextRanges:member(1)': +Word.Window#activePane:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml + await Word.run(async (context) => { - // Gets the complete sentence (as range) associated with the insertion point. - let sentences = context.document - .getSelection() - .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/); - sentences.load("$none"); + // Gets the pages enclosing the viewport. + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load(); + + // Get the active pane. + const activePane: Word.Pane = activeWindow.activePane; + activePane.load(); + + // Get pages enclosing the viewport. + const pages: Word.PageCollection = activePane.pagesEnclosingViewport; + pages.load(); + await context.sync(); - // Expands the range to the end of the paragraph to get all the complete sentences. - let sentencesToTheEndOfParagraph = sentences.items[0] - .getRange() - .expandTo( - context.document - .getSelection() - .paragraphs.getFirst() - .getRange("End") - ) - .getTextRanges(["."], false /* Don't trim spaces*/); - sentencesToTheEndOfParagraph.load("text"); + // Log the number of pages. + const pageCount = pages.items.length; + console.log(`Number of pages enclosing the viewport: ${pageCount}`); + + // Log index info of these pages. + const pagesIndexes = []; + for (let i = 0; i < pageCount; i++) { + const page = pages.items[i]; + page.load("index"); + pagesIndexes.push(page); + } + await context.sync(); - for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) { - console.log(sentencesToTheEndOfParagraph.items[i].text); + for (let i = 0; i < pagesIndexes.length; i++) { + console.log(`Page index: ${pagesIndexes[i].index}`); } }); -'Word.Section#getHeader:member(1)': +Word.Window#panes:member: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/insert-header-and-footer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml + await Word.run(async (context) => { - context.document.sections.getFirst().getHeader("Primary") - .insertParagraph("This is a header", "End"); + // Gets all the panes in the active document window. + + // Get the active window. + const activeWindow: Word.Window = context.document.activeWindow; + activeWindow.load("panes/items/length"); await context.sync(); + + const panes: Word.PaneCollection = activeWindow.panes; + console.log(`Number of panes in the current document window: ${panes.items.length}`); }); -'Word.Section#getFooter:member(1)': +Word.WindowCloseOptions:interface: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/25-paragraph/insert-header-and-footer.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/close-document-window.yaml - await Word.run(async (context) => { - context.document.sections.getFirst().getFooter("Primary") - .insertParagraph("This is a footer", "End"); - await context.sync(); + await Word.run(async (context) => { + // Closes the document window, prompting to save if this is a new document. + const window: Word.Window = context.document.activeWindow; + const closeOptions: Word.WindowCloseOptions = { saveChanges: Word.SaveConfiguration.promptToSaveChanges }; + console.log("About to close the document window..."); + window.close(closeOptions); }); -'Word.Table#getCell:member(1)': +Word.WindowCollection:class: - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/master/samples/word/40-tables/table-cell-access.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml + await Word.run(async (context) => { - let firstCell = context.document.body.tables.getFirst().getCell(0, 0).body; - firstCell.load("text"); + // Gets the document windows. + const windows: Word.WindowCollection = context.document.windows; + windows.load("windows/items/length"); await context.sync(); - console.log("First cell text is " + firstCell.text); + + console.log(`Number of windows for this document: ${windows.items.length}`); }); diff --git a/tsconfig.json b/tsconfig.json index 0fd566d63..a3ff66e69 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "es6", + "target": "es2018", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, + "esModuleInterop": true, "removeComments": false, "noImplicitAny": false, "noEmitOnError": true, @@ -17,8 +18,10 @@ "rootDir": "config", "lib": [ "dom", - "es2015" + "es2018" ], - "pretty": true + "pretty": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true } } \ No newline at end of file diff --git a/view-prod/excel.json b/view-prod/excel.json new file mode 100644 index 000000000..38e8b6628 --- /dev/null +++ b/view-prod/excel.json @@ -0,0 +1,151 @@ +{ + "excel-basics-basic-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-api-call.yaml", + "excel-basics-basic-api-call-es5": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-api-call-es5.yaml", + "excel-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/01-basics/basic-common-api-call.yaml", + "excel-chart-axis": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis.yaml", + "excel-chart-axis-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-axis-formatting.yaml", + "excel-chart-data-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-table.yaml", + "excel-chart-bubble-chart": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml", + "excel-chart-create-several-charts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-create-several-charts.yaml", + "excel-chart-create-doughnut-chart": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/create-doughnut-chart.yaml", + "excel-chart-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-formatting.yaml", + "excel-chart-legend": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-legend.yaml", + "excel-chart-point": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-point.yaml", + "excel-chart-series": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml", + "excel-chart-series-markers": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml", + "excel-chart-series-plotorder": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-plotorder.yaml", + "excel-chart-title-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-title-format.yaml", + "excel-chart-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml", + "excel-chart-trendlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml", + "excel-chart-data-labels": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml", + "excel-chart-leader-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-leader-lines.yaml", + "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml", + "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml", + "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml", + "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml", + "excel-note-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml", + "excel-range-conditional-formatting-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml", + "excel-range-conditional-formatting-advanced": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml", + "excel-custom-functions-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/basic-function.yaml", + "excel-custom-functions-volatile": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/volatile-function.yaml", + "excel-custom-functions-streaming": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/streaming-function.yaml", + "excel-custom-functions-web-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/web-call-function.yaml", + "excel-custom-functions-errors": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/custom-functions-errors.yaml", + "excel-data-types-custom-functions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/data-types-custom-functions.yaml", + "excel-custom-functions-custom-enum": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/custom-enum.yaml", + "excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml", + "excel-custom-xml-parts-test-xml-for-unique-namespace": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml", + "excel-chart-chart-title-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/private-samples/excel/20-chart/chart-title-ts.yaml", + "excel-data-types-doubles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml", + "excel-data-types-web-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml", + "excel-data-types-entity-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-values.yaml", + "excel-data-types-error-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml", + "excel-data-types-icons": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-icons.yaml", + "excel-data-types-entity-attribution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-attribution.yaml", + "excel-data-types-references": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-references.yaml", + "excel-data-types-basic-types": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-basic-types.yaml", + "excel-data-validation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml", + "excel-document-get-file-in-slices-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/get-file-in-slices-async.yaml", + "excel-document-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/properties.yaml", + "excel-document-custom-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml", + "excel-events-chartcollection-added-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chartcollection-added-activated.yaml", + "excel-events-chart-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-chart-activated.yaml", + "excel-event-column-and-row-sort": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml", + "excel-events-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-comment-event-handler.yaml", + "excel-events-data-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-changed.yaml", + "excel-data-change-event-details": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-change-event-details.yaml", + "excel-events-disable-events": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-disable-events.yaml", + "excel-events-formula-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-formula-changed.yaml", + "excel-selection-changed-events": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/selection-changed-events.yaml", + "excel-events-tablecollection-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-tablecollection-changed.yaml", + "excel-event-worksheet-single-click": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-worksheet-single-click.yaml", + "excel-events-table-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-table-changed.yaml", + "excel-events-workbook-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-activated.yaml", + "excel-events-workbook-and-worksheet-collection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml", + "excel-events-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml", + "excel-events-worksheet-protection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml", + "excel-named-item-create-and-remove-named-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/create-and-remove-named-item.yaml", + "excel-update-named-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/34-named-item/update-named-item.yaml", + "excel-pivottable-calculations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-calculations.yaml", + "excel-pivottable-create-and-modify": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-create-and-modify.yaml", + "excel-pivottable-filters-and-summaries": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml", + "excel-pivottables-get-pivottables": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-get-pivottables.yaml", + "excel-pivottables-pivotfilters": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml", + "excel-pivottable-pivotlayout": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml", + "excel-pivottable-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-source-data.yaml", + "excel-pivottable-refresh": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-refresh.yaml", + "excel-pivottable-slicer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-slicer.yaml", + "excel-range-auto-fill": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-auto-fill.yaml", + "excel-range-copyfrom": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-copyfrom.yaml", + "excel-range-areas": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-areas.yaml", + "excel-range-find": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-find.yaml", + "excel-range-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/formatting.yaml", + "excel-range-cell-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml", + "excel-range-hyperlink": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml", + "excel-range-insert-delete-and-clear-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/insert-delete-clear-range.yaml", + "excel-outline": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/outline.yaml", + "excel-range-range-relationships": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-relationships.yaml", + "excel-range-remove-duplicates": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-remove-duplicates.yaml", + "excel-range-selected-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/selected-range.yaml", + "excel-precedents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/precedents.yaml", + "excel-range-style": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/style.yaml", + "excel-range-text-orientation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-text-orientation.yaml", + "excel-range-dynamic-arrays": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/dynamic-arrays.yaml", + "excel-range-used-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/used-range.yaml", + "excel-range-values-and-formulas": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/set-get-values.yaml", + "excel-merged-ranges": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-merged-ranges.yaml", + "excel-range-get-range-edge": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml", + "excel-direct-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-direct-dependents.yaml", + "excel-range-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-dependents.yaml", + "excel-cell-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml", + "excel-shape-create-and-delete": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml", + "excel-shape-images": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml", + "excel-shape-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml", + "excel-shape-move-and-order": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-move-and-order.yaml", + "excel-shape-groups": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-groups.yaml", + "excel-shape-textboxes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-textboxes.yaml", + "excel-shape-get-active": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-get-active.yaml", + "excel-table-add-rows-and-columns-to-a-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/add-rows-and-columns-to-a-table.yaml", + "excel-table-convert-range-to-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/convert-range-to-table.yaml", + "excel-table-create-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/create-table.yaml", + "excel-table-filter-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/filter-data.yaml", + "excel-table-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/formatting.yaml", + "excel-table-get-data-from-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/get-data-from-table.yaml", + "excel-table-get-visible-range-of-a-filtered-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml", + "excel-table-import-json-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/import-json-data.yaml", + "excel-table-sort-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/sort-data.yaml", + "excel-table-resize": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/46-table/resize-table.yaml", + "excel-workbook-get-active-cell": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-get-active-cell.yaml", + "excel-settings-create-get-change-delete-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-get-change-delete-settings.yaml", + "excel-workbook-calculation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-calculation.yaml", + "excel-workbook-create-workbook": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/create-workbook.yaml", + "excel-culture-info": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml", + "excel-culture-info-date-time": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info-date-time.yaml", + "excel-workbook-data-protection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml", + "excel-workbook-save-and-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-save-and-close.yaml", + "excel-workbook-insert-external-worksheets": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml", + "excel-workbook-built-in-function": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/workbook-built-in-functions.yaml", + "excel-worksheet-active-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/active-worksheet.yaml", + "excel-worksheet-add-delete-rename-move-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml", + "excel-worksheet-auto-filter": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml", + "excel-worksheet-copy": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-copy.yaml", + "excel-worksheet-find-all": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-find-all.yaml", + "excel-worksheet-freeze-panes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml", + "excel-worksheet-worksheet-range-cell": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-range-cell.yaml", + "excel-worksheet-gridlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/gridlines.yaml", + "excel-worksheet-list-worksheets": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/list-worksheets.yaml", + "excel-worksheet-page-layout": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-page-layout.yaml", + "excel-worksheet-reference-worksheets-by-relative-position": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml", + "excel-worksheet-tab-color": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/tab-color.yaml", + "excel-worksheet-visibility": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-visibility.yaml", + "excel-performance-optimization": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/performance-optimization.yaml", + "excel-scenarios-report-generation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/report-generation.yaml", + "excel-scenarios-multiple-property-set": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/multiple-property-set.yaml", + "excel-scenarios-working-with-dates": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/working-with-dates.yaml", + "excel-scenarios-currency-converter": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/currency-converter.yaml", + "excel-just-for-fun-patterns": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/patterns.yaml", + "excel-just-for-fun-gradient": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/gradient.yaml", + "excel-just-for-fun-path-finder-game": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/path-finder-game.yaml", + "excel-just-for-fun-tetrominos": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/tetrominos.yaml", + "excel-just-for-fun-color-wheel": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/99-just-for-fun/color-wheel.yaml" +} \ No newline at end of file diff --git a/view-prod/outlook.json b/view-prod/outlook.json new file mode 100644 index 000000000..3eeda67db --- /dev/null +++ b/view-prod/outlook.json @@ -0,0 +1,90 @@ +{ + "outlook-roaming-settings-roaming-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/10-roaming-settings/roaming-settings.yaml", + "outlook-item-custom-properties-load-set-get-save": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml", + "outlook-item-body-get-selected-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-selected-data.yaml", + "outlook-item-body-replace-selected-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/replace-selected-text.yaml", + "outlook-item-body-add-inline-base64-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/add-inline-base64-image.yaml", + "outlook-item-body-get-body-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/get-body-format.yaml", + "outlook-item-body-append-text-on-send": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/append-text-on-send.yaml", + "outlook-item-body-prepend-text-to-item-body": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-to-item-body.yaml", + "outlook-item-body-prepend-text-on-send": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/prepend-text-on-send.yaml", + "outlook-item-save-and-close-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close.yaml", + "outlook-close-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/close-async.yaml", + "outlook-item-save-and-close-save": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/25-item-save-and-close/save.yaml", + "outlook-recipients-and-attendees-get-from-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml", + "outlook-recipients-and-attendees-get-from-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml", + "outlook-recipients-and-attendees-get-to-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml", + "outlook-recipients-and-attendees-get-set-to-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml", + "outlook-recipients-and-attendees-get-cc-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml", + "outlook-recipients-and-attendees-get-set-cc-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml", + "outlook-recipients-and-attendees-get-set-bcc-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml", + "outlook-recipients-and-attendees-get-sender-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml", + "outlook-recipients-and-attendees-get-required-attendees-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-set-required-attendees-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-optional-attendees-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-set-optional-attendees-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-organizer-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-organizer-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-all-attendees": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml", + "outlook-notifications-add-getall-remove": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml", + "outlook-attachments-attachments-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml", + "outlook-attachments-get-attachment-content": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachment-content.yaml", + "outlook-attachments-get-attachments-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml", + "outlook-categories-work-with-categories": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-categories.yaml", + "outlook-categories-work-with-master-categories": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/45-categories/work-with-master-categories.yaml", + "outlook-recurrence-get-series-id": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-series-id.yaml", + "outlook-recurrence-get-recurrence-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-recurrence-read.yaml", + "outlook-recurrence-get-set-recurrence-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml", + "outlook-display-items-display-new-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-message.yaml", + "outlook-display-items-display-new-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-new-appointment.yaml", + "outlook-display-items-display-existing-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-message.yaml", + "outlook-display-items-display-existing-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-existing-appointment.yaml", + "outlook-display-items-display-reply-forms": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml", + "outlook-display-items-display-reply-with-attachments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-with-attachments.yaml", + "outlook-sensitivity-labels-sensitivity-labels-catalog": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml", + "outlook-sensitivity-labels-sensitivity-label": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml", + "outlook-delegates-and-shared-folders-get-shared-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml", + "outlook-mime-headers-get-internet-headers-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml", + "outlook-mime-headers-manage-custom-internet-headers-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml", + "outlook-regex-matches-contextual": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml", + "outlook-events-drag-drop-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml", + "outlook-tokens-and-service-calls-ids-and-urls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml", + "outlook-tokens-and-service-calls-user-identity-token": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml", + "outlook-tokens-and-service-calls-user-callback-token": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml", + "outlook-tokens-and-service-calls-make-ews-request-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml", + "outlook-tokens-and-service-calls-send-message-using-make-ews-request-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml", + "outlook-tokens-and-service-calls-get-icaluid-as-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml", + "outlook-tokens-and-service-calls-get-icaluid-as-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml", + "outlook-other-item-apis-get-subject-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-subject-read.yaml", + "outlook-other-item-apis-get-set-subject-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml", + "outlook-item-body-set-selected-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/set-selected-data.yaml", + "outlook-other-item-apis-get-internet-message-id-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml", + "outlook-other-item-apis-get-item-class-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-read.yaml", + "outlook-other-item-apis-get-item-type": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml", + "outlook-other-item-apis-get-start-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml", + "outlook-other-item-apis-get-set-start-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml", + "outlook-other-item-apis-get-end-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml", + "outlook-other-item-apis-get-set-end-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml", + "outlook-other-item-apis-get-location-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-location-read.yaml", + "outlook-other-item-apis-get-set-location-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml", + "outlook-other-item-apis-get-add-remove-enhancedlocation-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml", + "outlook-other-item-apis-get-normalized-subject-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml", + "outlook-other-item-apis-get-conversation-id-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml", + "outlook-other-item-apis-get-date-time-created-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml", + "outlook-other-item-apis-get-date-time-modified-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml", + "outlook-other-item-apis-get-diagnostic-information": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml", + "outlook-other-item-apis-work-with-client-signatures": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml", + "outlook-other-item-apis-session-data-apis": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/session-data-apis.yaml", + "outlook-delay-message-delivery": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml", + "outlook-other-item-apis-get-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-message-properties.yaml", + "outlook-other-item-apis-get-set-sensitivity-level": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml", + "outlook-get-eml-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-eml-format.yaml", + "outlook-get-in-reply-to": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-in-reply-to.yaml", + "outlook-get-conversation-index": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-index.yaml", + "outlook-get-item-class-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-async.yaml", + "outlook-other-item-apis-item-id-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/item-id-compose.yaml", + "outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/send-async.yaml", + "outlook-other-item-apis-get-loaded-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml", + "outlook-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml", + "outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml" +} \ No newline at end of file diff --git a/view-prod/powerpoint.json b/view-prod/powerpoint.json new file mode 100644 index 000000000..3174b1a57 --- /dev/null +++ b/view-prod/powerpoint.json @@ -0,0 +1,23 @@ +{ + "powerpoint-basics-basic-api-call-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-api-call-ts.yaml", + "powerpoint-basics-basic-api-call-js": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-api-call-js.yaml", + "powerpoint-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/basics/basic-common-api-call.yaml", + "powerpoint-create-presentation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/document/create-presentation.yaml", + "powerpoint-hyperlinks-manage-hyperlinks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml", + "powerpoint-basics-insert-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/images/insert-image.yaml", + "powerpoint-basics-insert-svg": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/images/insert-svg.yaml", + "powerpoint-scenarios-searches-wikipedia-api": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/scenarios/searches-wikipedia-api.yaml", + "powerpoint-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml", + "powerpoint-shapes-get-set-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml", + "powerpoint-shapes-get-shapes-by-type": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml", + "powerpoint-shapes-add-modify-tables": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml", + "powerpoint-shapes-binding-to-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml", + "powerpoint-shapes-group-ungroup-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml", + "powerpoint-add-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml", + "powerpoint-insert-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/insert-slides.yaml", + "powerpoint-basics-get-slide-metadata": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-slide-metadata.yaml", + "powerpoint-slide-management-get-set-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml", + "powerpoint-slide-management-export-import-slide": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/export-import-slide.yaml", + "powerpoint-tags": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml", + "powerpoint-text-get-set-textrange": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml" +} \ No newline at end of file diff --git a/view-prod/project.json b/view-prod/project.json new file mode 100644 index 000000000..605dd28bd --- /dev/null +++ b/view-prod/project.json @@ -0,0 +1,3 @@ +{ + "project-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/project/basics/basic-common-api-call.yaml" +} \ No newline at end of file diff --git a/view-prod/word.json b/view-prod/word.json new file mode 100644 index 000000000..af44ad5a0 --- /dev/null +++ b/view-prod/word.json @@ -0,0 +1,67 @@ +{ + "word-basics-basic-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-api-call.yaml", + "word-basics-api-call-es5": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-api-call-es5.yaml", + "word-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/01-basics/basic-common-api-call.yaml", + "word-content-controls-insert-and-change-content-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml", + "word-content-controls-content-control-onadded-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onadded-event.yaml", + "word-content-controls-content-control-onentered-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onentered-event.yaml", + "word-content-controls-content-control-onselectionchanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml", + "word-content-controls-content-control-ondatachanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondatachanged-event.yaml", + "word-content-controls-content-control-onexited-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onexited-event.yaml", + "word-content-controls-content-control-ondeleted-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-ondeleted-event.yaml", + "word-content-controls-insert-and-change-checkbox-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml", + "word-content-controls-insert-and-change-combo-box-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml", + "word-content-controls-insert-and-change-dropdown-list-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml", + "word-content-controls-get-change-tracking-states": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/get-change-tracking-states.yaml", + "word-images-insert-and-get-pictures": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/15-images/insert-and-get-pictures.yaml", + "word-lists-insert-list": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml", + "word-lists-manage-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml", + "word-lists-organize-list": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/organize-list.yaml", + "word-paragraph-get-paragraph-on-insertion-point": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml", + "word-paragraph-insert-line-and-page-breaks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-line-and-page-breaks.yaml", + "word-paragraph-insert-in-different-locations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-in-different-locations.yaml", + "word-paragraph-insert-formatted-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-formatted-text.yaml", + "word-paragraph-insert-header-and-footer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-header-and-footer.yaml", + "word-paragraph-paragraph-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml", + "word-paragraph-search": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/search.yaml", + "word-paragraph-get-word-count": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-word-count.yaml", + "word-paragraph-get-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-text.yaml", + "word-paragraph-onadded-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onadded-event.yaml", + "word-paragraph-onchanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/onchanged-event.yaml", + "word-paragraph-ondeleted-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/ondeleted-event.yaml", + "word-properties-get-built-in-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/get-built-in-properties.yaml", + "word-properties-read-write-custom-document-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/30-properties/read-write-custom-document-properties.yaml", + "word-ranges-scroll-to-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml", + "word-ranges-split-words-of-first-paragraph": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/split-words-of-first-paragraph.yaml", + "word-ranges-compare-location": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/compare-location.yaml", + "word-ranges-get-pages": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/get-pages.yaml", + "word-tables-table-cell-access": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/table-cell-access.yaml", + "word-tables-manage-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml", + "word-tables-manage-custom-style": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-custom-style.yaml", + "word-shapes-manage-shapes-text-boxes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml", + "word-shapes-manage-geometric-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-geometric-shapes.yaml", + "word-shapes-group-ungroup": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/group-ungroup.yaml", + "word-shapes-manage-canvases": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-canvases.yaml", + "word-document-manage-body": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-body.yaml", + "word-document-insert-section-breaks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-section-breaks.yaml", + "word-document-insert-external-document": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/insert-external-document.yaml", + "word-document-manage-change-tracking": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml", + "word-document-manage-tracked-changes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-tracked-changes.yaml", + "word-document-manage-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-comments.yaml", + "word-document-manage-footnotes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml", + "word-document-manage-fields": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-fields.yaml", + "word-document-manage-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-settings.yaml", + "word-document-manage-custom-xml-part-ns": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part-ns.yaml", + "word-document-manage-custom-xml-part": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-custom-xml-part.yaml", + "word-document-manage-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml", + "word-document-get-external-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/get-external-styles.yaml", + "word-document-save-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/save-close.yaml", + "word-document-manage-annotations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml", + "word-document-compare-documents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/compare-documents.yaml", + "word-scenarios-doc-assembly": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml", + "word-scenarios-multiple-property-set": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/multiple-property-set.yaml", + "word-scenarios-correlated-objects-pattern": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/correlated-objects-pattern.yaml", + "word-close-document-window": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/close-document-window.yaml", + "word-insert-and-change-content-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-content-controls.yaml", + "word-manage-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/manage-comments.yaml" +} \ No newline at end of file diff --git a/view/excel.json b/view/excel.json index 90aa0e11f..6c50b9c80 100644 --- a/view/excel.json +++ b/view/excel.json @@ -1,121 +1,151 @@ { - "excel-basics-basic-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/01-basics/basic-api-call.yaml", - "excel-basics-basic-api-call-es5": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/01-basics/basic-api-call-es5.yaml", - "excel-basics-basic-common-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/01-basics/basic-common-api-call.yaml", - "excel-chart-axis": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-axis.yaml", - "excel-chart-axis-formatting": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-axis-formatting.yaml", - "excel-chart-bubble-chart": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-bubble-chart.yaml", - "excel-chart-create-several-charts": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-create-several-charts.yaml", - "excel-chart-create-doughnut-chart": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/create-doughnut-chart.yaml", - "excel-chart-formatting": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-formatting.yaml", - "excel-chart-legend": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-legend.yaml", - "excel-chart-point": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-point.yaml", - "excel-chart-series": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-series.yaml", - "excel-chart-series-markers": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-series-markers.yaml", - "excel-chart-series-plotorder": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-series-plotorder.yaml", - "excel-chart-title-format": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-title-format.yaml", - "excel-chart-trendlines": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/10-chart/chart-trendlines.yaml", - "excel-comment-basics": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/12-comment/comment-basics.yaml", - "excel-comment-mentions": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/12-comment/comment-mentions.yaml", - "excel-comment-replies": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/12-comment/comment-replies.yaml", - "excel-comment-resolution": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/12-comment/comment-resolution.yaml", - "excel-range-conditional-formatting-basic": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml", - "excel-range-conditional-formatting-advanced": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml", - "excel-custom-functions-basic": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/16-custom-functions/basic-function.yaml", - "excel-custom-functions-volatile": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/16-custom-functions/volatile-function.yaml", - "excel-custom-functions-streaming": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/16-custom-functions/streaming-function.yaml", - "excel-custom-functions-web-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/16-custom-functions/web-call-function.yaml", - "excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml", - "excel-custom-xml-parts-test-xml-for-unique-namespace": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml", - "excel-chart-chart-title-ts": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/private-samples/excel/20-chart/chart-title-ts.yaml", - "excel-data-validation": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/22-data-validation/data-validation.yaml", - "excel-document-get-file-in-slices-async": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/26-document/get-file-in-slices-async.yaml", - "excel-document-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/26-document/properties.yaml", - "excel-document-custom-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/26-document/custom-properties.yaml", - "excel-events-chartcollection-added-activated": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-chartcollection-added-activated.yaml", - "excel-events-chart-activated": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-chart-activated.yaml", - "excel-event-column-and-row-sort": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/event-column-and-row-sort.yaml", - "excel-events-data-changed": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/data-changed.yaml", - "excel-data-change-event-details": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/data-change-event-details.yaml", - "excel-events-disable-events": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-disable-events.yaml", - "excel-selection-changed-events": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/selection-changed-events.yaml", - "excel-event-worksheet-single-click": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/event-worksheet-single-click.yaml", - "excel-events-tablecollection-changed": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-tablecollection-changed.yaml", - "excel-events-table-changed": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-table-changed.yaml", - "excel-events-workbook-and-worksheet-collection": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml", - "excel-events-worksheet": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-worksheet.yaml", - "excel-events-comments": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/30-events/events-comment-event-handler.yaml", - "excel-named-item-create-and-remove-named-item": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/34-named-item/create-and-remove-named-item.yaml", - "excel-update-named-item": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/34-named-item/update-named-item.yaml", - "excel-pivottable-calculations": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-calculations.yaml", - "excel-pivottable-create-and-modify": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-create-and-modify.yaml", - "excel-pivottable-filters-and-summaries": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml", - "excel-pivottables-get-pivottables": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-get-pivottables.yaml", - "excel-pivottable-slicer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-slicer.yaml", - "excel-pivottables-pivotfilters": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/38-pivottable/pivottable-pivotfilters.yaml", - "excel-range-auto-fill": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-auto-fill.yaml", - "excel-range-copyfrom": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-copyfrom.yaml", - "excel-range-areas": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-areas.yaml", - "excel-range-find": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-find.yaml", - "excel-range-formatting": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/formatting.yaml", - "excel-range-cell-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/cell-properties.yaml", - "excel-range-hyperlink": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-hyperlink.yaml", - "excel-range-insert-delete-and-clear-range": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/insert-delete-clear-range.yaml", - "excel-outline": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/outline.yaml", - "excel-range-range-relationships": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-relationships.yaml", - "excel-range-remove-duplicates": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-remove-duplicates.yaml", - "excel-range-selected-range": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/selected-range.yaml", - "excel-direct-precedents": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/direct-precedents.yaml", - "excel-range-style": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/style.yaml", - "excel-range-text-orientation": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/range-text-orientation.yaml", - "excel-range-dynamic-arrays": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/dynamic-arrays.yaml", - "excel-range-used-range": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/used-range.yaml", - "excel-range-values-and-formulas": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/42-range/set-get-values.yaml", - "excel-shape-create-and-delete": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-create-and-delete.yaml", - "excel-shape-images": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-images.yaml", - "excel-shape-lines": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-lines.yaml", - "excel-shape-move-and-order": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-move-and-order.yaml", - "excel-shape-groups": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-groups.yaml", - "excel-shape-textboxes": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/44-shape/shape-textboxes.yaml", - "excel-table-add-rows-and-columns-to-a-table": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/add-rows-and-columns-to-a-table.yaml", - "excel-table-convert-range-to-table": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/convert-range-to-table.yaml", - "excel-table-create-table": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/create-table.yaml", - "excel-table-filter-data": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/filter-data.yaml", - "excel-table-formatting": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/formatting.yaml", - "excel-table-get-data-from-table": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/get-data-from-table.yaml", - "excel-table-get-visible-range-of-a-filtered-table": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml", - "excel-table-import-json-data": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/import-json-data.yaml", - "excel-table-sort-data": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/46-table/sort-data.yaml", - "excel-workbook-get-active-cell": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/workbook-get-active-cell.yaml", - "excel-settings-create-get-change-delete-settings": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/create-get-change-delete-settings.yaml", - "excel-workbook-calculation": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/workbook-calculation.yaml", - "excel-workbook-create-workbook": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/create-workbook.yaml", - "excel-culture-info": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/culture-info.yaml", - "excel-culture-info-date-time": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/culture-info-date-time.yaml", - "excel-workbook-data-protection": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/data-protection.yaml", - "excel-workbook-save-and-close": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/50-workbook/workbook-save-and-close.yaml", - "excel-worksheet-active-worksheet": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/active-worksheet.yaml", - "excel-worksheet-add-delete-rename-move-worksheet": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml", - "excel-worksheet-auto-filter": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-auto-filter.yaml", - "excel-worksheet-copy": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-copy.yaml", - "excel-worksheet-find-all": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-find-all.yaml", - "excel-worksheet-freeze-panes": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-freeze-panes.yaml", - "excel-worksheet-worksheet-range-cell": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-range-cell.yaml", - "excel-worksheet-gridlines": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/gridlines.yaml", - "excel-worksheet-list-worksheets": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/list-worksheets.yaml", - "excel-worksheet-page-layout": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-page-layout.yaml", - "excel-worksheet-reference-worksheets-by-relative-position": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml", - "excel-worksheet-tab-color": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/tab-color.yaml", - "excel-worksheet-visibility": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/54-worksheet/worksheet-visibility.yaml", - "excel-workbook-insert-external-worksheets": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/85-preview-apis/workbook-insert-external-worksheets.yaml", - "excel-performance-optimization": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/90-scenarios/performance-optimization.yaml", - "excel-scenarios-report-generation": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/90-scenarios/report-generation.yaml", - "excel-scenarios-multiple-property-set": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/90-scenarios/multiple-property-set.yaml", - "excel-scenarios-working-with-dates": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/90-scenarios/working-with-dates.yaml", - "excel-scenarios-currency-converter": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/90-scenarios/currency-converter.yaml", - "excel-just-for-fun-patterns": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/99-just-for-fun/patterns.yaml", - "excel-just-for-fun-gradient": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/99-just-for-fun/gradient.yaml", - "excel-just-for-fun-path-finder-game": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/99-just-for-fun/path-finder-game.yaml", - "excel-just-for-fun-tetrominos": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/99-just-for-fun/tetrominos.yaml", - "excel-just-for-fun-color-wheel": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/excel/99-just-for-fun/color-wheel.yaml" + "excel-basics-basic-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-api-call.yaml", + "excel-basics-basic-api-call-es5": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-api-call-es5.yaml", + "excel-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/01-basics/basic-common-api-call.yaml", + "excel-chart-axis": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-axis.yaml", + "excel-chart-axis-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-axis-formatting.yaml", + "excel-chart-data-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-table.yaml", + "excel-chart-bubble-chart": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-bubble-chart.yaml", + "excel-chart-create-several-charts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-create-several-charts.yaml", + "excel-chart-create-doughnut-chart": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/create-doughnut-chart.yaml", + "excel-chart-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-formatting.yaml", + "excel-chart-legend": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-legend.yaml", + "excel-chart-point": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-point.yaml", + "excel-chart-series": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series.yaml", + "excel-chart-series-markers": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series-markers.yaml", + "excel-chart-series-plotorder": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-series-plotorder.yaml", + "excel-chart-title-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-title-format.yaml", + "excel-chart-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-source.yaml", + "excel-chart-trendlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-trendlines.yaml", + "excel-chart-data-labels": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-labels.yaml", + "excel-chart-leader-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-leader-lines.yaml", + "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-basics.yaml", + "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-mentions.yaml", + "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-replies.yaml", + "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-resolution.yaml", + "excel-note-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/excel-note-basics.yaml", + "excel-range-conditional-formatting-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml", + "excel-range-conditional-formatting-advanced": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml", + "excel-custom-functions-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/basic-function.yaml", + "excel-custom-functions-volatile": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/volatile-function.yaml", + "excel-custom-functions-streaming": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/streaming-function.yaml", + "excel-custom-functions-web-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/web-call-function.yaml", + "excel-custom-functions-errors": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/custom-functions-errors.yaml", + "excel-data-types-custom-functions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/data-types-custom-functions.yaml", + "excel-custom-functions-custom-enum": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/custom-enum.yaml", + "excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml", + "excel-custom-xml-parts-test-xml-for-unique-namespace": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml", + "excel-chart-chart-title-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/private-samples/excel/20-chart/chart-title-ts.yaml", + "excel-data-types-doubles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-formatted-number.yaml", + "excel-data-types-web-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-web-image.yaml", + "excel-data-types-entity-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-values.yaml", + "excel-data-types-error-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-error-values.yaml", + "excel-data-types-icons": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-icons.yaml", + "excel-data-types-entity-attribution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-attribution.yaml", + "excel-data-types-references": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-references.yaml", + "excel-data-types-basic-types": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-basic-types.yaml", + "excel-data-validation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/22-data-validation/data-validation.yaml", + "excel-document-get-file-in-slices-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/get-file-in-slices-async.yaml", + "excel-document-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/properties.yaml", + "excel-document-custom-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/26-document/custom-properties.yaml", + "excel-events-chartcollection-added-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-chartcollection-added-activated.yaml", + "excel-events-chart-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-chart-activated.yaml", + "excel-event-column-and-row-sort": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/event-column-and-row-sort.yaml", + "excel-events-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-comment-event-handler.yaml", + "excel-events-data-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/data-changed.yaml", + "excel-data-change-event-details": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/data-change-event-details.yaml", + "excel-events-disable-events": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-disable-events.yaml", + "excel-events-formula-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-formula-changed.yaml", + "excel-selection-changed-events": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/selection-changed-events.yaml", + "excel-events-tablecollection-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-tablecollection-changed.yaml", + "excel-event-worksheet-single-click": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/event-worksheet-single-click.yaml", + "excel-events-table-changed": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-table-changed.yaml", + "excel-events-workbook-activated": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-workbook-activated.yaml", + "excel-events-workbook-and-worksheet-collection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml", + "excel-events-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-worksheet.yaml", + "excel-events-worksheet-protection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/30-events/events-worksheet-protection.yaml", + "excel-named-item-create-and-remove-named-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/34-named-item/create-and-remove-named-item.yaml", + "excel-update-named-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/34-named-item/update-named-item.yaml", + "excel-pivottable-calculations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-calculations.yaml", + "excel-pivottable-create-and-modify": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-create-and-modify.yaml", + "excel-pivottable-filters-and-summaries": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml", + "excel-pivottables-get-pivottables": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-get-pivottables.yaml", + "excel-pivottables-pivotfilters": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-pivotfilters.yaml", + "excel-pivottable-pivotlayout": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-pivotlayout.yaml", + "excel-pivottable-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-source-data.yaml", + "excel-pivottable-refresh": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-refresh.yaml", + "excel-pivottable-slicer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/38-pivottable/pivottable-slicer.yaml", + "excel-range-auto-fill": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-auto-fill.yaml", + "excel-range-copyfrom": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-copyfrom.yaml", + "excel-range-areas": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-areas.yaml", + "excel-range-find": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-find.yaml", + "excel-range-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/formatting.yaml", + "excel-range-cell-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/cell-properties.yaml", + "excel-range-hyperlink": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-hyperlink.yaml", + "excel-range-insert-delete-and-clear-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/insert-delete-clear-range.yaml", + "excel-outline": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/outline.yaml", + "excel-range-range-relationships": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-relationships.yaml", + "excel-range-remove-duplicates": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-remove-duplicates.yaml", + "excel-range-selected-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/selected-range.yaml", + "excel-precedents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/precedents.yaml", + "excel-range-style": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/style.yaml", + "excel-range-text-orientation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-text-orientation.yaml", + "excel-range-dynamic-arrays": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/dynamic-arrays.yaml", + "excel-range-used-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/used-range.yaml", + "excel-range-values-and-formulas": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/set-get-values.yaml", + "excel-merged-ranges": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-merged-ranges.yaml", + "excel-range-get-range-edge": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-get-range-edge.yaml", + "excel-direct-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-direct-dependents.yaml", + "excel-range-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-dependents.yaml", + "excel-cell-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-cell-control.yaml", + "excel-shape-create-and-delete": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-create-and-delete.yaml", + "excel-shape-images": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-images.yaml", + "excel-shape-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-lines.yaml", + "excel-shape-move-and-order": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-move-and-order.yaml", + "excel-shape-groups": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-groups.yaml", + "excel-shape-textboxes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-textboxes.yaml", + "excel-shape-get-active": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-get-active.yaml", + "excel-table-add-rows-and-columns-to-a-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/add-rows-and-columns-to-a-table.yaml", + "excel-table-convert-range-to-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/convert-range-to-table.yaml", + "excel-table-create-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/create-table.yaml", + "excel-table-filter-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/filter-data.yaml", + "excel-table-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/formatting.yaml", + "excel-table-get-data-from-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/get-data-from-table.yaml", + "excel-table-get-visible-range-of-a-filtered-table": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/get-visible-range-of-a-filtered-table.yaml", + "excel-table-import-json-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/import-json-data.yaml", + "excel-table-sort-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/sort-data.yaml", + "excel-table-resize": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/46-table/resize-table.yaml", + "excel-workbook-get-active-cell": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-get-active-cell.yaml", + "excel-settings-create-get-change-delete-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/create-get-change-delete-settings.yaml", + "excel-workbook-calculation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-calculation.yaml", + "excel-workbook-create-workbook": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/create-workbook.yaml", + "excel-culture-info": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/culture-info.yaml", + "excel-culture-info-date-time": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/culture-info-date-time.yaml", + "excel-workbook-data-protection": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/data-protection.yaml", + "excel-workbook-save-and-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-save-and-close.yaml", + "excel-workbook-insert-external-worksheets": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-insert-external-worksheets.yaml", + "excel-workbook-built-in-function": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/50-workbook/workbook-built-in-functions.yaml", + "excel-worksheet-active-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/active-worksheet.yaml", + "excel-worksheet-add-delete-rename-move-worksheet": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/add-delete-rename-move-worksheet.yaml", + "excel-worksheet-auto-filter": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-auto-filter.yaml", + "excel-worksheet-copy": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-copy.yaml", + "excel-worksheet-find-all": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-find-all.yaml", + "excel-worksheet-freeze-panes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-freeze-panes.yaml", + "excel-worksheet-worksheet-range-cell": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-range-cell.yaml", + "excel-worksheet-gridlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/gridlines.yaml", + "excel-worksheet-list-worksheets": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/list-worksheets.yaml", + "excel-worksheet-page-layout": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-page-layout.yaml", + "excel-worksheet-reference-worksheets-by-relative-position": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/reference-worksheets-by-relative-position.yaml", + "excel-worksheet-tab-color": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/tab-color.yaml", + "excel-worksheet-visibility": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/54-worksheet/worksheet-visibility.yaml", + "excel-performance-optimization": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/performance-optimization.yaml", + "excel-scenarios-report-generation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/report-generation.yaml", + "excel-scenarios-multiple-property-set": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/multiple-property-set.yaml", + "excel-scenarios-working-with-dates": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/working-with-dates.yaml", + "excel-scenarios-currency-converter": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/90-scenarios/currency-converter.yaml", + "excel-just-for-fun-patterns": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/patterns.yaml", + "excel-just-for-fun-gradient": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/gradient.yaml", + "excel-just-for-fun-path-finder-game": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/path-finder-game.yaml", + "excel-just-for-fun-tetrominos": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/tetrominos.yaml", + "excel-just-for-fun-color-wheel": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/99-just-for-fun/color-wheel.yaml" } \ No newline at end of file diff --git a/view/outlook.json b/view/outlook.json index 4819456ef..6e7f14ee6 100644 --- a/view/outlook.json +++ b/view/outlook.json @@ -1,67 +1,90 @@ { - "outlook-roaming-settings-roaming-settings": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/10-roaming-settings/roaming-settings.yaml", - "outlook-item-custom-properties-load-set-get-save": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/15-item-custom-properties/load-set-get-save.yaml", - "outlook-item-body-get-selected-data": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/20-item-body/get-selected-data.yaml", - "outlook-item-body-set-selected-data": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/20-item-body/set-selected-data.yaml", - "outlook-item-save-and-close-close": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/25-item-save-and-close/close.yaml", - "outlook-item-save-and-close-save": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/25-item-save-and-close/save.yaml", - "outlook-recipients-and-attendees-get-from-message-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml", - "outlook-recipients-and-attendees-get-from-message-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml", - "outlook-recipients-and-attendees-get-to-message-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml", - "outlook-recipients-and-attendees-get-set-to-message-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml", - "outlook-recipients-and-attendees-get-cc-message-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml", - "outlook-recipients-and-attendees-get-set-cc-message-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml", - "outlook-recipients-and-attendees-get-set-bcc-message-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml", - "outlook-recipients-and-attendees-get-sender-message-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml", - "outlook-recipients-and-attendees-get-required-attendees-appointment-attendee": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml", - "outlook-recipients-and-attendees-get-set-required-attendees-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml", - "outlook-recipients-and-attendees-get-optional-attendees-appointment-attendee": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml", - "outlook-recipients-and-attendees-get-set-optional-attendees-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml", - "outlook-recipients-and-attendees-get-organizer-appointment-attendee": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml", - "outlook-recipients-and-attendees-get-organizer-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml", - "outlook-notifications-add-getall-remove": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/35-notifications/add-getall-remove.yaml", - "outlook-attachments-attachments-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/40-attachments/attachments-compose.yaml", - "outlook-attachments-get-attachment-content": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/40-attachments/get-attachment-content.yaml", - "outlook-attachments-get-attachments-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/40-attachments/get-attachments-read.yaml", - "outlook-categories-work-with-categories": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/45-categories/work-with-categories.yaml", - "outlook-categories-work-with-master-categories": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/45-categories/work-with-master-categories.yaml", - "outlook-recurrence-get-series-id": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/50-recurrence/get-series-id.yaml", - "outlook-recurrence-get-recurrence-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/50-recurrence/get-recurrence-read.yaml", - "outlook-recurrence-get-set-recurrence-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml", - "outlook-display-items-display-existing-appointment": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-existing-appointment.yaml", - "outlook-display-items-display-existing-message": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-existing-message.yaml", - "outlook-display-items-display-new-appointment": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-new-appointment.yaml", - "outlook-display-items-display-new-message": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-new-message.yaml", - "outlook-display-items-display-reply-forms": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-reply-forms.yaml", - "outlook-display-items-display-reply-with-attachments": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/55-display-items/display-reply-with-attachments.yaml", - "outlook-delegates-and-shared-folders-get-shared-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml", - "outlook-entities-and-regex-matches-basic-entities": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/75-entities-and-regex-matches/basic-entities.yaml", - "outlook-entities-and-regex-matches-contextual": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/75-entities-and-regex-matches/contextual.yaml", - "outlook-entities-and-regex-matches-selected": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/75-entities-and-regex-matches/selected.yaml", - "outlook-tokens-and-service-calls-ids-and-urls": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/ids-and-urls.yaml", - "outlook-tokens-and-service-calls-user-identity-token": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/user-identity-token.yaml", - "outlook-tokens-and-service-calls-user-callback-token": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/user-callback-token.yaml", - "outlook-tokens-and-service-calls-basic-rest-cors": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/basic-rest-cors.yaml", - "outlook-tokens-and-service-calls-make-ews-request-async": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/make-ews-request-async.yaml", - "outlook-tokens-and-service-calls-send-message-using-make-ews-request-async": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/send-message-using-make-ews-request-async.yaml", - "outlook-tokens-and-service-calls-item-id-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/85-tokens-and-service-calls/item-id-compose.yaml", - "outlook-other-item-apis-get-subject-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-subject-read.yaml", - "outlook-other-item-apis-get-set-subject-compose": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml", - "outlook-other-item-apis-get-internet-message-id-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml", - "outlook-other-item-apis-get-item-class-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-item-class-read.yaml", - "outlook-other-item-apis-get-item-type": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-item-type.yaml", - "outlook-other-item-apis-get-start-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-start-read.yaml", - "outlook-other-item-apis-get-set-start-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml", - "outlook-other-item-apis-get-end-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-end-read.yaml", - "outlook-other-item-apis-get-set-end-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml", - "outlook-other-item-apis-get-location-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-location-read.yaml", - "outlook-other-item-apis-get-set-location-appointment-organizer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml", - "outlook-other-item-apis-get-add-remove-enhancedlocation-appointment": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml", - "outlook-other-item-apis-get-normalized-subject-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml", - "outlook-other-item-apis-get-conversation-id-message": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml", - "outlook-other-item-apis-get-date-time-created-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml", - "outlook-other-item-apis-get-date-time-modified-read": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml", - "outlook-calendar-properties-apis": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/99-preview-apis/calendar-properties-apis.yaml", - "outlook-session-data-apis": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/99-preview-apis/session-data-apis.yaml", - "outlook-work-with-client-signatures": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/outlook/99-preview-apis/work-with-client-signatures.yaml" + "outlook-roaming-settings-roaming-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/10-roaming-settings/roaming-settings.yaml", + "outlook-item-custom-properties-load-set-get-save": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/15-item-custom-properties/load-set-get-save.yaml", + "outlook-item-body-get-selected-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/get-selected-data.yaml", + "outlook-item-body-replace-selected-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/replace-selected-text.yaml", + "outlook-item-body-add-inline-base64-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/add-inline-base64-image.yaml", + "outlook-item-body-get-body-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/get-body-format.yaml", + "outlook-item-body-append-text-on-send": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/append-text-on-send.yaml", + "outlook-item-body-prepend-text-to-item-body": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/prepend-text-to-item-body.yaml", + "outlook-item-body-prepend-text-on-send": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/20-item-body/prepend-text-on-send.yaml", + "outlook-item-save-and-close-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/close.yaml", + "outlook-close-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/close-async.yaml", + "outlook-item-save-and-close-save": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/25-item-save-and-close/save.yaml", + "outlook-recipients-and-attendees-get-from-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml", + "outlook-recipients-and-attendees-get-from-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-from-message-compose.yaml", + "outlook-recipients-and-attendees-get-to-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml", + "outlook-recipients-and-attendees-get-set-to-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-to-message-compose.yaml", + "outlook-recipients-and-attendees-get-cc-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml", + "outlook-recipients-and-attendees-get-set-cc-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-cc-message-compose.yaml", + "outlook-recipients-and-attendees-get-set-bcc-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-bcc-message-compose.yaml", + "outlook-recipients-and-attendees-get-sender-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml", + "outlook-recipients-and-attendees-get-required-attendees-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-required-attendees-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-set-required-attendees-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-required-attendees-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-optional-attendees-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-optional-attendees-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-set-optional-attendees-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-set-optional-attendees-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-organizer-appointment-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-attendee.yaml", + "outlook-recipients-and-attendees-get-organizer-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-organizer-appointment-organizer.yaml", + "outlook-recipients-and-attendees-get-all-attendees": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/30-recipients-and-attendees/get-all-attendees.yaml", + "outlook-notifications-add-getall-remove": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/35-notifications/add-getall-remove.yaml", + "outlook-attachments-attachments-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/attachments-compose.yaml", + "outlook-attachments-get-attachment-content": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/get-attachment-content.yaml", + "outlook-attachments-get-attachments-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/40-attachments/get-attachments-read.yaml", + "outlook-categories-work-with-categories": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/45-categories/work-with-categories.yaml", + "outlook-categories-work-with-master-categories": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/45-categories/work-with-master-categories.yaml", + "outlook-recurrence-get-series-id": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-series-id.yaml", + "outlook-recurrence-get-recurrence-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-recurrence-read.yaml", + "outlook-recurrence-get-set-recurrence-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/50-recurrence/get-set-recurrence-appointment-organizer.yaml", + "outlook-display-items-display-new-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-new-message.yaml", + "outlook-display-items-display-new-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-new-appointment.yaml", + "outlook-display-items-display-existing-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-existing-message.yaml", + "outlook-display-items-display-existing-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-existing-appointment.yaml", + "outlook-display-items-display-reply-forms": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-reply-forms.yaml", + "outlook-display-items-display-reply-with-attachments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/55-display-items/display-reply-with-attachments.yaml", + "outlook-sensitivity-labels-sensitivity-labels-catalog": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/60-sensitivity-label/sensitivity-labels-catalog.yaml", + "outlook-sensitivity-labels-sensitivity-label": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/60-sensitivity-label/sensitivity-label.yaml", + "outlook-delegates-and-shared-folders-get-shared-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/65-delegates-and-shared-folders/get-shared-properties.yaml", + "outlook-mime-headers-get-internet-headers-message-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/70-mime-headers/get-internet-headers-message-read.yaml", + "outlook-mime-headers-manage-custom-internet-headers-message-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/70-mime-headers/manage-custom-internet-headers-message-compose.yaml", + "outlook-regex-matches-contextual": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/75-regex-matches/contextual.yaml", + "outlook-events-drag-drop-item": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/80-events/drag-drop-item.yaml", + "outlook-tokens-and-service-calls-ids-and-urls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/ids-and-urls.yaml", + "outlook-tokens-and-service-calls-user-identity-token": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/user-identity-token.yaml", + "outlook-tokens-and-service-calls-user-callback-token": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/user-callback-token.yaml", + "outlook-tokens-and-service-calls-make-ews-request-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/make-ews-request-async.yaml", + "outlook-tokens-and-service-calls-send-message-using-make-ews-request-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/send-message-using-make-ews-request-async.yaml", + "outlook-tokens-and-service-calls-get-icaluid-as-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-organizer.yaml", + "outlook-tokens-and-service-calls-get-icaluid-as-attendee": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/85-tokens-for-exchange-on-premises/get-icaluid-as-attendee.yaml", + "outlook-other-item-apis-get-subject-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-subject-read.yaml", + "outlook-other-item-apis-get-set-subject-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-subject-compose.yaml", + "outlook-item-body-set-selected-data": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/set-selected-data.yaml", + "outlook-other-item-apis-get-internet-message-id-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml", + "outlook-other-item-apis-get-item-class-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-class-read.yaml", + "outlook-other-item-apis-get-item-type": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-type.yaml", + "outlook-other-item-apis-get-start-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-start-read.yaml", + "outlook-other-item-apis-get-set-start-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml", + "outlook-other-item-apis-get-end-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-end-read.yaml", + "outlook-other-item-apis-get-set-end-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml", + "outlook-other-item-apis-get-location-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-location-read.yaml", + "outlook-other-item-apis-get-set-location-appointment-organizer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-location-appointment-organizer.yaml", + "outlook-other-item-apis-get-add-remove-enhancedlocation-appointment": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml", + "outlook-other-item-apis-get-normalized-subject-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml", + "outlook-other-item-apis-get-conversation-id-message": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml", + "outlook-other-item-apis-get-date-time-created-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml", + "outlook-other-item-apis-get-date-time-modified-read": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml", + "outlook-other-item-apis-get-diagnostic-information": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-diagnostic-information.yaml", + "outlook-other-item-apis-work-with-client-signatures": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/work-with-client-signatures.yaml", + "outlook-other-item-apis-session-data-apis": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/session-data-apis.yaml", + "outlook-delay-message-delivery": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/delay-message-delivery.yaml", + "outlook-other-item-apis-get-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-message-properties.yaml", + "outlook-other-item-apis-get-set-sensitivity-level": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-set-sensitivity-level.yaml", + "outlook-get-eml-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-eml-format.yaml", + "outlook-get-in-reply-to": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-in-reply-to.yaml", + "outlook-get-conversation-index": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-conversation-index.yaml", + "outlook-get-item-class-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-item-class-async.yaml", + "outlook-other-item-apis-item-id-compose": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/item-id-compose.yaml", + "outlook-send-async": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/send-async.yaml", + "outlook-other-item-apis-get-loaded-message-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/90-other-item-apis/get-loaded-message-properties.yaml", + "outlook-get-set-isalldayevent": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/get-set-isalldayevent.yaml", + "outlook-set-displayed-body-subject": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml" } \ No newline at end of file diff --git a/view/powerpoint.json b/view/powerpoint.json index 5f0e6cb1f..76e7bddc5 100644 --- a/view/powerpoint.json +++ b/view/powerpoint.json @@ -1,8 +1,23 @@ { - "powerpoint-basics-basic-common-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/basics/basic-common-api-call.yaml", - "powerpoint-create-presentation": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/basics/create-presentation.yaml", - "powerpoint-basics-get-slide-metadata": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/basics/get-slide-metadata.yaml", - "powerpoint-basics-insert-image": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/basics/insert-image.yaml", - "powerpoint-basics-insert-svg": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/basics/insert-svg.yaml", - "powerpoint-scenarios-searches-wikipedia-api": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/powerpoint/scenarios/searches-wikipedia-api.yaml" + "powerpoint-basics-basic-api-call-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-api-call-ts.yaml", + "powerpoint-basics-basic-api-call-js": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-api-call-js.yaml", + "powerpoint-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/basics/basic-common-api-call.yaml", + "powerpoint-create-presentation": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/document/create-presentation.yaml", + "powerpoint-hyperlinks-manage-hyperlinks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml", + "powerpoint-basics-insert-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/images/insert-image.yaml", + "powerpoint-basics-insert-svg": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/images/insert-svg.yaml", + "powerpoint-scenarios-searches-wikipedia-api": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/scenarios/searches-wikipedia-api.yaml", + "powerpoint-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/shapes.yaml", + "powerpoint-shapes-get-set-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/get-set-shapes.yaml", + "powerpoint-shapes-get-shapes-by-type": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/get-shapes-by-type.yaml", + "powerpoint-shapes-add-modify-tables": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/add-modify-tables.yaml", + "powerpoint-shapes-binding-to-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/binding-to-shapes.yaml", + "powerpoint-shapes-group-ungroup-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/shapes/group-ungroup-shapes.yaml", + "powerpoint-add-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/add-slides.yaml", + "powerpoint-insert-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/insert-slides.yaml", + "powerpoint-basics-get-slide-metadata": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/get-slide-metadata.yaml", + "powerpoint-slide-management-get-set-slides": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/get-set-slides.yaml", + "powerpoint-slide-management-export-import-slide": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/slide-management/export-import-slide.yaml", + "powerpoint-tags": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/tags/tags.yaml", + "powerpoint-text-get-set-textrange": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/powerpoint/text/get-set-textrange.yaml" } \ No newline at end of file diff --git a/view/project.json b/view/project.json index ddf6c8408..34242cfae 100644 --- a/view/project.json +++ b/view/project.json @@ -1,3 +1,3 @@ { - "project-basics-basic-common-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/project/basics/basic-common-api-call.yaml" + "project-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/project/basics/basic-common-api-call.yaml" } \ No newline at end of file diff --git a/view/word.json b/view/word.json index a4501639c..3e0da2a29 100644 --- a/view/word.json +++ b/view/word.json @@ -1,23 +1,67 @@ { - "word-basics-basic-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/01-basics/basic-api-call.yaml", - "word-basics-api-call-es5": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/01-basics/basic-api-call-es5.yaml", - "word-basics-basic-common-api-call": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/01-basics/basic-common-api-call.yaml", - "word-content-controls-insert-and-change-content-controls": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/10-content-controls/insert-and-change-content-controls.yaml", - "word-images-insert-and-get-pictures": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/15-images/insert-and-get-pictures.yaml", - "word-lists-insert-list": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/20-lists/insert-list.yaml", - "word-paragraph-get-paragraph-on-insertion-point": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml", - "word-paragraph-insert-line-and-page-breaks": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/insert-line-and-page-breaks.yaml", - "word-paragraph-insert-in-different-locations": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/insert-in-different-locations.yaml", - "word-paragraph-insert-formatted-text": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/insert-formatted-text.yaml", - "word-paragraph-insert-header-and-footer": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/insert-header-and-footer.yaml", - "word-paragraph-paragraph-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/paragraph-properties.yaml", - "word-paragraph-search": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/search.yaml", - "word-paragraph-get-word-count": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/25-paragraph/get-word-count.yaml", - "word-properties-get-built-in-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/30-properties/get-built-in-properties.yaml", - "word-properties-read-write-custom-document-properties": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/30-properties/read-write-custom-document-properties.yaml", - "word-ranges-scroll-to-range": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/35-ranges/scroll-to-range.yaml", - "word-ranges-split-words-of-first-paragraph": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/35-ranges/split-words-of-first-paragraph.yaml", - "word-tables-table-cell-access": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/40-tables/table-cell-access.yaml", - "word-scenarios-doc-assembly": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/90-scenarios/doc-assembly.yaml", - "word-scenarios-multiple-property-set": "https://raw.githubusercontent.com/%3CACCOUNT%3E/%3CREPO%3E/%3CBRANCH%3E/samples/word/90-scenarios/multiple-property-set.yaml" + "word-basics-basic-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-api-call.yaml", + "word-basics-api-call-es5": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-api-call-es5.yaml", + "word-basics-basic-common-api-call": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/01-basics/basic-common-api-call.yaml", + "word-content-controls-insert-and-change-content-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-content-controls.yaml", + "word-content-controls-content-control-onadded-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onadded-event.yaml", + "word-content-controls-content-control-onentered-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onentered-event.yaml", + "word-content-controls-content-control-onselectionchanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml", + "word-content-controls-content-control-ondatachanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-ondatachanged-event.yaml", + "word-content-controls-content-control-onexited-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-onexited-event.yaml", + "word-content-controls-content-control-ondeleted-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/content-control-ondeleted-event.yaml", + "word-content-controls-insert-and-change-checkbox-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml", + "word-content-controls-insert-and-change-combo-box-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-combo-box-content-control.yaml", + "word-content-controls-insert-and-change-dropdown-list-content-control": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/insert-and-change-dropdown-list-content-control.yaml", + "word-content-controls-get-change-tracking-states": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/10-content-controls/get-change-tracking-states.yaml", + "word-images-insert-and-get-pictures": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/15-images/insert-and-get-pictures.yaml", + "word-lists-insert-list": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/insert-list.yaml", + "word-lists-manage-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/manage-list-styles.yaml", + "word-lists-organize-list": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/20-lists/organize-list.yaml", + "word-paragraph-get-paragraph-on-insertion-point": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml", + "word-paragraph-insert-line-and-page-breaks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-line-and-page-breaks.yaml", + "word-paragraph-insert-in-different-locations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-in-different-locations.yaml", + "word-paragraph-insert-formatted-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-formatted-text.yaml", + "word-paragraph-insert-header-and-footer": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/insert-header-and-footer.yaml", + "word-paragraph-paragraph-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/paragraph-properties.yaml", + "word-paragraph-search": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/search.yaml", + "word-paragraph-get-word-count": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-word-count.yaml", + "word-paragraph-get-text": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/get-text.yaml", + "word-paragraph-onadded-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/onadded-event.yaml", + "word-paragraph-onchanged-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/onchanged-event.yaml", + "word-paragraph-ondeleted-event": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/25-paragraph/ondeleted-event.yaml", + "word-properties-get-built-in-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/30-properties/get-built-in-properties.yaml", + "word-properties-read-write-custom-document-properties": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/30-properties/read-write-custom-document-properties.yaml", + "word-ranges-scroll-to-range": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/scroll-to-range.yaml", + "word-ranges-split-words-of-first-paragraph": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/split-words-of-first-paragraph.yaml", + "word-ranges-compare-location": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/compare-location.yaml", + "word-ranges-get-pages": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/35-ranges/get-pages.yaml", + "word-tables-table-cell-access": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/table-cell-access.yaml", + "word-tables-manage-formatting": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/manage-formatting.yaml", + "word-tables-manage-custom-style": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/40-tables/manage-custom-style.yaml", + "word-shapes-manage-shapes-text-boxes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-shapes-text-boxes.yaml", + "word-shapes-manage-geometric-shapes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-geometric-shapes.yaml", + "word-shapes-group-ungroup": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/group-ungroup.yaml", + "word-shapes-manage-canvases": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/45-shapes/manage-canvases.yaml", + "word-document-manage-body": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-body.yaml", + "word-document-insert-section-breaks": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/insert-section-breaks.yaml", + "word-document-insert-external-document": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/insert-external-document.yaml", + "word-document-manage-change-tracking": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-change-tracking.yaml", + "word-document-manage-tracked-changes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-tracked-changes.yaml", + "word-document-manage-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-comments.yaml", + "word-document-manage-footnotes": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-footnotes.yaml", + "word-document-manage-fields": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-fields.yaml", + "word-document-manage-settings": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-settings.yaml", + "word-document-manage-custom-xml-part-ns": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-custom-xml-part-ns.yaml", + "word-document-manage-custom-xml-part": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-custom-xml-part.yaml", + "word-document-manage-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-styles.yaml", + "word-document-get-external-styles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/get-external-styles.yaml", + "word-document-save-close": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/save-close.yaml", + "word-document-manage-annotations": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/manage-annotations.yaml", + "word-document-compare-documents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/50-document/compare-documents.yaml", + "word-scenarios-doc-assembly": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/doc-assembly.yaml", + "word-scenarios-multiple-property-set": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/multiple-property-set.yaml", + "word-scenarios-correlated-objects-pattern": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/90-scenarios/correlated-objects-pattern.yaml", + "word-close-document-window": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/close-document-window.yaml", + "word-insert-and-change-content-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/insert-and-change-content-controls.yaml", + "word-manage-comments": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/word/99-preview-apis/manage-comments.yaml" } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index c8d9f9403..000000000 --- a/yarn.lock +++ /dev/null @@ -1,3572 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== - -"@babel/highlight@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" - integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@iarna/cli@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@iarna/cli/-/cli-1.2.0.tgz#0f7af5e851afe895104583c4ca07377a8094d641" - integrity sha512-ukITQAqVs2n9HGmn3car/Ir7d3ta650iXhrG7pjr3EWdFmJuuOVWgYsu7ftsSe5VifEFFhjxVuX9+8F7L8hwcA== - dependencies: - signal-exit "^3.0.2" - update-notifier "^2.2.0" - yargs "^8.0.2" - -"@types/chalk@0.4.31": - version "0.4.31" - resolved "https://registry.yarnpkg.com/@types/chalk/-/chalk-0.4.31.tgz#a31d74241a6b1edbb973cf36d97a2896834a51f9" - integrity sha1-ox10JBprHtu5c8822XooloNKUfk= - -"@types/fs-extra@3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-3.0.1.tgz#78293a68aad3d866751e8fcfd64d7dc9d0117476" - integrity sha1-eCk6aKrT2GZ1Ho/P1k19ydARdHY= - dependencies: - "@types/node" "*" - -"@types/glob@*": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183" - integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - -"@types/js-yaml@^3.12.0": - version "3.12.5" - resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.5.tgz#136d5e6a57a931e1cce6f9d8126aa98a9c92a6bb" - integrity sha512-JCcp6J0GV66Y4ZMDAQCXot4xprYB+Zfd3meK9+INSJeVZwJmHAW30BBEEkPzXswMXuiyReUGOP3GxrADc9wPww== - -"@types/lodash@^4.14.122": - version "4.14.161" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.161.tgz#a21ca0777dabc6e4f44f3d07f37b765f54188b18" - integrity sha512-EP6O3Jkr7bXvZZSZYlsgt5DIjiGr0dXP1/jVEwVLTFgg0d+3lWVQkRavYVQszV7dYUwvg0B8R0MBDpcmXg7XIA== - -"@types/minimatch@*": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" - integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== - -"@types/node@*": - version "14.11.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256" - integrity sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA== - -"@types/node@^11.10.5": - version "11.15.27" - resolved "https://registry.yarnpkg.com/@types/node/-/node-11.15.27.tgz#2473edcb8a9a51e25332dc24692cbce19dc89dc2" - integrity sha512-LbLwyGC/ukDV0EbHFP1OCfs2V5h3vUS8ZXJJjS2L5YYg8rNkJe6Tl/yv+L+g94sbHllyXUCfUCn5+sZLBegvyw== - -"@types/shelljs@^0.8.3": - version "0.8.8" - resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.8.tgz#e439c69929b88a2c8123c1a55e09eb708315addf" - integrity sha512-lD3LWdg6j8r0VRBFahJVaxoW0SIcswxKaFUrmKl33RJVeeoNYQAz4uqCJ5Z6v4oIBOsC5GozX+I5SorIKiTcQA== - dependencies: - "@types/glob" "*" - "@types/node" "*" - -JSONStream@^1.3.4, JSONStream@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" - integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -abbrev@1, abbrev@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - -agent-base@4, agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -agent-base@~4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" - integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg== - dependencies: - es6-promisify "^5.0.0" - -agentkeepalive@^3.4.1: - version "3.5.2" - resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-3.5.2.tgz#a113924dd3fa24a0bc3b78108c450c2abee00f67" - integrity sha512-e0L/HNe6qkQ7H19kTlRRqUibEAwDK5AFk6y3PtMsuut2VAH6+Q4xZml1tNDJD7kSAyqmbG/K08K5WEJYtUrSlQ== - dependencies: - humanize-ms "^1.2.1" - -ajv@^6.12.3: - version "6.12.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" - integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-align@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" - integrity sha1-w2rsy6VjuJzrVW82kPCx2eNUf38= - dependencies: - string-width "^2.0.0" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= - -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= - -ansi-styles@^3.2.0, ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansicolors@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" - integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk= - -ansistyles@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/ansistyles/-/ansistyles-0.1.3.tgz#5de60415bda071bb37127854c864f41b23254539" - integrity sha1-XeYEFb2gcbs3EnhUyGT0GyMlRTk= - -aproba@^1.0.3, aproba@^1.1.1, aproba@^1.1.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" - integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== - -"aproba@^1.1.2 || 2", aproba@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc" - integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== - -archy@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" - integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= - -are-we-there-yet@~1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" - integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== - dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -asap@^2.0.0: - version "2.0.6" - resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" - integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= - -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" - integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.10.1" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428" - integrity sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA== - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" - -big-integer@^1.6.17: - version "1.6.48" - resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e" - integrity sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w== - -bin-links@^1.1.2, bin-links@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/bin-links/-/bin-links-1.1.8.tgz#bd39aadab5dc4bdac222a07df5baf1af745b2228" - integrity sha512-KgmVfx+QqggqP9dA3iIc5pA4T1qEEEL+hOhOhNPaUm77OTrJoOXE/C05SJLNJe6m/2wUK7F1tDSou7n5TfCDzQ== - dependencies: - bluebird "^3.5.3" - cmd-shim "^3.0.0" - gentle-fs "^2.3.0" - graceful-fs "^4.1.15" - npm-normalize-package-bin "^1.0.0" - write-file-atomic "^2.3.0" - -binary@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" - integrity sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk= - dependencies: - buffers "~0.1.1" - chainsaw "~0.1.0" - -bluebird@^3.5.1, bluebird@^3.5.3, bluebird@^3.5.5: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - -bluebird@~3.4.1: - version "3.4.7" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" - integrity sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM= - -boxen@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" - integrity sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw== - dependencies: - ansi-align "^2.0.0" - camelcase "^4.0.0" - chalk "^2.0.1" - cli-boxes "^1.0.0" - string-width "^2.0.0" - term-size "^1.2.0" - widest-line "^2.0.0" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -buffer-indexof-polyfill@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz#d2732135c5999c64b277fcf9b1abe3498254729c" - integrity sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A== - -buffer-shims@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - integrity sha1-mXjOMXOIxkmth5MCjDR37wRKi1E= - -buffers@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" - integrity sha1-skV5w77U1tOWru5tmorn9Ugqt7s= - -builtin-modules@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= - -builtins@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" - integrity sha1-y5T662HIaWRR2zZTThQi+U8K7og= - -byline@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1" - integrity sha1-dBxSFkaOrcRXsDQQEYrXfejB3bE= - -byte-size@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/byte-size/-/byte-size-5.0.1.tgz#4b651039a5ecd96767e71a3d7ed380e48bed4191" - integrity sha512-/XuKeqWocKsYa/cBY1YbSJSWWqTi4cFgr9S6OyM7PBaPbr9zvNGwWP33vt0uqGhwDdN+y3yhbXVILEUpnwEWGw== - -cacache@^12.0.0, cacache@^12.0.2, cacache@^12.0.3: - version "12.0.4" - resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" - integrity sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ== - dependencies: - bluebird "^3.5.5" - chownr "^1.1.1" - figgy-pudding "^3.5.1" - glob "^7.1.4" - graceful-fs "^4.1.15" - infer-owner "^1.0.3" - lru-cache "^5.1.1" - mississippi "^3.0.0" - mkdirp "^0.5.1" - move-concurrently "^1.0.1" - promise-inflight "^1.0.1" - rimraf "^2.6.3" - ssri "^6.0.1" - unique-filename "^1.1.1" - y18n "^4.0.0" - -call-limit@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/call-limit/-/call-limit-1.1.1.tgz#ef15f2670db3f1992557e2d965abc459e6e358d4" - integrity sha512-5twvci5b9eRBw2wCfPtN0GmlR2/gadZqyFpPhOK6CvMFoFgA+USnZ6Jpu1lhG9h85pQ3Ouil3PfXWRD4EUaRiQ== - -camelcase@^4.0.0, camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= - -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -capture-stack-trace@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" - integrity sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw== - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= - -chainsaw@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" - integrity sha1-XqtQsor+WAdNDVgpE4iCi15fvJg= - dependencies: - traverse ">=0.3.0 <0.4" - -chalk@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -charm@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/charm/-/charm-1.0.1.tgz#68566a7a553d4fe91797030dd1852d0dd6efa82d" - integrity sha1-aFZqelU9T+kXlwMN0YUtDdbvqC0= - dependencies: - inherits "^2.0.1" - -chownr@^1.1.1, chownr@^1.1.2, chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -ci-info@^1.5.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497" - integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A== - -ci-info@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" - integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== - -cidr-regex@^2.0.10: - version "2.0.10" - resolved "https://registry.yarnpkg.com/cidr-regex/-/cidr-regex-2.0.10.tgz#af13878bd4ad704de77d6dc800799358b3afa70d" - integrity sha512-sB3ogMQXWvreNPbJUZMRApxuRYd+KoIo4RGQ81VatjmMW6WJPo+IJZ2846FGItr9VzKo5w7DXzijPLGtSd0N3Q== - dependencies: - ip-regex "^2.1.0" - -cli-boxes@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" - integrity sha1-T6kXw+WclKAEzWH47lCdplFocUM= - -cli-columns@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/cli-columns/-/cli-columns-3.1.2.tgz#6732d972979efc2ae444a1f08e08fa139c96a18e" - integrity sha1-ZzLZcpee/CrkRKHwjgj6E5yWoY4= - dependencies: - string-width "^2.0.0" - strip-ansi "^3.0.1" - -cli-cursor@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" - integrity sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc= - dependencies: - restore-cursor "^1.0.1" - -cli-spinners@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-0.2.0.tgz#85078737913b880f6ec9ffe7b65e83ec7776284f" - integrity sha1-hQeHN5E7iA9uyf/ntl6D7Hd2KE8= - -cli-table3@^0.5.0, cli-table3@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.5.1.tgz#0252372d94dfc40dbd8df06005f48f31f656f202" - integrity sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw== - dependencies: - object-assign "^4.1.0" - string-width "^2.1.1" - optionalDependencies: - colors "^1.1.2" - -cliui@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" - integrity sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0= - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - wrap-ansi "^2.0.0" - -cliui@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" - integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== - dependencies: - string-width "^3.1.0" - strip-ansi "^5.2.0" - wrap-ansi "^5.1.0" - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= - -cmd-shim@^3.0.0, cmd-shim@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/cmd-shim/-/cmd-shim-3.0.3.tgz#2c35238d3df37d98ecdd7d5f6b8dc6b21cadc7cb" - integrity sha512-DtGg+0xiFhQIntSBRzL2fRQBnmtAVwXIDo4Qq46HPpObYquxMaZS4sb82U9nH91qJrlosC1wa9gwr0QyL/HypA== - dependencies: - graceful-fs "^4.1.2" - mkdirp "~0.5.0" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -colors@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" - integrity sha1-FopHAXVran9RoSzgyXv6KMCE7WM= - -colors@^1.1.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -columnify@~1.5.4: - version "1.5.4" - resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" - integrity sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs= - dependencies: - strip-ansi "^3.0.0" - wcwidth "^1.0.0" - -combined-stream@^1.0.6, combined-stream@~1.0.6: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.12.1: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -concat-stream@^1.5.0: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - -config-chain@^1.1.12: - version "1.1.12" - resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" - integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA== - dependencies: - ini "^1.3.4" - proto-list "~1.2.1" - -configstore@^3.0.0: - version "3.1.5" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.5.tgz#e9af331fadc14dabd544d3e7e76dc446a09a530f" - integrity sha512-nlOhI4+fdzoK5xmJ+NY+1gZK56bwEaWZr8fYuXohZ9Vkc1o3a4T/R3M+yE/w7x/ZVJ1zF8c+oaOvF0dztdUgmA== - dependencies: - dot-prop "^4.2.1" - graceful-fs "^4.1.2" - make-dir "^1.0.0" - unique-string "^1.0.0" - write-file-atomic "^2.0.0" - xdg-basedir "^3.0.0" - -console-control-strings@^1.0.0, console-control-strings@^1.1.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - -copy-concurrently@^1.0.0: - version "1.0.5" - resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0" - integrity sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A== - dependencies: - aproba "^1.1.1" - fs-write-stream-atomic "^1.0.8" - iferr "^0.1.5" - mkdirp "^0.5.1" - rimraf "^2.5.4" - run-queue "^1.0.0" - -core-util-is@1.0.2, core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -create-error-class@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" - integrity sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y= - dependencies: - capture-stack-trace "^1.0.0" - -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -crypto-random-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" - integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= - -cyclist@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" - integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" - -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - -debug@^3.1.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -debuglog@*, debuglog@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" - integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= - -decamelize@^1.1.1, decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= - dependencies: - clone "^1.0.2" - -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - -detect-indent@~5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" - integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50= - -detect-newline@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" - integrity sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I= - -dezalgo@^1.0.0, dezalgo@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456" - integrity sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY= - dependencies: - asap "^2.0.0" - wrappy "1" - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -dot-prop@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" - integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== - dependencies: - is-obj "^1.0.0" - -dotenv@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef" - integrity sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow== - -duplexer2@~0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" - integrity sha1-ixLauHjA1p4+eJEFFmKjL8a93ME= - dependencies: - readable-stream "^2.0.2" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= - -duplexify@^3.4.2, duplexify@^3.6.0: - version "3.7.1" - resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309" - integrity sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g== - dependencies: - end-of-stream "^1.0.0" - inherits "^2.0.1" - readable-stream "^2.0.0" - stream-shift "^1.0.0" - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -editor@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/editor/-/editor-1.0.0.tgz#60c7f87bd62bcc6a894fa8ccd6afb7823a24f742" - integrity sha1-YMf4e9YrzGqJT6jM1q+3gjok90I= - -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== - -encoding@^0.1.11: - version "0.1.13" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" - integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== - dependencies: - iconv-lite "^0.6.2" - -end-of-stream@^1.0.0, end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -env-paths@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.0.tgz#cdca557dc009152917d6166e2febe1f039685e43" - integrity sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA== - -err-code@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960" - integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA= - -errno@~0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" - integrity sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg== - dependencies: - prr "~1.0.1" - -error-ex@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: - version "1.17.6" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" - integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-regex "^1.1.0" - object-inspect "^1.7.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-abstract@^1.18.0-next.0: - version "1.18.0-next.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.0.tgz#b302834927e624d8e5837ed48224291f2c66e6fc" - integrity sha512-elZXTZXKn51hUBdJjSZGYRujuzilgXo8vSPQzjGYXLvSlGiCo8VO8ZGV3kjo9a0WNJJ57hENagwbtlRuHuzkcQ== - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-negative-zero "^2.0.0" - is-regex "^1.1.1" - object-inspect "^1.8.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -excel@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/excel/-/excel-1.0.1.tgz#d6cf6a912cd3517a8b78861770a8e4d9be0919f2" - integrity sha512-Hr9p8R/rqZqMrqLa4OHP405BEFKG9Bg2W8Sb4YqRJJP70/lDJbJHZWY4E1wYI9qyavOjp3kheOSM7EzCYcU1nA== - dependencies: - unzipper "^0.8.11" - xmldom "^0.1.27" - xpath "0.0.27" - -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -exit-hook@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" - integrity sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g= - -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" - integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -figgy-pudding@^3.4.1, figgy-pudding@^3.5.1: - version "3.5.2" - resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" - integrity sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw== - -find-npm-prefix@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/find-npm-prefix/-/find-npm-prefix-1.0.2.tgz#8d8ce2c78b3b4b9e66c8acc6a37c231eb841cfdf" - integrity sha512-KEftzJ+H90x6pcKtdXZEPsQse8/y/UnvzRKrOSQFprnrGaFuJ62fVkP34Iu2IYuMvyauCyoLTNkJZgrrGA2wkA== - -find-up@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= - dependencies: - locate-path "^2.0.0" - -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - -flush-write-stream@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8" - integrity sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w== - dependencies: - inherits "^2.0.3" - readable-stream "^2.3.6" - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -from2@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/from2/-/from2-1.3.0.tgz#88413baaa5f9a597cfde9221d86986cd3c061dfd" - integrity sha1-iEE7qqX5pZfP3pIh2GmGzTwGHf0= - dependencies: - inherits "~2.0.1" - readable-stream "~1.1.10" - -from2@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af" - integrity sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8= - dependencies: - inherits "^2.0.1" - readable-stream "^2.0.0" - -fs-extra@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" - integrity sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE= - dependencies: - graceful-fs "^4.1.2" - jsonfile "^3.0.0" - universalify "^0.1.0" - -fs-minipass@^1.2.5: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - -fs-vacuum@^1.2.10, fs-vacuum@~1.2.10: - version "1.2.10" - resolved "https://registry.yarnpkg.com/fs-vacuum/-/fs-vacuum-1.2.10.tgz#b7629bec07a4031a2548fdf99f5ecf1cc8b31e36" - integrity sha1-t2Kb7AekAxolSP35n17PHMizHjY= - dependencies: - graceful-fs "^4.1.2" - path-is-inside "^1.0.1" - rimraf "^2.5.2" - -fs-write-stream-atomic@^1.0.8, fs-write-stream-atomic@~1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" - integrity sha1-tH31NJPvkR33VzHnCp3tAYnbQMk= - dependencies: - graceful-fs "^4.1.2" - iferr "^0.1.5" - imurmurhash "^0.1.4" - readable-stream "1 || 2" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fstream@~1.0.10: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045" - integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg== - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -gauge@~2.7.3: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" - -genfun@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537" - integrity sha512-KGDOARWVga7+rnB3z9Sd2Letx515owfk0hSxHGuqjANb1M+x2bGZGqHLiozPsYMdM2OubeMni/Hpwmjq6qIUhA== - -gentle-fs@^2.3.0, gentle-fs@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/gentle-fs/-/gentle-fs-2.3.1.tgz#11201bf66c18f930ddca72cf69460bdfa05727b1" - integrity sha512-OlwBBwqCFPcjm33rF2BjW+Pr6/ll2741l+xooiwTCeaX2CA1ZuclavyMBe0/KlR21/XGsgY6hzEQZ15BdNa13Q== - dependencies: - aproba "^1.1.2" - chownr "^1.1.2" - cmd-shim "^3.0.3" - fs-vacuum "^1.2.10" - graceful-fs "^4.1.11" - iferr "^0.1.5" - infer-owner "^1.0.4" - mkdirp "^0.5.1" - path-is-inside "^1.0.2" - read-cmd-shim "^1.0.1" - slide "^1.1.6" - -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== - -get-caller-file@^2.0.1: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-stream@^4.0.0, get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" - -glob@^7.0.0, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -global-dirs@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" - integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= - dependencies: - ini "^1.3.4" - -got@^6.7.1: - version "6.7.1" - resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" - integrity sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA= - dependencies: - create-error-class "^3.0.0" - duplexer3 "^0.1.4" - get-stream "^3.0.0" - is-redirect "^1.0.0" - is-retry-allowed "^1.0.0" - is-stream "^1.0.0" - lowercase-keys "^1.0.0" - safe-buffer "^5.0.1" - timed-out "^4.0.0" - unzip-response "^2.0.1" - url-parse-lax "^1.0.0" - -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.2, graceful-fs@^4.2.4: - version "4.2.4" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" - integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= - dependencies: - ansi-regex "^2.0.0" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-symbols@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" - integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== - -has-unicode@^2.0.0, has-unicode@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hosted-git-info@^2.1.4, hosted-git-info@^2.7.1, hosted-git-info@^2.8.8: - version "2.8.8" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" - integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== - -http-cache-semantics@^3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" - integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== - -http-proxy-agent@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405" - integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg== - dependencies: - agent-base "4" - debug "3.1.0" - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -https-proxy-agent@^2.2.3: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -humanize-ms@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" - integrity sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0= - dependencies: - ms "^2.0.0" - -iconv-lite@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01" - integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ== - dependencies: - safer-buffer ">= 2.1.2 < 3.0.0" - -iferr@^0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" - integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= - -iferr@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/iferr/-/iferr-1.0.2.tgz#e9fde49a9da06dc4a4194c6c9ed6d08305037a6d" - integrity sha512-9AfeLfji44r5TKInjhz3W9DyZI1zR1JAf2hVBMGhddAKPqBsupb89jGfbCTHIGZd6fGZl9WlHdn4AObygyMKwg== - -ignore-walk@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" - integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== - dependencies: - minimatch "^3.0.4" - -import-lazy@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" - integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= - -imurmurhash@*, imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= - -infer-owner@^1.0.3, infer-owner@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467" - integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== - -inflight@^1.0.4, inflight@~1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== - -init-package-json@^1.10.3: - version "1.10.3" - resolved "https://registry.yarnpkg.com/init-package-json/-/init-package-json-1.10.3.tgz#45ffe2f610a8ca134f2bd1db5637b235070f6cbe" - integrity sha512-zKSiXKhQveNteyhcj1CoOP8tqp1QuxPIPBl8Bid99DGLFqA1p87M6lNgfjJHSBoWJJlidGOv5rWjyYKEB3g2Jw== - dependencies: - glob "^7.1.1" - npm-package-arg "^4.0.0 || ^5.0.0 || ^6.0.0" - promzard "^0.3.0" - read "~1.0.1" - read-package-json "1 || 2" - semver "2.x || 3.x || 4 || 5" - validate-npm-package-license "^3.0.1" - validate-npm-package-name "^3.0.0" - -interpret@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" - integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== - -invert-kv@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" - integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= - -ip-regex@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" - integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk= - -ip@1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" - integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-callable@^1.1.4, is-callable@^1.2.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.2.tgz#c7c6715cd22d4ddb48d3e19970223aceabb080d9" - integrity sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA== - -is-ci@^1.0.10: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.2.1.tgz#e3779c8ee17fccf428488f6e281187f2e632841c" - integrity sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg== - dependencies: - ci-info "^1.5.0" - -is-cidr@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/is-cidr/-/is-cidr-3.1.1.tgz#e92ef121bdec2782271a77ce487a8b8df3718ab7" - integrity sha512-Gx+oErgq1j2jAKCR2Kbq0b3wbH0vQKqZ0wOlHxm0o56nq51Cs/DZA8oz9dMDhbHyHEGgJ86eTeVudtgMMOx3Mw== - dependencies: - cidr-regex "^2.0.10" - -is-date-object@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" - integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - -is-installed-globally@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" - integrity sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA= - dependencies: - global-dirs "^0.1.0" - is-path-inside "^1.0.0" - -is-negative-zero@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461" - integrity sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE= - -is-npm@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" - integrity sha1-8vtjpl5JBbQGyGBydloaTceTufQ= - -is-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" - integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= - -is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" - integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= - dependencies: - path-is-inside "^1.0.1" - -is-redirect@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" - integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= - -is-regex@^1.1.0, is-regex@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" - integrity sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg== - dependencies: - has-symbols "^1.0.1" - -is-retry-allowed@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== - -is-stream@^1.0.0, is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - -is-symbol@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" - integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== - dependencies: - has-symbols "^1.0.1" - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.1: - version "3.14.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" - integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - -json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= - -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -jsonfile@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-3.0.1.tgz#a5ecc6f65f53f662c4415c7675a0331d0992ec66" - integrity sha1-pezG9l9T9mLEQVx2daAzHQmS7GY= - optionalDependencies: - graceful-fs "^4.1.6" - -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - -latest-version@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" - integrity sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU= - dependencies: - package-json "^4.0.0" - -lazy-property@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lazy-property/-/lazy-property-1.0.0.tgz#84ddc4b370679ba8bd4cdcfa4c06b43d57111147" - integrity sha1-hN3Es3Bnm6i9TNz6TAa0PVcREUc= - -lcid@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" - integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= - dependencies: - invert-kv "^1.0.0" - -libcipm@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/libcipm/-/libcipm-4.0.8.tgz#dcea4919e10dfbce420327e63901613b9141bc89" - integrity sha512-IN3hh2yDJQtZZ5paSV4fbvJg4aHxCCg5tcZID/dSVlTuUiWktsgaldVljJv6Z5OUlYspx6xQkbR0efNodnIrOA== - dependencies: - bin-links "^1.1.2" - bluebird "^3.5.1" - figgy-pudding "^3.5.1" - find-npm-prefix "^1.0.2" - graceful-fs "^4.1.11" - ini "^1.3.5" - lock-verify "^2.1.0" - mkdirp "^0.5.1" - npm-lifecycle "^3.0.0" - npm-logical-tree "^1.2.1" - npm-package-arg "^6.1.0" - pacote "^9.1.0" - read-package-json "^2.0.13" - rimraf "^2.6.2" - worker-farm "^1.6.0" - -libnpm@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/libnpm/-/libnpm-3.0.1.tgz#0be11b4c9dd4d1ffd7d95c786e92e55d65be77a2" - integrity sha512-d7jU5ZcMiTfBqTUJVZ3xid44fE5ERBm9vBnmhp2ECD2Ls+FNXWxHSkO7gtvrnbLO78gwPdNPz1HpsF3W4rjkBQ== - dependencies: - bin-links "^1.1.2" - bluebird "^3.5.3" - find-npm-prefix "^1.0.2" - libnpmaccess "^3.0.2" - libnpmconfig "^1.2.1" - libnpmhook "^5.0.3" - libnpmorg "^1.0.1" - libnpmpublish "^1.1.2" - libnpmsearch "^2.0.2" - libnpmteam "^1.0.2" - lock-verify "^2.0.2" - npm-lifecycle "^3.0.0" - npm-logical-tree "^1.2.1" - npm-package-arg "^6.1.0" - npm-profile "^4.0.2" - npm-registry-fetch "^4.0.0" - npmlog "^4.1.2" - pacote "^9.5.3" - read-package-json "^2.0.13" - stringify-package "^1.0.0" - -libnpmaccess@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/libnpmaccess/-/libnpmaccess-3.0.2.tgz#8b2d72345ba3bef90d3b4f694edd5c0417f58923" - integrity sha512-01512AK7MqByrI2mfC7h5j8N9V4I7MHJuk9buo8Gv+5QgThpOgpjB7sQBDDkeZqRteFb1QM/6YNdHfG7cDvfAQ== - dependencies: - aproba "^2.0.0" - get-stream "^4.0.0" - npm-package-arg "^6.1.0" - npm-registry-fetch "^4.0.0" - -libnpmconfig@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/libnpmconfig/-/libnpmconfig-1.2.1.tgz#c0c2f793a74e67d4825e5039e7a02a0044dfcbc0" - integrity sha512-9esX8rTQAHqarx6qeZqmGQKBNZR5OIbl/Ayr0qQDy3oXja2iFVQQI81R6GZ2a02bSNZ9p3YOGX1O6HHCb1X7kA== - dependencies: - figgy-pudding "^3.5.1" - find-up "^3.0.0" - ini "^1.3.5" - -libnpmhook@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/libnpmhook/-/libnpmhook-5.0.3.tgz#4020c0f5edbf08ebe395325caa5ea01885b928f7" - integrity sha512-UdNLMuefVZra/wbnBXECZPefHMGsVDTq5zaM/LgKNE9Keyl5YXQTnGAzEo+nFOpdRqTWI9LYi4ApqF9uVCCtuA== - dependencies: - aproba "^2.0.0" - figgy-pudding "^3.4.1" - get-stream "^4.0.0" - npm-registry-fetch "^4.0.0" - -libnpmorg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/libnpmorg/-/libnpmorg-1.0.1.tgz#5d2503f6ceb57f33dbdcc718e6698fea6d5ad087" - integrity sha512-0sRUXLh+PLBgZmARvthhYXQAWn0fOsa6T5l3JSe2n9vKG/lCVK4nuG7pDsa7uMq+uTt2epdPK+a2g6btcY11Ww== - dependencies: - aproba "^2.0.0" - figgy-pudding "^3.4.1" - get-stream "^4.0.0" - npm-registry-fetch "^4.0.0" - -libnpmpublish@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/libnpmpublish/-/libnpmpublish-1.1.3.tgz#e3782796722d79eef1a0a22944c117e0c4ca4280" - integrity sha512-/3LsYqVc52cHXBmu26+J8Ed7sLs/hgGVFMH1mwYpL7Qaynb9RenpKqIKu0sJ130FB9PMkpMlWjlbtU8A4m7CQw== - dependencies: - aproba "^2.0.0" - figgy-pudding "^3.5.1" - get-stream "^4.0.0" - lodash.clonedeep "^4.5.0" - normalize-package-data "^2.4.0" - npm-package-arg "^6.1.0" - npm-registry-fetch "^4.0.0" - semver "^5.5.1" - ssri "^6.0.1" - -libnpmsearch@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/libnpmsearch/-/libnpmsearch-2.0.2.tgz#9a4f059102d38e3dd44085bdbfe5095f2a5044cf" - integrity sha512-VTBbV55Q6fRzTdzziYCr64+f8AopQ1YZ+BdPOv16UegIEaE8C0Kch01wo4s3kRTFV64P121WZJwgmBwrq68zYg== - dependencies: - figgy-pudding "^3.5.1" - get-stream "^4.0.0" - npm-registry-fetch "^4.0.0" - -libnpmteam@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/libnpmteam/-/libnpmteam-1.0.2.tgz#8b48bcbb6ce70dd8150c950fcbdbf3feb6eec820" - integrity sha512-p420vM28Us04NAcg1rzgGW63LMM6rwe+6rtZpfDxCcXxM0zUTLl7nPFEnRF3JfFBF5skF/yuZDUthTsHgde8QA== - dependencies: - aproba "^2.0.0" - figgy-pudding "^3.4.1" - get-stream "^4.0.0" - npm-registry-fetch "^4.0.0" - -libnpx@^10.2.4: - version "10.2.4" - resolved "https://registry.yarnpkg.com/libnpx/-/libnpx-10.2.4.tgz#ef0e3258e29aef2ec7ee3276115e20e67f67d4ee" - integrity sha512-BPc0D1cOjBeS8VIBKUu5F80s6njm0wbVt7CsGMrIcJ+SI7pi7V0uVPGpEMH9H5L8csOcclTxAXFE2VAsJXUhfA== - dependencies: - dotenv "^5.0.1" - npm-package-arg "^6.0.0" - rimraf "^2.6.2" - safe-buffer "^5.1.0" - update-notifier "^2.3.0" - which "^1.3.0" - y18n "^4.0.0" - yargs "^14.2.3" - -listenercount@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" - integrity sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc= - -load-json-file@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" - integrity sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg= - dependencies: - graceful-fs "^4.1.2" - parse-json "^2.2.0" - pify "^2.0.0" - strip-bom "^3.0.0" - -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - -lock-verify@^2.0.2, lock-verify@^2.1.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/lock-verify/-/lock-verify-2.2.1.tgz#81107948c51ed16f97b96ff8b60675affb243fc1" - integrity sha512-n0Zw2DVupKfZMazy/HIFVNohJ1z8fIoZ77WBnyyBGG6ixw83uJNyrbiJvvHWe1QKkGiBCjj8RCPlymltliqEww== - dependencies: - "@iarna/cli" "^1.2.0" - npm-package-arg "^6.1.0" - semver "^5.4.1" - -lockfile@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.4.tgz#07f819d25ae48f87e538e6578b6964a4981a5609" - integrity sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA== - dependencies: - signal-exit "^3.0.2" - -lodash._baseindexof@*: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" - integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw= - -lodash._baseuniq@~4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" - integrity sha1-DrtE5FaBSveQXGIS+iybLVG4Qeg= - dependencies: - lodash._createset "~4.0.0" - lodash._root "~3.0.0" - -lodash._bindcallback@*: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" - integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4= - -lodash._cacheindexof@*: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" - integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI= - -lodash._createcache@*: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" - integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM= - dependencies: - lodash._getnative "^3.0.0" - -lodash._createset@~4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" - integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= - -lodash._getnative@*, lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= - -lodash._root@~3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" - integrity sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI= - -lodash.clonedeep@^4.5.0, lodash.clonedeep@~4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= - -lodash.restparam@*: - version "3.6.1" - resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" - integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= - -lodash.union@~4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88" - integrity sha1-SLtQiECfFvGCFmZkHETdGqrjzYg= - -lodash.uniq@~4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" - integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= - -lodash.without@~4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" - integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw= - -lodash@^4.17.19: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== - -lowercase-keys@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== - -lru-cache@^4.0.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -lru-cache@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" - integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== - dependencies: - yallist "^3.0.2" - -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - -make-fetch-happen@^5.0.0: - version "5.0.2" - resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz#aa8387104f2687edca01c8687ee45013d02d19bd" - integrity sha512-07JHC0r1ykIoruKO8ifMXu+xEU8qOXDFETylktdug6vJDACnP+HKevOu3PXyNPzFyTSlz8vrBYlBO1JZRe8Cag== - dependencies: - agentkeepalive "^3.4.1" - cacache "^12.0.0" - http-cache-semantics "^3.8.1" - http-proxy-agent "^2.1.0" - https-proxy-agent "^2.2.3" - lru-cache "^5.1.1" - mississippi "^3.0.0" - node-fetch-npm "^2.0.2" - promise-retry "^1.1.1" - socks-proxy-agent "^4.0.0" - ssri "^6.0.0" - -meant@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.2.tgz#5d0c78310a3d8ae1408a16be0fe0bd42a969f560" - integrity sha512-KN+1uowN/NK+sT/Lzx7WSGIj2u+3xe5n2LbwObfjOhPZiA+cCfCm6idVl0RkEfjThkw5XJ96CyRcanq6GmKtUg== - -mem@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" - integrity sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y= - dependencies: - mimic-fn "^1.0.0" - -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - -mime-types@^2.1.12, mime-types@~2.1.19: - version "2.1.27" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" - integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== - dependencies: - mime-db "1.44.0" - -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -minipass@^2.3.5, minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.2.1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - -mississippi@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" - integrity sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA== - dependencies: - concat-stream "^1.5.0" - duplexify "^3.4.2" - end-of-stream "^1.1.0" - flush-write-stream "^1.0.0" - from2 "^2.1.0" - parallel-transform "^1.1.0" - pump "^3.0.0" - pumpify "^1.3.3" - stream-each "^1.1.0" - through2 "^2.0.0" - -"mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.0: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -move-concurrently@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" - integrity sha1-viwAX9oy4LKa8fBdfEszIUxwH5I= - dependencies: - aproba "^1.1.1" - copy-concurrently "^1.0.0" - fs-write-stream-atomic "^1.0.8" - mkdirp "^0.5.1" - rimraf "^2.5.4" - run-queue "^1.0.3" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@^2.0.0, ms@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -mute-stream@~0.0.4: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - -node-fetch-npm@^2.0.2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz#6507d0e17a9ec0be3bec516958a497cec54bf5a4" - integrity sha512-iOuIQDWDyjhv9qSDrj9aq/klt6F9z1p2otB3AV7v3zBDcL/x+OfGsvGQZZCcMZbUf4Ujw1xGNQkjvGnVT22cKg== - dependencies: - encoding "^0.1.11" - json-parse-better-errors "^1.0.0" - safe-buffer "^5.1.1" - -node-gyp@^5.0.2, node-gyp@^5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-5.1.1.tgz#eb915f7b631c937d282e33aed44cb7a025f62a3e" - integrity sha512-WH0WKGi+a4i4DUt2mHnvocex/xPLp9pYt5R6M2JdFB7pJ7Z34hveZ4nDTGTiLXCkitA9T8HFZjhinBCiVHYcWw== - dependencies: - env-paths "^2.2.0" - glob "^7.1.4" - graceful-fs "^4.2.2" - mkdirp "^0.5.1" - nopt "^4.0.1" - npmlog "^4.1.2" - request "^2.88.0" - rimraf "^2.6.3" - semver "^5.7.1" - tar "^4.4.12" - which "^1.3.1" - -node-status@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/node-status/-/node-status-1.0.0.tgz#7906a7c47a6587d03496bf74ec634abaa03f8e80" - integrity sha1-eQanxHplh9A0lr907GNKuqA/joA= - dependencies: - charm "1.0.1" - cli-cursor "^1.0.2" - cli-spinners "0.2.0" - colors "1.1.2" - -nopt@^4.0.1, nopt@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" - integrity sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg== - dependencies: - abbrev "1" - osenv "^0.1.4" - -normalize-package-data@^2.0.0, normalize-package-data@^2.3.2, normalize-package-data@^2.4.0, normalize-package-data@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -npm-audit-report@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/npm-audit-report/-/npm-audit-report-1.3.3.tgz#8226deeb253b55176ed147592a3995442f2179ed" - integrity sha512-8nH/JjsFfAWMvn474HB9mpmMjrnKb1Hx/oTAdjv4PT9iZBvBxiZ+wtDUapHCJwLqYGQVPaAfs+vL5+5k9QndXw== - dependencies: - cli-table3 "^0.5.0" - console-control-strings "^1.1.0" - -npm-bundled@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" - integrity sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-cache-filename@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/npm-cache-filename/-/npm-cache-filename-1.0.2.tgz#ded306c5b0bfc870a9e9faf823bc5f283e05ae11" - integrity sha1-3tMGxbC/yHCp6fr4I7xfKD4FrhE= - -npm-install-checks@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/npm-install-checks/-/npm-install-checks-3.0.2.tgz#ab2e32ad27baa46720706908e5b14c1852de44d9" - integrity sha512-E4kzkyZDIWoin6uT5howP8VDvkM+E8IQDcHAycaAxMbwkqhIg5eEYALnXOl3Hq9MrkdQB/2/g1xwBINXdKSRkg== - dependencies: - semver "^2.3.0 || 3.x || 4 || 5" - -npm-lifecycle@^3.0.0, npm-lifecycle@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/npm-lifecycle/-/npm-lifecycle-3.1.5.tgz#9882d3642b8c82c815782a12e6a1bfeed0026309" - integrity sha512-lDLVkjfZmvmfvpvBzA4vzee9cn+Me4orq0QF8glbswJVEbIcSNWib7qGOffolysc3teCqbbPZZkzbr3GQZTL1g== - dependencies: - byline "^5.0.0" - graceful-fs "^4.1.15" - node-gyp "^5.0.2" - resolve-from "^4.0.0" - slide "^1.1.6" - uid-number "0.0.6" - umask "^1.1.0" - which "^1.3.1" - -npm-logical-tree@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/npm-logical-tree/-/npm-logical-tree-1.2.1.tgz#44610141ca24664cad35d1e607176193fd8f5b88" - integrity sha512-AJI/qxDB2PWI4LG1CYN579AY1vCiNyWfkiquCsJWqntRu/WwimVrC8yXeILBFHDwxfOejxewlmnvW9XXjMlYIg== - -npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -"npm-package-arg@^4.0.0 || ^5.0.0 || ^6.0.0", npm-package-arg@^6.0.0, npm-package-arg@^6.1.0, npm-package-arg@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/npm-package-arg/-/npm-package-arg-6.1.1.tgz#02168cb0a49a2b75bf988a28698de7b529df5cb7" - integrity sha512-qBpssaL3IOZWi5vEKUKW0cO7kzLeT+EQO9W8RsLOZf76KF9E/K9+wH0C7t06HXPpaH8WH5xF1MExLuCwbTqRUg== - dependencies: - hosted-git-info "^2.7.1" - osenv "^0.1.5" - semver "^5.6.0" - validate-npm-package-name "^3.0.0" - -npm-packlist@^1.1.12, npm-packlist@^1.4.8: - version "1.4.8" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" - integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-normalize-package-bin "^1.0.1" - -npm-pick-manifest@^3.0.0, npm-pick-manifest@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/npm-pick-manifest/-/npm-pick-manifest-3.0.2.tgz#f4d9e5fd4be2153e5f4e5f9b7be8dc419a99abb7" - integrity sha512-wNprTNg+X5nf+tDi+hbjdHhM4bX+mKqv6XmPh7B5eG+QY9VARfQPfCEH013H5GqfNj6ee8Ij2fg8yk0mzps1Vw== - dependencies: - figgy-pudding "^3.5.1" - npm-package-arg "^6.0.0" - semver "^5.4.1" - -npm-profile@^4.0.2, npm-profile@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/npm-profile/-/npm-profile-4.0.4.tgz#28ee94390e936df6d084263ee2061336a6a1581b" - integrity sha512-Ta8xq8TLMpqssF0H60BXS1A90iMoM6GeKwsmravJ6wYjWwSzcYBTdyWa3DZCYqPutacBMEm7cxiOkiIeCUAHDQ== - dependencies: - aproba "^1.1.2 || 2" - figgy-pudding "^3.4.1" - npm-registry-fetch "^4.0.0" - -npm-registry-fetch@^4.0.0, npm-registry-fetch@^4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/npm-registry-fetch/-/npm-registry-fetch-4.0.7.tgz#57951bf6541e0246b34c9f9a38ab73607c9449d7" - integrity sha512-cny9v0+Mq6Tjz+e0erFAB+RYJ/AVGzkjnISiobqP8OWj9c9FLoZZu8/SPSKJWE17F1tk4018wfjV+ZbIbqC7fQ== - dependencies: - JSONStream "^1.3.4" - bluebird "^3.5.1" - figgy-pudding "^3.4.1" - lru-cache "^5.1.1" - make-fetch-happen "^5.0.0" - npm-package-arg "^6.1.0" - safe-buffer "^5.2.0" - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -npm-user-validate@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/npm-user-validate/-/npm-user-validate-1.0.0.tgz#8ceca0f5cea04d4e93519ef72d0557a75122e951" - integrity sha1-jOyg9c6gTU6TUZ73LQVXp1Ei6VE= - -npm@^6.14.6: - version "6.14.8" - resolved "https://registry.yarnpkg.com/npm/-/npm-6.14.8.tgz#64ef754345639bc035982ec3f609353c8539033c" - integrity sha512-HBZVBMYs5blsj94GTeQZel7s9odVuuSUHy1+AlZh7rPVux1os2ashvEGLy/STNK7vUjbrCg5Kq9/GXisJgdf6A== - dependencies: - JSONStream "^1.3.5" - abbrev "~1.1.1" - ansicolors "~0.3.2" - ansistyles "~0.1.3" - aproba "^2.0.0" - archy "~1.0.0" - bin-links "^1.1.8" - bluebird "^3.5.5" - byte-size "^5.0.1" - cacache "^12.0.3" - call-limit "^1.1.1" - chownr "^1.1.4" - ci-info "^2.0.0" - cli-columns "^3.1.2" - cli-table3 "^0.5.1" - cmd-shim "^3.0.3" - columnify "~1.5.4" - config-chain "^1.1.12" - detect-indent "~5.0.0" - detect-newline "^2.1.0" - dezalgo "~1.0.3" - editor "~1.0.0" - figgy-pudding "^3.5.1" - find-npm-prefix "^1.0.2" - fs-vacuum "~1.2.10" - fs-write-stream-atomic "~1.0.10" - gentle-fs "^2.3.1" - glob "^7.1.6" - graceful-fs "^4.2.4" - has-unicode "~2.0.1" - hosted-git-info "^2.8.8" - iferr "^1.0.2" - infer-owner "^1.0.4" - inflight "~1.0.6" - inherits "^2.0.4" - ini "^1.3.5" - init-package-json "^1.10.3" - is-cidr "^3.0.0" - json-parse-better-errors "^1.0.2" - lazy-property "~1.0.0" - libcipm "^4.0.8" - libnpm "^3.0.1" - libnpmaccess "^3.0.2" - libnpmhook "^5.0.3" - libnpmorg "^1.0.1" - libnpmsearch "^2.0.2" - libnpmteam "^1.0.2" - libnpx "^10.2.4" - lock-verify "^2.1.0" - lockfile "^1.0.4" - lodash._baseuniq "~4.6.0" - lodash.clonedeep "~4.5.0" - lodash.union "~4.6.0" - lodash.uniq "~4.5.0" - lodash.without "~4.4.0" - lru-cache "^5.1.1" - meant "^1.0.2" - mississippi "^3.0.0" - mkdirp "^0.5.5" - move-concurrently "^1.0.1" - node-gyp "^5.1.0" - nopt "^4.0.3" - normalize-package-data "^2.5.0" - npm-audit-report "^1.3.3" - npm-cache-filename "~1.0.2" - npm-install-checks "^3.0.2" - npm-lifecycle "^3.1.5" - npm-package-arg "^6.1.1" - npm-packlist "^1.4.8" - npm-pick-manifest "^3.0.2" - npm-profile "^4.0.4" - npm-registry-fetch "^4.0.7" - npm-user-validate "~1.0.0" - npmlog "~4.1.2" - once "~1.4.0" - opener "^1.5.1" - osenv "^0.1.5" - pacote "^9.5.12" - path-is-inside "~1.0.2" - promise-inflight "~1.0.1" - qrcode-terminal "^0.12.0" - query-string "^6.8.2" - qw "~1.0.1" - read "~1.0.7" - read-cmd-shim "^1.0.5" - read-installed "~4.0.3" - read-package-json "^2.1.1" - read-package-tree "^5.3.1" - readable-stream "^3.6.0" - readdir-scoped-modules "^1.1.0" - request "^2.88.0" - retry "^0.12.0" - rimraf "^2.7.1" - safe-buffer "^5.1.2" - semver "^5.7.1" - sha "^3.0.0" - slide "~1.1.6" - sorted-object "~2.0.1" - sorted-union-stream "~2.1.3" - ssri "^6.0.1" - stringify-package "^1.0.1" - tar "^4.4.13" - text-table "~0.2.0" - tiny-relative-date "^1.3.0" - uid-number "0.0.6" - umask "~1.1.0" - unique-filename "^1.1.1" - unpipe "~1.0.0" - update-notifier "^2.5.0" - uuid "^3.3.3" - validate-npm-package-license "^3.0.4" - validate-npm-package-name "~3.0.0" - which "^1.3.1" - worker-farm "^1.7.0" - write-file-atomic "^2.4.3" - -npmlog@^4.1.2, npmlog@~4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" - integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-inspect@^1.7.0, object-inspect@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" - integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.1.tgz#303867a666cdd41936ecdedfb1f8f3e32a478cdd" - integrity sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.18.0-next.0" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -object.getownpropertydescriptors@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz#369bf1f9592d8ab89d712dced5cb81c7c5352649" - integrity sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - -once@^1.3.0, once@^1.3.1, once@^1.4.0, once@~1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" - integrity sha1-ofeDj4MUxRbwXs78vEzP4EtO14k= - -opener@^1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" - integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A== - -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - -os-locale@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" - integrity sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA== - dependencies: - execa "^0.7.0" - lcid "^1.0.0" - mem "^1.1.0" - -os-tmpdir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -osenv@^0.1.4, osenv@^0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" - integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-limit@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" - integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== - dependencies: - p-try "^1.0.0" - -p-limit@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= - dependencies: - p-limit "^1.1.0" - -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== - dependencies: - p-limit "^2.0.0" - -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -package-json@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" - integrity sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0= - dependencies: - got "^6.7.1" - registry-auth-token "^3.0.1" - registry-url "^3.0.3" - semver "^5.1.0" - -pacote@^9.1.0, pacote@^9.5.12, pacote@^9.5.3: - version "9.5.12" - resolved "https://registry.yarnpkg.com/pacote/-/pacote-9.5.12.tgz#1e11dd7a8d736bcc36b375a9804d41bb0377bf66" - integrity sha512-BUIj/4kKbwWg4RtnBncXPJd15piFSVNpTzY0rysSr3VnMowTYgkGKcaHrbReepAkjTr8lH2CVWRi58Spg2CicQ== - dependencies: - bluebird "^3.5.3" - cacache "^12.0.2" - chownr "^1.1.2" - figgy-pudding "^3.5.1" - get-stream "^4.1.0" - glob "^7.1.3" - infer-owner "^1.0.4" - lru-cache "^5.1.1" - make-fetch-happen "^5.0.0" - minimatch "^3.0.4" - minipass "^2.3.5" - mississippi "^3.0.0" - mkdirp "^0.5.1" - normalize-package-data "^2.4.0" - npm-normalize-package-bin "^1.0.0" - npm-package-arg "^6.1.0" - npm-packlist "^1.1.12" - npm-pick-manifest "^3.0.0" - npm-registry-fetch "^4.0.0" - osenv "^0.1.5" - promise-inflight "^1.0.1" - promise-retry "^1.1.1" - protoduck "^5.0.1" - rimraf "^2.6.2" - safe-buffer "^5.1.2" - semver "^5.6.0" - ssri "^6.0.1" - tar "^4.4.10" - unique-filename "^1.1.1" - which "^1.3.1" - -parallel-transform@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/parallel-transform/-/parallel-transform-1.2.0.tgz#9049ca37d6cb2182c3b1d2c720be94d14a5814fc" - integrity sha512-P2vSmIu38uIlvdcU7fDkyrxj33gTUy/ABO5ZUbGowxNCopBq/OoD42bP4UmMrJoPyk4Uqf0mu3mtWBhHCZD8yg== - dependencies: - cyclist "^1.0.1" - inherits "^2.0.3" - readable-stream "^2.1.5" - -parse-json@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" - integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= - dependencies: - error-ex "^1.2.0" - -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-is-inside@^1.0.1, path-is-inside@^1.0.2, path-is-inside@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= - -path-key@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - -path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== - -path-type@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" - integrity sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM= - dependencies: - pify "^2.0.0" - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - -pify@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - -prepend-http@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - integrity sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M= - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -promise-inflight@^1.0.1, promise-inflight@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" - integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= - -promise-retry@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/promise-retry/-/promise-retry-1.1.1.tgz#6739e968e3051da20ce6497fb2b50f6911df3d6d" - integrity sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0= - dependencies: - err-code "^1.0.0" - retry "^0.10.0" - -promzard@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/promzard/-/promzard-0.3.0.tgz#26a5d6ee8c7dee4cb12208305acfb93ba382a9ee" - integrity sha1-JqXW7ox97kyxIggwWs+5O6OCqe4= - dependencies: - read "1" - -proto-list@~1.2.1: - version "1.2.4" - resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" - integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk= - -protoduck@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/protoduck/-/protoduck-5.0.1.tgz#03c3659ca18007b69a50fd82a7ebcc516261151f" - integrity sha512-WxoCeDCoCBY55BMvj4cAEjdVUFGRWed9ZxPlqTKYyw1nDDTQ4pqmnIMAGfJlg7Dx35uB/M+PHJPTmGOvaCaPTg== - dependencies: - genfun "^5.0.0" - -prr@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" - integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= - -psl@^1.1.28: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -pump@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" - integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pumpify@^1.3.3: - version "1.5.1" - resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" - integrity sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ== - dependencies: - duplexify "^3.6.0" - inherits "^2.0.3" - pump "^2.0.0" - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qrcode-terminal@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz#bb5b699ef7f9f0505092a3748be4464fe71b5819" - integrity sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ== - -qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - -query-string@^6.8.2: - version "6.13.4" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.4.tgz#b35a9a3bd4955bce55f94feb0e819b3d0be6f66f" - integrity sha512-E2NPIeJoBEJGQNy3ib1k/Z/OkDBUKIo8IV2ZVwbKfoa65IS9unqWWUlLcbfU70Da0qNoxUZZA8CfKUjKLE641Q== - dependencies: - decode-uri-component "^0.2.0" - split-on-first "^1.0.0" - strict-uri-encode "^2.0.0" - -qw@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/qw/-/qw-1.0.1.tgz#efbfdc740f9ad054304426acb183412cc8b996d4" - integrity sha1-77/cdA+a0FQwRCassYNBLMi5ltQ= - -rc@^1.0.1, rc@^1.1.6: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - -read-cmd-shim@^1.0.1, read-cmd-shim@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.5.tgz#87e43eba50098ba5a32d0ceb583ab8e43b961c16" - integrity sha512-v5yCqQ/7okKoZZkBQUAfTsQ3sVJtXdNfbPnI5cceppoxEVLYA3k+VtV2omkeo8MS94JCy4fSiUwlRBAwCVRPUA== - dependencies: - graceful-fs "^4.1.2" - -read-installed@~4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/read-installed/-/read-installed-4.0.3.tgz#ff9b8b67f187d1e4c29b9feb31f6b223acd19067" - integrity sha1-/5uLZ/GH0eTCm5/rMfayI6zRkGc= - dependencies: - debuglog "^1.0.1" - read-package-json "^2.0.0" - readdir-scoped-modules "^1.0.0" - semver "2 || 3 || 4 || 5" - slide "~1.1.3" - util-extend "^1.0.1" - optionalDependencies: - graceful-fs "^4.1.2" - -"read-package-json@1 || 2", read-package-json@^2.0.0, read-package-json@^2.0.13, read-package-json@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/read-package-json/-/read-package-json-2.1.2.tgz#6992b2b66c7177259feb8eaac73c3acd28b9222a" - integrity sha512-D1KmuLQr6ZSJS0tW8hf3WGpRlwszJOXZ3E8Yd/DNRaM5d+1wVRZdHlpGBLAuovjr28LbWvjpWkBHMxpRGGjzNA== - dependencies: - glob "^7.1.1" - json-parse-even-better-errors "^2.3.0" - normalize-package-data "^2.0.0" - npm-normalize-package-bin "^1.0.0" - -read-package-tree@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/read-package-tree/-/read-package-tree-5.3.1.tgz#a32cb64c7f31eb8a6f31ef06f9cedf74068fe636" - integrity sha512-mLUDsD5JVtlZxjSlPPx1RETkNjjvQYuweKwNVt1Sn8kP5Jh44pvYuUHCp6xSVDZWbNxVxG5lyZJ921aJH61sTw== - dependencies: - read-package-json "^2.0.0" - readdir-scoped-modules "^1.0.0" - util-promisify "^2.1.0" - -read-pkg-up@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" - integrity sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4= - dependencies: - find-up "^2.0.0" - read-pkg "^2.0.0" - -read-pkg@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" - integrity sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg= - dependencies: - load-json-file "^2.0.0" - normalize-package-data "^2.3.2" - path-type "^2.0.0" - -read@1, read@~1.0.1, read@~1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" - integrity sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ= - dependencies: - mute-stream "~0.0.4" - -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.6, readable-stream@~2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readable-stream@~1.1.10: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@~2.1.5: - version "2.1.5" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" - integrity sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA= - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readdir-scoped-modules@^1.0.0, readdir-scoped-modules@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz#8d45407b4f870a0dcaebc0e28670d18e74514309" - integrity sha512-asaikDeqAQg7JifRsZn1NJZXo9E+VwlyCfbkZhwyISinqk5zNS6266HS5kah6P0SaQKGF6SkNnZVHUzHFYxYDw== - dependencies: - debuglog "^1.0.1" - dezalgo "^1.0.0" - graceful-fs "^4.1.2" - once "^1.3.0" - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q= - dependencies: - resolve "^1.1.6" - -registry-auth-token@^3.0.1: - version "3.4.0" - resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e" - integrity sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A== - dependencies: - rc "^1.1.6" - safe-buffer "^5.0.1" - -registry-url@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" - integrity sha1-PU74cPc93h138M+aOBQyRE4XSUI= - dependencies: - rc "^1.0.1" - -request@^2.88.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.3.2: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -restore-cursor@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" - integrity sha1-NGYfRohjJ/7SmRR5FSJS35LapUE= - dependencies: - exit-hook "^1.0.0" - onetime "^1.0.0" - -retry@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4" - integrity sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q= - -retry@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" - integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= - -rimraf@2, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -rimraf@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -run-queue@^1.0.0, run-queue@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47" - integrity sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec= - dependencies: - aproba "^1.1.1" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -"safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -semver-diff@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" - integrity sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY= - dependencies: - semver "^5.0.3" - -"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.1, semver@^5.6.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -set-blocking@^2.0.0, set-blocking@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - -setimmediate@~1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -sha@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/sha/-/sha-3.0.0.tgz#b2f2f90af690c16a3a839a6a6c680ea51fedd1ae" - integrity sha512-DOYnM37cNsLNSGIG/zZWch5CKIRNoLdYUQTQlcgkRkoYIUwDYjqDyye16YcDZg/OPdcbUgTKMjc4SY6TB7ZAPw== - dependencies: - graceful-fs "^4.1.2" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -shelljs@^0.8.3: - version "0.8.4" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2" - integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ== - dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" - -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -slide@^1.1.6, slide@~1.1.3, slide@~1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" - integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc= - -smart-buffer@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.1.0.tgz#91605c25d91652f4661ea69ccf45f1b331ca21ba" - integrity sha512-iVICrxOzCynf/SNaBQCw34eM9jROU/s5rzIhpOvzhzuYHfJR/DhZfDkXiZSgKXfgv26HT3Yni3AV/DGw0cGnnw== - -socks-proxy-agent@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz#3c8991f3145b2799e70e11bd5fbc8b1963116386" - integrity sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg== - dependencies: - agent-base "~4.2.1" - socks "~2.3.2" - -socks@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/socks/-/socks-2.3.3.tgz#01129f0a5d534d2b897712ed8aceab7ee65d78e3" - integrity sha512-o5t52PCNtVdiOvzMry7wU4aOqYWL0PeCXRWBEiJow4/i/wr+wpsJQ9awEu1EonLIqsfGd5qSgDdxEOvCdmBEpA== - dependencies: - ip "1.1.5" - smart-buffer "^4.1.0" - -sorted-object@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/sorted-object/-/sorted-object-2.0.1.tgz#7d631f4bd3a798a24af1dffcfbfe83337a5df5fc" - integrity sha1-fWMfS9OnmKJK8d/8+/6DM3pd9fw= - -sorted-union-stream@~2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/sorted-union-stream/-/sorted-union-stream-2.1.3.tgz#c7794c7e077880052ff71a8d4a2dbb4a9a638ac7" - integrity sha1-x3lMfgd4gAUv9xqNSi27Sppjisc= - dependencies: - from2 "^1.3.0" - stream-iterate "^1.1.0" - -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" - integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== - -split-on-first@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f" - integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -ssri@^6.0.0, ssri@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" - integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA== - dependencies: - figgy-pudding "^3.5.1" - -stream-each@^1.1.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/stream-each/-/stream-each-1.2.3.tgz#ebe27a0c389b04fbcc233642952e10731afa9bae" - integrity sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw== - dependencies: - end-of-stream "^1.1.0" - stream-shift "^1.0.0" - -stream-iterate@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/stream-iterate/-/stream-iterate-1.2.0.tgz#2bd7c77296c1702a46488b8ad41f79865eecd4e1" - integrity sha1-K9fHcpbBcCpGSIuK1B95hl7s1OE= - dependencies: - readable-stream "^2.1.5" - stream-shift "^1.0.0" - -stream-shift@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" - integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== - -strict-uri-encode@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" - integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" - -string-width@^3.0.0, string-width@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== - dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" - -string.prototype.trimend@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" - integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string.prototype.trimstart@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" - integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -stringify-package@^1.0.0, stringify-package@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85" - integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg== - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= - dependencies: - ansi-regex "^3.0.0" - -strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= - -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -tar@^4.4.10, tar@^4.4.12, tar@^4.4.13: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" - -term-size@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" - integrity sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk= - dependencies: - execa "^0.7.0" - -text-table@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= - -through2@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" - integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== - dependencies: - readable-stream "~2.3.6" - xtend "~4.0.1" - -"through@>=2.2.7 <3": - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timed-out@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - -tiny-relative-date@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/tiny-relative-date/-/tiny-relative-date-1.3.0.tgz#fa08aad501ed730f31cc043181d995c39a935e07" - integrity sha512-MOQHpzllWxDCHHaDno30hhLfbouoYlOI8YlMNtvKe1zXbjEVhbcEovQxvZrPvtiYW630GQDoMMarCnjfyfHA+A== - -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -"traverse@>=0.3.0 <0.4": - version "0.3.9" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" - integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk= - -tslib@^1.13.0, tslib@^1.8.1: - version "1.13.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" - integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== - -tslint@^6.1.0: - version "6.1.3" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904" - integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg== - dependencies: - "@babel/code-frame" "^7.0.0" - builtin-modules "^1.1.1" - chalk "^2.3.0" - commander "^2.12.1" - diff "^4.0.1" - glob "^7.1.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" - mkdirp "^0.5.3" - resolve "^1.3.2" - semver "^5.3.0" - tslib "^1.13.0" - tsutils "^2.29.0" - -tsutils@^2.29.0: - version "2.29.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" - integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== - dependencies: - tslib "^1.8.1" - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - -typescript@^3.3.3333: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== - -uid-number@0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" - integrity sha1-DqEOgDXo61uOREnwbaHHMGY7qoE= - -umask@^1.1.0, umask@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d" - integrity sha1-8pzr8B31F5ErtY/5xOUP3o4zMg0= - -unique-filename@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" - integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== - dependencies: - unique-slug "^2.0.0" - -unique-slug@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.2.tgz#baabce91083fc64e945b0f3ad613e264f7cd4e6c" - integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== - dependencies: - imurmurhash "^0.1.4" - -unique-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" - integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - dependencies: - crypto-random-string "^1.0.0" - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -unzip-response@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" - integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c= - -unzipper@^0.8.11: - version "0.8.14" - resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.8.14.tgz#ade0524cd2fc14d11b8de258be22f9d247d3f79b" - integrity sha512-8rFtE7EP5ssOwGpN2dt1Q4njl0N1hUXJ7sSPz0leU2hRdq6+pra57z4YPBlVqm40vcgv6ooKZEAx48fMTv9x4w== - dependencies: - big-integer "^1.6.17" - binary "~0.3.0" - bluebird "~3.4.1" - buffer-indexof-polyfill "~1.0.0" - duplexer2 "~0.1.4" - fstream "~1.0.10" - listenercount "~1.0.1" - readable-stream "~2.1.5" - setimmediate "~1.0.4" - -update-notifier@^2.2.0, update-notifier@^2.3.0, update-notifier@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.5.0.tgz#d0744593e13f161e406acb1d9408b72cad08aff6" - integrity sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw== - dependencies: - boxen "^1.2.1" - chalk "^2.0.1" - configstore "^3.0.0" - import-lazy "^2.1.0" - is-ci "^1.0.10" - is-installed-globally "^0.1.0" - is-npm "^1.0.0" - latest-version "^3.0.0" - semver-diff "^2.0.0" - xdg-basedir "^3.0.0" - -uri-js@^4.2.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" - integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== - dependencies: - punycode "^2.1.0" - -url-parse-lax@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" - integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= - dependencies: - prepend-http "^1.0.1" - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -util-extend@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/util-extend/-/util-extend-1.0.3.tgz#a7c216d267545169637b3b6edc6ca9119e2ff93f" - integrity sha1-p8IW0mdUUWljeztu3GypEZ4v+T8= - -util-promisify@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/util-promisify/-/util-promisify-2.1.0.tgz#3c2236476c4d32c5ff3c47002add7c13b9a82a53" - integrity sha1-PCI2R2xNMsX/PEcAKt18E7moKlM= - dependencies: - object.getownpropertydescriptors "^2.0.3" - -uuid@^3.3.2, uuid@^3.3.3: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -validate-npm-package-name@^3.0.0, validate-npm-package-name@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz#5fa912d81eb7d0c74afc140de7317f0ca7df437e" - integrity sha1-X6kS2B630MdK/BQN5zF/DKffQ34= - dependencies: - builtins "^1.0.3" - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -wcwidth@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= - dependencies: - defaults "^1.0.3" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@^1.2.9, which@^1.3.0, which@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -wide-align@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== - dependencies: - string-width "^1.0.2 || 2" - -widest-line@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.1.tgz#7438764730ec7ef4381ce4df82fb98a53142a3fc" - integrity sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA== - dependencies: - string-width "^2.1.1" - -worker-farm@^1.6.0, worker-farm@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8" - integrity sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw== - dependencies: - errno "~0.1.7" - -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - -wrap-ansi@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" - integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== - dependencies: - ansi-styles "^3.2.0" - string-width "^3.0.0" - strip-ansi "^5.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, write-file-atomic@^2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481" - integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ== - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - -xdg-basedir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" - integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= - -xmldom@^0.1.27: - version "0.1.31" - resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.31.tgz#b76c9a1bd9f0a9737e5a72dc37231cf38375e2ff" - integrity sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ== - -xpath@0.0.27: - version "0.0.27" - resolved "https://registry.yarnpkg.com/xpath/-/xpath-0.0.27.tgz#dd3421fbdcc5646ac32c48531b4d7e9d0c2cfa92" - integrity sha512-fg03WRxtkCV6ohClePNAECYsmpKKTv5L8y/X3Dn1hQrec3POx2jHZ/0P2qQ6HvsrU1BmeqXcof3NGGueG6LxwQ== - -xtend@~4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -y18n@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= - -y18n@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== - -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= - -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - -yargs-parser@^15.0.1: - version "15.0.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.1.tgz#54786af40b820dcb2fb8025b11b4d659d76323b3" - integrity sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9" - integrity sha1-jQrELxbqVd69MyyvTEA4s+P139k= - dependencies: - camelcase "^4.1.0" - -yargs@^14.2.3: - version "14.2.3" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.3.tgz#1a1c3edced1afb2a2fea33604bc6d1d8d688a414" - integrity sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg== - dependencies: - cliui "^5.0.0" - decamelize "^1.2.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^15.0.1" - -yargs@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360" - integrity sha1-YpmpBVsc78lp/355wdkY3Osiw2A= - dependencies: - camelcase "^4.1.0" - cliui "^3.2.0" - decamelize "^1.1.1" - get-caller-file "^1.0.1" - os-locale "^2.0.0" - read-pkg-up "^2.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1" - yargs-parser "^7.0.0"