Hello.
Please help. I can’t find an example. How to replace an element on a pallet so that instead of a “Create expanded sub-process ” element, i can make a “Create collapsed sub-process ” element. So that when adding to a diagram, a collapsed subprocess is immediately created. When I saw in the blog that this element was immediately on the pallet. But unfortunately I still don’t understand how to do this. I was able to do it only by collapsing through modeling.toggleCollapse on the event eventBus.on("commandStack.shape.create.postExecuted
Example my code:
eventBus.on("commandStack.shape.create.postExecuted", (event) => {
if (event.context.shape.type == "bpmn:SubProcess") {
modeling.toggleCollapse(event.context.shape);
}
});
Maybe there is a way to replace the element directly with the required one on the pallet? Thanks
First, have a look at bpmn-js-example-custom-controls . It shows how to add a new entry to the palette.
Then, have a look at the following topic that shows how to remove entries from the default palette.
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 te…
If you don’t want to remove the default entry and add a new one, but actually replace the existing one, you can still do it using what you learnt from the linked resources.
Hi.
Thanks, I did it like this
CustomPaletteProvider.js
import inherits from 'inherits';
import BasePaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
export default function CustomPaletteProvider(palette, create, elementFactory, spaceTool, lassoTool) {
BasePaletteProvider.call(this, palette, create, elementFactory, spaceTool, lassoTool);
this.getPaletteEntries = function() {
return function(entries) {
delete entries['bpmn-tool-subprocess-expanded'];
entries['bpmn-tool-subprocess-collapsed'] = {
group: 'activity',
className: 'bpmn-icon-subprocess-collapsed',
title: 'Create sub-process',
action: {
dragstart: createSubprocess,
click: createSubprocess
}
};
function createSubprocess(event) {
const shape = elementFactory.createShape({ type: 'bpmn:SubProcess', isExpanded: false });
create.start(event, shape);
}
return entries;
};
};
palette.registerProvider(this);
}
inherits(CustomPaletteProvider, BasePaletteProvider);
CustomPaletteProvider.$inject = [
'palette',
'create',
'elementFactory',
'spaceTool',
'lassoTool'
];
Now I can’t figure out how to remove extra items from the “Change element” menu (
Change element menu is controlled by bpmn-js-create-append-anything module. It is currently not customizable, see:
I have several custom controls (added with custom palettes and custom context pad) and so when adding CreateAppendAnythingModule i dont see them as part of the search list.
How should I config/override CAAM so click/drag and create shape methods from custom controls entries are reused when picking this same item from the caam popup list?
fyi I know is possible to set the caam popup items adding a template using (elementTemplates.set) but this template wont be part of the context/palette either…
I also encourage you to do some deeper search before creating a topic next time. It seems all your questions have been already answered on the forum.