Skip to content

Commit 6456c9a

Browse files
author
github-actions
committed
Merge branch 'main' into live
2 parents 3633e9c + bcbe3dd commit 6456c9a

File tree

70 files changed

+4073
-2354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4073
-2354
lines changed

docs/code-snippets/office-snippets.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,26 @@ Office.CoercionType:enum:
979979
}
980980
});
981981
}
982+
Office.Context:interface:
983+
- |-
984+
// Get the Office host, version, and platform in which the add-in is running.
985+
const contextInfo = Office.context.diagnostics;
986+
console.log("Office application: " + contextInfo.host);
987+
console.log("Office version: " + contextInfo.version);
988+
console.log("Platform: " + contextInfo.platform);
989+
Office.Context#auth:member:
990+
- |-
991+
// Get an access token.
992+
const authContext = Office.context.auth;
993+
authContext.getAccessTokenAsync((result) => {
994+
if (result.status === Office.AsyncResultStatus.Failed) {
995+
console.log("Error obtaining token", result.error);
996+
return;
997+
}
998+
999+
const token = result.value;
1000+
console.log(token);
1001+
});
9821002
Office.Context#contentLanguage:member:
9831003
- |-
9841004
function sayHelloWithContentLanguage() {
@@ -1763,6 +1783,33 @@ Office.DevicePermissionType:enum:
17631783
} else {
17641784
console.log("The add-in isn't running in Excel, Outlook, PowerPoint, or Word.");
17651785
}
1786+
Office.Dialog:interface:
1787+
- |-
1788+
// The following example shows how to open a dialog with a specified size. It also shows
1789+
// how to register a function to handle the message when Office.UI.messageParent() is called
1790+
// in the dialog and how to use that handler to close the dialog.
1791+
1792+
Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
1793+
(asyncResult) => {
1794+
const dialog = asyncResult.value;
1795+
dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
1796+
dialog.close();
1797+
// Do something to process the message.
1798+
});
1799+
}
1800+
);
1801+
1802+
// The following example does the same thing in TypeScript.
1803+
1804+
Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
1805+
(asyncResult: Office.AsyncResult) => {
1806+
const dialog: Office.Dialog = asyncResult.value;
1807+
dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg: string) => {
1808+
dialog.close();
1809+
// Do something to process the message.
1810+
});
1811+
}
1812+
);
17661813
Office.Dialog#addEventHandler:member(1):
17671814
- |-
17681815
// The following example shows how to open a dialog with a specified size. It also shows
@@ -1833,6 +1880,10 @@ Office.Dialog#messageChild:member(1):
18331880
const messageToDialog = JSON.stringify(currentWorksheet);
18341881
dialog.messageChild(messageToDialog);
18351882
}
1883+
Office.DialogMessageOptions#targetOrigin:member:
1884+
- |-
1885+
// The following example shows how to send a message to the domain of the parent runtime.
1886+
Office.context.ui.messageParent("Some message", { targetOrigin: "https://resource.contoso.com" });
18361887
Office.DialogOptions#height:member:
18371888
- |-
18381889
// The following example shows how to open a dialog with a specified size. It also shows

docs/docs-ref-autogen/office/office/office.context.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ remarks: >-
2323
</strong></td><td> Not supported </td><td> Supported </td><td> Supported </td><td> Not supported </td><td> Not
2424
applicable </td></tr> <tr><td><strong> Word </strong></td><td> Supported </td><td> Supported </td><td> Supported
2525
</td><td> Supported </td><td> Not applicable </td></tr> </table>
26+
27+
28+
#### Examples
29+
30+
31+
```TypeScript
32+
33+
// Get the Office host, version, and platform in which the add-in is running.
34+
35+
const contextInfo = Office.context.diagnostics;
36+
37+
console.log("Office application: " + contextInfo.host);
38+
39+
console.log("Office version: " + contextInfo.version);
40+
41+
console.log("Platform: " + contextInfo.platform);
42+
43+
```
2644
isPreview: false
2745
isDeprecated: false
2846
type: interface
@@ -39,6 +57,24 @@ properties:
3957
content: 'auth: Auth;'
4058
return:
4159
type: '<xref uid="office!Office.Auth:interface" />'
60+
description: |-
61+
62+
63+
#### Examples
64+
65+
```TypeScript
66+
// Get an access token.
67+
const authContext = Office.context.auth;
68+
authContext.getAccessTokenAsync((result) => {
69+
if (result.status === Office.AsyncResultStatus.Failed) {
70+
console.log("Error obtaining token", result.error);
71+
return;
72+
}
73+
74+
const token = result.value;
75+
console.log(token);
76+
});
77+
```
4278
- name: commerceAllowed
4379
uid: 'office!Office.Context#commerceAllowed:member'
4480
package: office!

docs/docs-ref-autogen/office/office/office.dialog.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,45 @@ summary: >-
99
remarks: >-
1010
**Requirement set**:
1111
[DialogAPI](https://learn.microsoft.com/javascript/api/requirement-sets/common/dialog-api-requirement-sets)
12+
13+
14+
#### Examples
15+
16+
17+
```TypeScript
18+
19+
// The following example shows how to open a dialog with a specified size. It also shows
20+
21+
// how to register a function to handle the message when Office.UI.messageParent() is called
22+
23+
// in the dialog and how to use that handler to close the dialog.
24+
25+
26+
Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
27+
(asyncResult) => {
28+
const dialog = asyncResult.value;
29+
dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
30+
dialog.close();
31+
// Do something to process the message.
32+
});
33+
}
34+
);
35+
36+
37+
// The following example does the same thing in TypeScript.
38+
39+
40+
Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
41+
(asyncResult: Office.AsyncResult) => {
42+
const dialog: Office.Dialog = asyncResult.value;
43+
dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg: string) => {
44+
dialog.close();
45+
// Do something to process the message.
46+
});
47+
}
48+
);
49+
50+
```
1251
isPreview: false
1352
isDeprecated: false
1453
type: interface

docs/docs-ref-autogen/office/office/office.dialogmessageoptions.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@ properties:
2525
content: 'targetOrigin: string;'
2626
return:
2727
type: string
28+
description: |-
29+
30+
31+
#### Examples
32+
33+
```TypeScript
34+
// The following example shows how to send a message to the domain of the parent runtime.
35+
Office.context.ui.messageParent("Some message", { targetOrigin: "https://resource.contoso.com" });
36+
```

docs/docs-ref-autogen/office/office/office.ui.yml

Lines changed: 32 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ uid: 'office!Office.UI:interface'
44
package: office!
55
fullName: Office.UI
66
summary: >-
7-
Provides objects and methods that you can use to create and manipulate UI components, such as dialog boxes, in your
8-
Office Add-ins.
7+
Provides objects and methods to create and manipulate UI components, such as dialog boxes, in your Office Add-ins.
98
109
11-
Visit "[Use the Dialog API in your Office
12-
Add-ins](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-api-in-office-add-ins)<!-- -->" for more
13-
information.
10+
For guidance on how to configure dialog boxes, see [Use the Dialog API in your Office
11+
Add-ins](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-api-in-office-add-ins)<!-- -->.
1412
remarks: |-
1513
1614
@@ -210,62 +208,31 @@ methods:
210208
365](https://learn.microsoft.com/office/dev/add-ins/develop/unified-manifest-overview)<!-- -->.
211209
212210
213-
The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial
214-
page loads, you can go to other domains.
215-
216-
217-
Any page calling `Office.context.ui.messageParent` must also be on the same domain as the parent page.
218-
219-
220-
**Design considerations**:
221-
222-
223-
The following design considerations apply to dialog boxes.
224-
225-
226-
- An Office Add-in task pane can have only one dialog box open at any time. Multiple dialogs can be open at the
227-
same time from Add-in Commands (custom ribbon buttons or menu items).
228-
229-
230-
- Every dialog box can be moved and resized by the user.
211+
**Important**:
231212
232213
233-
- Every dialog box is centered on the screen when opened.
234-
235-
236-
- Dialog boxes appear on top of the application and in the order in which they were created.
237-
238-
239-
Use a dialog box to:
240-
241-
242-
- Display authentication pages to collect user credentials.
243-
244-
245-
- Display an error/progress/input screen from a ShowTaskpane or ExecuteAction command.
214+
- The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial
215+
page loads, you can go to other domains.
246216
247217
248-
- Temporarily increase the surface area that a user has available to complete a task.
218+
- Any page calling `Office.context.ui.messageParent` must also be on the same domain as the parent page.
249219
250220
251-
Do not use a dialog box to interact with a document. Use a task pane instead.
221+
- To learn about rules, limitations, and best practices for the Office Dialog API, see [Best practices and rules
222+
for the Office dialog API](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-best-practices)<!-- -->.
252223
253224
254-
**displayDialogAsync Errors**
225+
- For information on errors and how to handle them, see [Handle errors and events in the Office dialog
226+
box](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-handle-errors-events)<!-- -->.
255227
256228
257-
<table> <tr> <th>Code number</th> <th>Meaning</th> </tr> <tr> <td>12004</td> <td>The domain of the URL passed to
258-
displayDialogAsync isn't trusted. The domain must be either the same domain as the host page (including protocol
259-
and port number), or it must be registered in the <code>AppDomains</code> section of the add-in manifest.</td>
260-
</tr> <tr> <td>12005</td> <td>The URL passed to displayDialogAsync uses the HTTP protocol. HTTPS is required. (In
261-
some versions of Office, the error message returned with 12005 is the same one returned for 12004.)</td> </tr>
262-
<tr> <td>12007</td> <td>A dialog box is already opened from the task pane. A task pane add-in can only have one
263-
dialog box open at a time.</td> </tr> <tr> <td>12009</td> <td>The user chose to ignore the dialog box. This error
264-
can occur in online versions of Office, where users may choose not to allow an add-in to present a dialog.</td>
265-
</tr> </table>
229+
- In Outlook on the web and new Outlook on Windows, don't set the
230+
[window.name](https://developer.mozilla.org/docs/Web/API/Window/name) property when configuring a dialog in your
231+
add-in. The `window.name` property is used by these Outlook clients to maintain functionality across page
232+
redirects.
266233
267234
268-
In the callback function passed to the displayDialogAsync method, you can use the properties of the AsyncResult
235+
- In the callback function passed to the displayDialogAsync method, you can use the properties of the AsyncResult
269236
object to return the following information.
270237
271238
@@ -365,62 +332,31 @@ methods:
365332
365](https://learn.microsoft.com/office/dev/add-ins/develop/unified-manifest-overview)<!-- -->.
366333
367334
368-
The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial
369-
page loads, you can go to other domains.
335+
**Important**:
370336
371337
372-
Any page calling `Office.context.ui.messageParent` must also be on the same domain as the parent page.
373-
374-
375-
**Design considerations**:
376-
377-
378-
The following design considerations apply to dialog boxes.
379-
380-
381-
- An Office Add-in task pane can have only one dialog box open at any time. Multiple dialogs can be open at the
382-
same time from Add-in Commands (custom ribbon buttons or menu items).
383-
384-
385-
- Every dialog box can be moved and resized by the user.
386-
387-
388-
- Every dialog box is centered on the screen when opened.
389-
390-
391-
- Dialog boxes appear on top of the application and in the order in which they were created.
392-
393-
394-
Use a dialog box to:
395-
396-
397-
- Display authentication pages to collect user credentials.
398-
399-
400-
- Display an error/progress/input screen from a ShowTaskpane or ExecuteAction command.
338+
- The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial
339+
page loads, you can go to other domains.
401340
402341
403-
- Temporarily increase the surface area that a user has available to complete a task.
342+
- Any page calling `Office.context.ui.messageParent` must also be on the same domain as the parent page.
404343
405344
406-
Do not use a dialog box to interact with a document. Use a task pane instead.
345+
- To learn about rules, limitations, and best practices for the Office Dialog API, see [Best practices and rules
346+
for the Office dialog API](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-best-practices)<!-- -->.
407347
408348
409-
**displayDialogAsync Errors**
349+
- For information on errors and how to handle them, see [Handle errors and events in the Office dialog
350+
box](https://learn.microsoft.com/office/dev/add-ins/develop/dialog-handle-errors-events)<!-- -->.
410351
411352
412-
<table> <tr> <th>Code number</th> <th>Meaning</th> </tr> <tr> <td>12004</td> <td>The domain of the URL passed to
413-
displayDialogAsync isn't trusted. The domain must be either the same domain as the host page (including protocol
414-
and port number), or it must be registered in the <code>AppDomains</code> section of the add-in manifest.</td>
415-
</tr> <tr> <td>12005</td> <td>The URL passed to displayDialogAsync uses the HTTP protocol. HTTPS is required. (In
416-
some versions of Office, the error message returned with 12005 is the same one returned for 12004.)</td> </tr>
417-
<tr> <td>12007</td> <td>A dialog box is already opened from the task pane. A task pane add-in can only have one
418-
dialog box open at a time.</td> </tr> <tr> <td>12009</td> <td>The user chose to ignore the dialog box. This error
419-
can occur in online versions of Office, where users may choose not to allow an add-in to present a dialog.</td>
420-
</tr> </table>
353+
- In Outlook on the web and new Outlook on Windows, don't set the
354+
[window.name](https://developer.mozilla.org/docs/Web/API/Window/name) property when configuring a dialog in your
355+
add-in. The `window.name` property is used by these Outlook clients to maintain functionality across page
356+
redirects.
421357
422358
423-
In the callback function passed to the displayDialogAsync method, you can use the properties of the AsyncResult
359+
- In the callback function passed to the displayDialogAsync method, you can use the properties of the AsyncResult
424360
object to return the following information.
425361
426362
@@ -533,7 +469,9 @@ methods:
533469
content: 'openBrowserWindow(url: string): void;'
534470
parameters:
535471
- id: url
536-
description: 'The full URL to be opened including protocol (e.g., https), and port number, if any.'
472+
description: >-
473+
The full URL to be opened including protocol (http or https), and port number, if any. Other protocols like
474+
mailto aren't supported.
537475
type: string
538476
return:
539477
type: void

docs/docs-ref-autogen/office_release/office/office.context.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ remarks: >-
2323
</strong></td><td> Not supported </td><td> Supported </td><td> Supported </td><td> Not supported </td><td> Not
2424
applicable </td></tr> <tr><td><strong> Word </strong></td><td> Supported </td><td> Supported </td><td> Supported
2525
</td><td> Supported </td><td> Not applicable </td></tr> </table>
26+
27+
28+
#### Examples
29+
30+
31+
```TypeScript
32+
33+
// Get the Office host, version, and platform in which the add-in is running.
34+
35+
const contextInfo = Office.context.diagnostics;
36+
37+
console.log("Office application: " + contextInfo.host);
38+
39+
console.log("Office version: " + contextInfo.version);
40+
41+
console.log("Platform: " + contextInfo.platform);
42+
43+
```
2644
isPreview: false
2745
isDeprecated: false
2846
type: interface

0 commit comments

Comments
 (0)