diagram-gost/src/CustomPaletteModule.ts

72 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-01-14 16:14:56 +03:00
import ElementFactory from "diagram-js/lib/core/ElementFactory";
import Palette from "diagram-js/lib/features/palette/Palette";
import LassoTool from "diagram-js/lib/features/lasso-tool/LassoTool";
import Create from "diagram-js/lib/features/create/Create";
import GlobalConnect from "diagram-js/lib/features/global-connect/GlobalConnect";
function PalettePlugin (create: Create,
elementFactory:ElementFactory,
globalConnect: GlobalConnect,
lassoTool: LassoTool,
palette: Palette) {
2025-01-13 15:00:11 +03:00
palette.registerProvider({
getPaletteEntries: () => ({
'hand-tool': {
group: 'tools',
className: 'icon-hand-tool',
title: 'Hand Tool',
action: {
2025-01-14 16:14:56 +03:00
click: function() {
2025-01-13 15:00:11 +03:00
console.log("Hello");
}
}
},
'lasso-tool': {
group: 'tools',
className: 'icon-lasso-tool',
title: 'Lasso Tool',
action: {
click: function(event) {
2025-01-14 16:14:56 +03:00
lassoTool.activateSelection(event as MouseEvent);
2025-01-13 15:00:11 +03:00
}
}
},
'tool-separator': {
group: 'tools',
2025-01-14 16:14:56 +03:00
separator: true,
action: {}
2025-01-13 15:00:11 +03:00
},
'create-shape': {
group: 'create',
className: 'icon-create-shape',
title: 'Create Shape',
action: {
click: function() {
var shape = elementFactory.createShape({
width: 100,
height: 80,
canStartConnection:true
});
console.log(shape.canStartConnection);
create.start(event, shape);
}
}
},
'create-connection': {
group: 'create',
className: 'connection-create-shape',
title: 'Create Connection',
action: {
click: (event) => {
2025-01-14 16:14:56 +03:00
globalConnect.start(event, false);
2025-01-13 15:00:11 +03:00
}
}
}
})
});
}
export default {
__init__: [ 'palettePlugin' ],
palettePlugin: [ 'type', PalettePlugin ]
};