bpmn-js-copy-as-image

0.1.0 • Public • Published

bpmn-js-copy-as-image

CI

This project allows to capture elements as PNG or SVG programmatically, and to copy rendered PNG to the clipboard via context pad.

pasted screenshot

Features

  • copy selected elements as PNG via the context pad
  • render elements as PNG
  • render elements as SVG

Usage

The project exposes 2 modules which can be used with bpmn-js.

Context pad extension

To use the context pad extension, import the CopyAsImageModule:

import BpmnModeler from 'bpmn-js/lib/Modeler';
import { CopyAsImageModule } from 'bpmn-js-copy-as-image';

const modeler = new BpmnModeler({
  container: '#container',
  additionalModules: [
    CopyAsImageModule
  ]
});

await modeler.importXML(/* ... */);

Programmatic API only

The programmatic API is included in the context pad extension. If you want to use only the former, import only the ElementsRendererModule:

import BpmnModeler from 'bpmn-js/lib/Modeler';
import { ElementsRendererModule } from 'bpmn-js-copy-as-image';

const modeler = new BpmnModeler({
  container: '#container',
  additionalModules: [
    ElementsRendererModule
  ]
});

await modeler.importXML(/* ... */);

const elementsRenderer = modeler.get('elementsRenderer');
const png = await elementsRenderer.renderAsPNG([ 'Task_1' ]);

Demo

# install dependencies
npm install

# run in browser
npm start

Go to http://localhost:9876/debug.html.

Credits

The project was built on top of @nikku's native copy and paste example.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i bpmn-js-copy-as-image

Weekly Downloads

16

Version

0.1.0

License

MIT

Unpacked Size

7.12 kB

Total Files

5

Last publish

Collaborators

  • bpmn-io-admin
  • nikku
  • barmac
  • philippfromme
  • maxtru
  • abdul99ahad
  • skaiir-camunda
  • vsgoulart
  • jarekdanielak
  • simon-steinruecken-camunda