Make sure that you JSON.stringify the clipboard contents and deserialize them before putting them back to the clipboard. Other than that, the code you’ve pasted looks good to me.
// copy
var clipboardContents = JSON.stringify(modeler.get('clipboard').get());
localforage.setItem('bpmn', clipboardContents);
// paste
localforage.getItem('bpmn').then(function(value) {
var clipboardContents = JSON.parse(value);
modeler.get('clipboard').set(clipboardContents);
modeler.get('editorActions').trigger('paste');
});
I’ve detected the problem. It’s the JSON.stringify or the JSON.parser
If I do the following it crashes as well:
// copy and paste in the same function:
modeler.get('editorActions').trigger('copy');
var getClipboard = modeler.get('clipboard').get();
// it would return the origional clipboard content, not the case!
var myClipBoard = JSON.parse(JSON.stringify(getClipboard));
modeler.get('clipboard').set(myClipBoard);
modeler.get('editorActions').trigger('paste');
Something is getting lost when stringify or parse the content of the clipboard.