@plait/core 0.24.0-next.8 → 0.28.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 +1 -1
- package/constants/selection.d.ts +1 -0
- package/core/children/children.component.d.ts +3 -3
- package/core/element/element.component.d.ts +1 -1
- package/esm2022/board/board.component.mjs +9 -7
- package/esm2022/constants/resize.mjs +1 -1
- package/esm2022/constants/selection.mjs +2 -1
- package/esm2022/core/children/children.component.mjs +11 -9
- package/esm2022/core/element/context.mjs +1 -1
- package/esm2022/core/element/element.component.mjs +4 -3
- package/esm2022/interfaces/board.mjs +1 -1
- package/esm2022/interfaces/direction.mjs +8 -0
- package/esm2022/interfaces/index.mjs +2 -1
- package/esm2022/interfaces/plugin-key.mjs +1 -1
- package/esm2022/interfaces/point.mjs +1 -1
- package/esm2022/interfaces/rectangle-client.mjs +4 -1
- package/esm2022/interfaces/viewport.mjs +2 -2
- package/esm2022/plugins/create-board.mjs +10 -9
- package/esm2022/plugins/with-hotkey.mjs +5 -3
- package/esm2022/plugins/with-moving.mjs +17 -4
- package/esm2022/plugins/with-options.mjs +1 -1
- package/esm2022/plugins/with-selection.mjs +37 -25
- package/esm2022/public-api.mjs +1 -2
- package/esm2022/testing/core/fake-weak-map.mjs +2 -2
- package/esm2022/testing/core/index.mjs +1 -1
- package/esm2022/testing/fake-events/event-objects.mjs +1 -1
- package/esm2022/testing/fake-events/index.mjs +1 -1
- package/esm2022/testing/index.mjs +1 -1
- package/esm2022/testing/test-element.mjs +1 -1
- package/esm2022/transforms/element.mjs +4 -4
- package/esm2022/transforms/selection.mjs +16 -6
- package/esm2022/utils/board.mjs +1 -1
- package/esm2022/utils/draw/line.mjs +2 -1
- package/esm2022/utils/draw/rectangle.mjs +1 -1
- package/esm2022/utils/element.mjs +3 -3
- package/esm2022/utils/reaction-manager.mjs +370 -0
- package/esm2022/utils/to-image.mjs +106 -34
- package/esm2022/utils/touch.mjs +3 -3
- package/esm2022/utils/tree.mjs +2 -2
- package/esm2022/utils/weak-maps.mjs +1 -1
- package/fesm2022/plait-core.mjs +732 -256
- package/fesm2022/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +2 -1
- package/interfaces/direction.d.ts +7 -0
- package/interfaces/index.d.ts +1 -0
- package/interfaces/rectangle-client.d.ts +6 -0
- package/package.json +3 -2
- package/plugins/with-selection.d.ts +5 -1
- package/public-api.d.ts +0 -1
- package/styles/styles.scss +1 -1
- package/testing/core/fake-weak-map.d.ts +2 -2
- package/transforms/element.d.ts +2 -2
- package/transforms/selection.d.ts +2 -2
- package/utils/reaction-manager.d.ts +41 -0
- package/utils/to-image.d.ts +11 -0
- package/utils/touch.d.ts +1 -1
- package/utils/tree.d.ts +2 -2
- package/utils/weak-maps.d.ts +4 -1
- package/esm2022/plait.module.mjs +0 -21
- package/plait.module.d.ts +0 -10
package/interfaces/board.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface PlaitBoard {
|
|
|
36
36
|
keydown: (event: KeyboardEvent) => void;
|
|
37
37
|
globalKeydown: (event: KeyboardEvent) => void;
|
|
38
38
|
keyup: (event: KeyboardEvent) => void;
|
|
39
|
-
setFragment: (data: DataTransfer | null, rectangle: RectangleClient | null) => void;
|
|
39
|
+
setFragment: (data: DataTransfer | null, rectangle: RectangleClient | null, type: 'copy' | 'cut') => void;
|
|
40
40
|
insertFragment: (data: DataTransfer | null, targetPoint: Point) => void;
|
|
41
41
|
deleteFragment: (data: DataTransfer | null) => void;
|
|
42
42
|
getDeletedFragment: (data: PlaitElement[]) => PlaitElement[];
|
|
@@ -52,6 +52,7 @@ export interface PlaitBoard {
|
|
|
52
52
|
pathRef: (path: Path, options?: PathRefOptions) => PathRef;
|
|
53
53
|
pathRefs: () => Set<PathRef>;
|
|
54
54
|
applyTheme: (element: PlaitElement) => void;
|
|
55
|
+
isAlign: (element: PlaitElement) => boolean;
|
|
55
56
|
pointerDown: (pointer: PointerEvent) => void;
|
|
56
57
|
pointerMove: (pointer: PointerEvent) => void;
|
|
57
58
|
pointerUp: (pointer: PointerEvent) => void;
|
package/interfaces/index.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface RectangleClient {
|
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* [x, y] x,y between 0 and 1
|
|
10
|
+
* represents a point in the rectangle
|
|
11
|
+
*/
|
|
12
|
+
export type PointOfRectangle = [number, number];
|
|
8
13
|
export declare const RectangleClient: {
|
|
9
14
|
isHit: (origin: RectangleClient, target: RectangleClient) => boolean;
|
|
10
15
|
toRectangleClient: (points: [Point, Point]) => {
|
|
@@ -28,4 +33,5 @@ export declare const RectangleClient: {
|
|
|
28
33
|
isEqual: (rectangle: RectangleClient, otherRectangle: RectangleClient) => boolean;
|
|
29
34
|
getCornerPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
|
|
30
35
|
getEdgeCenterPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
|
|
36
|
+
getConnectionPoint: (rectangle: RectangleClient, point: PointOfRectangle) => Point;
|
|
31
37
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plait/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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"
|
|
@@ -7,8 +7,12 @@ export interface WithPluginOptions extends PlaitPluginOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function withSelection(board: PlaitBoard): PlaitBoard;
|
|
9
9
|
export declare function getTemporaryElements(board: PlaitBoard): PlaitElement[] | undefined;
|
|
10
|
+
export declare function getTemporaryRef(board: PlaitBoard): {
|
|
11
|
+
elements: PlaitElement[];
|
|
12
|
+
timeoutId: any;
|
|
13
|
+
} | undefined;
|
|
10
14
|
export declare function deleteTemporaryElements(board: PlaitBoard): void;
|
|
11
15
|
export declare function isSelectionMoving(board: PlaitBoard): boolean;
|
|
12
16
|
export declare function setSelectionMoving(board: PlaitBoard): void;
|
|
13
17
|
export declare function clearSelectionMoving(board: PlaitBoard): void;
|
|
14
|
-
export declare function
|
|
18
|
+
export declare function createSelectionRectangleG(board: PlaitBoard): SVGGElement | null;
|
package/public-api.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './core/children/children.component';
|
|
|
6
6
|
export * from './core/element/context-change';
|
|
7
7
|
export * from './core/island/island-base.component';
|
|
8
8
|
export * from './interfaces';
|
|
9
|
-
export * from './plait.module';
|
|
10
9
|
export * from './transforms';
|
|
11
10
|
export * from './utils';
|
|
12
11
|
export * from './plugins/with-selection';
|
package/styles/styles.scss
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlaitBoard } from
|
|
2
|
-
import { PlaitNode } from
|
|
1
|
+
import { PlaitBoard } from '../../interfaces/board';
|
|
2
|
+
import { PlaitNode } from '../../interfaces/node';
|
|
3
3
|
export declare const fakeNodeWeakMap: (object: PlaitNode | PlaitBoard) => void;
|
|
4
4
|
export declare const clearNodeWeakMap: (object: PlaitNode | PlaitBoard) => void;
|
package/transforms/element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PlaitBoard } from
|
|
2
|
-
import { PlaitElement } from
|
|
1
|
+
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
+
import { PlaitElement } from '../interfaces/element';
|
|
3
3
|
export declare const removeElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
4
4
|
export declare const CoreTransforms: {
|
|
5
5
|
removeElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
@@ -4,7 +4,7 @@ import { PlaitElement } from '../interfaces/element';
|
|
|
4
4
|
export declare function setSelection(board: PlaitBoard, selection: Selection | null): void;
|
|
5
5
|
export interface SelectionTransforms {
|
|
6
6
|
setSelection: (board: PlaitBoard, selection: Selection | null) => void;
|
|
7
|
-
|
|
7
|
+
addSelectionWithTemporaryElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
8
8
|
}
|
|
9
9
|
export declare const SelectionTransforms: SelectionTransforms;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function addSelectionWithTemporaryElements(board: PlaitBoard, elements: PlaitElement[]): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
+
import { PlaitElement } from '../interfaces/element';
|
|
3
|
+
import { Point, RectangleClient } from '../interfaces';
|
|
4
|
+
export interface AlignRef {
|
|
5
|
+
deltaX: number;
|
|
6
|
+
deltaY: number;
|
|
7
|
+
g: SVGGElement;
|
|
8
|
+
}
|
|
9
|
+
export interface DistributeRef {
|
|
10
|
+
before: {
|
|
11
|
+
distance: number;
|
|
12
|
+
index: number;
|
|
13
|
+
}[];
|
|
14
|
+
after: {
|
|
15
|
+
distance: number;
|
|
16
|
+
index: number;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
export declare class AlignReaction {
|
|
20
|
+
private board;
|
|
21
|
+
private activeElements;
|
|
22
|
+
private activeRectangle;
|
|
23
|
+
alignRectangles: RectangleClient[];
|
|
24
|
+
constructor(board: PlaitBoard, activeElements: PlaitElement[], activeRectangle: RectangleClient);
|
|
25
|
+
getAlignRectangle(): RectangleClient[];
|
|
26
|
+
handleAlign(): AlignRef;
|
|
27
|
+
calculateClosestDistances(activeRectangle: RectangleClient, alignRectangle: RectangleClient): {
|
|
28
|
+
absXDistance: number;
|
|
29
|
+
xDistance: number;
|
|
30
|
+
absYDistance: number;
|
|
31
|
+
yDistance: number;
|
|
32
|
+
indexX: number;
|
|
33
|
+
indexY: number;
|
|
34
|
+
};
|
|
35
|
+
alignDistribute(alignRectangles: RectangleClient[], isHorizontal: boolean): {
|
|
36
|
+
delta: number;
|
|
37
|
+
distributeLines: any[];
|
|
38
|
+
};
|
|
39
|
+
drawAlignLines(lines: number[][], g: SVGGElement): void;
|
|
40
|
+
drawDistributeLines(lines: Point[][], g: SVGGElement): void;
|
|
41
|
+
}
|
package/utils/to-image.d.ts
CHANGED
|
@@ -6,5 +6,16 @@ export interface ToImageOptions {
|
|
|
6
6
|
fillStyle?: string;
|
|
7
7
|
inlineStyleClassNames?: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* current board transfer pictures
|
|
11
|
+
* @param board board
|
|
12
|
+
* @param options parameter configuration
|
|
13
|
+
* @returns images in the specified format base64
|
|
14
|
+
*/
|
|
9
15
|
export declare function toImage(board: PlaitBoard, options: ToImageOptions): Promise<string | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* download the file with the specified name
|
|
18
|
+
* @param url download url
|
|
19
|
+
* @param name file name
|
|
20
|
+
*/
|
|
10
21
|
export declare function downloadImage(url: string, name: string): void;
|
package/utils/touch.d.ts
CHANGED
package/utils/tree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PlaitBoard } from
|
|
2
|
-
import { PlaitElement } from
|
|
1
|
+
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
+
import { PlaitElement } from '../interfaces/element';
|
|
3
3
|
export declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void, recursion?: (node: T) => boolean, isReverse?: boolean): void;
|
|
4
4
|
export declare const getIsRecursionFunc: (board: PlaitBoard) => (element: PlaitElement | PlaitBoard) => boolean;
|
|
5
5
|
export interface TreeNode {
|
package/utils/weak-maps.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export declare const BOARD_TO_MOVING_POINT_IN_BOARD: WeakMap<PlaitBoard, Point>;
|
|
|
20
20
|
export declare const BOARD_TO_MOVING_POINT: WeakMap<PlaitBoard, Point>;
|
|
21
21
|
export declare const BOARD_TO_VIEWPORT_ORIGINATION: WeakMap<PlaitBoard, Point>;
|
|
22
22
|
export declare const BOARD_TO_IS_SELECTION_MOVING: WeakMap<PlaitBoard, boolean>;
|
|
23
|
-
export declare const BOARD_TO_TEMPORARY_ELEMENTS: WeakMap<PlaitBoard,
|
|
23
|
+
export declare const BOARD_TO_TEMPORARY_ELEMENTS: WeakMap<PlaitBoard, {
|
|
24
|
+
elements: PlaitElement[];
|
|
25
|
+
timeoutId: any;
|
|
26
|
+
}>;
|
|
24
27
|
export declare const BOARD_TO_MOVING_ELEMENT: WeakMap<PlaitBoard, PlaitElement[]>;
|
|
25
28
|
export declare const PATH_REFS: WeakMap<PlaitBoard, Set<PathRef>>;
|
package/esm2022/plait.module.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { PlaitBoardComponent } from './board/board.component';
|
|
4
|
-
import { PlaitElementComponent } from './core/element/element.component';
|
|
5
|
-
import { PlaitChildrenElement } from './core/children/children.component';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent];
|
|
8
|
-
export class PlaitModule {
|
|
9
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
10
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent], imports: [CommonModule], exports: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent] }); }
|
|
11
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: PlaitModule, imports: [CommonModule] }); }
|
|
12
|
-
}
|
|
13
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: PlaitModule, decorators: [{
|
|
14
|
-
type: NgModule,
|
|
15
|
-
args: [{
|
|
16
|
-
declarations: [...COMPONENTS],
|
|
17
|
-
imports: [CommonModule],
|
|
18
|
-
exports: [...COMPONENTS]
|
|
19
|
-
}]
|
|
20
|
-
}] });
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhaXQubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcGFja2FnZXMvY29yZS9zcmMvcGxhaXQubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzlELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ3pFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG9DQUFvQyxDQUFDOztBQUUxRSxNQUFNLFVBQVUsR0FBRyxDQUFDLG1CQUFtQixFQUFFLG9CQUFvQixFQUFFLHFCQUFxQixDQUFDLENBQUM7QUFPdEYsTUFBTSxPQUFPLFdBQVc7OEdBQVgsV0FBVzsrR0FBWCxXQUFXLGlCQVBKLG1CQUFtQixFQUFFLG9CQUFvQixFQUFFLHFCQUFxQixhQUl0RSxZQUFZLGFBSk4sbUJBQW1CLEVBQUUsb0JBQW9CLEVBQUUscUJBQXFCOytHQU92RSxXQUFXLFlBSFYsWUFBWTs7MkZBR2IsV0FBVztrQkFMdkIsUUFBUTttQkFBQztvQkFDTixZQUFZLEVBQUUsQ0FBQyxHQUFHLFVBQVUsQ0FBQztvQkFDN0IsT0FBTyxFQUFFLENBQUMsWUFBWSxDQUFDO29CQUN2QixPQUFPLEVBQUUsQ0FBQyxHQUFHLFVBQVUsQ0FBQztpQkFDM0IiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuaW1wb3J0IHsgQ29tbW9uTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29tbW9uJztcbmltcG9ydCB7IFBsYWl0Qm9hcmRDb21wb25lbnQgfSBmcm9tICcuL2JvYXJkL2JvYXJkLmNvbXBvbmVudCc7XG5pbXBvcnQgeyBQbGFpdEVsZW1lbnRDb21wb25lbnQgfSBmcm9tICcuL2NvcmUvZWxlbWVudC9lbGVtZW50LmNvbXBvbmVudCc7XG5pbXBvcnQgeyBQbGFpdENoaWxkcmVuRWxlbWVudCB9IGZyb20gJy4vY29yZS9jaGlsZHJlbi9jaGlsZHJlbi5jb21wb25lbnQnO1xuXG5jb25zdCBDT01QT05FTlRTID0gW1BsYWl0Qm9hcmRDb21wb25lbnQsIFBsYWl0Q2hpbGRyZW5FbGVtZW50LCBQbGFpdEVsZW1lbnRDb21wb25lbnRdO1xuXG5ATmdNb2R1bGUoe1xuICAgIGRlY2xhcmF0aW9uczogWy4uLkNPTVBPTkVOVFNdLFxuICAgIGltcG9ydHM6IFtDb21tb25Nb2R1bGVdLFxuICAgIGV4cG9ydHM6IFsuLi5DT01QT05FTlRTXVxufSlcbmV4cG9ydCBjbGFzcyBQbGFpdE1vZHVsZSB7fVxuIl19
|
package/plait.module.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
import * as i1 from "./board/board.component";
|
|
3
|
-
import * as i2 from "./core/children/children.component";
|
|
4
|
-
import * as i3 from "./core/element/element.component";
|
|
5
|
-
import * as i4 from "@angular/common";
|
|
6
|
-
export declare class PlaitModule {
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<PlaitModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<PlaitModule, [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent], [typeof i4.CommonModule], [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent]>;
|
|
9
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<PlaitModule>;
|
|
10
|
-
}
|