我有两个问题。
action有点击事件吗?我有一个简单的操作,如下所示: 如果用户单击该操作,我想运行一些打字稿代码,这可能吗?这些操作是否有事件处理程序?
从那个点击我可以打开作为我的插件一部分的任务窗格吗?我试过使用
Office.addin.showAsTaskpane()
但我没有运气触发任务窗格。我一直在 github 上关注这个问题,但即便如此,除了单击用于切换任务窗格的功能区按钮之外,我还没有成功地以任何其他方式打开我的任务窗格。
我尝试将
Office.addin.ShowAsTaskpane()
移动到我的 commands.ts
的几个区域。我已经在onRready()
以及我的event.complete()
之前和之后尝试过我的commands.ts
的完整代码如下:
Office.onReady(() => {
Office.addin.showAsTaskpane().then();
});
/**
* Shows a notification when the add-in command is executed.
* @param event
*/
function action(event: Office.AddinCommands.Event) {
const message: Office.NotificationMessageDetails = {
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Performed action. - Click",
icon: "Icon.80x80",
persistent: true,
};
// Show a notification message
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
// Be sure to indicate when the add-in command function is complete
event.completed();
Office.addin.showAsTaskpane().then();
}
function getGlobal() {
return typeof self !== "undefined"
? self
: typeof window !== "undefined"
? window
: typeof global !== "undefined"
? global
: undefined;
}
const g = getGlobal() as any;
// The add-in command functions need to be available in global scope
g.action = action;
看起来你正在寻找的是 InsightMessage 类型的通知。请参阅https://learn.microsoft.com/en-us/javascript/api/outlook/office.notificationmessageaction?view=outlook-js-preview