@plait/core 0.2.4 → 0.3.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.
- package/board/board.component.d.ts +4 -3
- package/board/board.component.interface.d.ts +2 -1
- package/esm2020/board/board.component.interface.mjs +1 -1
- package/esm2020/board/board.component.mjs +10 -9
- package/esm2020/core/children/children.component.mjs +3 -3
- package/esm2020/core/element/element.component.mjs +3 -3
- package/esm2020/core/element/plugin-element.mjs +5 -5
- package/esm2020/core/toolbar/toolbar.component.mjs +3 -3
- package/esm2020/interfaces/board.mjs +11 -2
- package/esm2020/interfaces/node.mjs +1 -1
- package/esm2020/interfaces/path-ref.mjs +15 -0
- package/esm2020/plait.module.mjs +4 -4
- package/esm2020/plugins/create-board.mjs +32 -3
- package/esm2020/plugins/with-hand.mjs +5 -11
- package/esm2020/plugins/with-selection.mjs +17 -15
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/testing/core/create-board.mjs +13 -0
- package/esm2020/testing/core/fake-weak-map.mjs +18 -0
- package/esm2020/testing/core/index.mjs +3 -0
- package/esm2020/testing/index.mjs +2 -0
- package/esm2020/transforms/board.mjs +1 -1
- package/esm2020/utils/selected-element.mjs +5 -3
- package/esm2020/utils/weak-maps.mjs +2 -1
- package/fesm2015/plait-core.mjs +134 -55
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +133 -53
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +8 -2
- package/interfaces/node.d.ts +1 -1
- package/interfaces/path-ref.d.ts +13 -0
- package/package.json +3 -3
- package/plugins/create-board.d.ts +1 -1
- package/public-api.d.ts +1 -0
- package/testing/core/create-board.d.ts +6 -0
- package/testing/core/fake-weak-map.d.ts +4 -0
- package/testing/core/index.d.ts +2 -0
- package/testing/index.d.ts +1 -0
- package/transforms/board.d.ts +2 -2
- package/utils/selected-element.d.ts +2 -2
- package/utils/weak-maps.d.ts +2 -0
package/interfaces/board.d.ts
CHANGED
|
@@ -10,14 +10,15 @@ import { RoughSVG } from 'roughjs/bin/svg';
|
|
|
10
10
|
import { BoardComponentInterface } from '../board/board.component.interface';
|
|
11
11
|
import { Point } from './point';
|
|
12
12
|
import { RectangleClient } from './rectangle-client';
|
|
13
|
-
import {
|
|
13
|
+
import { PathRef, PathRefOptions } from './path-ref';
|
|
14
14
|
import { PlaitNode } from './node';
|
|
15
|
+
import { Path } from './path';
|
|
15
16
|
export interface PlaitBoard {
|
|
16
17
|
viewport: Viewport;
|
|
17
18
|
children: PlaitElement[];
|
|
18
19
|
operations: PlaitOperation[];
|
|
19
20
|
selection: Selection | null;
|
|
20
|
-
pointer: PlaitPointerType;
|
|
21
|
+
pointer: PlaitPointerType | string;
|
|
21
22
|
history: PlaitHistory;
|
|
22
23
|
options: PlaitBoardOptions;
|
|
23
24
|
undo: () => void;
|
|
@@ -43,6 +44,8 @@ export interface PlaitBoard {
|
|
|
43
44
|
isMovable: (element: PlaitElement) => boolean;
|
|
44
45
|
getRectangle: (element: PlaitElement) => RectangleClient | null;
|
|
45
46
|
isWithinSelection: (element: PlaitElement) => boolean;
|
|
47
|
+
pathRef: (path: Path, options?: PathRefOptions) => PathRef;
|
|
48
|
+
pathRefs: () => Set<PathRef>;
|
|
46
49
|
}
|
|
47
50
|
export interface PlaitBoardChangeEvent {
|
|
48
51
|
children: PlaitElement[];
|
|
@@ -71,4 +74,7 @@ export declare const PlaitBoard: {
|
|
|
71
74
|
isFocus(board: PlaitBoard): boolean;
|
|
72
75
|
isReadonly(board: PlaitBoard): boolean;
|
|
73
76
|
hasBeenTextEditing(board: PlaitBoard): boolean;
|
|
77
|
+
getPointer<T = PlaitPointerType>(board: PlaitBoard): T;
|
|
78
|
+
isPointer<T_1 = PlaitPointerType>(board: PlaitBoard, pointer: T_1): boolean;
|
|
79
|
+
getMovingPoint(board: PlaitBoard): Point | undefined;
|
|
74
80
|
};
|
package/interfaces/node.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export declare const PlaitNode: {
|
|
|
15
15
|
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
16
16
|
*/
|
|
17
17
|
parents(root: PlaitBoard, path: Path, options?: NodeParentsOptions): Generator<PlaitNode, void, undefined>;
|
|
18
|
-
get(root: PlaitBoard, path: Path):
|
|
18
|
+
get<T extends PlaitElement = PlaitElement>(root: PlaitBoard, path: Path): T;
|
|
19
19
|
last(board: PlaitBoard, path: Path): PlaitElement;
|
|
20
20
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlaitOperation } from './operation';
|
|
2
|
+
import { Path } from './path';
|
|
3
|
+
export interface PathRef {
|
|
4
|
+
current: Path | null;
|
|
5
|
+
affinity: 'forward' | 'backward' | null;
|
|
6
|
+
unref(): Path | null;
|
|
7
|
+
}
|
|
8
|
+
export interface PathRefOptions {
|
|
9
|
+
affinity?: 'forward' | 'backward' | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const PathRef: {
|
|
12
|
+
transform(ref: PathRef, op: PlaitOperation): void;
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plait/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^
|
|
6
|
-
"@angular/core": "^
|
|
5
|
+
"@angular/common": "^15.2.2",
|
|
6
|
+
"@angular/core": "^15.2.2"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"tslib": "^2.3.0"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PlaitBoard, PlaitBoardOptions } from '../interfaces/board';
|
|
2
2
|
import { PlaitElement } from '../interfaces/element';
|
|
3
|
-
export declare function createBoard(children: PlaitElement[], options
|
|
3
|
+
export declare function createBoard(children: PlaitElement[], options?: PlaitBoardOptions): PlaitBoard;
|
package/public-api.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PlaitBoardOptions, PlaitElement, PlaitPlugin } from '../../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* 1.create board instance
|
|
4
|
+
* 2.build fake node weak map
|
|
5
|
+
*/
|
|
6
|
+
export declare const createTestingBoard: (plugins: PlaitPlugin[], children: PlaitElement[], options?: PlaitBoardOptions) => import("../../interfaces").PlaitBoard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core';
|
package/transforms/board.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PlaitBoard } from '../interfaces/board';
|
|
2
2
|
import { PlaitPointerType } from '../interfaces/pointer';
|
|
3
|
-
export declare const updatePointerType: (board: PlaitBoard, pointer:
|
|
3
|
+
export declare const updatePointerType: <T extends string = PlaitPointerType>(board: PlaitBoard, pointer: T) => void;
|
|
4
4
|
export declare const BoardTransforms: {
|
|
5
|
-
updatePointerType: (board: PlaitBoard, pointer:
|
|
5
|
+
updatePointerType: <T extends string = PlaitPointerType>(board: PlaitBoard, pointer: T) => void;
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
-
import { Range } from '../interfaces/selection';
|
|
2
|
+
import { Selection, Range } from '../interfaces/selection';
|
|
3
3
|
import { PlaitElement } from '../interfaces/element';
|
|
4
|
-
export declare const getHitElements: (board: PlaitBoard) => PlaitElement[];
|
|
4
|
+
export declare const getHitElements: (board: PlaitBoard, selection?: Selection) => PlaitElement[];
|
|
5
5
|
export declare const isIntersectionElements: (board: PlaitBoard, elements: PlaitElement[], ranges: Range[]) => boolean;
|
|
6
6
|
export declare const cacheSelectedElements: (board: PlaitBoard, selectedElements: PlaitElement[]) => void;
|
|
7
7
|
export declare const getSelectedElements: (board: PlaitBoard) => PlaitElement[];
|
package/utils/weak-maps.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PlaitElement } from '../interfaces/element';
|
|
|
4
4
|
import { PlaitBoard } from '../interfaces/board';
|
|
5
5
|
import { Point } from '../interfaces/point';
|
|
6
6
|
import { Ancestor } from '../interfaces/node';
|
|
7
|
+
import { PathRef } from '../interfaces/path-ref';
|
|
7
8
|
export declare const IS_BOARD_CACHE: WeakMap<Object, boolean>;
|
|
8
9
|
export declare const FLUSHING: WeakMap<PlaitBoard, boolean>;
|
|
9
10
|
export declare const NODE_TO_INDEX: WeakMap<PlaitElement, number>;
|
|
@@ -20,3 +21,4 @@ export declare const BOARD_TO_VIEWPORT_ORIGINATION: WeakMap<PlaitBoard, Point>;
|
|
|
20
21
|
export declare const BOARD_TO_IS_SELECTION_MOVING: WeakMap<PlaitBoard, boolean>;
|
|
21
22
|
export declare const BOARD_TO_TEMPORARY_ELEMENTS: WeakMap<PlaitBoard, PlaitElement[]>;
|
|
22
23
|
export declare const BOARD_TO_MOVING_ELEMENT: WeakMap<PlaitBoard, PlaitElement[]>;
|
|
24
|
+
export declare const PATH_REFS: WeakMap<PlaitBoard, Set<PathRef>>;
|