我正在尝试通过功能区按钮打开一个对话框。
我在MessageComposeCommandSurface中添加了一个功能区按钮Engagement,它将在功能文件中执行功能以打开对话框
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>d52ea32e-267b-422c-85be-72fabbf1f5c9</Id>
<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>1.0.0.0</Version>
<ProviderName>APP</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="Appliaction " />
<Description DefaultValue="Application Description"/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="https://localhost:44340/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://localhost:44340/assets/hi-res-icon.png"/>
<!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
<SupportUrl DefaultValue="http://support.contoso.com" />
<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
<AppDomain>https://localhost:44340</AppDomain>
<AppDomain>https://appsforoffice.microsoft.com</AppDomain>
<AppDomain>https://ajax.aspnetcdn.com</AppDomain>
</AppDomains>
<!--End Basic Settings. -->
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:44340/"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox" />
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
<FunctionFile resid="functionFile" />
<!-- Message Compose -->
<ExtensionPoint xsi:type="MessageComposeCommandSurface">
<OfficeTab id="TabDefault">
<Group id ="msgComposeGroup">
<Label resid="groupLabel"/>
<Control xsi:type="Button" id="msgComposeOpenPane">
<Label resid="paneComposeButtonLabel"/>
<Supertip>
<Title resid="paneComposeSuperTipTitle" />
<Description resid="paneComposeSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16" />
<bt:Image size="32" resid="icon32" />
<bt:Image size="80" resid="icon80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>openEngagementDiag</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
<!-- Message Read -->
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
<OfficeTab id="TabDefault">
<!-- Up to 6 Groups added per Tab -->
<Group id="msgReadGroup">
<Label resid="groupLabel" />
<!-- Launch the add-in : task pane button -->
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="paneReadButtonLabel" />
<Supertip>
<Title resid="paneReadSuperTipTitle" />
<Description resid="paneReadSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16" />
<bt:Image size="32" resid="icon32" />
<bt:Image size="80" resid="icon80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="messageReadTaskPaneUrl" />
</Action>
</Control>
<!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
</Group>
</OfficeTab>
</ExtensionPoint>
<!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="icon16" DefaultValue="https://localhost:44340/assets/app-16.png"/>
<bt:Image id="icon32" DefaultValue="https://localhost:44340/assets/app-32.png"/>
<bt:Image id="icon80" DefaultValue="https://localhost:44340/assets/app-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="functionFile" DefaultValue="https://localhost:44340/Function-File/function-file.html"/>
<bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:44340/Home/ReadPane"/>
<bt:Url id="messageComposeTaskPaneUrl" DefaultValue="https://localhost:44340/Home/Compose"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="groupLabel" DefaultValue="Sample Label"/>
<bt:String id="customTabLabel" DefaultValue="Application"/>
<bt:String id="paneReadButtonLabel" DefaultValue="Engagement"/>
<bt:String id="paneReadSuperTipTitle" DefaultValue="Map to Engagement"/>
<bt:String id="paneComposeSuperTipTitle" DefaultValue="Map to Engagement"/>
<bt:String id="paneComposeButtonLabel" DefaultValue="Engagement"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="paneReadSuperTipDescription" DefaultValue="Opens a pane displaying current engagement"/>
<bt:String id="paneComposeSuperTipDescription" DefaultValue="Opens a pane displaying current engagement"/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
以下是定义的功能文件。
declare var Office;
(() => {
// The initialize function must be run each time a new page is loaded
Office.initialize = () => {
console.log("Hello World")
};
function openEngagementDiag(){
Office.context.ui.displayDialogAsync(
'https://localhost:4200/#/MessageCompose',
{height: 30, width: 20},
function(asyncResult){
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
let errorMessage = null;
switch (asyncResult.error.code) {
case 12004:
errorMessage = 'Domain is not trusted';
break;
case 12005:
errorMessage = 'HTTPS is required';
break;
case 12007:
errorMessage = 'A dialog is already opened.';
break;
default:
errorMessage = asyncResult.error.message;
break;
}
}
else {
}
});
}
})();
将显示功能区按钮,单击它时,将显示一个信息栏,如下所示,指示“ TestApp正在处理请求”,表明幕后发生了某些事情
我在这里做错了什么?
编辑:我的Outlook Web外接程序项目是使用angular v6.x的SPA
答案 0 :(得分:0)
这可能会或可能不会为您做到,但是根据我最近使用Word加载项的经验,机会很大。在您的处理函数中添加一个event
参数,并确保通过调用其completed
方法来表示事件已完成。
function openEngagementDiag(event) {
// ...
event.completed();
}
我希望这会有所帮助。