如何将模型从Word 2016传递到Office 365对话框? [英] How to pass model to Office 365 Dialog from Word 2016?
问题描述
我正在使用MS Word的Office 365加载项.我有一个对话框来操纵所选的单词图像.我需要将该图像(可能是该图像的Base64值)传递到对话框中,以便在替换回单词(相同位置)之前可以使用该图像.
I was playing with Office 365 add-in for MS word. I have a dialog to manipulate selected word image. I need to pass that image (maybe a Base64 value of that) to my dialog so that I can play with the image before replacing back to the word(same location).
我正在使用以下代码显示弹出窗口:
I am using below code to show the popup:
Office.context.ui.displayDialogAsync("https://" + location.host + "/Views/ImageManager.html", { width: 64, height: 55, requireHTTPS: true }, function (asyncResult) {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
return;
}
});
我想做什么?
当用户选择一个图像与Word文档中的图像一起播放并单击功能区按钮以打开此对话框时,我需要将该图像传递到对话框中以在对话框中显示.
When the user selects an image to play with that in a word document and click ribbon button to open this dialog, I need to pass that image to the dialog to show in the dialog.
如何将我的图像模型传递给对话框?
How can I pass my Image model to the dialog?
推荐答案
至少有两种方法可以将内容传递给对话框:
There are at least two ways to pass things to the dialog:
- 将其作为查询参数传递到您传递给displayDialogAsync()的URL上
- 将其存储在宿主脚本的window.localStorage中,然后在对话框页面的脚本中从那里检索它.
更新:您可以投票赞成该Office Dev User Voice请求,以便在对话框与其主机之间进行更好的通信:
UPDATE: You can vote up this Office Dev User Voice request for better communication between the dialog and its host: https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/17196659-improve-custom-dialog
这篇关于如何将模型从Word 2016传递到Office 365对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!