Modeler Plugin: Open URL in browser

Hi,

I’m experimenting with creating a modeler plugin for a while now and some questions arose.
First of all: is there any full documentation I missed, which states what is possible with the plugin interface and what not? So far I only managed to achieve something by looking into other open-source plugins and the modeler source itself, which is kind of tedious…

But now to my current question:

Is it possible to open an URL in the os default browser from within the modeler-plugin code?
When writing direct electron code I would do it like this:

(I know that it is possible by an usual link, but I’d prefer to open the page triggered by a function)

Thanks for any help!

There is some documentation about creating plugins, but yeah, it’s not complete, since we do not tackle the newer client extension capabilities. The simple reason is that the API around this is still not 100% defined and might change in the future. Therefore, examples are the only way to get know how to use those currently.

Opening external urls from such a plugin is doable via the ‘open-external-url’ action

export default class MyPlugin extends React.Component {
   doStuff() {
     const { triggerAction } = this.props;

     await triggerAction('open-external-url', {
        url: 'https://forum.camunda.org/c/modeler'
      });
   }
}

If you don’t want to use a (React) client extension, it’s also doable via menu entries, in which you have access to the electron app itself. The example attached in the docs inside the link beforehand is showcasing exactly your use case:

module.exports = function(electronApp, menuState) {
  return [{
    label: 'Open BPMN Reference',
    accelerator: 'CommandOrControl+[',
    enabled: function() {

      // only enabled for BPMN diagrams
      return menuState.bpmn;
    },
    action: function() {
      var shell = require('electron').shell;
      shell.openExternal('https://camunda.org/bpmn/reference/');
    }
  }];
};
1 Like