Setting custom attributes for customPalette groups/entries

If anyone is interested.
You can overwrite the methods used by your CustomPaletteProvider directly in your CustomPalette(Provider) like this:

constructor(create, elementFactory, palette, translate) {
    this.create = create;
    this.elementFactory = elementFactory;
    this.translate = translate;

    palette.registerProvider(this);
    // https://github.com/bpmn-io/diagram-js/blob/master/lib/features/palette/Palette.js#L186
    palette._update = function () {
        // Replace functionality. In my case
        // * I copied the function from the link above,
        // * replaced `this.` by `palette.`
        // * and imported all missing packages
        ...
        // * to set the id, i added the following lines
        if (entry.id) {
            domAttr(control, 'id', entry.id)
        }
        ...
    }
}
1 Like