Canvas plugin development

Hello,

Kibana version: 7.3.1

I'm trying to develop a simple canvas plugins that can contains a html button or something similar.

I have followed this post:

And the basic plugin works, but I can't make It works when I tried to use ReactDom.render

Is there any documentation about developing plugins on canvas??

Thanks in advance, Luis

Hi Luis! Can you provide me the exact error you're getting? It's likely you haven't registered a renderer with the kbnInterpreter. For example, take a look at the markdown renderer.

domNode
The HTML node provided by Canvas to manipulate and render within.
config
Parameters passed by the expression to the renderer.
handlers
Handlers invoked by Canvas when rendering, moving, destroying, etc

You should be able to register a renderer using the same call:

const fooRenderer = ({
  name: 'foo',
  displayName: 'Foo',
  help: 'Render Foo',
  reuseDomNode: true,
  render(domNode, config, handlers) {
    ReactDOM.render(
      <div className="fooContainer">{config.foo}, {config.baz}</div>,
      domNode,
      () => handlers.done()
    );

    handlers.onDestroy(() => ReactDOM.unmountComponentAtNode(domNode));
  },
});

const renderers = [ fooRenderer];

kbnInterpreter.register({
  elements,
  browserFunctions,
  renderers,
});

Hope this helps!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.