How to make undo and redo work with bpmn bower bundle?


#1

Client

var BpmnViewer = window.BpmnJS;

    var bpmnModeler = new BpmnViewer({
      container: '#canvas',
      propertiesPanel:{
        parent: '#js-properties-panel'
      },
       keyboard: { bindTo: document }
    });

bpmnModeler.redo(function(err) {
            if(err) {
              console.log(err);
            }
          });

Bower

var BpmnViewer = require('bpmn-js/lib/Modeler');

var camundaModdleDescriptor = require('camunda-bpmn-moddle/resources/camunda');

var additionalModules = [
  require('bpmn-js-properties-panel'),

  // 1. require camunda provider instead of the bpmn one (!)
  require('bpmn-js-properties-panel/lib/provider/camunda')
];

BpmnViewer.prototype._modules = BpmnViewer.prototype._modules.concat(additionalModules);

// 2. include camunda moddle descriptor
BpmnViewer.prototype._moddleExtensions = { camunda: camundaModdleDescriptor }

module.exports = BpmnViewer;

#2

Two issues here:

  • You need to use the modeler for modeling capabilities and redo / undo functionality
  • You need to carry out redo / undo via the CommandStack:
    modeler.get('commandStack').undo();
    

#3

is it possible to provide example using my code ? When you say “you need to use the modeler for modeling capabilities” you meant i can use bpmnModeler.get('commandStack').undo(); Or i have to import some other module ? I tried below code but its not doing anything ('commandStack').redo() is coming undefined.

 $scope.redoXml = function () {
    console.log('testing redo');
    bpmnModeler.get('commandStack').redo();
    }

#4

I made it worked i really appreciate your help and support.Thank you for the help.