I am using contextPad to customize the bpmn js popup in react `import React, { useRef, useEffect, useState } from ‘react’;
import BpmnModeler from ‘bpmn-js/lib/Modeler’;
import ‘bpmn-js/dist/assets/bpmn-font/css/bpmn.css’;
import ‘bpmn-js/dist/assets/diagram-js.css’;
const BpmnEditor = () => {
const [bpmnXml, setBpmnXml] = useState(null);
const containerRef = useRef(null);
const modelerRef = useRef(null);
const createDiagram = async () => {
try {
const newDiagram = await modelerRef.current.createDiagram();
if (newDiagram) {
console.log('BPMN diagram created successfully!');
} else {
console.error('Error creating BPMN diagram.');
}
} catch (err) {
console.error('Error creating BPMN diagram:', err);
}
};
const openDiagram = (xml) => {
modelerRef.current.importXML(xml, (err, warnings) => {
if (err) {
console.error('Error rendering BPMN diagram:', err);
} else {
console.log('BPMN diagram rendered successfully!');
if (warnings && warnings.length) {
console.warn('Warnings:', warnings);
}
}
});
};
const registerCustomMenu = () => {
const contextPad = modelerRef.current.get('contextPad');
contextPad.registerProvider('bpmn.Task', {
getEntries: function (element) {
const entries = [];
entries.push({
id: 'partCreation',
label: 'Part Creation',
action: function (event, element) {
console.log('Part Creation triggered');
},
priority: 1
});
entries.push({
id: 'documentCreation',
label: 'Document Creation',
action: function (event, element) {
console.log('Document Creation triggered');
},
priority: 2
});
return entries;
},
});
};
useEffect(() => {
modelerRef.current = new BpmnModeler({
container: containerRef.current,
});
if (bpmnXml) {
openDiagram(bpmnXml);
} else {
createDiagram();
}
registerCustomMenu();
return () => {
modelerRef.current.destroy();
};
}, [bpmnXml]);
return (
<div>
<div ref={containerRef} style={{ height: '800px' }} />
</div>
);
};
export default BpmnEditor;`
this is my code but it gives Uncaught Error: priority must be a number
on EventBus.js:135
registerProvider ContextPad.js:135
registerCustomMenu CustomTypeBPMNEditor.js:1705
BpmnEditor CustomTypeBPMNEditor.js:1742
React 8
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
on EventBus.js:135
registerProvider ContextPad.js:135
registerCustomMenu CustomTypeBPMNEditor.js:1705
BpmnEditor CustomTypeBPMNEditor.js:1742
React 8
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
(Async: EventHandlerNonNull)
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
Uncaught Error: priority must be a number
on EventBus.js:135
registerProvider ContextPad.js:135
registerCustomMenu CustomTypeBPMNEditor.js:1705
BpmnEditor CustomTypeBPMNEditor.js:1742
React 7
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
this error as you see include priority number inside the code. can anybody please help me with this