bpmn-js icon indicating copy to clipboard operation
bpmn-js copied to clipboard

Copy and paste between different browser windows

Open nikku opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe.

As a user I want to copy and paste parts of my diagram between different browser/app windows.

Use case: Have multiple diagrams opened in different tabs, but also have diagrams opened in different bpmn-js based applications (Camunda Modeler, Camunda Web Modeler, bpmn.io demo).

Describe the solution you'd like

  • [ ] If I copy parts of the diagram it is put into the system clipboard in a way that
  • [ ] Pasting with the canvas selected pastes from the system clipboard, if it holds bpmn-js contents

Describe alternatives you've considered

None.

Additional context

The web platform provides clipboard API as well as copy events we may be able to hook into.

On the bpmn-js side we'd need to ensure our copy/paste implementation is side-effect free, and the copied tree is serializable.


Depends on https://github.com/bpmn-io/diagram-js/pull/659.

nikku avatar Aug 12 '22 11:08 nikku

Investigating this issue we found a couple of copy and paste related issues: https://github.com/bpmn-io/bpmn-js/issues/1708.

nikku avatar Aug 12 '22 11:08 nikku

A poor mans version of this feature can be implemented following along the bpmn-js-copy-paste-example.

It has the following limitations:

  • Not using system clipboard, but instead using on board diagram-js facilities
  • Only copying to local storage / reading from local storage => in browser, cross-tab copy + paste solution

nikku avatar Oct 18 '22 16:10 nikku

We were not able to follow up on the required changes to make browser native focus handling + copy/paste available across all our toolkits (https://github.com/bpmn-io/internal-docs/issues/614#issuecomment-1220481826).

nikku avatar Oct 18 '22 16:10 nikku

It seems that the problem comes from the breaking change of passing to the bpmn-js version 11.0.0 using the 3rd party library to handle the keyboard: https://www.npmjs.com/package/keyboardevent-key-polyfill

This library is instantiated at the page load but not updated while changing tabs or windows. The method keyboardeventKeyPolyfill.polyfill() should be called each time a BPMN Diagram is rendered (?).

The problem is not yet fixed, but it would be nice if someone from BPMN.io look at it more carefully.

BricePissard avatar Jun 08 '23 10:06 BricePissard