Skip to content

Commit ca18769

Browse files
[All hosts] (dialog) Move modal dialog article (OfficeDev#4313)
* Resolve merge conflicts * link typo * Resolve merge conflicts * Transfer modal dialog article to excludes folder --------- Co-authored-by: Rick Kirkham <[email protected]>
1 parent 8ffc4d3 commit ca18769

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

docs/develop/dialog-api-in-office-add-ins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The dialog box always opens in the center of the screen. The user can move and r
2727

2828
The Office JavaScript APIs include a [Dialog](/javascript/api/office/office.dialog) object and two functions in the [Office.context.ui namespace](/javascript/api/office/office.ui).
2929

30-
To open a dialog box, your code, typically a page in a task pane, calls the [displayDialogAsync](/javascript/api/office/office.ui) method and passes to it the URL of the resource that you want to open. The page on which this method is called is known as the "host page". For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.
30+
To open a dialog box, your code, typically a page in a task pane, calls the [displayDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaydialogasync-member(1)) method and passes to it the URL of the resource that you want to open. The page on which this method is called is known as the "host page". For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.
3131

3232
The resource that is opened in the dialog box is usually a page, but it can be a controller method in an MVC application, a route, a web service method, or any other resource. In this article, 'page' or 'website' refers to the resource in the dialog box. The following code is a simple example.
3333

@@ -231,7 +231,7 @@ Office.context.ui.messageParent("Some message", { targetOrigin: "*" });
231231
> [!TIP]
232232
> The `DialogMessageOptions` parameter was added to the `messageParent` method as a required parameter in mid-2021. Older add-ins that send a cross-domain message with the method no longer work until they are updated to use the new parameter. Until the add-in is updated, *in Office on Windows only*, users and system administrators can enable those add-ins to continue working by specifying the trusted domains with a registry setting: **HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains**. To do this, create a file with a `.reg` extension, save it to the Windows computer, and then double-click it to run it. The following is an example of the contents of such a file.
233233
>
234-
> ```
234+
> ```properties
235235
> Windows Registry Editor Version 5.00
236236
>
237237
> [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains]
@@ -363,7 +363,7 @@ For example, your code could use the [Office.onReady or Office.initialize functi
363363
> [!TIP]
364364
> The `DialogMessageOptions` parameter was added to the `messageChild` method as a required parameter in mid-2021. Older add-ins that send a cross-domain message with the method no longer work until they are updated to use the new parameter. Until the add-in is updated, *in Office on Windows only*, users and system administrators can enable those add-ins to continue working by specifying the trusted domains with a registry setting: **HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains**. To do this, create a file with a `.reg` extension, save it to the Windows computer, and then double-click it to run it. The following is an example of the contents of such a file.
365365
>
366-
> ```
366+
> ```properties
367367
> Windows Registry Editor Version 5.00
368368
>
369369
> [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains]

docs/excludes/modal-dialog-tip.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- Add to https://learn.microsoft.com/office/dev/add-ins/develop/dialog-api-in-office-add-ins when modal dialog feature is deployed. -->
2+
3+
> [!TIP]
4+
> If the child dialog is the [preview modal dialog](modal-dialog.md), then a call of `messageChild` can't be triggered by user interaction with the add-in's task pane or add-in commands, because user interaction is blocked while the modal dialog is open. So, if your dialog use case requires messaging from the parent to the dialog, you will nearly always need to use the non-modal dialog API. However, calling `Office.context.ui.messageParent` in the dialog triggers the `DialogMessageReceived` event in the parent, and code in the handler for that event can call `messageChild`.

docs/excludes/modal-dialog.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Use the Office modal dialog API in your Office Add-ins
3+
description: Learn the basics of creating a modal dialog box in an Office Add-in.
4+
ms.date: 04/30/2022
5+
ms.topic: how-to
6+
ms.localizationpriority: medium
7+
---
8+
9+
# Use the Office modal dialog API in Office Add-ins (preview)
10+
11+
There's a *modal* dialog API available in preview. It shouldn't be used in production add-ins, but we encourage you to experiment with it.
12+
13+
[!INCLUDE [Information about using preview APIs](../includes/using-preview-apis-host.md)]
14+
15+
When the modal dialog is open, the user experiences the following behavior.
16+
17+
- The user can't interact with the Office document.
18+
- The user can't interact with Office application (for example, Excel or Word).
19+
- The user also can't interact with any other instances of the same Office application.
20+
- The user can't interact with the add-in's task pane, if any, or custom add-in commands, if any.
21+
- Event handlers registered by the add-in do run, but the only events that can occur are those that don't require user interaction with the document, the Office application, or the add-in, other than the dialog itself. For example, calling `Office.context.ui.messageParent` in the dialog triggers the `DialogMessageReceived` event in the parent.
22+
23+
Everything in the article [Use the Office dialog API in your Office Add-ins](dialog-api-in-office-add-ins.md), including the **Advanced topics and special scenarios** and **Next steps** sections (and the articles that are linked to in those sections), applies to the modal dialog as well as the non-modal dialog except that the method that opens the modal dialog is [Office.context.ui.displayModalDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaymodaldialogasync-member(1)) instead of [Office.context.ui.displayDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaydialogasync-member(1)). In all the code examples, and the add-in samples linked to in the **Samples** section, you can simply replace calls of `displayDialogAsync` with calls of `displayModalDialogAsync`.

0 commit comments

Comments
 (0)