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) { palette.registerProvider({ getPaletteEntries: () => ({ 'hand-tool': { group: 'tools', className: 'icon-hand-tool', title: 'Hand Tool', action: { click: function() { //console.log("Hello"); } } }, 'lasso-tool': { group: 'tools', className: 'icon-lasso-tool', title: 'Lasso Tool', action: { click: function(event) { lassoTool.activateSelection(event as MouseEvent); } } }, 'tool-separator': { group: 'tools', separator: true, action: {} }, '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-device': { group: 'create', className: 'icon-create-shape', title: 'Create Device', action: { click: function() { var shape = elementFactory.createShape({ width: 100, height: 80, canStartConnection:true, type: 'custom:circle' }); console.log(shape.canStartConnection); create.start(event, shape); } } }, 'create-connection': { group: 'create', className: 'icon-connect', title: 'Create Connection', action: { click: (event) => { globalConnect.start(event, false); } } } }) }); } export default { __init__: [ 'palettePlugin' ], palettePlugin: [ 'type', PalettePlugin ] };