🤖 Merge PR #48159 Adding definition for SharedRuntime API in office-js and adding office.actions.associate in office-js-preview by @madhavagrawal17

* Updating the Office-js with Addin API and office-js-preview with the acoffice.actions.associate APi.

* fixing the comments

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
This commit is contained in:
madhavagrawal17 2020-09-25 11:02:05 -07:00 committed by GitHub
parent 9e16ef768a
commit a0739729bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 1 deletions

View File

@ -330,6 +330,10 @@ declare namespace Office {
* @param useShortNamespace True to use the shortcut alias; otherwise false to disable it. The default is true.
*/
function useShortNamespace(useShortNamespace: boolean): void;
/**
* Provides a method for associating action names with functions that carry out an action.
*/
const actions: Actions;
/**
* Represents the add-in.
*/
@ -521,6 +525,15 @@ declare namespace Office {
*/
value: T;
}
/**
* Used to associate an action name to a function.
*/
interface Actions {
/**
* Function to associate a name with the action function.
*/
associate: (actionName: string, action: (arg?: any) => void) => void;
}
/**
* Message used in the `onVisibilityModeChanged` invocation.
*/

View File

@ -330,7 +330,37 @@ declare namespace Office {
* @param useShortNamespace True to use the shortcut alias; otherwise false to disable it. The default is true.
*/
function useShortNamespace(useShortNamespace: boolean): void;
/**
* Represents the add-in.
*/
const addin: Addin;
// Enumerations
/**
* Provides options to determine the startup behavior of the add-in upon next start-up.
*/
enum StartupBehavior {
/**
* The add-in does not load until opened by the user.
*/
none = 'None',
/**
* Load the add-in but do not show UI.
*/
load = 'Load',
}
/**
* Visibility mode of the add-in.
*/
enum VisibilityMode {
/**
* UI is Hidden
*/
hidden = 'Hidden',
/**
* Displayed as taskpane
*/
taskpane = 'Taskpane',
}
/**
* Specifies the result of an asynchronous call.
*
@ -481,7 +511,51 @@ declare namespace Office {
*/
value: T;
}
/**
* Message used in the `onVisibilityModeChanged` invocation.
*/
interface VisibilityModeChangedMessage {
/**
* Visibility changed state.
*/
visibilityMode: Office.VisibilityMode;
}
/**
* Function type to turn off the event.
*/
type RemoveEventListener = () => Promise<void>;
/**
* Represents add-in level functionality for operating or configuring various aspects of the add-in.
*/
interface Addin {
/**
* Sets the startup behavior for the add-in for when the document is opened next time.
* @param behavior - Specifies startup behavior of the add-in.
*/
setStartupBehavior(behavior: Office.StartupBehavior): Promise<void>;
/**
* Gets the current startup behavior for the add-in.
*/
getStartupBehavior(): Promise<Office.StartupBehavior>;
/**
* Shows the task pane associated with the add-in.
* @returns A promise that is resolved when the UI is shown.
*/
showAsTaskpane(): Promise<void>;
/**
* Hides the task pane.
* @returns A promise that is resolved when the UI is hidden.
*/
hide(): Promise<void>;
/**
* Adds a listener for the `onVisbilityModeChanged` event.
* @param listener - The listener function that is called when the event is emitted. This function takes in a message for the receiving component.
* @returns A promise that resolves when the listener is added.
*/
onVisibilityModeChanged(
listener: (message: VisibilityModeChangedMessage) => void,
): Promise<RemoveEventListener>;
}
/**
* An interface that contains all the functionality provided to manage the state of the Office ribbon.
*