Skip to content

Commit 3892778

Browse files
Use associate instead of global (#222)
* Use associate instead of global * Run commands and update readme
1 parent 4fae4d2 commit 3892778

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Office-Addin-TaskPane
22

3-
This repository contains the source code used by the [Yo Office generator](https://github.com/OfficeDev/generator-office) when you create a new Office Add-in that appears in the task pane. You can also use this repository as a sample to base your own project from if you choose not to use the generator.
3+
This repository contains the source code used by the [Yo Office generator](https://github.com/OfficeDev/generator-office) when you create a new Office Add-in that appears in the task pane. You can also use this repository as a sample to base your own project from if you choose not to use the generator.
44

55
## TypeScript
66

@@ -10,27 +10,29 @@ This template is written using [TypeScript](http://www.typescriptlang.org/). For
1010

1111
This template supports debugging using any of the following techniques:
1212

13-
- [Use a browser's developer tools](https://docs.microsoft.com/office/dev/add-ins/testing/debug-add-ins-in-office-online)
14-
- [Attach a debugger from the task pane](https://docs.microsoft.com/office/dev/add-ins/testing/attach-debugger-from-task-pane)
15-
- [Use F12 developer tools on Windows 10](https://docs.microsoft.com/office/dev/add-ins/testing/debug-add-ins-using-f12-developer-tools-on-windows-10)
13+
- [Use a browser's developer tools](https://learn.microsoft.com/office/dev/add-ins/testing/debug-add-ins-in-office-online)
14+
- [Attach a debugger from the task pane](https://learn.microsoft.com/office/dev/add-ins/testing/attach-debugger-from-task-pane)
15+
- [Use F12 developer tools on Windows 10](https://learn.microsoft.com/office/dev/add-ins/testing/debug-add-ins-using-f12-developer-tools-on-windows-10)
1616

1717
## Questions and comments
1818

1919
We'd love to get your feedback about this sample. You can send your feedback to us in the *Issues* section of this repository.
2020

21-
Questions about Office Add-ins development in general should be posted to [Microsoft Q&A](https://docs.microsoft.com/answers/questions/185087/questions-about-office-add-ins.html). If your question is about the Office JavaScript APIs, make sure it's tagged with [office-js-dev].
21+
Questions about Office Add-ins development in general should be posted to [Microsoft Q&A](https://learn.microsoft.com/answers/questions/185087/questions-about-office-add-ins.html). If your question is about the Office JavaScript APIs, make sure it's tagged with [office-js-dev].
2222

2323
## Join the Microsoft 365 Developer Program
24+
2425
Get a free sandbox, tools, and other resources you need to build solutions for the Microsoft 365 platform.
26+
2527
- [Free developer sandbox](https://developer.microsoft.com/microsoft-365/dev-program#Subscription) Get a free, renewable 90-day Microsoft 365 E5 developer subscription.
2628
- [Sample data packs](https://developer.microsoft.com/microsoft-365/dev-program#Sample) Automatically configure your sandbox by installing user data and content to help you build your solutions.
2729
- [Access to experts](https://developer.microsoft.com/microsoft-365/dev-program#Experts) Access community events to learn from Microsoft 365 experts.
2830
- [Personalized recommendations](https://developer.microsoft.com/microsoft-365/dev-program#Recommendations) Find developer resources quickly from your personalized dashboard.
2931

3032
## Additional resources
3133

32-
* [Office Add-ins documentation](https://docs.microsoft.com/office/dev/add-ins/overview/office-add-ins)
33-
* More Office Add-ins samples at [OfficeDev on Github](https://github.com/officedev)
34+
- [Office Add-ins documentation](https://learn.microsoft.com/office/dev/add-ins/overview/office-add-ins)
35+
- More Office Add-ins samples at [OfficeDev on Github](https://github.com/officedev)
3436

3537
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.
3638

src/commands/commands.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* See LICENSE in the project root for license information.
44
*/
55

6-
/* global global, Office, self, window */
6+
/* global Office */
77

88
Office.onReady(() => {
9-
// If needed, Office.js is ready to be called
9+
// If needed, Office.js is ready to be called.
1010
});
1111

1212
/**
@@ -21,24 +21,12 @@ function action(event: Office.AddinCommands.Event) {
2121
persistent: true,
2222
};
2323

24-
// Show a notification message
24+
// Show a notification message.
2525
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
2626

27-
// Be sure to indicate when the add-in command function is complete
27+
// Be sure to indicate when the add-in command function is complete.
2828
event.completed();
2929
}
3030

31-
function getGlobal() {
32-
return typeof self !== "undefined"
33-
? self
34-
: typeof window !== "undefined"
35-
? window
36-
: typeof global !== "undefined"
37-
? global
38-
: undefined;
39-
}
40-
41-
const g = getGlobal() as any;
42-
43-
// The add-in command functions need to be available in global scope
44-
g.action = action;
31+
// Register the function with Office.
32+
Office.actions.associate("action", action);

0 commit comments

Comments
 (0)