Skip to content

Commit 8fdfc42

Browse files
[office-js][office-js-preview] (Common) Document Context Menu API (DefinitelyTyped#71671)
1 parent 0d9acac commit 8fdfc42

File tree

2 files changed

+132
-6
lines changed

2 files changed

+132
-6
lines changed

types/office-js-preview/index.d.ts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ declare namespace Office {
241241
* Represents the Auth interface.
242242
*/
243243
const auth: Auth;
244+
/**
245+
* Represents the context menu object associated with the Office application.
246+
*/
247+
const contextMenu: ContextMenu;
244248
/**
245249
* Represents the Device Permission interface.
246250
*/
@@ -4796,12 +4800,71 @@ declare namespace Office {
47964800
*/
47974801
version: string;
47984802
}
4803+
/**
4804+
* Provides options to manage the state of the Office context menu.
4805+
*
4806+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4807+
*
4808+
* @remarks
4809+
*
4810+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4811+
*/
4812+
interface ContextMenu {
4813+
/**
4814+
* Sends a request to Office to update the context menu.
4815+
*
4816+
* @remarks
4817+
*
4818+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4819+
*
4820+
* **Important**: This API is only used to request an update. The actual UI update to the context menu is controlled by the Office application,
4821+
* so the exact timing of the context menu update (or refresh) can't be determined by the completion of this API.
4822+
*
4823+
* @param input - Represents the updates to be made to the context menu controls. Only the changes specified in the `control` parameter are made.
4824+
* Other context menu controls that aren't specified remain as is in the Office application.
4825+
*/
4826+
requestUpdate(input: ContextMenuUpdaterData): Promise<void>;
4827+
}
4828+
/**
4829+
* Represents an individual context menu control and its state.
4830+
*
4831+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4832+
*
4833+
* @remarks
4834+
*
4835+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4836+
*/
4837+
interface ContextMenuControl {
4838+
/**
4839+
* Identifier of the context menu control as specified in the manifest.
4840+
*/
4841+
id: string;
4842+
/**
4843+
* Indicates whether the control is available on the context menu.
4844+
*/
4845+
enabled?: boolean;
4846+
}
4847+
/**
4848+
* Represents the changes to the context menu.
4849+
*
4850+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4851+
*
4852+
* @remarks
4853+
*
4854+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4855+
*/
4856+
interface ContextMenuUpdaterData {
4857+
/**
4858+
* Collection of context menu controls whose state is set using `Office.contextMenu.requestUpdate`.
4859+
*/
4860+
controls: ContextMenuControl[];
4861+
}
47994862
/**
48004863
* Represents an individual control or command and the state it should have.
48014864
*
48024865
* @remarks
48034866
*
4804-
* For code samples showing how to use a `Control` object and its properties, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
4867+
* For code samples showing how to use a `Control` object and its properties, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
48054868
*
48064869
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/ribbon-api-requirement-sets | RibbonApi 1.1}
48074870
*/
@@ -7241,7 +7304,7 @@ declare namespace Office {
72417304
*
72427305
* Note that this API is only to request an update. The actual UI update to the ribbon is controlled by the Office application and hence the exact timing of the ribbon update (or refresh) cannot be determined by the completion of this API.
72437306
*
7244-
* For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
7307+
* For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
72457308
*
72467309
* @param input - Represents the updates to be made to the ribbon. Note that only the changes specified in the input parameter are made.
72477310
*/
@@ -7788,7 +7851,7 @@ declare namespace Office {
77887851
size: number;
77897852
}
77907853
/**
7791-
* Represents an individual tab and the state it should have. For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
7854+
* Represents an individual tab and the state it should have. For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
77927855
*
77937856
* @remarks
77947857
*

types/office-js/index.d.ts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ declare namespace Office {
241241
* Represents the Auth interface.
242242
*/
243243
const auth: Auth;
244+
/**
245+
* Represents the context menu object associated with the Office application.
246+
*/
247+
const contextMenu: ContextMenu;
244248
/**
245249
* Represents the Device Permission interface.
246250
*/
@@ -4744,12 +4748,71 @@ declare namespace Office {
47444748
*/
47454749
version: string;
47464750
}
4751+
/**
4752+
* Provides options to manage the state of the Office context menu.
4753+
*
4754+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4755+
*
4756+
* @remarks
4757+
*
4758+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4759+
*/
4760+
interface ContextMenu {
4761+
/**
4762+
* Sends a request to Office to update the context menu.
4763+
*
4764+
* @remarks
4765+
*
4766+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4767+
*
4768+
* **Important**: This API is only used to request an update. The actual UI update to the context menu is controlled by the Office application,
4769+
* so the exact timing of the context menu update (or refresh) can't be determined by the completion of this API.
4770+
*
4771+
* @param input - Represents the updates to be made to the context menu controls. Only the changes specified in the `control` parameter are made.
4772+
* Other context menu controls that aren't specified remain as is in the Office application.
4773+
*/
4774+
requestUpdate(input: ContextMenuUpdaterData): Promise<void>;
4775+
}
4776+
/**
4777+
* Represents an individual context menu control and its state.
4778+
*
4779+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4780+
*
4781+
* @remarks
4782+
*
4783+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4784+
*/
4785+
interface ContextMenuControl {
4786+
/**
4787+
* Identifier of the context menu control as specified in the manifest.
4788+
*/
4789+
id: string;
4790+
/**
4791+
* Indicates whether the control is available on the context menu.
4792+
*/
4793+
enabled?: boolean;
4794+
}
4795+
/**
4796+
* Represents the changes to the context menu.
4797+
*
4798+
* To learn more, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands}.
4799+
*
4800+
* @remarks
4801+
*
4802+
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/context-menu-api-requirement-sets | ContextMenuApi 1.1}
4803+
*/
4804+
interface ContextMenuUpdaterData {
4805+
/**
4806+
* Collection of context menu controls whose state is set using `Office.contextMenu.requestUpdate`.
4807+
*/
4808+
controls: ContextMenuControl[];
4809+
}
47474810
/**
47484811
* Represents an individual control or command and the state it should have.
47494812
*
47504813
* @remarks
47514814
*
4752-
* For code samples showing how to use a `Control` object and its properties, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
4815+
* For code samples showing how to use a `Control` object and its properties, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
47534816
*
47544817
* **Requirement set**: {@link https://learn.microsoft.com/javascript/api/requirement-sets/common/ribbon-api-requirement-sets | RibbonApi 1.1}
47554818
*/
@@ -7189,7 +7252,7 @@ declare namespace Office {
71897252
*
71907253
* Note that this API is only to request an update. The actual UI update to the ribbon is controlled by the Office application and hence the exact timing of the ribbon update (or refresh) cannot be determined by the completion of this API.
71917254
*
7192-
* For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
7255+
* For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
71937256
*
71947257
* @param input - Represents the updates to be made to the ribbon. Note that only the changes specified in the input parameter are made.
71957258
*/
@@ -7736,7 +7799,7 @@ declare namespace Office {
77367799
size: number;
77377800
}
77387801
/**
7739-
* Represents an individual tab and the state it should have. For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Enable and Disable Add-in Commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
7802+
* Represents an individual tab and the state it should have. For code examples, see {@link https://learn.microsoft.com/office/dev/add-ins/design/disable-add-in-commands | Change the availability of add-in commands} and {@link https://learn.microsoft.com/office/dev/add-ins/design/contextual-tabs | Create custom contextual tabs}.
77407803
*
77417804
* @remarks
77427805
*

0 commit comments

Comments
 (0)