Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blocksuite/connector

Package Overview
Dependencies
Maintainers
5
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/connector

Library for creating orthogonal connectors with pathfinding support

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
77
decreased by-48.67%
Maintainers
5
Weekly downloads
 
Created
Source

@blocksuite/connector

How to use

import { route, Rectangle } from '@blocksuite/connector';

const rects = [
  new Rectangle(30, 30, 200, 200),
  new Rectangle(160, 160, 300, 300),
];

const points = [
  { x: 50, y: 30 },
  { x: 160, y: 200 },
];

const path = route(rects, points);
console.log('path', path);

Example

See packages/playground/examples/canvas/connector.html

Info

The main idea comes from https://medium.com/swlh/routing-orthogonal-diagram-connectors-in-javascript-191dc2c5ff70 . The final implementation is based on the idea of the blog and modifies the following parts:

  • When generating graph, do not rely on the binding of rectangle and point
  • When generating graphs, do not limit the number of rectangles and points
  • When the path is finally calculated, select any two points from the graph
  • When there are only two points or only one rectangle, manually generate the points of the graph

Problems caused by modifications:

  • The Graph becomes larger, and more points.length lines are added, causing the final path point to increase points.length * 2n

References

Blog:

Code:

Visualized path finding:

FAQs

Package last updated on 06 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc