@plait/core 0.1.9 → 0.2.0-next.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/core/children/children.component.d.ts +17 -0
- package/core/children/effect.d.ts +2 -0
- package/core/element/context-change.d.ts +10 -0
- package/core/element/context.d.ts +4 -2
- package/core/element/element.component.d.ts +10 -13
- package/core/element/plugin-element.d.ts +5 -4
- package/esm2020/board/board.component.mjs +15 -23
- package/esm2020/core/children/children.component.mjs +58 -0
- package/esm2020/core/children/effect.mjs +2 -0
- package/esm2020/core/element/context-change.mjs +13 -0
- package/esm2020/core/element/context.mjs +1 -1
- package/esm2020/core/element/element.component.mjs +47 -37
- package/esm2020/core/element/plugin-element.mjs +36 -27
- package/esm2020/interfaces/board.mjs +33 -2
- package/esm2020/interfaces/element.mjs +15 -4
- package/esm2020/interfaces/node.mjs +23 -3
- package/esm2020/interfaces/operation.mjs +1 -1
- package/esm2020/interfaces/path.mjs +36 -1
- package/esm2020/interfaces/rectangle-client.mjs +9 -1
- package/esm2020/plait.module.mjs +4 -3
- package/esm2020/plugins/create-board.mjs +2 -1
- package/esm2020/plugins/with-moving.mjs +4 -4
- package/esm2020/plugins/with-selection.mjs +4 -4
- package/esm2020/public-api.mjs +3 -3
- package/esm2020/utils/draw/circle.mjs +4 -0
- package/esm2020/utils/draw/line.mjs +4 -0
- package/esm2020/utils/draw/rectangle.mjs +43 -1
- package/esm2020/utils/element.mjs +2 -2
- package/esm2020/utils/index.mjs +3 -1
- package/esm2020/utils/selected-element.mjs +11 -4
- package/esm2020/utils/tree.mjs +7 -5
- package/esm2020/utils/weak-maps.mjs +4 -1
- package/fesm2015/plait-core.mjs +417 -187
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +416 -185
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +5 -0
- package/interfaces/element.d.ts +6 -3
- package/interfaces/node.d.ts +17 -9
- package/interfaces/operation.d.ts +1 -1
- package/interfaces/path.d.ts +18 -0
- package/interfaces/rectangle-client.d.ts +6 -0
- package/package.json +1 -1
- package/plait.module.d.ts +5 -4
- package/public-api.d.ts +2 -2
- package/styles/styles.scss +4 -0
- package/utils/draw/circle.d.ts +4 -0
- package/utils/draw/line.d.ts +4 -0
- package/utils/draw/rectangle.d.ts +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/selected-element.d.ts +2 -2
- package/utils/tree.d.ts +1 -1
- package/utils/weak-maps.d.ts +4 -0
- package/core/base/detector.d.ts +0 -7
- package/core/element/before-context-change.d.ts +0 -6
- package/esm2020/core/base/detector.mjs +0 -2
- package/esm2020/core/element/before-context-change.mjs +0 -7
package/interfaces/board.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ 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 { Path } from './path';
|
|
14
|
+
import { PlaitNode } from './node';
|
|
13
15
|
export interface PlaitBoard {
|
|
14
16
|
viewport: Viewport;
|
|
15
17
|
children: PlaitElement[];
|
|
@@ -37,6 +39,7 @@ export interface PlaitBoard {
|
|
|
37
39
|
redrawElement: (context: PlaitPluginElementContext, previousContext?: PlaitPluginElementContext) => SVGGElement[] | void;
|
|
38
40
|
destroyElement: (context: PlaitPluginElementContext) => void;
|
|
39
41
|
isHitSelection: (element: PlaitElement, range: Range) => boolean;
|
|
42
|
+
isRecursion: (element: PlaitElement) => boolean;
|
|
40
43
|
isMovable: (element: PlaitElement) => boolean;
|
|
41
44
|
getRectangle: (element: PlaitElement) => RectangleClient | null;
|
|
42
45
|
isWithinSelection: (element: PlaitElement) => boolean;
|
|
@@ -56,6 +59,8 @@ export interface PlaitBoardMove {
|
|
|
56
59
|
y: number;
|
|
57
60
|
}
|
|
58
61
|
export declare const PlaitBoard: {
|
|
62
|
+
isBoard(value: any): value is PlaitBoard;
|
|
63
|
+
findPath(board: PlaitBoard, node: PlaitNode): Path;
|
|
59
64
|
getHost(board: PlaitBoard): SVGSVGElement;
|
|
60
65
|
getElementHost(board: PlaitBoard): SVGGElement;
|
|
61
66
|
getRoughSVG(board: PlaitBoard): RoughSVG;
|
package/interfaces/element.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaitPluginElementComponent } from '../core/element/plugin-element';
|
|
2
2
|
import { Point } from './point';
|
|
3
|
-
export interface PlaitElement
|
|
3
|
+
export interface PlaitElement {
|
|
4
|
+
[key: string]: any;
|
|
4
5
|
id: string;
|
|
6
|
+
children?: PlaitElement[];
|
|
5
7
|
points?: Point[];
|
|
6
8
|
type?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare const PlaitElement: {
|
|
9
|
-
|
|
11
|
+
isRootElement(value: PlaitElement): boolean;
|
|
12
|
+
getComponent(value: PlaitElement): PlaitPluginElementComponent<PlaitElement>;
|
|
10
13
|
};
|
|
11
14
|
export interface ComponentType<T> {
|
|
12
15
|
new (...args: any[]): T;
|
package/interfaces/node.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { PlaitElement } from './element';
|
|
1
2
|
import { PlaitBoard } from './board';
|
|
2
3
|
import { Path } from './path';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type PlaitNode = PlaitElement;
|
|
5
|
+
export type Ancestor = PlaitBoard | PlaitElement;
|
|
6
|
+
export interface NodeParentsOptions {
|
|
7
|
+
reverse?: boolean;
|
|
6
8
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare const PlaitNode: {
|
|
10
|
+
parent: (board: PlaitBoard, path: Path) => PlaitElement;
|
|
11
|
+
/**
|
|
12
|
+
* Return a generator of all the ancestor nodes above a specific path.
|
|
13
|
+
*
|
|
14
|
+
* By default the order is top-down, from highest to lowest ancestor in
|
|
15
|
+
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
16
|
+
*/
|
|
17
|
+
parents(root: PlaitBoard, path: Path, options?: NodeParentsOptions): Generator<PlaitNode, void, undefined>;
|
|
18
|
+
get(root: PlaitBoard, path: Path): PlaitNode;
|
|
19
|
+
last(board: PlaitBoard, path: Path): PlaitElement;
|
|
20
|
+
};
|
package/interfaces/path.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { PlaitOperation } from './operation';
|
|
2
|
+
export interface PathLevelsOptions {
|
|
3
|
+
reverse?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export type Path = number[];
|
|
3
6
|
export declare const Path: {
|
|
7
|
+
/**
|
|
8
|
+
* Get a list of ancestor paths for a given path.
|
|
9
|
+
*
|
|
10
|
+
* The paths are sorted from shallowest to deepest ancestor. However, if the
|
|
11
|
+
* `reverse: true` option is passed, they are reversed.
|
|
12
|
+
*/
|
|
13
|
+
ancestors(path: Path, options?: PathLevelsOptions): Path[];
|
|
14
|
+
/**
|
|
15
|
+
* Get a list of paths at every level down to a path. Note: this is the same
|
|
16
|
+
* as `Path.ancestors`, but including the path itself.
|
|
17
|
+
*
|
|
18
|
+
* The paths are sorted from shallowest to deepest. However, if the `reverse:
|
|
19
|
+
* true` option is passed, they are reversed.
|
|
20
|
+
*/
|
|
21
|
+
levels(path: Path, options?: PathLevelsOptions): Path[];
|
|
4
22
|
parent(path: Path): Path;
|
|
5
23
|
next(path: Path): Path;
|
|
6
24
|
/**
|
package/package.json
CHANGED
package/plait.module.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import * as i1 from "./board/board.component";
|
|
3
|
-
import * as i2 from "./core/
|
|
4
|
-
import * as i3 from "./core/
|
|
5
|
-
import * as i4 from "
|
|
3
|
+
import * as i2 from "./core/children/children.component";
|
|
4
|
+
import * as i3 from "./core/element/element.component";
|
|
5
|
+
import * as i4 from "./core/toolbar/toolbar.component";
|
|
6
|
+
import * as i5 from "@angular/platform-browser";
|
|
6
7
|
export declare class PlaitModule {
|
|
7
8
|
static ɵfac: i0.ɵɵFactoryDeclaration<PlaitModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<PlaitModule, [typeof i1.PlaitBoardComponent, typeof i2.
|
|
9
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<PlaitModule, [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent, typeof i4.PlaitToolbarComponent], [typeof i5.BrowserModule], [typeof i1.PlaitBoardComponent, typeof i2.PlaitChildrenElement, typeof i3.PlaitElementComponent, typeof i4.PlaitToolbarComponent]>;
|
|
9
10
|
static ɵinj: i0.ɵɵInjectorDeclaration<PlaitModule>;
|
|
10
11
|
}
|
package/public-api.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './board/board.component';
|
|
2
2
|
export * from './constants';
|
|
3
|
-
export * from './core/base/detector';
|
|
4
3
|
export * from './core/element/plugin-element';
|
|
5
4
|
export * from './core/element/element.component';
|
|
6
|
-
export * from './core/
|
|
5
|
+
export * from './core/children/children.component';
|
|
6
|
+
export * from './core/element/context-change';
|
|
7
7
|
export * from './core/toolbar/toolbar.component';
|
|
8
8
|
export * from './interfaces';
|
|
9
9
|
export * from './plait.module';
|
package/styles/styles.scss
CHANGED
|
@@ -4,3 +4,4 @@ import { RoughSVG } from 'roughjs/bin/svg';
|
|
|
4
4
|
* drawRoundRectangle
|
|
5
5
|
*/
|
|
6
6
|
export declare function drawRoundRectangle(rs: RoughSVG, x1: number, y1: number, x2: number, y2: number, options: Options, outline?: boolean, borderRadius?: number): SVGGElement;
|
|
7
|
+
export declare function drawAbstractRoundRectangle(rs: RoughSVG, x1: number, y1: number, x2: number, y2: number, isHorizontal: boolean, options: Options): SVGGElement;
|
package/utils/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from './weak-maps';
|
|
|
10
10
|
export * from './selected-element';
|
|
11
11
|
export * from './draw/rectangle';
|
|
12
12
|
export * from './draw/arrow';
|
|
13
|
+
export * from './draw/circle';
|
|
14
|
+
export * from './draw/line';
|
|
13
15
|
export * from './tree';
|
|
14
16
|
export * from './element';
|
|
15
17
|
export * from './viewport';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlaitBoard } from '../interfaces/board';
|
|
2
|
-
import { PlaitElement } from '../interfaces/element';
|
|
3
2
|
import { Range } from '../interfaces/selection';
|
|
4
|
-
|
|
3
|
+
import { PlaitElement } from '../interfaces/element';
|
|
4
|
+
export declare const getHitElements: (board: PlaitBoard) => 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/tree.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void): void;
|
|
1
|
+
export declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void, recursion?: (node: T) => boolean): void;
|
|
2
2
|
export interface TreeNode {
|
|
3
3
|
children?: TreeNode[];
|
|
4
4
|
}
|
package/utils/weak-maps.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { BoardComponentInterface } from '../board/board.component.interface';
|
|
|
3
3
|
import { PlaitElement } from '../interfaces/element';
|
|
4
4
|
import { PlaitBoard } from '../interfaces/board';
|
|
5
5
|
import { Point } from '../interfaces/point';
|
|
6
|
+
import { Ancestor } from '../interfaces/node';
|
|
7
|
+
export declare const IS_BOARD_CACHE: WeakMap<Object, boolean>;
|
|
6
8
|
export declare const FLUSHING: WeakMap<PlaitBoard, boolean>;
|
|
9
|
+
export declare const NODE_TO_INDEX: WeakMap<PlaitElement, number>;
|
|
10
|
+
export declare const NODE_TO_PARENT: WeakMap<PlaitElement, Ancestor>;
|
|
7
11
|
export declare const IS_TEXT_EDITABLE: WeakMap<PlaitBoard, boolean>;
|
|
8
12
|
export declare const BOARD_TO_ON_CHANGE: WeakMap<PlaitBoard, () => void>;
|
|
9
13
|
export declare const BOARD_TO_COMPONENT: WeakMap<PlaitBoard, BoardComponentInterface>;
|
package/core/base/detector.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Point } from '../../interfaces/point';
|
|
2
|
-
import { PlaitElement } from '../../interfaces/element';
|
|
3
|
-
import { Selection } from '../../interfaces/selection';
|
|
4
|
-
export interface BaseDetector {
|
|
5
|
-
contian: (selection: Selection, element: PlaitElement) => boolean;
|
|
6
|
-
hit: (point: Point, element: PlaitElement) => boolean;
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PlaitElement } from "../../interfaces";
|
|
2
|
-
import { PlaitPluginElementContext } from "./context";
|
|
3
|
-
export interface BeforeContextChange<T extends PlaitElement = PlaitElement> {
|
|
4
|
-
beforeContextChange: (value: PlaitPluginElementContext<T>) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function hasBeforeContextChange<T extends PlaitElement = PlaitElement>(value: any): value is BeforeContextChange<T>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV0ZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9wbGFpdC9zcmMvY29yZS9iYXNlL2RldGVjdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBQb2ludCB9IGZyb20gJy4uLy4uL2ludGVyZmFjZXMvcG9pbnQnO1xuaW1wb3J0IHsgUGxhaXRFbGVtZW50IH0gZnJvbSAnLi4vLi4vaW50ZXJmYWNlcy9lbGVtZW50JztcbmltcG9ydCB7IFNlbGVjdGlvbiB9IGZyb20gJy4uLy4uL2ludGVyZmFjZXMvc2VsZWN0aW9uJztcblxuZXhwb3J0IGludGVyZmFjZSBCYXNlRGV0ZWN0b3Ige1xuICAgIGNvbnRpYW46IChzZWxlY3Rpb246IFNlbGVjdGlvbiwgZWxlbWVudDogUGxhaXRFbGVtZW50KSA9PiBib29sZWFuOyAvLyDmoYbpgIlcbiAgICBoaXQ6IChwb2ludDogUG9pbnQsIGVsZW1lbnQ6IFBsYWl0RWxlbWVudCkgPT4gYm9vbGVhbjtcbn1cbiJdfQ==
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function hasBeforeContextChange(value) {
|
|
2
|
-
if (value.beforeContextChange) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVmb3JlLWNvbnRleHQtY2hhbmdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvcGxhaXQvc3JjL2NvcmUvZWxlbWVudC9iZWZvcmUtY29udGV4dC1jaGFuZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBT0EsTUFBTSxVQUFVLHNCQUFzQixDQUF3QyxLQUFVO0lBQ3BGLElBQUksS0FBSyxDQUFDLG1CQUFtQixFQUFFO1FBQzNCLE9BQU8sSUFBSSxDQUFDO0tBQ2Y7SUFDRCxPQUFPLEtBQUssQ0FBQztBQUNqQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUGxhaXRFbGVtZW50IH0gZnJvbSBcIi4uLy4uL2ludGVyZmFjZXNcIjtcbmltcG9ydCB7IFBsYWl0UGx1Z2luRWxlbWVudENvbnRleHQgfSBmcm9tIFwiLi9jb250ZXh0XCI7XG5cbmV4cG9ydCBpbnRlcmZhY2UgQmVmb3JlQ29udGV4dENoYW5nZTxUIGV4dGVuZHMgUGxhaXRFbGVtZW50ID0gUGxhaXRFbGVtZW50PiB7XG4gICAgYmVmb3JlQ29udGV4dENoYW5nZTogKHZhbHVlOiBQbGFpdFBsdWdpbkVsZW1lbnRDb250ZXh0PFQ+KSA9PiB2b2lkO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gaGFzQmVmb3JlQ29udGV4dENoYW5nZTxUIGV4dGVuZHMgUGxhaXRFbGVtZW50ID0gUGxhaXRFbGVtZW50Pih2YWx1ZTogYW55KTogdmFsdWUgaXMgQmVmb3JlQ29udGV4dENoYW5nZTxUPiB7XG4gICAgaWYgKHZhbHVlLmJlZm9yZUNvbnRleHRDaGFuZ2UpIHtcbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIHJldHVybiBmYWxzZTtcbn1cbiJdfQ==
|