@plait/draw 0.1.0-next.4 → 0.1.0-next.6
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/esm2022/generator/geometry-shape.generator.mjs +2 -2
- package/esm2022/geometry.component.mjs +2 -2
- package/esm2022/interfaces/element.mjs +6 -0
- package/esm2022/interfaces/geometry.mjs +1 -1
- package/esm2022/interfaces/index.mjs +2 -1
- package/esm2022/interfaces/line.mjs +7 -1
- package/esm2022/plugins/with-draw-fragment.mjs +12 -6
- package/esm2022/plugins/with-draw-hotkey.mjs +2 -2
- package/esm2022/plugins/with-draw.mjs +8 -3
- package/esm2022/plugins/with-line-bound-reaction.mjs +2 -2
- package/esm2022/utils/clipboard.mjs +35 -5
- package/esm2022/utils/geometry.mjs +2 -2
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/line.mjs +10 -4
- package/esm2022/utils/style/index.mjs +2 -0
- package/esm2022/utils/style/stroke.mjs +21 -0
- package/fesm2022/plait-draw.mjs +70 -9
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/interfaces/element.d.ts +4 -0
- package/interfaces/geometry.d.ts +1 -1
- package/interfaces/index.d.ts +1 -0
- package/interfaces/line.d.ts +4 -1
- package/package.json +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/line.d.ts +1 -0
- package/utils/style/index.d.ts +1 -0
- package/utils/{geometry-style → style}/stroke.d.ts +2 -1
- package/esm2022/utils/geometry-style/stroke.mjs +0 -17
package/interfaces/geometry.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlaitBoard, PlaitElement, Point, RectangleClient } from '@plait/core';
|
|
2
2
|
import { Options } from 'roughjs/bin/core';
|
|
3
|
-
import { StrokeStyle } from './line';
|
|
4
3
|
import { ParagraphElement } from '@plait/text';
|
|
4
|
+
import { StrokeStyle } from './element';
|
|
5
5
|
export declare enum GeometryShape {
|
|
6
6
|
rectangle = "rectangle",
|
|
7
7
|
ellipse = "ellipse",
|
package/interfaces/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PlaitText } from './text';
|
|
|
4
4
|
export * from './line';
|
|
5
5
|
export * from './geometry';
|
|
6
6
|
export * from './text';
|
|
7
|
+
export * from './element';
|
|
7
8
|
export type PlaitDrawElement = PlaitGeometry | PlaitLine;
|
|
8
9
|
export declare const PlaitDrawElement: {
|
|
9
10
|
isGeometry: (value: any) => value is PlaitGeometry;
|
package/interfaces/line.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PlaitElement, Point } from '@plait/core';
|
|
2
2
|
import { Element } from 'slate';
|
|
3
|
+
import { PlaitGeometry } from './geometry';
|
|
4
|
+
import { StrokeStyle } from './element';
|
|
3
5
|
export declare enum LineMarkerType {
|
|
4
6
|
arrow = "arrow",
|
|
5
7
|
none = "none"
|
|
@@ -32,7 +34,6 @@ export interface PlaitLine extends PlaitElement {
|
|
|
32
34
|
strokeStyle?: StrokeStyle;
|
|
33
35
|
opacity: number;
|
|
34
36
|
}
|
|
35
|
-
export type StrokeStyle = 'solid' | 'dashed';
|
|
36
37
|
export interface PlaitStraightLine extends PlaitLine {
|
|
37
38
|
shape: LineShape.straight;
|
|
38
39
|
}
|
|
@@ -46,4 +47,6 @@ export declare const PlaitLine: {
|
|
|
46
47
|
getTextEditors(element: PlaitLine): (import("slate").BaseEditor & import("slate-angular").AngularEditor & import("slate-history").HistoryEditor)[];
|
|
47
48
|
isSourceMark(line: PlaitLine, markType: LineMarkerType): boolean;
|
|
48
49
|
isTargetMark(line: PlaitLine, markType: LineMarkerType): boolean;
|
|
50
|
+
isBoundElementOfSource(line: PlaitLine, element: PlaitGeometry): boolean;
|
|
51
|
+
isBoundElementOfTarget(line: PlaitLine, element: PlaitGeometry): boolean;
|
|
49
52
|
};
|
package/package.json
CHANGED
package/utils/index.d.ts
CHANGED
package/utils/line.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare const getConnectionPoint: (geometry: PlaitGeometry, connection: P
|
|
|
14
14
|
export declare const transformPointToConnection: (board: PlaitBoard, point: Point, hitElement: PlaitGeometry) => Point;
|
|
15
15
|
export declare const getHitConnectorPoint: (movingPoint: Point, hitElement: PlaitGeometry, rectangle: RectangleClient) => Point | undefined;
|
|
16
16
|
export declare const getLineTextRectangle: (board: PlaitBoard, element: PlaitLine, index: number) => RectangleClient;
|
|
17
|
+
export declare const getBoardLines: (board: PlaitBoard) => PlaitLine[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stroke';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PlaitGeometry, PlaitLine } from '../../interfaces';
|
|
1
|
+
import { PlaitGeometry, PlaitLine, StrokeStyle } from '../../interfaces';
|
|
2
2
|
export declare const getStrokeWidthByElement: (element: PlaitGeometry | PlaitLine) => number;
|
|
3
3
|
export declare const getStrokeColorByElement: (element: PlaitGeometry | PlaitLine) => string;
|
|
4
4
|
export declare const getFillByElement: (element: PlaitGeometry | PlaitLine) => any;
|
|
5
5
|
export declare const getLineDashByElement: (element: PlaitGeometry | PlaitLine) => number[] | undefined;
|
|
6
|
+
export declare const getStrokeStyleByElement: (element: PlaitGeometry | PlaitLine) => StrokeStyle;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DefaultGeometryStyle } from '../../constants';
|
|
2
|
-
export const getStrokeWidthByElement = (element) => {
|
|
3
|
-
const strokeWidth = element.strokeWidth || DefaultGeometryStyle.strokeWidth;
|
|
4
|
-
return strokeWidth;
|
|
5
|
-
};
|
|
6
|
-
export const getStrokeColorByElement = (element) => {
|
|
7
|
-
const strokeColor = element.strokeColor || DefaultGeometryStyle.strokeColor;
|
|
8
|
-
return strokeColor;
|
|
9
|
-
};
|
|
10
|
-
export const getFillByElement = (element) => {
|
|
11
|
-
const fill = element.fill || DefaultGeometryStyle.fill;
|
|
12
|
-
return fill;
|
|
13
|
-
};
|
|
14
|
-
export const getLineDashByElement = (element) => {
|
|
15
|
-
return element.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