Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[All Hosts] (manifest) account for unified manifest in UX/UI articles #4757

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
8 changes: 7 additions & 1 deletion docs/design/add-in-icons-fresh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Fresh style icon guidelines for Office Add-ins
description: Guidelines for using Fresh style icons in Office Add-ins.
ms.date: 08/18/2023
ms.date: 09/19/2024
ms.topic: best-practice
ms.localizationpriority: medium
---
Expand Down Expand Up @@ -128,6 +128,12 @@ Office icons are designed to render well in high contrast modes. Foreground elem

## See also

### Unified manifest reference

- ["extensions.ribbons" array](/microsoftteams/platform/resources/schema/manifest-schema#extensionsribbons)

### Add-in only manifest reference

- [Icon manifest element](/javascript/api/manifest/icon)
- [IconUrl manifest element](/javascript/api/manifest/iconurl)
- [HighResolutionIconUrl manifest element](/javascript/api/manifest/highresolutioniconurl)
Expand Down
8 changes: 7 additions & 1 deletion docs/design/add-in-icons-monoline.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Monoline style icon guidelines for Office Add-ins
description: Guidelines for using Monoline style icons in Office Add-ins.
ms.date: 08/18/2023
ms.date: 09/19/2024
ms.topic: best-practice
ms.localizationpriority: medium
---
Expand Down Expand Up @@ -205,6 +205,12 @@ The final icons should be saved as .png image files. Use PNG format with a trans

## See also

### Unified manifest reference

- ["extensions.ribbons" array](/microsoftteams/platform/resources/schema/manifest-schema#extensionsribbons)

### Add-in only manifest reference

- [Icon manifest element](/javascript/api/manifest/icon)
- [IconUrl manifest element](/javascript/api/manifest/iconurl)
- [HighResolutionIconUrl manifest element](/javascript/api/manifest/highresolutioniconurl)
Expand Down
88 changes: 86 additions & 2 deletions docs/design/built-in-button-integration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Integrate built-in Office buttons into custom control groups and tabs
description: Learn how to include built-in Office buttons in your custom command groups and tabs on the Office ribbon.
ms.date: 06/26/2024
ms.date: 09/19/2024
ms.topic: how-to
ms.localizationpriority: medium
---
Expand All @@ -17,6 +17,88 @@ You can insert built-in Office buttons into your custom control groups on the Of
> [!IMPORTANT]
> The add-in feature described in this article is only available in **PowerPoint** on the web, on Windows, and on Mac.

Open the tab for the type of manifest your add-in uses for the details of the manifest markup.

# [Unified manifest for Microsoft 365](#tab/jsonmanifest)

[!include[Unified manifest host application support note](../includes/unified-manifest-support-note.md)]

## Insert a built-in control group into a custom tab

To insert a built-in Office control group into a custom tab, add a group object with a "builtInGroupId" property *instead of an "id" property* to the "groups" array of your custom tab object. Set to the ID of the built-in group. See [Find the IDs of controls and control groups](#find-the-ids-of-controls-and-control-groups). *The built-in group object should have no other properties.*
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved

The following example adds the Office Paragraph control group to a custom tab.


```json
"extensions": [
...
{
...
"ribbons": [
...
{
...
"tabs": [
{
"id": "MyTab",
...
"groups": [
... // Optionally, other groups in the tab
{
"builtInGroupId": "Paragraph"
},
... // Optionally, other groups in the tab
]
}
]
}
]
}
]
```

## Insert a built-in control into a custom group

To insert a built-in Office control into a custom group, add a control object with a "builtInControlId" property *instead of an "id" property* to the "controls" array of your custom group object. Set to the ID of the built-in control. See [Find the IDs of controls and control groups](#find-the-ids-of-controls-and-control-groups). *The built-in control object should have no other properties.*
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved

The following example adds the Office Superscript control to a custom group.

```json
"extensions": [
...
{
...
"ribbons": [
...
{
...
"tabs": [
{
...
"groups": [
{
"id": "MyGroup",
...
"controls": [
... // Optionally, other controls in the group
{
"builtInControlId": "Superscript"
},
... // Optionally, other controls in the group
]
}
]
}
]
}
]
}
]
```

# [Add-in only manifest](#tab/xmlmanifest)

## Insert a built-in control group into a custom tab

To insert a built-in Office control group into a tab, add an [OfficeGroup](/javascript/api/manifest/customtab#officegroup) element as a child element in the parent **\<CustomTab\>** element. The `id` attribute of the of the **\<OfficeGroup\>** element is set to the ID of the built-in group. See [Find the IDs of controls and control groups](#find-the-ids-of-controls-and-control-groups).
Expand Down Expand Up @@ -62,6 +144,8 @@ The following markup example adds the Office Superscript control to a custom gro
</ExtensionPoint>
```

---

> [!NOTE]
> Users can customize the ribbon in the Office application. Any user customizations will override your manifest settings. For example, a user can remove a button from any group and remove any group from a tab.

Expand All @@ -71,4 +155,4 @@ The IDs for supported controls and control groups are in files in the repo [Offi

## Behavior on unsupported platforms

If your add-in is installed on a platform that doesn't support [requirement set AddinCommands 1.3](/javascript/api/requirement-sets/common/add-in-commands-requirement-sets), then the markup described in this article is ignored and the built-in Office controls/groups won't appear in your custom groups/tabs. To prevent your add-in from being installed on platforms that don't support the markup, add a reference to the requirement set in the **\<Requirements\>** section of the manifest. For instructions, see [Specify which Office versions and platforms can host your add-in](../develop/specify-office-hosts-and-api-requirements.md#specify-which-office-versions-and-platforms-can-host-your-add-in). Alternatively, design your add-in to have an experience when **AddinCommands 1.3** isn't supported, as described in [Design for alternate experiences](../develop/specify-office-hosts-and-api-requirements.md#design-for-alternate-experiences). For example, if your add-in contains instructions that assume the built-in buttons are in your custom groups, you could design a version that assumes that the built-in buttons are only in their usual places.
If your add-in is installed on a platform that doesn't support [requirement set AddinCommands 1.3](/javascript/api/requirement-sets/common/add-in-commands-requirement-sets), then the markup described in this article is ignored and the built-in Office controls/groups won't appear in your custom groups/tabs. To prevent your add-in from being installed on platforms that don't support the markup, you must specify **AddinCommands 1.3** in the manifest as a requirement for installation. For instructions, see [Specify which Office versions and platforms can host your add-in](../develop/specify-office-hosts-and-api-requirements.md#specify-which-office-versions-and-platforms-can-host-your-add-in). Alternatively, design your add-in to have an experience when **AddinCommands 1.3** isn't supported, as described in [Design for alternate experiences](../develop/specify-office-hosts-and-api-requirements.md#design-for-alternate-experiences). For example, if your add-in contains instructions that assume the built-in buttons are in your custom groups, you could design a version that assumes that the built-in buttons are only in their usual places.
64 changes: 56 additions & 8 deletions docs/design/contextual-tabs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Create custom contextual tabs in Office Add-ins
description: Learn how to add custom contextual tabs to your Office Add-in.
ms.date: 08/21/2024
ms.date: 09/19/2024
ms.topic: how-to
ms.localizationpriority: medium
---
Expand Down Expand Up @@ -60,9 +60,6 @@ Adding custom contextual tabs requires your add-in to use the [shared runtime](.

Unlike custom core tabs, which are defined with XML in the manifest, custom contextual tabs are defined at runtime with a JSON blob. Your code parses the blob into a JavaScript object, and then passes the object to the [Office.ribbon.requestCreateControls](/javascript/api/office/office.ribbon?view=common-js&preserve-view=true#office-office-ribbon-requestcreatecontrols-member(1)) method. Custom contextual tabs are only present in documents on which your add-in is currently running. This is different from custom core tabs which are added to the Office application ribbon when the add-in is installed and remain present when another document is opened. Also, the `requestCreateControls` method may be run only once in a session of your add-in. If it's called again, an error is thrown.
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> The structure of the JSON blob's properties and subproperties (and the key names) is roughly parallel to the structure of the [CustomTab](/javascript/api/manifest/customtab) element and its descendant elements in the manifest XML.

We'll construct an example of a contextual tabs JSON blob step-by-step. The full schema for the contextual tab JSON is at [dynamic-ribbon.schema.json](https://developer.microsoft.com/json-schemas/office-js/dynamic-ribbon.schema.json). If you're working in Visual Studio Code, you can use this file to get IntelliSense and to validate your JSON. For more information, see [Editing JSON with Visual Studio Code - JSON schemas and settings](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings).

1. Begin by creating a JSON string with two array properties named `actions` and `tabs`. The `actions` array is a specification of all the functions that can be executed by controls on the contextual tab. The `tabs` array defines one or more contextual tabs, *up to a maximum of 20*.
Expand Down Expand Up @@ -379,7 +376,7 @@ function myContextChanges() {

## Open a task pane from contextual tabs

To open your task pane from a button on a custom contextual tab, create an action in the JSON with a `type` of `ShowTaskpane`. Then define a button with the `actionId` property set to the `id` of the action. This opens the default task pane specified by the **\<Runtime\>** element in your manifest.
To open your task pane from a button on a custom contextual tab, create an action in the JSON with a `type` of `ShowTaskpane`. Then define a button with the `actionId` property set to the `id` of the action. This opens the default task pane specified in your manifest.

```json
`{
Expand Down Expand Up @@ -529,9 +526,58 @@ Some combinations of platform, Office application, and Office build don't suppor

#### Use noncontextual tabs or controls

There's a manifest element, [OverriddenByRibbonApi](/javascript/api/manifest/overriddenbyribbonapi), that's designed to create a fallback experience in an add-in that implements custom contextual tabs when the add-in is running on an application or platform that doesn't support custom contextual tabs.
The add-in's manifest provides a way to create a fallback experience in an add-in that implements custom contextual tabs when the add-in is running on an application or platform that doesn't support custom contextual tabs. The strategy is to define a custom core tab (that is, *noncontextual* custom tab) in the manifest that duplicates the ribbon customizations of the custom contextual tabs in your add-in. Then you use special manifest markup to enable the custom core tab to be visible all the time on platform and version combinations that don't support custom contextual tabs. The process depends on which type of manifest your add-in uses.

# [Unified manifest for Microsoft 365](#tab/jsonmanifest)

[!include[Unified manifest host application support note](../includes/unified-manifest-support-note.md)]

Begin by defining a custom core tab (that is, *noncontextual* custom tab) in the manifest that duplicates the ribbon customizations of the custom contextual tabs in your add-in. But add a "overriddenByRibbonApi" property to each of the control objects and menu items and set its value to "true". The effect of doing so is the following:
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved

- If the add-in runs on an application and platform that support custom contextual tabs, then the custom controls and menu items won't appear on the ribbon. Instead, the custom contextual tab will be created when the add-in calls the `requestCreateControls` method.
- If the add-in runs on an application or platform that *doesn't* support `requestCreateControls`, then the controls and menu items do appear on the custom core tab.

The following is an example. Note that "MyButton" will appear on the custom core tab only when custom contextual tabs aren't supported. But the parent group and custom core tab will appear regardless of whether custom contextual tabs are supported.
Rick-Kirkham marked this conversation as resolved.
Show resolved Hide resolved

```json
"extensions": [
...
{
...
"ribbons": [
...
{
...
"tabs": [
{
"id": "MyTab",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"id": "MyTab",
"id": "MyButton",

To match the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the description.

Actually, what I needed to do was add "id": "MyButton", to the child control object. Done that now.

"groups": [
{
...
"controls": [
{
...
"overriddenByRibbonApi": true
}
]
}
]
}
]
}
]
}
]
```

When a parent menu control is marked with `"overriddenByRibbonApi": true`, then it isn't visible, and all of its child markup is ignored when custom contextual tabs aren't supported. So, it doesn't matter if any of those child menu items have the "overriddenByRibbonApi" property or what its value is. The implication of this is that if a menu item must be visible in all contexts, then not only should it not be marked with `"overriddenByRibbonApi": true`, but *its ancestor menu control must also not be marked this way*.

> [!IMPORTANT]
> Don't mark *all* of the child items of a menu with `"overriddenByRibbonApi": true`. This is pointless if the parent element is marked with `"overriddenByRibbonApi": true` for reasons given in the preceding paragraph. Moreover, if you leave out the "overriddenByRibbonApi" property on the parent menu control (or set it to `false`), then the parent will appear regardless of whether custom contextual tabs are supported, but it will be empty when they are supported. So, if all the child elements shouldn't appear when custom contextual tabs are supported, mark the *parent* menu control with `"overriddenByRibbonApi": true`.

The simplest strategy for using this element is to define a custom core tab (that is, *noncontextual* custom tab) in the manifest that duplicates the ribbon customizations of the custom contextual tabs in your add-in. But you add `<OverriddenByRibbonApi>true</OverriddenByRibbonApi>` as the first child element of the duplicate [Group](/javascript/api/manifest/group), [Control](/javascript/api/manifest/control), and menu **\<Item\>** elements on the custom core tabs. The effect of doing so is the following:
# [Add-in only manifest](#tab/xmlmanifest)

Begin by defining a custom core tab (that is, *noncontextual* custom tab) in the manifest that duplicates the ribbon customizations of the custom contextual tabs in your add-in. But add an [OverriddenByRibbonApi](/javascript/api/manifest/overriddenbyribbonapi) element as the first child element of the duplicate [Group](/javascript/api/manifest/group), [Control](/javascript/api/manifest/control), and menu **\<Item\>** elements on the custom core tabs. The effect of doing so is the following:

- If the add-in runs on an application and platform that support custom contextual tabs, then the custom core groups and controls won't appear on the ribbon. Instead, the custom contextual tab will be created when the add-in calls the `requestCreateControls` method.
- If the add-in runs on an application or platform that *doesn't* support `requestCreateControls`, then the elements do appear on the custom core tab.
Expand Down Expand Up @@ -567,9 +613,11 @@ When a parent group, or menu is marked with `<OverriddenByRibbonApi>true</Overri
> [!IMPORTANT]
> Don't mark *all* of the child elements of a group or menu with `<OverriddenByRibbonApi>true</OverriddenByRibbonApi>`. This is pointless if the parent element is marked with `<OverriddenByRibbonApi>true</OverriddenByRibbonApi>` for reasons given in the preceding paragraph. Moreover, if you leave out the **\<OverriddenByRibbonApi\>** on the parent (or set it to `false`), then the parent will appear regardless of whether custom contextual tabs are supported, but it will be empty when they are supported. So, if all the child elements shouldn't appear when custom contextual tabs are supported, mark the parent with `<OverriddenByRibbonApi>true</OverriddenByRibbonApi>`.

---

#### Use APIs that show or hide a task pane in specified contexts

As an alternative to **\<OverriddenByRibbonApi\>**, your add-in can define a task pane with UI controls that duplicate the functionality of the controls on a custom contextual tab. Then use the [Office.addin.showAsTaskpane](/javascript/api/office/office.addin?view=common-js&preserve-view=true#office-office-addin-showastaskpane-member(1)) and [Office.addin.hide](/javascript/api/office/office.addin?view=common-js&preserve-view=true#office-office-addin-hide-member(1)) methods to show the task pane when the contextual tab would have been shown if it was supported. For details on how to use these methods, see [Show or hide the task pane of your Office Add-in](../develop/show-hide-add-in.md).
As an alternative to using the manifest, your add-in can define a task pane with UI controls that duplicate the functionality of the controls on a custom contextual tab. Then use the [Office.addin.showAsTaskpane](/javascript/api/office/office.addin?view=common-js&preserve-view=true#office-office-addin-showastaskpane-member(1)) and [Office.addin.hide](/javascript/api/office/office.addin?view=common-js&preserve-view=true#office-office-addin-hide-member(1)) methods to show the task pane when the contextual tab would have been shown if it was supported. For details on how to use these methods, see [Show or hide the task pane of your Office Add-in](../develop/show-hide-add-in.md).

### Handle the HostRestartNeeded error

Expand Down
Loading