@plait/draw 0.1.0-next.11 → 0.1.0-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { PlaitBoard, PlaitElement, Point, RectangleClient } from '@plait/core';
1
+ import { PlaitBoard, PlaitElement, Point, PointOfRectangle, RectangleClient, Vector } from '@plait/core';
2
2
  import { Options } from 'roughjs/bin/core';
3
3
  import { ParagraphElement } from '@plait/text';
4
4
  import { StrokeStyle } from './element';
@@ -8,7 +8,11 @@ export declare enum GeometryShape {
8
8
  diamond = "diamond",
9
9
  roundRectangle = "roundRectangle",
10
10
  parallelogram = "parallelogram",
11
- text = "text"
11
+ text = "text",
12
+ triangle = "triangle",
13
+ leftArrow = "leftArrow",
14
+ trapezoid = "trapezoid",
15
+ rightArrow = "rightArrow"
12
16
  }
13
17
  export interface PlaitGeometry extends PlaitElement {
14
18
  points: [Point, Point];
@@ -40,5 +44,8 @@ export interface ShapeEngine {
40
44
  isHit: (rectangle: RectangleClient, point: Point) => boolean;
41
45
  getNearestPoint: (rectangle: RectangleClient, point: Point) => Point;
42
46
  getConnectorPoints: (rectangle: RectangleClient) => Point[];
47
+ getCornerPoints: (rectangle: RectangleClient) => Point[];
48
+ getEdgeByConnectionPoint?: (rectangle: RectangleClient, point: PointOfRectangle) => [Point, Point] | null;
49
+ getTangentVectorByConnectionPoint?: (rectangle: RectangleClient, point: PointOfRectangle) => Vector | null;
43
50
  draw: (board: PlaitBoard, rectangle: RectangleClient, options: Options) => SVGGElement;
44
51
  }
@@ -1,4 +1,4 @@
1
- import { PlaitElement, Point } from '@plait/core';
1
+ import { Direction, PlaitElement, Point, PointOfRectangle } from '@plait/core';
2
2
  import { Element } from 'slate';
3
3
  import { PlaitGeometry } from './geometry';
4
4
  import { StrokeStyle } from './element';
@@ -26,9 +26,15 @@ export interface LineText {
26
26
  }
27
27
  export interface LineHandle {
28
28
  boundId?: string;
29
- connection?: Point;
29
+ connection?: PointOfRectangle;
30
30
  marker: LineMarkerType;
31
31
  }
32
+ export interface LineHandleRef {
33
+ key: LineHandleKey;
34
+ direction: Direction;
35
+ point: PointOfRectangle;
36
+ boundElement?: PlaitGeometry;
37
+ }
32
38
  export interface PlaitLine extends PlaitElement {
33
39
  type: 'line';
34
40
  shape: LineShape;
@@ -52,6 +58,7 @@ export interface PlaitElbowLine extends PlaitLine {
52
58
  }
53
59
  export declare const PlaitLine: {
54
60
  getTextEditors(element: PlaitLine): (import("slate").BaseEditor & import("slate-angular").AngularEditor & import("slate-history").HistoryEditor)[];
61
+ isSourceMarkOrTargetMark(line: PlaitLine, markType: LineMarkerType, handleKey: LineHandleKey): boolean;
55
62
  isSourceMark(line: PlaitLine, markType: LineMarkerType): boolean;
56
63
  isTargetMark(line: PlaitLine, markType: LineMarkerType): boolean;
57
64
  isBoundElementOfSource(line: PlaitLine, element: PlaitGeometry): boolean;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@plait/draw",
3
- "version": "0.1.0-next.11",
3
+ "version": "0.1.0-next.12",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^16.0.0",
6
- "@angular/core": "^16.0.0"
6
+ "@angular/core": "^16.0.0",
7
+ "is-hotkey": "^0.2.0"
7
8
  },
8
9
  "dependencies": {
9
10
  "tslib": "^2.3.0"
@@ -4,7 +4,7 @@
4
4
  cursor: default;
5
5
  }
6
6
  }
7
- &:not(.pointer-text):not(.pointer-selection):not(.pointer-hand)
7
+ &:not(.pointer-text):not(.pointer-selection):not(.pointer-hand)
8
8
  {
9
9
  .board-host-svg {
10
10
  cursor: crosshair;
@@ -0,0 +1,4 @@
1
+ import { Point, RectangleClient } from '@plait/core';
2
+ import { ShapeEngine } from '../../interfaces';
3
+ export declare const LeftArrowEngine: ShapeEngine;
4
+ export declare const getLeftArrowPoints: (rectangle: RectangleClient) => Point[];
@@ -1,4 +1,4 @@
1
1
  import { Point, RectangleClient } from '@plait/core';
2
2
  import { ShapeEngine } from '../../interfaces';
3
3
  export declare const ParallelogramEngine: ShapeEngine;
4
- export declare const getParallelogramPoints: (rectangle: RectangleClient) => Point[];
4
+ export declare const getParallelogramCornerPoints: (rectangle: RectangleClient) => Point[];
@@ -0,0 +1,4 @@
1
+ import { Point, RectangleClient } from '@plait/core';
2
+ import { ShapeEngine } from '../../interfaces';
3
+ export declare const RightArrowEngine: ShapeEngine;
4
+ export declare const getRightArrowPoints: (rectangle: RectangleClient) => Point[];
@@ -0,0 +1,4 @@
1
+ import { Point, RectangleClient } from '@plait/core';
2
+ import { ShapeEngine } from '../../interfaces';
3
+ export declare const TrapezoidEngine: ShapeEngine;
4
+ export declare const getTrapezoidPoints: (rectangle: RectangleClient) => Point[];
@@ -0,0 +1,4 @@
1
+ import { Point, RectangleClient } from '@plait/core';
2
+ import { ShapeEngine } from '../../interfaces';
3
+ export declare const TriangleEngine: ShapeEngine;
4
+ export declare const getTrianglePoints: (rectangle: RectangleClient) => Point[];
@@ -14,3 +14,4 @@ export declare const drawBoundMask: (board: PlaitBoard, element: PlaitGeometry)
14
14
  export declare const drawGeometry: (board: PlaitBoard, outerRectangle: RectangleClient, shape: GeometryShape, options: Options) => SVGGElement;
15
15
  export declare const getNearestPoint: (element: PlaitGeometry, point: Point, inflateDelta?: number) => Point;
16
16
  export declare const getCenterPointsOnPolygon: (points: Point[]) => Point[];
17
+ export declare const getEdgeOnPolygonByPoint: (corners: Point[], point: Point) => [Point, Point] | null;
package/utils/line.d.ts CHANGED
@@ -1,16 +1,20 @@
1
- import { Point, PlaitBoard, RectangleClient } from '@plait/core';
2
- import { LineHandle, LineShape, PlaitGeometry, PlaitLine } from '../interfaces';
1
+ import { Point, PlaitBoard, RectangleClient, PointOfRectangle, Direction } from '@plait/core';
2
+ import { LineHandle, LineHandleRef, LineShape, PlaitGeometry, PlaitLine } from '../interfaces';
3
3
  export declare const createLineElement: (shape: LineShape, points: [Point, Point], source: LineHandle, target: LineHandle, options?: Pick<PlaitLine, 'strokeColor' | 'strokeWidth'>) => PlaitLine;
4
4
  export declare const getLinePoints: (board: PlaitBoard, element: PlaitLine) => Point[];
5
- export declare const getStraightPoints: (board: PlaitBoard, element: PlaitLine) => Point[];
5
+ export declare const getStraightPoints: (board: PlaitBoard, element: PlaitLine) => PointOfRectangle[];
6
+ export declare const getLineHandlePoints: (board: PlaitBoard, element: PlaitLine) => PointOfRectangle[];
7
+ export declare const getLineHandleRefPair: (board: PlaitBoard, element: PlaitLine) => {
8
+ source: LineHandleRef;
9
+ target: LineHandleRef;
10
+ };
6
11
  export declare const getElbowPoints: (board: PlaitBoard, element: PlaitLine) => Point[];
7
12
  export declare const isHitPolyLine: (pathPoints: Point[], point: Point, strokeWidth: number, expand?: number) => boolean;
8
13
  export declare const getHitLineTextIndex: (board: PlaitBoard, element: PlaitLine, point: Point) => number;
9
14
  export declare const isHitLineText: (board: PlaitBoard, element: PlaitLine, point: Point) => boolean;
10
15
  export declare const drawLine: (board: PlaitBoard, element: PlaitLine) => SVGGElement;
11
- export declare const getSourcePoint: (board: PlaitBoard, element: PlaitLine) => Point;
12
- export declare const getTargetPoint: (board: PlaitBoard, element: PlaitLine) => Point;
13
- export declare const getConnectionPoint: (geometry: PlaitGeometry, connection: Point, offset: number) => Point;
16
+ export declare const getDirectionByBoundElementAndConnection: (board: PlaitBoard, boundElement: PlaitGeometry, connection: PointOfRectangle) => Direction | null;
17
+ export declare const getConnectionPoint: (geometry: PlaitGeometry, connection: Point, direction?: Direction, delta?: number) => Point;
14
18
  export declare const transformPointToConnection: (board: PlaitBoard, point: Point, hitElement: PlaitGeometry) => Point;
15
19
  export declare const getHitConnectorPoint: (movingPoint: Point, hitElement: PlaitGeometry, rectangle: RectangleClient) => Point | undefined;
16
20
  export declare const getLineTextRectangle: (board: PlaitBoard, element: PlaitLine, index: number) => RectangleClient;