Skip to content

Request for custom addPointToLink function on the DefaultLinkWidget #1036

Open
@JarneVanAerde

Description

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions