I am using the following code to allow editing Camunda-base workflows. It works fine with a modeler, but NOT with a viewer:
import * as BpmnJS from 'bpmn-js/dist/bpmn-modeler.production.min.js';
import camundaExtensionModule from 'camunda-bpmn-moddle/lib'
import camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json'
[...]
bpmnJS = new BpmnJS({
additionalModules: [
customRenderer,
camundaExtensionModule,
],
moddleExtensions: {
camunda: camundaModdle
}
});
When I replace âmodelerâ with âviewerâ in the 1st import, I get the following 2 errors:
Error: No provider for "moddleCopy"! (Resolving: camundaCopyPasteRootElementBehavior -> moddleCopy)
ERROR Error: Uncaught (in promise): Error: No provider for "moddleCopy"! (Resolving: camundaCopyPasteRootElementBehavior -> moddleCopy)
Error: No provider for "moddleCopy"! (Resolving: camundaCopyPasteRootElementBehavior -> moddleCopy)
Is there anything I can do to make Camunda extensions work with the viewer and not the modeler?
My goal is to have a web page of my application where a workflow can only be viewed. It should not be editable, and there should be no palette, among other restrictions.
Thanks Beatriz.
I have developed a custom renderer which is based (amonth other stuff) on the camunda:topic attribute for Service Tasks. I would like to let some users visualize the wokrlfows, in a way where the custom renderer is used to customize the drawing, but they should not be able to modify anything in the workflow.
Any other way to achieve this? (maybe by using the modeler instead of the view, but with some settings which de-activate all editing capabilities?)
@bfredo123 as youâve asked on certain ways to activate / deactivate editing capabilities, let me try to elaborate.
To sum it up bpmn-js Extensions work well for both, modeler and viewer as long as they do not use modeler specifics.
In your case an extension uses the moddleCopy service which is a modeler only feature. To build extensions compatible for viewer and modeler youâd need to do any of the two things:
Provide Viewer Only Distribution
Add a viewer only distribution and exclude parts of your extension that require modeler features.
Gracefully Handle Missing Components
Use the injector to load services you depend on in a graceful manner:
function MyBpmnJSExtension(injector) {
const moddleCopy = injector.get('moddleCopy', false);
if (!moddleCopy) {
// oops, I'm not in the modeler context,
// what shall I do?
}
...
}
Many thanks Nikku, interesting to have further background. I donât get what is a âdistributionâ in this case (distribution of what?). Does it mean that I would have to clone the camunda extensions to make them work in the restricted world of the viewer? (maybe itâs not worth it that you answer right now as Beatrizâs suggestion should make me happy, however, I am still interested, just out of curiosity)
If you create your own extensions, you shall also be clear about that and, if needed, simply provide two separate distributions of your extension, one for the viewer and one for the editor. Checkout an example.