Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for custom addPointToLink function on the DefaultLinkWidget #1036

Open
JarneVanAerde opened this issue Jul 8, 2024 · 0 comments
Open

Comments

@JarneVanAerde
Copy link

Hi,

Thanks for making this library!

There is a piece of functionality that we were using to customize the way points are added to the lines that connect the widgets. We only want this to trigger when the user does a mouse click in combination with pressing the CTRL-key.

The way we did this is by overriding the addPointToLink function:

import { DefaultLinkWidget, PointModel } from '@projectstorm/react-diagrams'

class BaseLinkWidget extends DefaultLinkWidget {
  addPointToLink = (event: any, index: number) => {
    if (
      event.ctrlKey &&
      !this.props.link.isLocked() &&
      this.props.link.getPoints().length - 1 <= this.props.diagramEngine.getMaxNumberPointsPerLink()
    ) {
      const point = new PointModel({
        link: this.props.link,
        position: this.props.diagramEngine.getRelativeMousePoint(event)
      })
      this.props.link.addPoint(point, index)
      event.persist()
      event.stopPropagation()
      this.forceUpdate(() => {
        this.props.diagramEngine.getActionEventBus().fireAction({
          event,
          model: point
        })
      })
    }
  }
}

export default BaseLinkWidget

This is no longer possible since the following commit: 20766f5

Can this functionality be added back or be provided in another way?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant