Remove elements from palette and context menu

Hi there!

Im trying to customize de palete and the context menu to remove some of the elements.

I already looked at the examples, but they show only how to add features, not how to remove.

Right now, I accomplished just part of the problem with:

import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
import BpmnModeler from 'bpmn-js/lib/Modeler';
import diagramXML from '../resources/diagram.bpmn';

var _getPaletteEntries = PaletteProvider.prototype.getPaletteEntries;
PaletteProvider.prototype.getPaletteEntries = function(element) {
	 var entries = _getPaletteEntries.apply(this);
	 delete entries['create.task'];
	 delete entries['create.data-store'];
     return entries; 
}


const containerEl = document.getElementById('container');

// create modeler
const bpmnModeler = new BpmnModeler({
  container: containerEl
});

// import XML
bpmnModeler.importXML(diagramXML, (err) => {
  if (err) {
    console.error(err);
  }
});

This is the right way to do that? There is an easier way?

Also i didnt find out how to remove elements from “element type” dialog (Script task, Business task…) without breaking the code.

Thanks

Anybody, there is any alternatives? Im doing right?

If you want to generally keep the defaults, but remove some of them, then the way you do this is OK.

You need to overwrite ReplaceMenuProvider to achieve this.

Thanks for the reply. This technique will not stop working on futures changes or the possibility is low?

I doubt we make any breaking changes there any time soon.

1 Like

Please do not necrobump old topics. Instead link to this thread from new topic.