Closed tbo47 closed 2 years ago
Thanks for suggest.
We cant add every needed event to core diagram functionality:
Currently you need click
event on a shape. Tomorrow I will need clickOnConnector
event. Then I will want to draw a slider inside the shape.
Use decorators to add events and functionality to shapes:
const diagram = svgDiagramCreate(
svg,
// ShapeDecoratorFuctory
function(shape, param) {
// the way to add custom logic inside shapes - decorators
return new ClickDecorator(shape, param.createParams.props)
.on('click', del);
// or access svg dom element directly
shape.svgEl.addEventListener('click', ...);
return shape;
});
Decorator example - svg-shape-texteditor-decorator.js Other comment about decorators.
CLose PR if the solution suits you.
oh, perfect, thanks!
I have a read only mode where when user click on a shape it should trigger an action. So the
select
event is not enough. I suggest we add this event too.