如何将模型从 Word 2016 传递到 Office 365 Dialog? [英] 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 请求,以便对话与其主持人之间更好地沟通:https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/17196659-improve-custom-dialog
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 Dialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!