How to custom menu provider

Hi,

I am trying to custom menu provider,I do not how to replace replaceMenuProvider.
What should I do? Thank you!
123

What you’d want to change are the entries in the replace menu. Take a look at this.

This is how I do it:
1.Copy full file ReplaceMenuProvider.js,and in the new ReplaceMenuProvider.js, change the import of ReplaceOptions.js which to change the entries in the replace menu.
2.mkdir new Modeler: add new ReplaceMenuProvider.js as a modules.

I think the step one is too low. Do you have any other good idea?

ReplaceOptions.js
2

ReplaceMenuProvider.js
1

Modeler
CustomModule include replaceMenuProvider:['type',ReplaceMenuProvider]
3

You can override getEntries like this

import inherits from ‘inherits’;
import ReplaceMenuProvider from ‘bpmn-js/lib/features/popup-menu/ReplaceMenuProvider’;

export default function CustomReplaceMenuProvider() {

}

const _getEntries = ReplaceMenuProvider.prototype.getEntries;
ReplaceMenuProvider.prototype.getEntries = function (element) {
const entries = _getEntries.apply(this, [element]);

return  entries.filter(elem=> elem.label=='User Task' ||elem.label=='Service Task' )

}
inherits(CustomReplaceMenuProvider, ReplaceMenuProvider);