Remove palette entries

Hi, I am new to Bpmn-js, have browsed and practice around almost all examples, but I am stuck at removing items from the standard palette.

I have seen this: Remove elements from palette and context menu

But I don’t understand how to retrieve the PaletteProvider. It looks like it can be done that way:

import PaletteProvider from ‘bpmn-js/lib/features/palette/PaletteProvider’;

However, the code doing “delete entries[]” has no effect.

Could someone please direct me to some documentation, or tell me how to do remove items from Palette, or point me to a full working example?

Many thanks!

Hi @bfredo123 and welcome to the forum!

You need to provide a customPaletteProvider and inject the palette into this. For example to remove the hand tool:

export default class MyPaletteProvider {
  constructor(eventBus, palette, translate) {
    this.eventBus = eventBus;
    this.translate = translate;

    palette.registerProvider(this);
  }

  getPaletteEntries(element) {
    return function(entries) {

      delete entries['hand-tool'];

      return entries;
    };
  }
}

MyPaletteProvider.$inject = [
  'eventBus',
  'palette',
  'translate'
];

Please find a full working example in this sandbox

Best
Max

1 Like

Thank you so much! I have already seen the working example, and will try that out this evening.

BTW, what would be your recommendation for me to learn how to know this kind of things by myself (I could not find an example in the examples lib). Is it just reading the source code if bpmn-js? Or is there some documentation elsewhere?

Thank you again, really appreciated.

Tried it in my code, it definitely works, thanks again!