I’m trying to have my custom element template. In the process, I face challenge to enable the element-template block in the property panel. I’ve tried the above mentioned post. But no luck.
Below is my code.
import { BpmnJS } from 'bpmn-js/dist/bpmn-modeler.development';
import propertiesPanelModule from 'bpmn-js-properties-panel/';
import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda';
import camundaModdleDescriptor from 'camunda-bpmn-moddle/resources/camunda.json';
import customElementTemplate from '../../.camunda/element-templates/EmailTask.json';
loadModeler() {
this.container = document.getElementById('js-drop-zone');
this.modeler = new BpmnJS({
container: '#js-canvas',
keyboard: { bindTo: document },
propertiesPanel: {
parent: '#js-properties-panel'
},
additionalModules: [
propertiesPanelModule,
propertiesProviderModule
],
elementTemplates: [customElementTemplate], // <-- tried with --> elementTemplates: customElementTemplate,
moddleExtensions: {
camunda: camundaModdleDescriptor
}
});
// this.modeler.get('elementTemplates');
}
Bpmn-js Modeler :
element-templates path
Kindly throw some lights on this.
Note: Tried with Camunda Modeler - Electron App with the reference on this article. It enables element-template. But not in Bpmn.js
An additional thing that may help you track down the issue: You may listen to the elementTemplates.errors event to get notified if template loading fails for whatever reason:
When I pass as elementTemplates: customElementTemplate, ElementTemplatesLoader.reload method is not satisfy any condition, Since it is not satisfy no exception thrown.
Code:
loadModeler() {
this.container = document.getElementById('js-drop-zone');
this.modeler = new BpmnJS({
container: '#js-canvas',
keyboard: { bindTo: document },
propertiesPanel: {
parent: '#js-properties-panel'
},
additionalModules: [
propertiesPanelModule,
propertiesProviderModule
],
elementTemplates: customElementTemplate, // <-- In ElementTemplateLoader.reload => not satisfy any condition.
// customElementTemplate, // <-- In ElementTemplateLoader.reload, this._loadTemplate is undefined.
moddleExtensions: {
camunda: camundaModdleDescriptor,
qa: qaPackage
}
});
this.modeler.on('elementTemplates.errors', function (event) {
console.log('template load errors', event.errors);
});
this.modeler.get('elementTemplatesLoader').reload();
// this.modeler.get('elementTemplates');
}
The approach which I’m using to enable or load the elementTemplate is correct?
i.e., customElementTemplate is a direct MailTask.json result (import customElementTemplate from ‘…/…/.camunda/element-templates/EmailTask.json’) and passing the same as elementTemplate property to BpmnJS instance (elementTemplates: customElementTemplate).
I found the issue. The issue is with the custom element template generation. The template structure is not valid. System I got the error. But I ignored it. My bad