如何在Mattermost桌面应用程序中在新标签页中打开我的插件内容

huangapple go评论69阅读模式
英文:

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,
如何在Mattermost桌面应用程序中在新标签页中打开我的插件内容

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.

huangapple
  • 本文由 发表于 2023年6月1日 00:17:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定