@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.
- package/constants/pointer.d.ts +5 -1
- package/esm2022/constants/pointer.mjs +10 -2
- package/esm2022/generators/line-active.generator.mjs +3 -4
- package/esm2022/interfaces/geometry.mjs +5 -1
- package/esm2022/interfaces/line.mjs +11 -3
- package/esm2022/plugins/with-draw.mjs +1 -1
- package/esm2022/utils/engine/diamond.mjs +11 -3
- package/esm2022/utils/engine/ellipse.mjs +38 -1
- package/esm2022/utils/engine/index.mjs +10 -2
- package/esm2022/utils/engine/left-arrow.mjs +45 -0
- package/esm2022/utils/engine/parallelogram.mjs +16 -9
- package/esm2022/utils/engine/rectangle.mjs +11 -3
- package/esm2022/utils/engine/right-arrow.mjs +45 -0
- package/esm2022/utils/engine/round-rectangle.mjs +11 -1
- package/esm2022/utils/engine/trapezoid.mjs +40 -0
- package/esm2022/utils/engine/triangle.mjs +40 -0
- package/esm2022/utils/geometry.mjs +13 -2
- package/esm2022/utils/line.mjs +75 -39
- package/esm2022/utils/position/line.mjs +3 -4
- package/fesm2022/plait-draw.mjs +353 -56
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/interfaces/geometry.d.ts +9 -2
- package/interfaces/line.d.ts +9 -2
- package/package.json +3 -2
- package/styles/styles.scss +1 -1
- package/utils/engine/left-arrow.d.ts +4 -0
- package/utils/engine/parallelogram.d.ts +1 -1
- package/utils/engine/right-arrow.d.ts +4 -0
- package/utils/engine/trapezoid.d.ts +4 -0
- package/utils/engine/triangle.d.ts +4 -0
- package/utils/geometry.d.ts +1 -0
- package/utils/line.d.ts +10 -6
package/interfaces/geometry.d.ts
CHANGED
|
@@ -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
|
}
|
package/interfaces/line.d.ts
CHANGED
|
@@ -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?:
|
|
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.
|
|
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"
|
package/styles/styles.scss
CHANGED
|
@@ -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
|
|
4
|
+
export declare const getParallelogramCornerPoints: (rectangle: RectangleClient) => Point[];
|
package/utils/geometry.d.ts
CHANGED
|
@@ -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) =>
|
|
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
|
|
12
|
-
export declare const
|
|
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;
|