[英]Communicate between Office taskpane and content addin
I am working on a taskpane addin and a content addin for Powerpoint.我正在为 Powerpoint 开发任务窗格插件和内容插件。 I want to have the possibility to manipulate the content of the content addin through the taskpane addin, eg pushing a button in the taskpane addin to change an image or other web content in the content addin on the selected slide.
我希望有可能通过任务面板插件来操作内容插件的内容,例如按下任务面板插件中的按钮以更改所选幻灯片上内容插件中的图像或其他 web 内容。
I can host both addins within the same React project, but I don't have the possibility to communicate between them in powerpoint to my knowledge.我可以在同一个 React 项目中托管两个插件,但据我所知,我无法在 powerpoint 中在它们之间进行通信。
If the two add-ins are both hosted on the exact same domain, you could try using LocalStorage as a go-between.如果这两个加载项都托管在完全相同的域中,您可以尝试使用 LocalStorage 作为中间人。 Your task pane stores a signal in a specific key of LocalStorage.
您的任务窗格将信号存储在 LocalStorage 的特定键中。 Your content add-in must be setup to periodically check that key for changes and then respond accordingly.
您的内容加载项必须设置为定期检查该密钥的更改,然后做出相应的响应。 I haven't tried this, but it might work.
我没有尝试过这个,但它可能会起作用。
This is a well-known and solved problem - you're looking for communication between windows or tabs.这是一个众所周知且已解决的问题 - 您正在寻找 windows 或选项卡之间的通信。
Check out here: Communication between tabs or windows在这里查看: 选项卡之间的通信或 windows
In your apps, at the initialization part, you have to register the event listener for storage.在您的应用程序中,在初始化部分,您必须注册事件侦听器以进行存储。
window.addEventListener('storage', () => {
console.log('your local storage has changed');
});
and based on the received event payload, you can manipulate data.并且基于接收到的事件负载,您可以操作数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.