英文:
How to open my plugin contents in a new tab in the Mattermost desktop app
问题
I'm developing a plugin for Mattermost which shows an iframe and the contents I need inside the iframe. Currently, I have managed to register this as a product, and now it shows in the product switcher.
When I click the Iframe button, it opens the Iframe in the same window as the channels. What I need is to open it in a new tab, similar to boards and playbooks in the Mattermost desktop app. In the web browser, it can remain as it is now.
Thank you for your support.
英文:
I’m developing a plugin for Mattermsot which shows an iframe and the contents I need inside the iframe, Currently, I have managed to register this as a product and now it shows in the product switcher,
When I click the Iframe button it opens the Iframe in the same window as the channels, What I need is open it from a new tab similar to boards and playbooks in the Mattermost desktop app, in the web browser it can be as it is now.
Thank you for your support.
Here is my plugin code
import React from 'react';
let iframeURL = "https://codepen.io/rdesigncode/details/zYPzaqb"
const customRoute = '/myplugin';
class myplugin{
initialize(registry, store) {
const IframeComponent = () => {
return (
<iframe src={iframeURL} height="100%" width="100%" title="myplugin"></iframe>
);
};
registry.registerProduct(
customRoute,
'kanban',
"IFrame",
customRoute,
IframeComponent,
'headerCentreComponent',
'headerRightComponent',
true,
true,
true
);
}
}
window.registerPlugin('myplugin', new myplugin());
答案1
得分: 1
当您点击“Iframe”按钮时,它会在与频道相同的窗口中打开Iframe。您希望像“Mattermost桌面应用程序”中的“boards and playbooks”一样在新标签页中打开它。目前“Mattermost桌面应用程序”不支持这一功能。
一个替代方法是,使用JavaScript在新窗口而不是新标签页中打开插件的内容(当用户点击“Iframe”按钮时打开所需的URL)。如下所示:
const openInNewWindow = () => {
window.open(iframeURL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');
}
在用户点击“Iframe”按钮时调用此函数,以在新窗口中打开您的插件内容。
英文:
When you click the Iframe
button, it opens the Iframe in the same window as the channels. You would like to open it from a new tab similar to boards and playbooks
in the Mattermost desktop app
. Currently this isn't not supported by Mattermost desktop app.
one alternative could be to open the contents of your plugin in a new window instead of a new tab, using JavaScript
( open a new window with the desired URL when the user clicks on the Iframe
button ) . See below
const openInNewWindow = () => {
window.open(iframeURL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');
}
call this function when the user clicks on the Iframe
button to open the contents of your plugin
in a new window.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论