@plait/draw 0.36.0 → 0.38.0

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,12 +1,12 @@
1
1
  import { PlaitBoard } from '@plait/core';
2
- import { PlaitGeometry } from '../interfaces';
2
+ import { PlaitGeometry, PlaitShape } from '../interfaces';
3
3
  import { ActiveGeneratorExtraData, Generator } from '@plait/common';
4
- export declare class LineAutoCompleteGenerator extends Generator<PlaitGeometry, ActiveGeneratorExtraData> {
4
+ export declare class LineAutoCompleteGenerator extends Generator<PlaitShape, ActiveGeneratorExtraData> {
5
5
  board: PlaitBoard;
6
6
  autoCompleteG: SVGGElement;
7
7
  hoverElement: SVGGElement | null;
8
8
  constructor(board: PlaitBoard);
9
- canDraw(element: PlaitGeometry, data: ActiveGeneratorExtraData): boolean;
9
+ canDraw(element: PlaitShape, data: ActiveGeneratorExtraData): boolean;
10
10
  draw(element: PlaitGeometry, data: ActiveGeneratorExtraData): SVGGElement;
11
11
  removeAutoCompleteG(index: number): void;
12
12
  recoverAutoCompleteG(): void;
@@ -3,6 +3,7 @@ import { PlaitBoard, PlaitPluginElementContext, OnContextChanged } from '@plait/
3
3
  import { Subject } from 'rxjs';
4
4
  import { CommonPluginElement, ImageGenerator } from '@plait/common';
5
5
  import { PlaitImage } from './interfaces/image';
6
+ import { LineAutoCompleteGenerator } from './generators/line-auto-complete.generator';
6
7
  import * as i0 from "@angular/core";
7
8
  export declare class ImageComponent extends CommonPluginElement<PlaitImage, PlaitBoard> implements OnInit, OnDestroy, OnContextChanged<PlaitImage, PlaitBoard> {
8
9
  private viewContainerRef;
@@ -10,6 +11,7 @@ export declare class ImageComponent extends CommonPluginElement<PlaitImage, Plai
10
11
  destroy$: Subject<void>;
11
12
  get activeGenerator(): import("@plait/common").ActiveGenerator<import("@plait/core").PlaitElement>;
12
13
  imageGenerator: ImageGenerator<PlaitImage>;
14
+ lineAutoCompleteGenerator: LineAutoCompleteGenerator;
13
15
  constructor(viewContainerRef: ViewContainerRef, cdr: ChangeDetectorRef);
14
16
  initializeGenerator(): void;
15
17
  ngOnInit(): void;
@@ -14,7 +14,7 @@ export declare const PlaitDrawElement: {
14
14
  isText: (value: any) => value is PlaitText;
15
15
  isImage: (value: any) => value is PlaitImage;
16
16
  isDrawElement: (value: any) => value is PlaitDrawElement;
17
- isShape: (value: any) => boolean;
17
+ isShape: (value: any) => value is PlaitShape;
18
18
  isBasicShape: (value: any) => boolean;
19
19
  isFlowchart: (value: any) => boolean;
20
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/draw",
3
- "version": "0.36.0",
3
+ "version": "0.38.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^16.0.0",
6
6
  "@angular/core": "^16.0.0",
@@ -1,9 +1,8 @@
1
- import { PlaitBoard, Point } from '@plait/core';
2
- import { DrawPointerType } from '../constants';
1
+ import { PlaitBoard } from '@plait/core';
2
+ import { TextManage } from '@plait/text';
3
+ export interface FakeCreateTextRef {
4
+ g: SVGGElement;
5
+ textManage: TextManage;
6
+ }
3
7
  export declare const withGeometryCreateByDrag: (board: PlaitBoard) => PlaitBoard;
4
8
  export declare const withGeometryCreateByDrawing: (board: PlaitBoard) => PlaitBoard;
5
- export declare const getDefaultGeometryPoints: (pointer: DrawPointerType, targetPoint: Point) => [Point, Point];
6
- export declare const getGeometryDefaultProperty: (pointer: DrawPointerType) => {
7
- width: number;
8
- height: number;
9
- };
@@ -10,8 +10,4 @@ export declare const DrawTransforms: {
10
10
  setLineMark: (board: import("@plait/core").PlaitBoard, element: import("@plait/draw").PlaitLine, handleKey: import("@plait/draw").LineHandleKey, marker: import("@plait/draw").LineMarkerType) => void;
11
11
  insertImage: (board: import("@plait/core").PlaitBoard, imageItem: import("@plait/common").CommonImageItem, startPoint?: import("@plait/core").Point | undefined) => void;
12
12
  transformShape: (board: import("@plait/core").PlaitBoard, element: import("@plait/draw").PlaitGeometry, shape: import("@plait/draw").GeometryShapes) => void;
13
- setStrokeColor: (board: import("@plait/core").PlaitBoard, strokeColor: string) => void;
14
- setStrokeWidth: (board: import("@plait/core").PlaitBoard, strokeWidth: number) => void;
15
- setFillColor: (board: import("@plait/core").PlaitBoard, fill: string) => void;
16
- setStrokeStyle: (board: import("@plait/core").PlaitBoard, strokeStyle: string) => void;
17
13
  };
@@ -2,10 +2,13 @@ import { PlaitBoard, Point, RectangleClient, ThemeColorMode } from '@plait/core'
2
2
  import { GeometryShapes, PlaitGeometry, FlowchartSymbols } from '../interfaces/geometry';
3
3
  import { Alignment, CustomText } from '@plait/text';
4
4
  import { Element } from 'slate';
5
+ import { DrawPointerType } from '../constants';
5
6
  import { Options } from 'roughjs/bin/core';
7
+ import { PlaitShape } from '../interfaces';
6
8
  export type GeometryStyleOptions = Pick<PlaitGeometry, 'fill' | 'strokeColor' | 'strokeWidth'>;
7
9
  export type TextProperties = Partial<CustomText> & {
8
10
  align?: Alignment;
11
+ textHeight?: number;
9
12
  };
10
13
  export declare const createGeometryElement: (shape: GeometryShapes, points: [Point, Point], text: string | Element, options?: GeometryStyleOptions, textProperties?: TextProperties) => PlaitGeometry;
11
14
  export declare const getPointsByCenterPoint: (point: Point, width: number, height: number) => [Point, Point];
@@ -17,7 +20,7 @@ export declare const getTextRectangle: (element: PlaitGeometry) => {
17
20
  };
18
21
  export declare const drawBoundMask: (board: PlaitBoard, element: PlaitGeometry) => SVGGElement;
19
22
  export declare const drawGeometry: (board: PlaitBoard, outerRectangle: RectangleClient, shape: GeometryShapes, options: Options) => SVGGElement;
20
- export declare const getNearestPoint: (element: PlaitGeometry, point: Point, inflateDelta?: number) => Point;
23
+ export declare const getNearestPoint: (element: PlaitShape, point: Point, inflateDelta?: number) => Point;
21
24
  export declare const getCenterPointsOnPolygon: (points: Point[]) => Point[];
22
25
  export declare const getEdgeOnPolygonByPoint: (corners: Point[], point: Point) => [Point, Point] | null;
23
26
  export declare const getDefaultFlowchartProperty: (symbol: FlowchartSymbols) => {
@@ -40,7 +43,18 @@ export declare const getDefaultFlowchartProperty: (symbol: FlowchartSymbols) =>
40
43
  height: number;
41
44
  };
42
45
  export declare const createDefaultFlowchart: (point: Point) => (import("../interfaces").PlaitLine | PlaitGeometry)[];
43
- export declare const getAutoCompletePoints: (element: PlaitGeometry) => [Point, Point, Point, Point];
46
+ export declare const getAutoCompletePoints: (element: PlaitShape) => [Point, Point, Point, Point];
44
47
  export declare const getHitIndexOfAutoCompletePoint: (movingPoint: Point, points: Point[]) => number;
45
48
  export declare const getDrawDefaultStrokeColor: (theme: ThemeColorMode) => string;
46
49
  export declare const getFlowchartDefaultFill: (theme: ThemeColorMode) => string;
50
+ export declare const getDefaultTextShapeProperty: (board: PlaitBoard, fontSize?: number | string) => {
51
+ width: number;
52
+ height: number;
53
+ text: string;
54
+ };
55
+ export declare const getDefaultGeometryPoints: (pointer: DrawPointerType, centerPoint: Point) => [Point, Point];
56
+ export declare const getDefaultGeometryProperty: (pointer: DrawPointerType) => {
57
+ width: number;
58
+ height: number;
59
+ };
60
+ export declare const getDefaultTextPoints: (board: PlaitBoard, centerPoint: Point, fontSize?: number | string) => [Point, Point];
package/utils/line.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Point, PlaitBoard, RectangleClient, PointOfRectangle, Direction, Vector } from '@plait/core';
2
- import { LineHandle, LineHandleRef, LineShape, LineText, PlaitGeometry, PlaitLine } from '../interfaces';
2
+ import { LineHandle, LineHandleRef, LineShape, LineText, PlaitGeometry, PlaitLine, PlaitShape } from '../interfaces';
3
3
  import { Op } from 'roughjs/bin/core';
4
4
  export declare const createLineElement: (shape: LineShape, points: [Point, Point], source: LineHandle, target: LineHandle, texts?: LineText[], options?: Pick<PlaitLine, 'strokeColor' | 'strokeWidth'>) => PlaitLine;
5
5
  export declare const getLinePoints: (board: PlaitBoard, element: PlaitLine) => Point[];
@@ -15,11 +15,11 @@ export declare const getHitLineTextIndex: (board: PlaitBoard, element: PlaitLine
15
15
  export declare const isHitLineText: (board: PlaitBoard, element: PlaitLine, point: Point) => boolean;
16
16
  export declare const drawLine: (board: PlaitBoard, element: PlaitLine) => SVGGElement;
17
17
  export declare const getConnectionPoint: (geometry: PlaitGeometry, connection: Point, direction?: Direction, delta?: number) => Point;
18
- export declare const transformPointToConnection: (board: PlaitBoard, point: Point, hitElement: PlaitGeometry) => Point;
19
- export declare const getHitConnectorPoint: (movingPoint: Point, hitElement: PlaitGeometry, rectangle: RectangleClient) => Point | undefined;
18
+ export declare const transformPointToConnection: (board: PlaitBoard, point: Point, hitElement: PlaitShape) => Point;
19
+ export declare const getHitConnectorPoint: (movingPoint: Point, hitElement: PlaitShape, rectangle: RectangleClient) => Point | undefined;
20
20
  export declare const getLineTextRectangle: (board: PlaitBoard, element: PlaitLine, index: number) => RectangleClient;
21
21
  export declare const getBoardLines: (board: PlaitBoard) => PlaitLine[];
22
22
  export declare const Q2C: (points: Point[]) => Point[];
23
23
  export declare const getVectorByConnection: (boundElement: PlaitGeometry, connection: PointOfRectangle) => Vector;
24
24
  export declare const alignPoints: (basePoint: Point, movingPoint: Point) => Point;
25
- export declare const handleLineCreating: (board: PlaitBoard, lineShape: LineShape, startPoint: Point, movingPoint: Point, sourceElement: PlaitGeometry | null, lineShapeG: SVGGElement) => PlaitLine;
25
+ export declare const handleLineCreating: (board: PlaitBoard, lineShape: LineShape, startPoint: Point, movingPoint: Point, sourceElement: PlaitShape | null, lineShapeG: SVGGElement) => PlaitLine;
@@ -3,7 +3,13 @@ import { GeometryShapes, PlaitDrawElement } from '../interfaces';
3
3
  import { DrawPointerType } from '../constants';
4
4
  import { BaseOperation } from 'slate';
5
5
  export declare const getMemorizeKey: (element: PlaitElement) => string;
6
- export declare const getLineMemorizedLatest: () => PlaitElement;
6
+ export declare const getLineMemorizedLatest: () => {
7
+ [x: string]: any;
8
+ id: string;
9
+ children?: PlaitElement[] | undefined;
10
+ points?: import("@plait/core").Point[] | undefined;
11
+ type?: string | undefined;
12
+ };
7
13
  export declare const getMemorizedLatestByPointer: (pointer: DrawPointerType) => {
8
14
  textProperties: any;
9
15
  geometryProperties: {
@@ -1,15 +0,0 @@
1
- import { PropertyTransforms } from '@plait/common';
2
- import { getMemorizeKey } from '../utils/memorize';
3
- export const setStrokeColor = (board, strokeColor) => {
4
- PropertyTransforms.setProperty(board, { strokeColor }, { getMemorizeKey });
5
- };
6
- export const setStrokeWidth = (board, strokeWidth) => {
7
- PropertyTransforms.setProperty(board, { strokeWidth }, { getMemorizeKey });
8
- };
9
- export const setFillColor = (board, fill) => {
10
- PropertyTransforms.setProperty(board, { fill }, { getMemorizeKey });
11
- };
12
- export const setStrokeStyle = (board, strokeStyle) => {
13
- PropertyTransforms.setProperty(board, { strokeStyle }, { getMemorizeKey });
14
- };
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcGVydHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wYWNrYWdlcy9kcmF3L3NyYy90cmFuc2Zvcm1zL3Byb3BlcnR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUVuRCxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFbkQsTUFBTSxDQUFDLE1BQU0sY0FBYyxHQUFHLENBQUMsS0FBaUIsRUFBRSxXQUFtQixFQUFFLEVBQUU7SUFDckUsa0JBQWtCLENBQUMsV0FBVyxDQUFDLEtBQUssRUFBRSxFQUFFLFdBQVcsRUFBRSxFQUFFLEVBQUUsY0FBYyxFQUFFLENBQUMsQ0FBQztBQUMvRSxDQUFDLENBQUM7QUFFRixNQUFNLENBQUMsTUFBTSxjQUFjLEdBQUcsQ0FBQyxLQUFpQixFQUFFLFdBQW1CLEVBQUUsRUFBRTtJQUNyRSxrQkFBa0IsQ0FBQyxXQUFXLEN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V2lkdGg6IG51bWJlcikgPT4ge1xuICAgIFByb3BlcnR5VHJhbnNmb3Jtcy5zZXRQcm9wZXJ0eShib2FyZCwgeyBzdHJva2VXaWR0aCB9LCB7IGdldE1lbW9yaXplS2V5IH0pO1xufTtcblxuZXhwb3J0IGNvbnN0IHNldEZpbGxDb2xvciA9IChib2FyZDogUGxhaXRCb2FyZCwgZmlsbDogc3RyaW5nKSA9PiB7XG4gICAgUHJvcGVydHlUcmFuc2Zvcm1zLnNldFByb3BlcnR5KGJvYXJkLCB7IGZpbGwgfSwgeyBnZXRNZW1vcml6ZUtleSB9KTtcbn07XG5cbmV4cG9ydCBjb25zdCBzZXRTdHJva2VTdHlsZSA9IChib2FyZDogUGxhaXRCb2FyZCwgc3Ryb2tlU3R5bGU6IHN0cmluZykgPT4ge1xuICAgIFByb3BlcnR5VHJhbnNmb3Jtcy5zZXRQcm9wZXJ0eShib2FyZCwgeyBzdHJva2VTdHlsZSB9LCB7IGdldE1lbW9yaXplS2V5IH0pO1xufTtcbiJdfQ==
@@ -1,5 +0,0 @@
1
- import { PlaitBoard } from '@plait/core';
2
- export declare const setStrokeColor: (board: PlaitBoard, strokeColor: string) => void;
3
- export declare const setStrokeWidth: (board: PlaitBoard, strokeWidth: number) => void;
4
- export declare const setFillColor: (board: PlaitBoard, fill: string) => void;
5
- export declare const setStrokeStyle: (board: PlaitBoard, strokeStyle: string) => void;