@plait/core 0.91.0 → 0.92.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/index.d.ts +1464 -3
- package/package.json +1 -1
- package/constants/cursor.d.ts +0 -10
- package/constants/index.d.ts +0 -19
- package/constants/keycodes.d.ts +0 -126
- package/constants/selection.d.ts +0 -5
- package/constants/zoom.d.ts +0 -3
- package/context.d.ts +0 -7
- package/core/element/context-change.d.ts +0 -10
- package/core/element/context.d.ts +0 -14
- package/core/element/element-flavour.d.ts +0 -30
- package/core/element/element-ref.d.ts +0 -5
- package/core/list-render.d.ts +0 -14
- package/differs/default_iterable_differ.d.ts +0 -141
- package/differs/iterable_differs.d.ts +0 -141
- package/interfaces/board.d.ts +0 -113
- package/interfaces/custom-types.d.ts +0 -9
- package/interfaces/direction.d.ts +0 -11
- package/interfaces/element.d.ts +0 -27
- package/interfaces/group.d.ts +0 -7
- package/interfaces/history.d.ts +0 -10
- package/interfaces/index.d.ts +0 -18
- package/interfaces/node.d.ts +0 -21
- package/interfaces/operation.d.ts +0 -53
- package/interfaces/path-ref.d.ts +0 -13
- package/interfaces/path.d.ts +0 -52
- package/interfaces/plugin.d.ts +0 -17
- package/interfaces/point.d.ts +0 -15
- package/interfaces/pointer.d.ts +0 -4
- package/interfaces/rectangle-client.d.ts +0 -49
- package/interfaces/selection.d.ts +0 -10
- package/interfaces/svg-arc-command.d.ts +0 -9
- package/interfaces/theme.d.ts +0 -24
- package/interfaces/viewport.d.ts +0 -18
- package/plugins/create-board.d.ts +0 -3
- package/plugins/index.d.ts +0 -11
- package/plugins/with-board.d.ts +0 -2
- package/plugins/with-hand.d.ts +0 -4
- package/plugins/with-history.d.ts +0 -2
- package/plugins/with-hotkey.d.ts +0 -2
- package/plugins/with-i18n.d.ts +0 -6
- package/plugins/with-moving.d.ts +0 -8
- package/plugins/with-options.d.ts +0 -7
- package/plugins/with-related-fragment.d.ts +0 -2
- package/plugins/with-selection.d.ts +0 -2
- package/public-api.d.ts +0 -12
- package/testing/core/create-board.d.ts +0 -6
- package/testing/core/fake-weak-map.d.ts +0 -4
- package/testing/core/index.d.ts +0 -2
- package/testing/fake-events/event-objects.d.ts +0 -46
- package/testing/fake-events/index.d.ts +0 -1
- package/testing/index.d.ts +0 -2
- package/testing/test-element.d.ts +0 -14
- package/transforms/board.d.ts +0 -25
- package/transforms/element.d.ts +0 -6
- package/transforms/general.d.ts +0 -6
- package/transforms/group.d.ts +0 -11
- package/transforms/index.d.ts +0 -9
- package/transforms/node.d.ts +0 -14
- package/transforms/selection.d.ts +0 -10
- package/transforms/theme.d.ts +0 -7
- package/transforms/viewport.d.ts +0 -7
- package/transforms/z-index.d.ts +0 -13
- package/utils/angle.d.ts +0 -24
- package/utils/board.d.ts +0 -11
- package/utils/clipboard/clipboard.d.ts +0 -5
- package/utils/clipboard/common.d.ts +0 -12
- package/utils/clipboard/data-transfer.d.ts +0 -5
- package/utils/clipboard/index.d.ts +0 -2
- package/utils/clipboard/navigator-clipboard.d.ts +0 -3
- package/utils/clipboard/types.d.ts +0 -24
- package/utils/common.d.ts +0 -13
- package/utils/debug.d.ts +0 -14
- package/utils/dnd.d.ts +0 -4
- package/utils/dom/common.d.ts +0 -23
- package/utils/dom/environment.d.ts +0 -1
- package/utils/dom/foreign.d.ts +0 -3
- package/utils/dom/index.d.ts +0 -3
- package/utils/drawing/arrow.d.ts +0 -8
- package/utils/drawing/circle.d.ts +0 -4
- package/utils/drawing/line.d.ts +0 -6
- package/utils/drawing/rectangle.d.ts +0 -9
- package/utils/element.d.ts +0 -11
- package/utils/environment.d.ts +0 -8
- package/utils/fragment.d.ts +0 -5
- package/utils/group.d.ts +0 -25
- package/utils/helper.d.ts +0 -17
- package/utils/history.d.ts +0 -49
- package/utils/hotkeys.d.ts +0 -37
- package/utils/id-creator.d.ts +0 -1
- package/utils/index.d.ts +0 -34
- package/utils/iterable.d.ts +0 -10
- package/utils/math.d.ts +0 -67
- package/utils/moving-element.d.ts +0 -5
- package/utils/pointer.d.ts +0 -5
- package/utils/position.d.ts +0 -2
- package/utils/selected-element.d.ts +0 -19
- package/utils/selection.d.ts +0 -18
- package/utils/snap/snap-moving.d.ts +0 -5
- package/utils/snap/snap.d.ts +0 -31
- package/utils/to-image.d.ts +0 -22
- package/utils/to-point.d.ts +0 -31
- package/utils/tree.d.ts +0 -7
- package/utils/viewport.d.ts +0 -50
- package/utils/weak-maps.d.ts +0 -43
- package/utils/z-index.d.ts +0 -5
package/index.d.ts
CHANGED
|
@@ -1,5 +1,1466 @@
|
|
|
1
|
+
import { RoughSVG } from 'roughjs/bin/svg';
|
|
2
|
+
import { Options } from 'roughjs/bin/core';
|
|
3
|
+
import * as _plait_core from '@plait/core';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright Google LLC All Rights Reserved.
|
|
8
|
+
*
|
|
9
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
10
|
+
* found in the LICENSE file at https://angular.io/license
|
|
3
11
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
declare const MAC_ENTER = 3;
|
|
13
|
+
declare const BACKSPACE = 8;
|
|
14
|
+
declare const TAB = 9;
|
|
15
|
+
declare const NUM_CENTER = 12;
|
|
16
|
+
declare const ENTER = 13;
|
|
17
|
+
declare const SHIFT = 16;
|
|
18
|
+
declare const CONTROL = 17;
|
|
19
|
+
declare const ALT = 18;
|
|
20
|
+
declare const PAUSE = 19;
|
|
21
|
+
declare const CAPS_LOCK = 20;
|
|
22
|
+
declare const ESCAPE = 27;
|
|
23
|
+
declare const SPACE = 32;
|
|
24
|
+
declare const PAGE_UP = 33;
|
|
25
|
+
declare const PAGE_DOWN = 34;
|
|
26
|
+
declare const END = 35;
|
|
27
|
+
declare const HOME = 36;
|
|
28
|
+
declare const LEFT_ARROW = 37;
|
|
29
|
+
declare const UP_ARROW = 38;
|
|
30
|
+
declare const RIGHT_ARROW = 39;
|
|
31
|
+
declare const DOWN_ARROW = 40;
|
|
32
|
+
declare const PLUS_SIGN = 43;
|
|
33
|
+
declare const PRINT_SCREEN = 44;
|
|
34
|
+
declare const INSERT = 45;
|
|
35
|
+
declare const DELETE = 46;
|
|
36
|
+
declare const ZERO = 48;
|
|
37
|
+
declare const ONE = 49;
|
|
38
|
+
declare const TWO = 50;
|
|
39
|
+
declare const THREE = 51;
|
|
40
|
+
declare const FOUR = 52;
|
|
41
|
+
declare const FIVE = 53;
|
|
42
|
+
declare const SIX = 54;
|
|
43
|
+
declare const SEVEN = 55;
|
|
44
|
+
declare const EIGHT = 56;
|
|
45
|
+
declare const NINE = 57;
|
|
46
|
+
declare const FF_SEMICOLON = 59;
|
|
47
|
+
declare const FF_EQUALS = 61;
|
|
48
|
+
declare const QUESTION_MARK = 63;
|
|
49
|
+
declare const AT_SIGN = 64;
|
|
50
|
+
declare const A = 65;
|
|
51
|
+
declare const B = 66;
|
|
52
|
+
declare const C = 67;
|
|
53
|
+
declare const D = 68;
|
|
54
|
+
declare const E = 69;
|
|
55
|
+
declare const F = 70;
|
|
56
|
+
declare const G = 71;
|
|
57
|
+
declare const H = 72;
|
|
58
|
+
declare const I = 73;
|
|
59
|
+
declare const J = 74;
|
|
60
|
+
declare const K = 75;
|
|
61
|
+
declare const L = 76;
|
|
62
|
+
declare const M = 77;
|
|
63
|
+
declare const N = 78;
|
|
64
|
+
declare const O = 79;
|
|
65
|
+
declare const P = 80;
|
|
66
|
+
declare const Q = 81;
|
|
67
|
+
declare const R = 82;
|
|
68
|
+
declare const S = 83;
|
|
69
|
+
declare const T = 84;
|
|
70
|
+
declare const U = 85;
|
|
71
|
+
declare const V = 86;
|
|
72
|
+
declare const W = 87;
|
|
73
|
+
declare const X = 88;
|
|
74
|
+
declare const Y = 89;
|
|
75
|
+
declare const Z = 90;
|
|
76
|
+
declare const META = 91;
|
|
77
|
+
declare const MAC_WK_CMD_LEFT = 91;
|
|
78
|
+
declare const MAC_WK_CMD_RIGHT = 93;
|
|
79
|
+
declare const CONTEXT_MENU = 93;
|
|
80
|
+
declare const NUMPAD_ZERO = 96;
|
|
81
|
+
declare const NUMPAD_ONE = 97;
|
|
82
|
+
declare const NUMPAD_TWO = 98;
|
|
83
|
+
declare const NUMPAD_THREE = 99;
|
|
84
|
+
declare const NUMPAD_FOUR = 100;
|
|
85
|
+
declare const NUMPAD_FIVE = 101;
|
|
86
|
+
declare const NUMPAD_SIX = 102;
|
|
87
|
+
declare const NUMPAD_SEVEN = 103;
|
|
88
|
+
declare const NUMPAD_EIGHT = 104;
|
|
89
|
+
declare const NUMPAD_NINE = 105;
|
|
90
|
+
declare const NUMPAD_MULTIPLY = 106;
|
|
91
|
+
declare const NUMPAD_PLUS = 107;
|
|
92
|
+
declare const NUMPAD_MINUS = 109;
|
|
93
|
+
declare const NUMPAD_PERIOD = 110;
|
|
94
|
+
declare const NUMPAD_DIVIDE = 111;
|
|
95
|
+
declare const F1 = 112;
|
|
96
|
+
declare const F2 = 113;
|
|
97
|
+
declare const F3 = 114;
|
|
98
|
+
declare const F4 = 115;
|
|
99
|
+
declare const F5 = 116;
|
|
100
|
+
declare const F6 = 117;
|
|
101
|
+
declare const F7 = 118;
|
|
102
|
+
declare const F8 = 119;
|
|
103
|
+
declare const F9 = 120;
|
|
104
|
+
declare const F10 = 121;
|
|
105
|
+
declare const F11 = 122;
|
|
106
|
+
declare const F12 = 123;
|
|
107
|
+
declare const NUM_LOCK = 144;
|
|
108
|
+
declare const SCROLL_LOCK = 145;
|
|
109
|
+
declare const FIRST_MEDIA = 166;
|
|
110
|
+
declare const FF_MINUS = 173;
|
|
111
|
+
declare const MUTE = 173;
|
|
112
|
+
declare const VOLUME_DOWN = 174;
|
|
113
|
+
declare const VOLUME_UP = 175;
|
|
114
|
+
declare const FF_MUTE = 181;
|
|
115
|
+
declare const FF_VOLUME_DOWN = 182;
|
|
116
|
+
declare const LAST_MEDIA = 183;
|
|
117
|
+
declare const FF_VOLUME_UP = 183;
|
|
118
|
+
declare const SEMICOLON = 186;
|
|
119
|
+
declare const EQUALS = 187;
|
|
120
|
+
declare const COMMA = 188;
|
|
121
|
+
declare const DASH = 189;
|
|
122
|
+
declare const PERIOD = 190;
|
|
123
|
+
declare const SLASH = 191;
|
|
124
|
+
declare const APOSTROPHE = 192;
|
|
125
|
+
declare const TILDE = 192;
|
|
126
|
+
declare const OPEN_SQUARE_BRACKET = 219;
|
|
127
|
+
declare const BACKSLASH = 220;
|
|
128
|
+
declare const CLOSE_SQUARE_BRACKET = 221;
|
|
129
|
+
declare const SINGLE_QUOTE = 222;
|
|
130
|
+
declare const MAC_META = 224;
|
|
131
|
+
|
|
132
|
+
declare enum ResizeCursorClass {
|
|
133
|
+
ew = "ew-resize",
|
|
134
|
+
ns = "ns-resize",
|
|
135
|
+
nesw = "nesw-resize",
|
|
136
|
+
nwse = "nwse-resize"
|
|
137
|
+
}
|
|
138
|
+
declare enum CursorClass {
|
|
139
|
+
crosshair = "crosshair"
|
|
140
|
+
}
|
|
141
|
+
declare const RESIZE_CURSORS: ResizeCursorClass[];
|
|
142
|
+
|
|
143
|
+
declare const ATTACHED_ELEMENT_CLASS_NAME = "plait-board-attached";
|
|
144
|
+
declare const ACTIVE_STROKE_WIDTH = 1;
|
|
145
|
+
declare const SNAPPING_STROKE_WIDTH = 2;
|
|
146
|
+
declare const SELECTION_RECTANGLE_CLASS_NAME = "selection-rectangle";
|
|
147
|
+
declare const SELECTION_RECTANGLE_BOUNDING_CLASS_NAME = "selection-rectangle-bounding";
|
|
148
|
+
|
|
149
|
+
declare const ZOOM_STEP = 0.1;
|
|
150
|
+
declare const MIN_ZOOM = 0.1;
|
|
151
|
+
declare const MAX_ZOOM = 4;
|
|
152
|
+
|
|
153
|
+
declare const HOST_CLASS_NAME = "plait-board-container";
|
|
154
|
+
declare const ACTIVE_MOVING_CLASS_NAME = "active-with-moving";
|
|
155
|
+
declare const ROTATE_HANDLE_CLASS_NAME = "rotate-handle";
|
|
156
|
+
declare const RESIZE_HANDLE_CLASS_NAME = "resize-handle";
|
|
157
|
+
declare const SCROLL_BAR_WIDTH = 20;
|
|
158
|
+
declare const MAX_RADIUS = 16;
|
|
159
|
+
declare const POINTER_BUTTON: {
|
|
160
|
+
readonly MAIN: 0;
|
|
161
|
+
readonly WHEEL: 1;
|
|
162
|
+
readonly SECONDARY: 2;
|
|
163
|
+
readonly TOUCH: -1;
|
|
164
|
+
};
|
|
165
|
+
declare const PRESS_AND_MOVE_BUFFER = 3;
|
|
166
|
+
declare const DRAG_SELECTION_PRESS_AND_MOVE_BUFFER = 10;
|
|
167
|
+
declare const HIT_DISTANCE_BUFFER = 5;
|
|
168
|
+
|
|
169
|
+
declare enum PlaitPointerType {
|
|
170
|
+
'hand' = "hand",
|
|
171
|
+
'selection' = "selection"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface XYPosition {
|
|
175
|
+
x: number;
|
|
176
|
+
y: number;
|
|
177
|
+
}
|
|
178
|
+
type Point = [number, number];
|
|
179
|
+
declare const Point: {
|
|
180
|
+
isEquals(point?: Point, otherPoint?: Point): boolean | undefined;
|
|
181
|
+
isHorizontal(point?: Point, otherPoint?: Point, tolerance?: number): boolean | undefined;
|
|
182
|
+
isOverHorizontal(points: Point[], tolerance?: number): boolean;
|
|
183
|
+
isVertical(point?: Point, otherPoint?: Point, tolerance?: number): boolean | undefined;
|
|
184
|
+
isOverVertical(points: Point[], tolerance?: number): boolean;
|
|
185
|
+
isAlign(points: Point[], tolerance?: number): boolean;
|
|
186
|
+
getOffsetX(point1: Point, point2: Point): number;
|
|
187
|
+
getOffsetY(point1: Point, point2: Point): number;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* store the instance ref for element
|
|
192
|
+
*/
|
|
193
|
+
interface PlaitElementRef {
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface PlaitElement {
|
|
197
|
+
[key: string]: any;
|
|
198
|
+
id: string;
|
|
199
|
+
children?: PlaitElement[];
|
|
200
|
+
points?: Point[];
|
|
201
|
+
type?: string;
|
|
202
|
+
groupId?: string;
|
|
203
|
+
angle?: number;
|
|
204
|
+
}
|
|
205
|
+
declare const PlaitElement: {
|
|
206
|
+
isRootElement(value: PlaitElement): boolean;
|
|
207
|
+
getElementRef<T extends PlaitElementRef = PlaitElementRef>(value: PlaitElement): T;
|
|
208
|
+
getElementG(value: PlaitElement): SVGGElement;
|
|
209
|
+
hasMounted(element: PlaitElement): boolean;
|
|
210
|
+
getContainerG<T extends boolean>(value: PlaitElement, options: {
|
|
211
|
+
suppressThrow: T;
|
|
212
|
+
}): T extends true ? SVGGElement | null : SVGGElement;
|
|
213
|
+
};
|
|
214
|
+
interface ComponentType<T> {
|
|
215
|
+
new (...args: any[]): T;
|
|
216
|
+
}
|
|
217
|
+
interface ImageEntry {
|
|
218
|
+
url: string;
|
|
219
|
+
file: File;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface PlaitPluginElementContext<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard> {
|
|
223
|
+
element: T;
|
|
224
|
+
parent: T | K;
|
|
225
|
+
selected: boolean;
|
|
226
|
+
board: K;
|
|
227
|
+
index: number;
|
|
228
|
+
hasThemeChanged: boolean;
|
|
229
|
+
}
|
|
230
|
+
interface PlaitChildrenContext<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard> {
|
|
231
|
+
board: K;
|
|
232
|
+
parentG: SVGGElement;
|
|
233
|
+
parent: T | K;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface PathLevelsOptions {
|
|
237
|
+
reverse?: boolean;
|
|
238
|
+
}
|
|
239
|
+
type Path = number[];
|
|
240
|
+
declare const Path: {
|
|
241
|
+
/**
|
|
242
|
+
* Get a list of ancestor paths for a given path.
|
|
243
|
+
*
|
|
244
|
+
* The paths are sorted from shallowest to deepest ancestor. However, if the
|
|
245
|
+
* `reverse: true` option is passed, they are reversed.
|
|
246
|
+
*/
|
|
247
|
+
ancestors(path: Path, options?: PathLevelsOptions): Path[];
|
|
248
|
+
/**
|
|
249
|
+
* Get a list of paths at every level down to a path. Note: this is the same
|
|
250
|
+
* as `Path.ancestors`, but including the path itself.
|
|
251
|
+
*
|
|
252
|
+
* The paths are sorted from shallowest to deepest. However, if the `reverse:
|
|
253
|
+
* true` option is passed, they are reversed.
|
|
254
|
+
*/
|
|
255
|
+
levels(path: Path, options?: PathLevelsOptions): Path[];
|
|
256
|
+
parent(path: Path): Path;
|
|
257
|
+
next(path: Path): Path;
|
|
258
|
+
hasPrevious(path: Path): boolean;
|
|
259
|
+
previous(path: Path): Path;
|
|
260
|
+
/**
|
|
261
|
+
* Check if a path is an ancestor of another.
|
|
262
|
+
*/
|
|
263
|
+
isAncestor(path: Path, another: Path): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Compare a path to another, returning an integer indicating whether the path
|
|
266
|
+
* was before, at, or after the other.
|
|
267
|
+
*
|
|
268
|
+
* Note: Two paths of unequal length can still receive a `0` result if one is
|
|
269
|
+
* directly above or below the other. If you want exact matching, use
|
|
270
|
+
* [[Path.equals]] instead.
|
|
271
|
+
*/
|
|
272
|
+
compare(path: Path, another: Path): -1 | 0 | 1;
|
|
273
|
+
/**
|
|
274
|
+
* Check if a path is exactly equal to another.
|
|
275
|
+
*/
|
|
276
|
+
equals(path: Path, another: Path): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Check if a path ends before one of the indexes in another.
|
|
279
|
+
*/
|
|
280
|
+
endsBefore(path: Path, another: Path): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Check if a path is a sibling of another.
|
|
283
|
+
*/
|
|
284
|
+
isSibling(path: Path, another: Path): boolean;
|
|
285
|
+
transform(path: Path | null, operation: PlaitOperation): Path | null;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
type Ancestor = PlaitBoard | PlaitElement;
|
|
289
|
+
interface NodeParentsOptions {
|
|
290
|
+
reverse?: boolean;
|
|
291
|
+
}
|
|
292
|
+
type PlaitNode = PlaitElement;
|
|
293
|
+
declare const PlaitNode: {
|
|
294
|
+
parent: (board: PlaitBoard, path: Path) => PlaitElement;
|
|
295
|
+
/**
|
|
296
|
+
* Return a generator of all the ancestor nodes above a specific path.
|
|
297
|
+
*
|
|
298
|
+
* By default the order is top-down, from highest to lowest ancestor in
|
|
299
|
+
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
300
|
+
*/
|
|
301
|
+
parents(root: PlaitBoard, path: Path, options?: NodeParentsOptions): Generator<PlaitNode, void, undefined>;
|
|
302
|
+
get<T extends PlaitNode = PlaitElement>(root: PlaitBoard, path: Path): T;
|
|
303
|
+
last(board: PlaitBoard, path: Path): PlaitElement;
|
|
304
|
+
first(board: PlaitBoard, path: Path): PlaitElement;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
declare const SELECTION_BORDER_COLOR = "#6698FF";
|
|
308
|
+
declare const SELECTION_FILL_COLOR = "#6698FF25";
|
|
309
|
+
interface Selection {
|
|
310
|
+
anchor: Point;
|
|
311
|
+
focus: Point;
|
|
312
|
+
}
|
|
313
|
+
declare const Selection: {
|
|
314
|
+
isCollapsed(selection: Selection): boolean;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
interface PlaitTheme {
|
|
318
|
+
themeColorMode: ThemeColorMode;
|
|
319
|
+
}
|
|
320
|
+
interface ThemeColor {
|
|
321
|
+
mode: ThemeColorMode | string;
|
|
322
|
+
boardBackground?: string;
|
|
323
|
+
textColor: string;
|
|
324
|
+
}
|
|
325
|
+
declare enum ThemeColorMode {
|
|
326
|
+
'default' = "default",
|
|
327
|
+
'colorful' = "colorful",
|
|
328
|
+
'soft' = "soft",
|
|
329
|
+
'retro' = "retro",
|
|
330
|
+
'dark' = "dark",
|
|
331
|
+
'starry' = "starry"
|
|
332
|
+
}
|
|
333
|
+
declare const DEFAULT_COLOR = "#333333";
|
|
334
|
+
declare const DefaultThemeColor: ThemeColor;
|
|
335
|
+
declare const ColorfulThemeColor: ThemeColor;
|
|
336
|
+
declare const SoftThemeColor: ThemeColor;
|
|
337
|
+
declare const RetroThemeColor: ThemeColor;
|
|
338
|
+
declare const DarkThemeColor: ThemeColor;
|
|
339
|
+
declare const StarryThemeColor: ThemeColor;
|
|
340
|
+
declare const ThemeColors: ThemeColor[];
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Extendable Custom Types Interface
|
|
344
|
+
*/
|
|
345
|
+
type ExtendableTypes = 'Viewport' | 'SetViewportOperation' | 'SetSelectionOperation';
|
|
346
|
+
interface CustomTypes {
|
|
347
|
+
[key: string]: unknown;
|
|
348
|
+
}
|
|
349
|
+
type ExtendedType<K extends ExtendableTypes, B> = unknown extends CustomTypes[K] ? B : CustomTypes[K];
|
|
350
|
+
|
|
351
|
+
interface BaseViewport {
|
|
352
|
+
[key: string]: any;
|
|
353
|
+
zoom: number;
|
|
354
|
+
origination?: Point;
|
|
355
|
+
}
|
|
356
|
+
interface ViewportInterface {
|
|
357
|
+
isViewport: (value: any) => value is Viewport;
|
|
358
|
+
}
|
|
359
|
+
type Viewport = ExtendedType<'Viewport', BaseViewport>;
|
|
360
|
+
declare const Viewport: ViewportInterface;
|
|
361
|
+
interface FitViewportOptions {
|
|
362
|
+
maxWidth?: number;
|
|
363
|
+
limitHeight: number;
|
|
364
|
+
autoFitPadding: number;
|
|
365
|
+
containerClass: string;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
type InsertNodeOperation = {
|
|
369
|
+
type: 'insert_node';
|
|
370
|
+
path: Path;
|
|
371
|
+
node: PlaitNode;
|
|
372
|
+
};
|
|
373
|
+
type RemoveNodeOperation = {
|
|
374
|
+
type: 'remove_node';
|
|
375
|
+
path: Path;
|
|
376
|
+
node: PlaitNode;
|
|
377
|
+
};
|
|
378
|
+
type MoveNodeOperation = {
|
|
379
|
+
type: 'move_node';
|
|
380
|
+
path: Path;
|
|
381
|
+
newPath: Path;
|
|
382
|
+
};
|
|
383
|
+
type SetThemeOperation = {
|
|
384
|
+
type: 'set_theme';
|
|
385
|
+
properties: Partial<PlaitTheme>;
|
|
386
|
+
newProperties: Partial<PlaitTheme>;
|
|
387
|
+
};
|
|
388
|
+
type SetViewportOperation = {
|
|
389
|
+
type: 'set_viewport';
|
|
390
|
+
properties: Partial<Viewport>;
|
|
391
|
+
newProperties: Partial<Viewport>;
|
|
392
|
+
};
|
|
393
|
+
type SetSelectionOperation = {
|
|
394
|
+
type: 'set_selection';
|
|
395
|
+
properties: Selection | null;
|
|
396
|
+
newProperties: Selection | null;
|
|
397
|
+
};
|
|
398
|
+
type SetNodeOperation = {
|
|
399
|
+
type: 'set_node';
|
|
400
|
+
path: Path;
|
|
401
|
+
properties: Partial<PlaitNode>;
|
|
402
|
+
newProperties: Partial<PlaitNode>;
|
|
403
|
+
};
|
|
404
|
+
interface PlaitOperationInterface {
|
|
405
|
+
inverse: (op: PlaitOperation) => PlaitOperation;
|
|
406
|
+
isSetViewportOperation: (value: PlaitOperation) => boolean;
|
|
407
|
+
isSetSelectionOperation: (value: PlaitOperation) => boolean;
|
|
408
|
+
isSetThemeOperation: (value: PlaitOperation) => boolean;
|
|
409
|
+
}
|
|
410
|
+
declare const isSetViewportOperation: (value: any) => value is SetViewportOperation;
|
|
411
|
+
declare const isSetSelectionOperation: (value: any) => value is SetSelectionOperation;
|
|
412
|
+
declare const isSetThemeOperation: (value: any) => value is SetThemeOperation;
|
|
413
|
+
declare const inverse: (op: PlaitOperation) => PlaitOperation;
|
|
414
|
+
type PlaitOperation = InsertNodeOperation | SetViewportOperation | SetSelectionOperation | SetNodeOperation | RemoveNodeOperation | MoveNodeOperation | SetThemeOperation;
|
|
415
|
+
declare const PlaitOperation: PlaitOperationInterface;
|
|
416
|
+
|
|
417
|
+
interface PlaitHistory {
|
|
418
|
+
redos: PlaitOperation[][];
|
|
419
|
+
undos: PlaitOperation[][];
|
|
420
|
+
}
|
|
421
|
+
declare const SAVING: WeakMap<PlaitBoard, boolean | undefined>;
|
|
422
|
+
declare const MERGING: WeakMap<PlaitBoard, boolean | undefined>;
|
|
423
|
+
declare const HISTORY: WeakMap<PlaitBoard, History>;
|
|
424
|
+
declare const SPLITTING_ONCE: WeakMap<PlaitBoard, boolean | undefined>;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* [x, y] x,y between 0 and 1
|
|
428
|
+
* represents a point in the rectangle
|
|
429
|
+
*/
|
|
430
|
+
type PointOfRectangle = [number, number];
|
|
431
|
+
interface RectangleClient {
|
|
432
|
+
x: number;
|
|
433
|
+
y: number;
|
|
434
|
+
width: number;
|
|
435
|
+
height: number;
|
|
436
|
+
}
|
|
437
|
+
declare const RectangleClient: {
|
|
438
|
+
isHit: (origin: RectangleClient, target: RectangleClient) => boolean;
|
|
439
|
+
isHitX: (origin: RectangleClient, target: RectangleClient) => boolean;
|
|
440
|
+
isHitY: (origin: RectangleClient, target: RectangleClient) => boolean;
|
|
441
|
+
getPoints(rectangle: RectangleClient): [Point, Point];
|
|
442
|
+
getRectangleByCenterPoint(point: Point, width: number, height: number): RectangleClient;
|
|
443
|
+
getRectangleByPoint(point: Point, width: number, height: number): RectangleClient;
|
|
444
|
+
getRectangleByPoints(points: Point[] | Point[][]): RectangleClient;
|
|
445
|
+
getCornerPointsByPoints(points: Point[]): [Point, Point, Point, Point];
|
|
446
|
+
getOutlineRectangle: (rectangle: RectangleClient, offset: number) => {
|
|
447
|
+
x: number;
|
|
448
|
+
y: number;
|
|
449
|
+
width: number;
|
|
450
|
+
height: number;
|
|
451
|
+
};
|
|
452
|
+
inflate: (rectangle: RectangleClient, delta: number) => {
|
|
453
|
+
x: number;
|
|
454
|
+
y: number;
|
|
455
|
+
width: number;
|
|
456
|
+
height: number;
|
|
457
|
+
};
|
|
458
|
+
isEqual: (rectangle: RectangleClient, otherRectangle: RectangleClient) => boolean;
|
|
459
|
+
getCornerPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
|
|
460
|
+
getCenterPoint: (rectangle: RectangleClient) => Point;
|
|
461
|
+
getCenterPointByPoints: (points: Point[]) => Point;
|
|
462
|
+
getEdgeCenterPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
|
|
463
|
+
getConnectionPoint: (rectangle: RectangleClient, point: PointOfRectangle) => Point;
|
|
464
|
+
expand(rectangle: RectangleClient, left: number, top?: number, right?: number, bottom?: number): {
|
|
465
|
+
x: number;
|
|
466
|
+
y: number;
|
|
467
|
+
width: number;
|
|
468
|
+
height: number;
|
|
469
|
+
};
|
|
470
|
+
getGapCenter(rectangle1: RectangleClient, rectangle2: RectangleClient, isHorizontal: boolean): number;
|
|
471
|
+
isPointInRectangle(rectangle: RectangleClient, point: Point): boolean;
|
|
472
|
+
getBoundingRectangle(rectangles: RectangleClient[]): RectangleClient;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
interface PathRefOptions {
|
|
476
|
+
affinity?: 'forward' | 'backward' | null;
|
|
477
|
+
}
|
|
478
|
+
interface PathRef {
|
|
479
|
+
current: Path | null;
|
|
480
|
+
affinity: 'forward' | 'backward' | null;
|
|
481
|
+
unref(): Path | null;
|
|
482
|
+
}
|
|
483
|
+
declare const PathRef: {
|
|
484
|
+
transform(ref: PathRef, op: PlaitOperation): void;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type ViewBox = {
|
|
488
|
+
minX: number;
|
|
489
|
+
minY: number;
|
|
490
|
+
width: number;
|
|
491
|
+
height: number;
|
|
492
|
+
viewportWidth: number;
|
|
493
|
+
viewportHeight: number;
|
|
494
|
+
};
|
|
495
|
+
declare function isInPlaitBoard(board: PlaitBoard, x: number, y: number): boolean;
|
|
496
|
+
declare function getRealScrollBarWidth(board: PlaitBoard): number;
|
|
497
|
+
|
|
498
|
+
declare const NS = "http://www.w3.org/2000/svg";
|
|
499
|
+
declare function createG(): SVGGElement;
|
|
500
|
+
declare function createPath(): SVGPathElement;
|
|
501
|
+
declare function createRect(rectangle: RectangleClient, options?: Options): SVGRectElement;
|
|
502
|
+
declare const setStrokeLinecap: (g: SVGGElement, value: "round" | "square") => void;
|
|
503
|
+
declare const setPathStrokeLinecap: (g: SVGGElement, value: "round" | "square") => void;
|
|
504
|
+
declare function createMask(): SVGMaskElement;
|
|
505
|
+
declare function createSVG(): SVGSVGElement;
|
|
506
|
+
declare function createText(x: number, y: number, fill: string, textContent: string): SVGTextElement;
|
|
507
|
+
/**
|
|
508
|
+
* Check if a DOM node is an element node.
|
|
509
|
+
*/
|
|
510
|
+
declare const isDOMElement: (value: any) => value is Element;
|
|
511
|
+
/**
|
|
512
|
+
* Check if a value is a DOM node.
|
|
513
|
+
*/
|
|
514
|
+
declare const isDOMNode: (value: any) => value is Node;
|
|
515
|
+
declare const hasInputOrTextareaTarget: (target: EventTarget | null) => boolean;
|
|
516
|
+
declare const isSecondaryPointer: (event: MouseEvent) => boolean;
|
|
517
|
+
declare const isMainPointer: (event: MouseEvent) => boolean;
|
|
518
|
+
declare const isWheelPointer: (event: MouseEvent) => boolean;
|
|
519
|
+
|
|
520
|
+
declare function createForeignObject(x: number, y: number, width: number, height: number): SVGForeignObjectElement;
|
|
521
|
+
declare function updateForeignObject(target: SVGForeignObjectElement | SVGGElement, width: number, height: number, x: number, y: number): void;
|
|
522
|
+
declare function updateForeignObjectWidth(target: SVGForeignObjectElement | SVGGElement, width: number): void;
|
|
523
|
+
|
|
524
|
+
declare const IS_MAC: boolean;
|
|
525
|
+
|
|
526
|
+
declare const IS_IOS: boolean;
|
|
527
|
+
declare const IS_APPLE: boolean;
|
|
528
|
+
declare const IS_FIREFOX: boolean;
|
|
529
|
+
declare const IS_SAFARI: boolean;
|
|
530
|
+
declare const IS_EDGE_LEGACY: boolean;
|
|
531
|
+
declare const IS_CHROME: boolean;
|
|
532
|
+
declare const IS_CHROME_LEGACY: boolean;
|
|
533
|
+
declare const IS_WINDOWS: boolean;
|
|
534
|
+
|
|
535
|
+
declare function isNullOrUndefined(value: any): boolean;
|
|
536
|
+
/**
|
|
537
|
+
* get {x,y} point
|
|
538
|
+
* @param point
|
|
539
|
+
* @returns point
|
|
540
|
+
*/
|
|
541
|
+
declare function normalizePoint(point: number[]): {
|
|
542
|
+
x: number;
|
|
543
|
+
y: number;
|
|
544
|
+
};
|
|
545
|
+
declare const rgbaToHEX: (rgb: string, opacity: number) => string;
|
|
546
|
+
declare function isContextmenu(event: MouseEvent): boolean;
|
|
547
|
+
declare function uniqueById(elements: PlaitElement[]): any[];
|
|
548
|
+
declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
549
|
+
declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
550
|
+
declare const isIndicesContinuous: (indexes: number[]) => boolean;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Check whether to merge an operation into the previous operation.
|
|
554
|
+
*/
|
|
555
|
+
declare const shouldMerge: (op: PlaitOperation, prev: PlaitOperation | undefined) => boolean;
|
|
556
|
+
/**
|
|
557
|
+
* Check whether an operation needs to be saved to the history.
|
|
558
|
+
*/
|
|
559
|
+
declare const shouldSave: (op: PlaitOperation, prev: PlaitOperation | undefined) => boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Check whether an operation should clear the redos stack.
|
|
562
|
+
*/
|
|
563
|
+
declare const shouldClear: (op: PlaitOperation) => boolean;
|
|
564
|
+
declare const PlaitHistoryBoard: {
|
|
565
|
+
/**
|
|
566
|
+
* Get the saving flag's current value.
|
|
567
|
+
*/
|
|
568
|
+
isSaving(board: PlaitBoard): boolean | undefined;
|
|
569
|
+
/**
|
|
570
|
+
* Get the merge flag's current value.
|
|
571
|
+
*/
|
|
572
|
+
isMerging(board: PlaitBoard): boolean | undefined;
|
|
573
|
+
/**
|
|
574
|
+
* Get the splitting once flag's current value.
|
|
575
|
+
*/
|
|
576
|
+
isSplittingOnce(board: PlaitBoard): boolean | undefined;
|
|
577
|
+
setSplittingOnce(board: PlaitBoard, value: boolean | undefined): void;
|
|
578
|
+
/**
|
|
579
|
+
* Apply a series of changes inside a synchronous `fn`, These operations will
|
|
580
|
+
* be merged into the previous history.
|
|
581
|
+
*/
|
|
582
|
+
withMerging(board: PlaitBoard, fn: () => void): void;
|
|
583
|
+
/**
|
|
584
|
+
* Apply a series of changes inside a synchronous `fn`, ensuring that the first
|
|
585
|
+
* operation starts a new batch in the history. Subsequent operations will be
|
|
586
|
+
* merged as usual.
|
|
587
|
+
*/
|
|
588
|
+
withNewBatch(board: PlaitBoard, fn: () => void): void;
|
|
589
|
+
/**
|
|
590
|
+
* Apply a series of changes inside a synchronous `fn`, without merging any of
|
|
591
|
+
* the new operations into previous save point in the history.
|
|
592
|
+
*/
|
|
593
|
+
withoutMerging(board: PlaitBoard, fn: () => void): void;
|
|
594
|
+
/**
|
|
595
|
+
* Apply a series of changes inside a synchronous `fn`, without saving any of
|
|
596
|
+
* their operations into the history.
|
|
597
|
+
*/
|
|
598
|
+
withoutSaving(board: PlaitBoard, fn: () => void): void;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Hotkeys.
|
|
603
|
+
*/
|
|
604
|
+
declare const hotkeys: {
|
|
605
|
+
isBold: (event: KeyboardEvent) => boolean;
|
|
606
|
+
isCompose: (event: KeyboardEvent) => boolean;
|
|
607
|
+
isArrow: (event: KeyboardEvent) => boolean;
|
|
608
|
+
isMoveBackward: (event: KeyboardEvent) => boolean;
|
|
609
|
+
isMoveForward: (event: KeyboardEvent) => boolean;
|
|
610
|
+
isMoveUp: (event: KeyboardEvent) => boolean;
|
|
611
|
+
isMoveDown: (event: KeyboardEvent) => boolean;
|
|
612
|
+
isDeleteBackward: (event: KeyboardEvent) => boolean;
|
|
613
|
+
isDeleteForward: (event: KeyboardEvent) => boolean;
|
|
614
|
+
isDeleteLineBackward: (event: KeyboardEvent) => boolean;
|
|
615
|
+
isDeleteLineForward: (event: KeyboardEvent) => boolean;
|
|
616
|
+
isDeleteWordBackward: (event: KeyboardEvent) => boolean;
|
|
617
|
+
isDeleteWordForward: (event: KeyboardEvent) => boolean;
|
|
618
|
+
isExtendBackward: (event: KeyboardEvent) => boolean;
|
|
619
|
+
isExtendForward: (event: KeyboardEvent) => boolean;
|
|
620
|
+
isExtendUp: (event: KeyboardEvent) => boolean;
|
|
621
|
+
isExtendDown: (event: KeyboardEvent) => boolean;
|
|
622
|
+
isExtendArrow: (event: KeyboardEvent) => boolean;
|
|
623
|
+
isExtendLineBackward: (event: KeyboardEvent) => boolean;
|
|
624
|
+
isExtendLineForward: (event: KeyboardEvent) => boolean;
|
|
625
|
+
isItalic: (event: KeyboardEvent) => boolean;
|
|
626
|
+
isMoveLineBackward: (event: KeyboardEvent) => boolean;
|
|
627
|
+
isMoveLineForward: (event: KeyboardEvent) => boolean;
|
|
628
|
+
isMoveWordBackward: (event: KeyboardEvent) => boolean;
|
|
629
|
+
isMoveWordForward: (event: KeyboardEvent) => boolean;
|
|
630
|
+
isRedo: (event: KeyboardEvent) => boolean;
|
|
631
|
+
isSplitBlock: (event: KeyboardEvent) => boolean;
|
|
632
|
+
isTransposeCharacter: (event: KeyboardEvent) => boolean;
|
|
633
|
+
isUndo: (event: KeyboardEvent) => boolean;
|
|
634
|
+
isShift: (event: KeyboardEvent) => boolean;
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
declare function idCreator(length?: number): string;
|
|
638
|
+
|
|
639
|
+
declare function distanceBetweenPointAndSegment(x: number, y: number, x1: number, y1: number, x2: number, y2: number): number;
|
|
640
|
+
declare function getNearestPointBetweenPointAndSegment(point: Point, linePoints: [Point, Point]): Point;
|
|
641
|
+
declare function distanceBetweenPointAndSegments(point: Point, points: Point[]): number;
|
|
642
|
+
declare function getNearestPointBetweenPointAndSegments(point: Point, points: Point[], isClose?: Boolean): Point;
|
|
643
|
+
declare function getNearestPointBetweenPointAndDiscreteSegments(point: Point, segments: [Point, Point][]): Point;
|
|
644
|
+
declare function getNearestPointBetweenPointAndEllipse(point: Point, center: Point, rx: number, ry: number): Point;
|
|
645
|
+
declare function rotate(x1: number, y1: number, x2: number, y2: number, angle: number): number[];
|
|
646
|
+
declare function distanceBetweenPointAndPoint(x1: number, y1: number, x2: number, y2: number): number;
|
|
647
|
+
declare function distanceBetweenPointAndRectangle(x: number, y: number, rect: RectangleClient): number;
|
|
648
|
+
declare const isLineHitLine: (a: Point, b: Point, c: Point, d: Point) => boolean;
|
|
649
|
+
declare const isLineHitRectangle: (points: Point[], rectangle: RectangleClient) => boolean;
|
|
650
|
+
declare const isLineHitRectangleEdge: (points: Point[], rectangle: RectangleClient, isClose?: boolean) => boolean;
|
|
651
|
+
declare const isSingleLineHitRectangleEdge: (p1: Point, p2: Point, rectangle: RectangleClient) => boolean;
|
|
652
|
+
declare const isPointInPolygon: (point: Point, points: Point[]) => boolean;
|
|
653
|
+
declare const isPointInEllipse: (point: Point, center: Point, rx: number, ry: number, angle?: number) => boolean;
|
|
654
|
+
declare const isPointInRoundRectangle: (point: Point, rectangle: RectangleClient, radius: number, angle?: number) => boolean;
|
|
655
|
+
declare const catmullRomFitting: (points: Point[]) => Point[];
|
|
656
|
+
/**
|
|
657
|
+
* the result of slope is based on Cartesian coordinate system
|
|
658
|
+
* x, y are based on the position in the Cartesian coordinate system
|
|
659
|
+
*/
|
|
660
|
+
declare function getEllipseTangentSlope(x: number, y: number, a: number, b: number): number;
|
|
661
|
+
/**
|
|
662
|
+
* x, y are based on the position in the Cartesian coordinate system
|
|
663
|
+
*/
|
|
664
|
+
declare function getVectorFromPointAndSlope(x: number, y: number, slope: number): Point;
|
|
665
|
+
/**
|
|
666
|
+
* The DOM likes values to be fixed to 3 decimal places
|
|
667
|
+
*/
|
|
668
|
+
declare function toDomPrecision(v: number): number;
|
|
669
|
+
declare function toFixed(v: number): number;
|
|
670
|
+
declare function ceilToDecimal(value: number, decimalPlaces: number): number;
|
|
671
|
+
/**
|
|
672
|
+
* Whether two numbers numbers a and b are approximately equal.
|
|
673
|
+
*
|
|
674
|
+
* @param a - The first point.
|
|
675
|
+
* @param b - The second point.
|
|
676
|
+
* @public
|
|
677
|
+
*/
|
|
678
|
+
declare function approximately(a: number, b: number, precision?: number): boolean;
|
|
679
|
+
declare function getCrossingPointsBetweenEllipseAndSegment(startPoint: Point, endPoint: Point, cx: number, cy: number, rx: number, ry: number, segment_only?: boolean): number[][];
|
|
680
|
+
/**
|
|
681
|
+
* Get a point between two points.
|
|
682
|
+
* @param x0 The x-axis coordinate of the first point.
|
|
683
|
+
* @param y0 The y-axis coordinate of the first point.
|
|
684
|
+
* @param x1 The x-axis coordinate of the second point.
|
|
685
|
+
* @param y1 The y-axis coordinate of the second point.
|
|
686
|
+
* @param d Normalized
|
|
687
|
+
*/
|
|
688
|
+
declare function getPointBetween(x0: number, y0: number, x1: number, y1: number, d?: number): number[];
|
|
689
|
+
/**
|
|
690
|
+
* 获取点到半椭圆弧段的最近点
|
|
691
|
+
* @param point 目标点
|
|
692
|
+
* @param startPoint 弧段起点
|
|
693
|
+
* @param arcCommand SVG 弧形命令参数
|
|
694
|
+
*/
|
|
695
|
+
/**
|
|
696
|
+
* 计算椭圆弧的中心点和实际半径
|
|
697
|
+
*/
|
|
698
|
+
declare function getEllipseArcCenter(startPoint: Point, arcCommand: SVGArcCommand): {
|
|
699
|
+
center: Point;
|
|
700
|
+
rx: number;
|
|
701
|
+
ry: number;
|
|
702
|
+
};
|
|
703
|
+
declare function getNearestPointBetweenPointAndArc(point: Point, startPoint: Point, arcCommand: SVGArcCommand): Point;
|
|
704
|
+
|
|
705
|
+
declare class PlaitBoardContext {
|
|
706
|
+
private uploadingFiles;
|
|
707
|
+
getUploadingFile(url: string): ImageEntry | undefined;
|
|
708
|
+
setUploadingFile(file: ImageEntry): number;
|
|
709
|
+
removeUploadingFile(fileEntry: ImageEntry): void;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
declare const IS_BOARD_CACHE: WeakMap<Object, boolean>;
|
|
713
|
+
declare const FLUSHING: WeakMap<PlaitBoard, boolean>;
|
|
714
|
+
declare const NODE_TO_INDEX: WeakMap<PlaitElement, number>;
|
|
715
|
+
declare const NODE_TO_PARENT: WeakMap<PlaitElement, Ancestor>;
|
|
716
|
+
declare const KEY_TO_ELEMENT_MAP: WeakMap<PlaitBoard, Map<String, PlaitElement>>;
|
|
717
|
+
declare const NODE_TO_G: WeakMap<PlaitElement, SVGGElement>;
|
|
718
|
+
declare const NODE_TO_CONTAINER_G: WeakMap<PlaitElement, SVGGElement>;
|
|
719
|
+
declare const IS_TEXT_EDITABLE: WeakMap<PlaitBoard, boolean>;
|
|
720
|
+
declare const BOARD_TO_ON_CHANGE: WeakMap<PlaitBoard, () => void>;
|
|
721
|
+
declare const BOARD_TO_AFTER_CHANGE: WeakMap<PlaitBoard, () => void>;
|
|
722
|
+
declare const BOARD_TO_ROUGH_SVG: WeakMap<PlaitBoard, RoughSVG>;
|
|
723
|
+
declare const BOARD_TO_HOST: WeakMap<PlaitBoard, SVGSVGElement>;
|
|
724
|
+
declare const BOARD_TO_CONTEXT: WeakMap<PlaitBoard, PlaitBoardContext>;
|
|
725
|
+
declare const IS_BOARD_ALIVE: WeakMap<PlaitBoard, boolean>;
|
|
726
|
+
declare const BOARD_TO_ELEMENT_HOST: WeakMap<PlaitBoard, {
|
|
727
|
+
lowerHost: SVGGElement;
|
|
728
|
+
host: SVGGElement;
|
|
729
|
+
upperHost: SVGGElement;
|
|
730
|
+
topHost: SVGGElement;
|
|
731
|
+
activeHost: SVGGElement;
|
|
732
|
+
container: HTMLElement;
|
|
733
|
+
viewportContainer: HTMLElement;
|
|
734
|
+
}>;
|
|
735
|
+
declare const BOARD_TO_SELECTED_ELEMENT: WeakMap<PlaitBoard, PlaitElement[]>;
|
|
736
|
+
declare const BOARD_TO_MOVING_POINT_IN_BOARD: WeakMap<PlaitBoard, Point>;
|
|
737
|
+
declare const BOARD_TO_MOVING_POINT: WeakMap<PlaitBoard, Point>;
|
|
738
|
+
declare const BOARD_TO_VIEWPORT_ORIGINATION: WeakMap<PlaitBoard, Point>;
|
|
739
|
+
declare const BOARD_TO_IS_SELECTION_MOVING: WeakMap<PlaitBoard, boolean>;
|
|
740
|
+
declare const BOARD_TO_TEMPORARY_ELEMENTS: WeakMap<PlaitBoard, {
|
|
741
|
+
elements: PlaitElement[];
|
|
742
|
+
timeoutId: any;
|
|
743
|
+
}>;
|
|
744
|
+
declare const BOARD_TO_MOVING_ELEMENT: WeakMap<PlaitBoard, PlaitElement[]>;
|
|
745
|
+
declare const PATH_REFS: WeakMap<PlaitBoard, Set<PathRef>>;
|
|
746
|
+
declare const ELEMENT_TO_REF: WeakMap<PlaitElement, PlaitElementRef>;
|
|
747
|
+
|
|
748
|
+
type PlaitPlugin = (board: PlaitBoard) => PlaitBoard;
|
|
749
|
+
interface WithPluginOptions {
|
|
750
|
+
disabled?: boolean;
|
|
751
|
+
}
|
|
752
|
+
interface WithSelectionPluginOptions extends WithPluginOptions {
|
|
753
|
+
isMultipleSelection: boolean;
|
|
754
|
+
isDisabledSelection: boolean;
|
|
755
|
+
isPreventClearSelection: boolean;
|
|
756
|
+
}
|
|
757
|
+
interface WithHandPluginOptions extends WithPluginOptions {
|
|
758
|
+
isHandMode: (board: PlaitBoard, event: PointerEvent) => boolean;
|
|
759
|
+
}
|
|
760
|
+
declare enum PlaitPluginKey {
|
|
761
|
+
'withSelection' = "withSelection",
|
|
762
|
+
'withHand' = "withHand"
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
interface PlaitOptionsBoard extends PlaitBoard {
|
|
766
|
+
getPluginOptions: <K = WithPluginOptions>(key: string) => K;
|
|
767
|
+
setPluginOptions: <K = WithPluginOptions>(key: string, value: Partial<K>) => void;
|
|
768
|
+
}
|
|
769
|
+
declare const withOptions: (board: PlaitBoard) => PlaitOptionsBoard;
|
|
770
|
+
|
|
771
|
+
declare const getHitElementsBySelection: (board: PlaitBoard, selection?: Selection, match?: (element: PlaitElement) => boolean) => PlaitElement[];
|
|
772
|
+
declare const getHitElementsByPoint: (board: PlaitBoard, point: Point, match?: (element: PlaitElement) => boolean, isStrict?: boolean) => PlaitElement[];
|
|
773
|
+
declare const getHitElementByPoint: (board: PlaitBoard, point: Point, match?: (element: PlaitElement) => boolean, isStrict?: boolean) => undefined | PlaitElement;
|
|
774
|
+
declare const getHitSelectedElements: (board: PlaitBoard, point: Point) => PlaitElement[];
|
|
775
|
+
declare const cacheSelectedElements: (board: PlaitBoard, selectedElements: PlaitElement[]) => void;
|
|
776
|
+
declare const getSelectedElements: (board: PlaitBoard) => PlaitElement[];
|
|
777
|
+
declare const addSelectedElement: (board: PlaitBoard, element: PlaitElement | PlaitElement[]) => void;
|
|
778
|
+
declare const removeSelectedElement: (board: PlaitBoard, element: PlaitElement, isRemoveChildren?: boolean) => void;
|
|
779
|
+
declare const replaceSelectedElement: (board: PlaitBoard, element: PlaitElement, newElement: PlaitElement) => void;
|
|
780
|
+
declare const clearSelectedElement: (board: PlaitBoard) => void;
|
|
781
|
+
declare const isSelectedElement: (board: PlaitBoard, element: PlaitElement) => boolean;
|
|
782
|
+
declare const temporaryDisableSelection: (board: PlaitOptionsBoard) => void;
|
|
783
|
+
declare const isHitSelectedRectangle: (board: PlaitBoard, point: Point) => boolean;
|
|
784
|
+
declare const isHitElement: (board: PlaitBoard, point: Point) => boolean;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* drawRoundRectangle
|
|
788
|
+
*/
|
|
789
|
+
declare function drawRoundRectangle(rs: RoughSVG, x1: number, y1: number, x2: number, y2: number, options: Options, outline?: boolean, borderRadius?: number): SVGGElement;
|
|
790
|
+
declare const drawRectangle: (board: PlaitBoard, rectangle: RectangleClient, options: Options) => SVGGElement;
|
|
791
|
+
|
|
792
|
+
declare function arrowPoints(start: Point, end: Point, degree?: number): {
|
|
793
|
+
pointLeft: Point;
|
|
794
|
+
pointRight: Point;
|
|
795
|
+
};
|
|
796
|
+
declare function drawArrow(rs: RoughSVG, start: Point, end: Point, options: Options, maxHypotenuseLength?: number, degree?: number): SVGGElement[];
|
|
797
|
+
|
|
798
|
+
declare function drawCircle(roughSVG: RoughSVG, point: Point, diameter: number, options: Options): SVGGElement;
|
|
799
|
+
|
|
800
|
+
declare function drawLine(rs: RoughSVG, start: Point, end: Point, options: Options): SVGGElement;
|
|
801
|
+
declare function drawLinearPath(points: Point[], options?: Options, closePath?: boolean): SVGGElement;
|
|
802
|
+
declare function drawBezierPath(points: Point[], options?: Options): SVGGElement;
|
|
803
|
+
|
|
804
|
+
declare function depthFirstRecursion<T extends TreeNode = TreeNode>(node: T, callback: (node: T) => void, recursion?: (node: T) => boolean, isReverse?: boolean): void;
|
|
805
|
+
declare const getIsRecursionFunc: (board: PlaitBoard) => (element: PlaitElement | PlaitBoard) => boolean;
|
|
806
|
+
interface TreeNode {
|
|
807
|
+
children?: TreeNode[];
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
declare function getRectangleByElements(board: PlaitBoard, elements: PlaitElement[], recursion: boolean): RectangleClient;
|
|
811
|
+
declare function getBoundingRectangleByElements(board: PlaitBoard, elements: PlaitElement[], recursion: boolean): RectangleClient;
|
|
812
|
+
declare function getBoardRectangle(board: PlaitBoard): RectangleClient;
|
|
813
|
+
declare function getElementById<T extends PlaitElement = PlaitElement>(board: PlaitBoard, id: string, dataSource?: PlaitElement[]): T | undefined;
|
|
814
|
+
declare function getElementMap(board: PlaitBoard): Map<String, PlaitElement>;
|
|
815
|
+
declare function findElements<T extends PlaitElement = PlaitElement>(board: PlaitBoard, options: {
|
|
816
|
+
match: (element: PlaitElement) => boolean;
|
|
817
|
+
recursion: (element: PlaitElement) => boolean;
|
|
818
|
+
isReverse?: boolean;
|
|
819
|
+
}): T[];
|
|
820
|
+
|
|
821
|
+
declare const VIEWPORT_PADDING_RATIO = 0.75;
|
|
822
|
+
interface ElementHostBBox {
|
|
823
|
+
left: number;
|
|
824
|
+
right: number;
|
|
825
|
+
top: number;
|
|
826
|
+
bottom: number;
|
|
827
|
+
}
|
|
828
|
+
declare function getViewportContainerRect(board: PlaitBoard): {
|
|
829
|
+
width: number;
|
|
830
|
+
height: number;
|
|
831
|
+
};
|
|
832
|
+
declare function getElementHostBBox(board: PlaitBoard, zoom: number): ElementHostBBox;
|
|
833
|
+
/**
|
|
834
|
+
* Normalize the scaling ratio, or return the corrected scaling ratio if the limit is exceeded
|
|
835
|
+
*/
|
|
836
|
+
declare function clampZoomLevel(zoom: number, minZoom?: number, maxZoom?: number): number;
|
|
837
|
+
/**
|
|
838
|
+
* Prepares element bounding box with minimum size constraints
|
|
839
|
+
*/
|
|
840
|
+
declare function prepareElementBBox(board: PlaitBoard, zoom: number): {
|
|
841
|
+
elementHostBBox: ElementHostBBox;
|
|
842
|
+
containerWidth: number;
|
|
843
|
+
containerHeight: number;
|
|
844
|
+
width: number;
|
|
845
|
+
height: number;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* Calculates viewBox based on element bounding box with padding
|
|
849
|
+
*/
|
|
850
|
+
declare function calculateViewBox(elementHostBBox: ElementHostBBox, containerWidth: number, containerHeight: number, width: number, height: number, zoom: number, paddingRatio?: number): number[];
|
|
851
|
+
declare function calcNewViewBox(board: PlaitBoard, zoom: number): number[];
|
|
852
|
+
declare function getViewBoxCenterPoint(board: PlaitBoard): Point;
|
|
853
|
+
declare function setSVGViewBox(board: PlaitBoard, viewBox: number[]): void;
|
|
854
|
+
declare function updateViewportOffset(board: PlaitBoard): void;
|
|
855
|
+
declare function updateViewportContainerScroll(board: PlaitBoard, left: number, top: number, isFromViewportChange?: boolean): void;
|
|
856
|
+
declare function updateViewportByScrolling(board: PlaitBoard, scrollLeft: number, scrollTop: number): void;
|
|
857
|
+
declare function initializeViewportContainer(board: PlaitBoard): void;
|
|
858
|
+
declare function initializeViewBox(board: PlaitBoard): void;
|
|
859
|
+
declare function updateViewBox(board: PlaitBoard): void;
|
|
860
|
+
declare function initializeViewportOffset(board: PlaitBoard): void;
|
|
861
|
+
declare const updateViewportOrigination: (board: PlaitBoard, origination: Point) => void;
|
|
862
|
+
declare const clearViewportOrigination: (board: PlaitBoard) => void;
|
|
863
|
+
declare const getViewportOrigination: (board: PlaitBoard) => Point | undefined;
|
|
864
|
+
declare const isFromScrolling: (board: PlaitBoard) => boolean;
|
|
865
|
+
declare const setIsFromScrolling: (board: PlaitBoard, state: boolean) => void;
|
|
866
|
+
declare const isFromViewportChange: (board: PlaitBoard) => boolean;
|
|
867
|
+
declare const setIsFromViewportChange: (board: PlaitBoard, state: boolean) => void;
|
|
868
|
+
declare const isInVisibleViewport: (board: PlaitBoard, client: RectangleClient, isOpenKeyboard?: boolean) => boolean;
|
|
869
|
+
declare function scrollToVisibleWhenKeyboardOpening(board: PlaitBoard, client: RectangleClient): void;
|
|
870
|
+
|
|
871
|
+
interface MoveNodeOption {
|
|
872
|
+
element: PlaitElement;
|
|
873
|
+
newPath: Path;
|
|
874
|
+
}
|
|
875
|
+
declare const throttleRAF: (board: PlaitBoard, key: string, fn: () => void) => void;
|
|
876
|
+
declare const debounce: <T>(func: (args?: T) => void, wait: number, options?: {
|
|
877
|
+
leading: boolean;
|
|
878
|
+
}) => (args?: T) => void;
|
|
879
|
+
declare const getElementsIndices: (board: PlaitBoard, elements: PlaitElement[]) => number[];
|
|
880
|
+
declare const getHighestIndexOfElement: (board: PlaitBoard, elements: PlaitElement[]) => number;
|
|
881
|
+
declare const moveElementsToNewPath: (board: PlaitBoard, moveOptions: MoveNodeOption[]) => void;
|
|
882
|
+
|
|
883
|
+
declare const getMovingElements: (board: PlaitBoard) => PlaitElement[];
|
|
884
|
+
declare const isMovingElements: (board: PlaitBoard) => boolean;
|
|
885
|
+
declare const removeMovingElements: (board: PlaitBoard) => void;
|
|
886
|
+
declare const cacheMovingElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
887
|
+
|
|
888
|
+
interface ToImageOptions {
|
|
889
|
+
elements?: PlaitElement[];
|
|
890
|
+
name?: string;
|
|
891
|
+
ratio?: number;
|
|
892
|
+
padding?: number;
|
|
893
|
+
fillStyle?: string;
|
|
894
|
+
inlineStyleClassNames?: string;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* current board transfer pictures
|
|
898
|
+
* @param board board
|
|
899
|
+
* @param options parameter configuration
|
|
900
|
+
* @returns images in the specified format base64
|
|
901
|
+
*/
|
|
902
|
+
declare function toImage(board: PlaitBoard, options: ToImageOptions): Promise<string | undefined>;
|
|
903
|
+
/**
|
|
904
|
+
* download the file with the specified name
|
|
905
|
+
* @param url download url
|
|
906
|
+
* @param name file name
|
|
907
|
+
*/
|
|
908
|
+
declare function downloadImage(url: string, name: string): void;
|
|
909
|
+
|
|
910
|
+
declare enum WritableClipboardType {
|
|
911
|
+
'medias' = "medias",
|
|
912
|
+
'elements' = "elements"
|
|
913
|
+
}
|
|
914
|
+
declare enum WritableClipboardOperationType {
|
|
915
|
+
'copy' = "copy",
|
|
916
|
+
'cut' = "cut",
|
|
917
|
+
'duplicate' = "duplicate",
|
|
918
|
+
'paste' = "paste"
|
|
919
|
+
}
|
|
920
|
+
type WritableClipboardData = PlaitElement[] | any[];
|
|
921
|
+
interface WritableClipboardContext {
|
|
922
|
+
text: string;
|
|
923
|
+
type: WritableClipboardType;
|
|
924
|
+
elements: WritableClipboardData;
|
|
925
|
+
}
|
|
926
|
+
interface ClipboardData {
|
|
927
|
+
files?: File[];
|
|
928
|
+
elements?: PlaitElement[];
|
|
929
|
+
medias?: any[];
|
|
930
|
+
text?: string;
|
|
931
|
+
operationType?: WritableClipboardOperationType;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
declare const cacheClipboardData: (clipboardData: ClipboardData) => void;
|
|
935
|
+
declare const getCachedClipboardData: () => any;
|
|
936
|
+
declare const getClipboardData: (dataTransfer: DataTransfer | null) => Promise<ClipboardData | null>;
|
|
937
|
+
declare const setClipboardData: (dataTransfer: DataTransfer | null, clipboardContext: WritableClipboardContext | null) => Promise<void>;
|
|
938
|
+
|
|
939
|
+
declare const buildPlaitHtml: (type: WritableClipboardType, data: WritableClipboardData) => string;
|
|
940
|
+
declare const getClipboardFromHtml: (html: string) => ClipboardData | null;
|
|
941
|
+
declare const stripHtml: (html: string) => string;
|
|
942
|
+
declare const getProbablySupportsClipboardWrite: () => boolean;
|
|
943
|
+
declare const getProbablySupportsClipboardWriteText: () => boolean;
|
|
944
|
+
declare const getProbablySupportsClipboardRead: () => boolean;
|
|
945
|
+
declare const createClipboardContext: (type: WritableClipboardType, elements: WritableClipboardData, text: string) => WritableClipboardContext;
|
|
946
|
+
declare const addClipboardContext: (clipboardContext: WritableClipboardContext, addition: WritableClipboardContext) => WritableClipboardContext;
|
|
947
|
+
declare const addOrCreateClipboardContext: (clipboardContext: WritableClipboardContext | null, addition: WritableClipboardContext) => WritableClipboardContext;
|
|
948
|
+
declare const replaceAngleBrackets: (str: string) => string;
|
|
949
|
+
declare const reverseReplaceAngleBrackets: (str: string) => string;
|
|
950
|
+
|
|
951
|
+
declare const setDataTransferClipboard: (dataTransfer: DataTransfer | null, type: WritableClipboardType, data: WritableClipboardData) => void;
|
|
952
|
+
declare const setDataTransferClipboardText: (data: DataTransfer | null, text: string) => void;
|
|
953
|
+
declare const getDataTransferClipboard: (data: DataTransfer | null) => ClipboardData;
|
|
954
|
+
declare const getDataTransferClipboardText: (data: DataTransfer | null) => ClipboardData;
|
|
955
|
+
|
|
956
|
+
declare const IS_DRAGGING: WeakMap<PlaitBoard, boolean>;
|
|
957
|
+
declare const isDragging: (board: PlaitBoard) => boolean;
|
|
958
|
+
declare const setDragging: (board: PlaitBoard, state: boolean) => void;
|
|
959
|
+
|
|
960
|
+
declare const getViewBox: (board: PlaitBoard) => DOMRect;
|
|
961
|
+
/**
|
|
962
|
+
* Get the screen point starting from the upper left corner of the svg element (based on the svg screen coordinate system)
|
|
963
|
+
* reference: https://github.com/worktile/plait/blob/develop/packages/core/src/utils/to-point.md
|
|
964
|
+
*/
|
|
965
|
+
declare function toHostPoint(board: PlaitBoard, x: number, y: number): Point;
|
|
966
|
+
declare function toActiveRectangleFromViewBoxRectangle(board: PlaitBoard, rectangle: RectangleClient): RectangleClient;
|
|
967
|
+
declare function toActivePointFromViewBoxPoint(board: PlaitBoard, point: Point): Point;
|
|
968
|
+
/**
|
|
969
|
+
* Get the screen point starting from the upper left corner of the svg element (based on the svg screen coordinate system)
|
|
970
|
+
*/
|
|
971
|
+
declare function toActivePoint(board: PlaitBoard, x: number, y: number): Point;
|
|
972
|
+
declare function toScreenPointFromActivePoint(board: PlaitBoard, activePoint: Point): Point;
|
|
973
|
+
/**
|
|
974
|
+
* Get the point in the coordinate system of the svg viewBox
|
|
975
|
+
* reference: https://github.com/worktile/plait/blob/develop/packages/core/src/utils/to-point.md
|
|
976
|
+
*/
|
|
977
|
+
declare function toViewBoxPoint(board: PlaitBoard, hostPoint: Point): Point;
|
|
978
|
+
declare function toViewBoxPoints(board: PlaitBoard, hostPoints: Point[]): Point[];
|
|
979
|
+
/**
|
|
980
|
+
* `toHostPoint` reverse processing
|
|
981
|
+
* Get the screen point starting from the upper left corner of the browser window or the viewport (based on the screen coordinate system)
|
|
982
|
+
*/
|
|
983
|
+
declare function toScreenPointFromHostPoint(board: PlaitBoard, hostPoint: Point): Point;
|
|
984
|
+
/**
|
|
985
|
+
* `toViewBoxPoint` reverse processing
|
|
986
|
+
*/
|
|
987
|
+
declare function toHostPointFromViewBoxPoint(board: PlaitBoard, viewBoxPoint: Point): Point;
|
|
988
|
+
|
|
989
|
+
declare const getElementsInGroup: (board: PlaitBoard, group: PlaitGroup, recursion?: boolean, includeGroup?: boolean) => PlaitElement[];
|
|
990
|
+
declare const getAllElementsInGroup: (board: PlaitBoard, group: PlaitGroup, recursion?: boolean, includeGroup?: boolean) => PlaitElement[];
|
|
991
|
+
declare const getRectangleByGroup: (board: PlaitBoard, group: PlaitGroup, recursion?: boolean) => RectangleClient;
|
|
992
|
+
declare const getGroupByElement: (board: PlaitBoard, element: PlaitElement, recursion?: boolean, originElements?: PlaitElement[]) => PlaitGroup | PlaitGroup[] | null;
|
|
993
|
+
declare const getHighestGroup: (board: PlaitBoard, element: PlaitElement) => PlaitGroup | null;
|
|
994
|
+
declare const getElementsInGroupByElement: (board: PlaitBoard, element: PlaitElement) => PlaitElement[];
|
|
995
|
+
declare const getAllGroups: (board: PlaitBoard) => PlaitGroup[];
|
|
996
|
+
declare const isSelectedElementOrGroup: (board: PlaitBoard, element: PlaitElement, elements?: PlaitElement[]) => boolean;
|
|
997
|
+
declare const isSelectedAllElementsInGroup: (board: PlaitBoard, group: PlaitGroup, elements?: PlaitElement[]) => boolean;
|
|
998
|
+
declare const filterSelectedGroups: (board: PlaitBoard, groups: PlaitGroup[], elements?: PlaitElement[]) => PlaitGroup[];
|
|
999
|
+
declare const getSelectedGroups: (board: PlaitBoard, elements?: PlaitElement[], originElements?: PlaitElement[]) => PlaitGroup[];
|
|
1000
|
+
declare const getHighestSelectedGroup: (board: PlaitBoard, element: PlaitElement, elements?: PlaitElement[], originElements?: PlaitElement[]) => PlaitGroup | null;
|
|
1001
|
+
declare const getHighestSelectedGroups: (board: PlaitBoard, elements?: PlaitElement[], originElements?: PlaitElement[]) => PlaitGroup[];
|
|
1002
|
+
declare const getSelectedIsolatedElements: (board: PlaitBoard, elements?: PlaitElement[]) => PlaitElement[];
|
|
1003
|
+
declare const getSelectedIsolatedElementsCanAddToGroup: (board: PlaitBoard, elements?: PlaitElement[]) => PlaitElement[];
|
|
1004
|
+
declare const getHighestSelectedElements: (board: PlaitBoard, elements?: PlaitElement[]) => PlaitElement[];
|
|
1005
|
+
declare const createGroupRectangleG: (board: PlaitBoard, elements: PlaitElement[]) => SVGGElement | null;
|
|
1006
|
+
declare const createGroup: (groupId?: string) => PlaitGroup;
|
|
1007
|
+
declare const nonGroupInHighestSelectedElements: (elements: PlaitElement[]) => boolean;
|
|
1008
|
+
declare const hasSelectedElementsInSameGroup: (elements: PlaitElement[]) => boolean;
|
|
1009
|
+
declare const canAddGroup: (board: PlaitBoard, elements?: PlaitElement[]) => boolean;
|
|
1010
|
+
declare const canRemoveGroup: (board: PlaitBoard, elements?: PlaitElement[], originElements?: PlaitElement[]) => boolean;
|
|
1011
|
+
declare const getEditingGroup: (board: PlaitBoard, element: PlaitElement) => PlaitGroup | null;
|
|
1012
|
+
declare const moveElementsToNewPathAfterAddGroup: (board: PlaitBoard, selectedElements: PlaitElement[], newPath: Path) => void;
|
|
1013
|
+
|
|
1014
|
+
declare function isSelectionMoving(board: PlaitBoard): boolean;
|
|
1015
|
+
declare function setSelectionMoving(board: PlaitBoard): void;
|
|
1016
|
+
declare function clearSelectionMoving(board: PlaitBoard): void;
|
|
1017
|
+
declare function isHandleSelection(board: PlaitBoard): boolean;
|
|
1018
|
+
declare function hasSetSelectionOperation(board: PlaitBoard): boolean;
|
|
1019
|
+
declare function getTemporaryElements(board: PlaitBoard): PlaitElement[] | undefined;
|
|
1020
|
+
declare function getTemporaryRef(board: PlaitBoard): {
|
|
1021
|
+
elements: PlaitElement[];
|
|
1022
|
+
timeoutId: any;
|
|
1023
|
+
} | undefined;
|
|
1024
|
+
declare function deleteTemporaryElements(board: PlaitBoard): void;
|
|
1025
|
+
declare function drawSelectionRectangleG(board: PlaitBoard): SVGGElement | null;
|
|
1026
|
+
declare function setSelectedElementsWithGroup(board: PlaitBoard, elements: PlaitElement[], isShift: boolean): void;
|
|
1027
|
+
declare function cacheSelectedElementsWithGroupOnShift(board: PlaitBoard, elements: PlaitElement[], isSelectGroupElement: boolean, elementsInHighestGroup: PlaitElement[]): void;
|
|
1028
|
+
declare function cacheSelectedElementsWithGroup(board: PlaitBoard, elements: PlaitElement[], isSelectGroupElement: boolean, hitElementGroups: PlaitGroup[]): void;
|
|
1029
|
+
declare const getSelectionOptions: (board: PlaitBoard) => WithSelectionPluginOptions;
|
|
1030
|
+
declare const setSelectionOptions: (board: PlaitBoard, options: Partial<WithSelectionPluginOptions>) => void;
|
|
1031
|
+
|
|
1032
|
+
declare const rotatePoints: <T>(points: T, centerPoint: Point, angle?: number) => T;
|
|
1033
|
+
declare const getSelectionAngle: (elements: PlaitElement[]) => number;
|
|
1034
|
+
declare const hasSameAngle: (elements: PlaitElement[]) => boolean;
|
|
1035
|
+
declare const getRotatedBoundingRectangle: (rectanglesCornerPoints: [Point, Point, Point, Point][], angle: number) => RectangleClient;
|
|
1036
|
+
declare const getOffsetAfterRotate: (rectangle: RectangleClient, rotateCenterPoint: Point, angle: number) => {
|
|
1037
|
+
offsetX: number;
|
|
1038
|
+
offsetY: number;
|
|
1039
|
+
};
|
|
1040
|
+
declare const rotatedDataPoints: (points: Point[], rotateCenterPoint: Point, angle: number) => Point[];
|
|
1041
|
+
declare const hasValidAngle: (node: PlaitElement) => boolean | 0 | undefined;
|
|
1042
|
+
declare const isValidAngle: (angle: undefined | number) => boolean | 0 | undefined;
|
|
1043
|
+
declare const rotatePointsByElement: <T>(points: T, element: PlaitElement) => T | null;
|
|
1044
|
+
declare const rotatePointsByAngle: (points: Point[], angle: number | undefined) => Point[] | null;
|
|
1045
|
+
declare const rotateAntiPointsByElement: <T>(board: PlaitBoard, points: T, element: PlaitElement, isToActive?: boolean) => T | null;
|
|
1046
|
+
declare const getRectangleByAngle: (rectangle: RectangleClient, angle: number) => RectangleClient;
|
|
1047
|
+
declare const isAxisChangedByAngle: (angle: number) => boolean;
|
|
1048
|
+
declare function degreesToRadians(d: number): number;
|
|
1049
|
+
declare function radiansToDegrees(r: number): number;
|
|
1050
|
+
declare function rotateElements(board: PlaitBoard, elements: PlaitElement[], angle: number): void;
|
|
1051
|
+
declare const normalizeAngle: (angle: number) => number;
|
|
1052
|
+
declare const getAngleBetweenPoints: (startPoint: Point, endPoint: Point, centerPoint: Point) => number;
|
|
1053
|
+
declare const getAngleByElement: (element: PlaitElement) => number | undefined;
|
|
1054
|
+
declare const setAngleForG: (g: SVGGElement, centerPoint: Point, angle: number) => void;
|
|
1055
|
+
|
|
1056
|
+
declare const deleteFragment: (board: PlaitBoard) => void;
|
|
1057
|
+
declare const setFragment: (board: PlaitBoard, operationType: WritableClipboardOperationType, clipboardData: DataTransfer | null) => void;
|
|
1058
|
+
declare const duplicateElements: (board: PlaitBoard, elements?: PlaitElement[], point?: Point) => void;
|
|
1059
|
+
|
|
1060
|
+
interface SnapDelta {
|
|
1061
|
+
deltaX: number;
|
|
1062
|
+
deltaY: number;
|
|
1063
|
+
}
|
|
1064
|
+
interface SnapRef extends SnapDelta {
|
|
1065
|
+
snapG: SVGGElement;
|
|
1066
|
+
}
|
|
1067
|
+
interface GapSnapRef {
|
|
1068
|
+
before: {
|
|
1069
|
+
distance: number;
|
|
1070
|
+
index: number;
|
|
1071
|
+
}[];
|
|
1072
|
+
after: {
|
|
1073
|
+
distance: number;
|
|
1074
|
+
index: number;
|
|
1075
|
+
}[];
|
|
1076
|
+
}
|
|
1077
|
+
type TripleSnapAxis = [number, number, number];
|
|
1078
|
+
declare const SNAP_TOLERANCE = 2;
|
|
1079
|
+
declare function getSnapRectangles(board: PlaitBoard, activeElements: PlaitElement[]): RectangleClient[];
|
|
1080
|
+
declare function getBarPoint(point: Point, isHorizontal: boolean): number[][];
|
|
1081
|
+
declare function getMinPointDelta(pointRectangles: RectangleClient[], axis: number, isHorizontal: boolean): number;
|
|
1082
|
+
declare const getNearestDelta: (axis: number, rectangle: RectangleClient, isHorizontal: boolean) => number;
|
|
1083
|
+
declare const getTripleAxis: (rectangle: RectangleClient, isHorizontal: boolean) => TripleSnapAxis;
|
|
1084
|
+
declare function getNearestPointRectangle(snapRectangles: RectangleClient[], activeRectangle: RectangleClient): RectangleClient;
|
|
1085
|
+
declare const isSnapPoint: (axis: number, rectangle: RectangleClient, isHorizontal: boolean) => boolean;
|
|
1086
|
+
declare function drawPointSnapLines(board: PlaitBoard, activeRectangle: RectangleClient, snapRectangles: RectangleClient[], drawHorizontal?: boolean, drawVertical?: boolean, snapMiddle?: boolean): SVGGElement;
|
|
1087
|
+
declare function drawDashedLines(board: PlaitBoard, lines: [Point, Point][]): SVGGElement;
|
|
1088
|
+
declare function drawSolidLines(board: PlaitBoard, lines: Point[][]): SVGGElement;
|
|
1089
|
+
|
|
1090
|
+
declare const getOneMoveOptions: (board: PlaitBoard, direction: "down" | "up") => MoveNodeOption[];
|
|
1091
|
+
declare const getAllMoveOptions: (board: PlaitBoard, direction: "down" | "up") => MoveNodeOption[];
|
|
1092
|
+
declare const canSetZIndex: (board: PlaitBoard) => boolean;
|
|
1093
|
+
|
|
1094
|
+
declare const sortElements: (board: PlaitBoard, elements: PlaitElement[], ascendingOrder?: boolean) => PlaitElement[];
|
|
1095
|
+
|
|
1096
|
+
declare const isMobileDeviceEvent: (event: PointerEvent) => boolean;
|
|
1097
|
+
declare const isPencilEvent: (event: PointerEvent) => boolean;
|
|
1098
|
+
declare const isTouchEvent: (event: PointerEvent) => boolean;
|
|
1099
|
+
declare const isMouseEvent: (event: PointerEvent) => boolean;
|
|
1100
|
+
declare const isTouchDevice: () => number | true;
|
|
1101
|
+
|
|
1102
|
+
declare class ListRender {
|
|
1103
|
+
private board;
|
|
1104
|
+
private children;
|
|
1105
|
+
private instances;
|
|
1106
|
+
private contexts;
|
|
1107
|
+
private differ;
|
|
1108
|
+
initialized: boolean;
|
|
1109
|
+
constructor(board: PlaitBoard);
|
|
1110
|
+
initialize(children: PlaitElement[], childrenContext: PlaitChildrenContext): void;
|
|
1111
|
+
update(children: PlaitElement[], childrenContext: PlaitChildrenContext): void;
|
|
1112
|
+
destroy(): void;
|
|
1113
|
+
}
|
|
1114
|
+
declare const mountElementG: (index: number, g: SVGGElement, childrenContext: PlaitChildrenContext, currentIndexForFirstElement?: number | null) => void;
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* 基于 element-flavour 实现元素的绘制,取代 Angular 组件
|
|
1118
|
+
*/
|
|
1119
|
+
|
|
1120
|
+
declare class ElementFlavour<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard, R extends PlaitElementRef = PlaitElementRef> {
|
|
1121
|
+
private ref;
|
|
1122
|
+
private _g;
|
|
1123
|
+
private _containerG;
|
|
1124
|
+
private _rootContainerG?;
|
|
1125
|
+
initialized: boolean;
|
|
1126
|
+
protected _context: PlaitPluginElementContext<T, K>;
|
|
1127
|
+
get hasChildren(): boolean;
|
|
1128
|
+
set context(value: PlaitPluginElementContext<T, K>);
|
|
1129
|
+
get context(): PlaitPluginElementContext<T, K>;
|
|
1130
|
+
get element(): T;
|
|
1131
|
+
get board(): K;
|
|
1132
|
+
get selected(): boolean;
|
|
1133
|
+
listRender?: ListRender;
|
|
1134
|
+
getContainerG(): SVGGElement;
|
|
1135
|
+
getElementG(): SVGGElement;
|
|
1136
|
+
constructor(ref: R);
|
|
1137
|
+
initialize(): void;
|
|
1138
|
+
initializeListRender(): void;
|
|
1139
|
+
getRef(): R;
|
|
1140
|
+
private updateListRender;
|
|
1141
|
+
private initializeChildrenContext;
|
|
1142
|
+
destroy(): void;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
interface PlaitBoardOptions {
|
|
1146
|
+
readonly?: boolean;
|
|
1147
|
+
hideScrollbar?: boolean;
|
|
1148
|
+
disabledScrollOnNonFocus?: boolean;
|
|
1149
|
+
themeColors?: ThemeColor[];
|
|
1150
|
+
}
|
|
1151
|
+
interface PlaitBoardMove {
|
|
1152
|
+
x: number;
|
|
1153
|
+
y: number;
|
|
1154
|
+
}
|
|
1155
|
+
interface PlaitBoard {
|
|
1156
|
+
viewport: Viewport;
|
|
1157
|
+
children: PlaitElement[];
|
|
1158
|
+
theme: PlaitTheme;
|
|
1159
|
+
operations: PlaitOperation[];
|
|
1160
|
+
selection: Selection | null;
|
|
1161
|
+
pointer: PlaitPointerType | string;
|
|
1162
|
+
history: PlaitHistory;
|
|
1163
|
+
options: PlaitBoardOptions;
|
|
1164
|
+
undo: () => void;
|
|
1165
|
+
redo: () => void;
|
|
1166
|
+
apply: (operation: PlaitOperation) => void;
|
|
1167
|
+
onChange: () => void;
|
|
1168
|
+
afterChange: () => void;
|
|
1169
|
+
drawSelectionRectangle: () => SVGGElement | null;
|
|
1170
|
+
mousedown: (event: MouseEvent) => void;
|
|
1171
|
+
mousemove: (event: MouseEvent) => void;
|
|
1172
|
+
mouseleave: (event: MouseEvent) => void;
|
|
1173
|
+
mouseup: (event: MouseEvent) => void;
|
|
1174
|
+
globalMousemove: (event: MouseEvent) => void;
|
|
1175
|
+
globalMouseup: (event: MouseEvent) => void;
|
|
1176
|
+
keyDown: (event: KeyboardEvent) => void;
|
|
1177
|
+
globalKeyDown: (event: KeyboardEvent) => void;
|
|
1178
|
+
keyUp: (event: KeyboardEvent) => void;
|
|
1179
|
+
buildFragment: (clipboardContext: WritableClipboardContext | null, rectangle: RectangleClient | null, operationType: WritableClipboardOperationType, originData?: PlaitElement[]) => WritableClipboardContext | null;
|
|
1180
|
+
insertFragment: (clipboardData: ClipboardData | null, targetPoint: Point, operationType?: WritableClipboardOperationType) => void;
|
|
1181
|
+
deleteFragment: (data: PlaitElement[]) => void;
|
|
1182
|
+
getDeletedFragment: (data: PlaitElement[]) => PlaitElement[];
|
|
1183
|
+
getRelatedFragment: (data: PlaitElement[], originData?: PlaitElement[]) => PlaitElement[];
|
|
1184
|
+
dblClick: (event: MouseEvent) => void;
|
|
1185
|
+
normalizeElement: (context: PlaitPluginElementContext) => void;
|
|
1186
|
+
drawElement: (context: PlaitPluginElementContext) => ComponentType<ElementFlavour>;
|
|
1187
|
+
isRectangleHit: (element: PlaitElement, range: Selection) => boolean;
|
|
1188
|
+
isHit: (element: PlaitElement, point: Point, isStrict?: boolean) => boolean;
|
|
1189
|
+
isInsidePoint: (element: PlaitElement, point: Point) => boolean;
|
|
1190
|
+
getOneHitElement: (hitElements: PlaitElement[]) => PlaitElement;
|
|
1191
|
+
isRecursion: (element: PlaitElement) => boolean;
|
|
1192
|
+
isMovable: (element: PlaitElement) => boolean;
|
|
1193
|
+
getRectangle: (element: PlaitElement) => RectangleClient | null;
|
|
1194
|
+
isWithinSelection: (element: PlaitElement) => boolean;
|
|
1195
|
+
pathRef: (path: Path, options?: PathRefOptions) => PathRef;
|
|
1196
|
+
pathRefs: () => Set<PathRef>;
|
|
1197
|
+
applyTheme: (element: PlaitElement) => void;
|
|
1198
|
+
isAlign: (element: PlaitElement) => boolean;
|
|
1199
|
+
isImageBindingAllowed: (element: PlaitElement) => boolean;
|
|
1200
|
+
canAddToGroup: (element: PlaitElement) => boolean;
|
|
1201
|
+
canSetZIndex: (element: PlaitElement) => boolean;
|
|
1202
|
+
isExpanded: (element: PlaitElement) => boolean;
|
|
1203
|
+
pointerDown: (pointer: PointerEvent) => void;
|
|
1204
|
+
pointerMove: (pointer: PointerEvent) => void;
|
|
1205
|
+
pointerUp: (pointer: PointerEvent) => void;
|
|
1206
|
+
pointerCancel: (pointer: PointerEvent) => void;
|
|
1207
|
+
pointerOut: (pointer: PointerEvent) => void;
|
|
1208
|
+
pointerLeave: (pointer: PointerEvent) => void;
|
|
1209
|
+
globalPointerMove: (pointer: PointerEvent) => void;
|
|
1210
|
+
globalPointerUp: (pointer: PointerEvent) => void;
|
|
1211
|
+
drop: (event: DragEvent) => boolean;
|
|
1212
|
+
touchStart: (event: TouchEvent) => void;
|
|
1213
|
+
touchMove: (event: TouchEvent) => void;
|
|
1214
|
+
touchEnd: (event: TouchEvent) => void;
|
|
1215
|
+
}
|
|
1216
|
+
declare const PlaitBoard: {
|
|
1217
|
+
isBoard(value: any): value is PlaitBoard;
|
|
1218
|
+
isAlive(board: PlaitBoard): boolean;
|
|
1219
|
+
findPath(board: PlaitBoard, node: PlaitNode): Path;
|
|
1220
|
+
getHost(board: PlaitBoard): SVGSVGElement;
|
|
1221
|
+
getElementLowerHost(board: PlaitBoard): SVGSVGElement;
|
|
1222
|
+
getElementHost(board: PlaitBoard): SVGSVGElement;
|
|
1223
|
+
getElementUpperHost(board: PlaitBoard): SVGSVGElement;
|
|
1224
|
+
getElementTopHost(board: PlaitBoard): SVGSVGElement;
|
|
1225
|
+
getActiveHost(board: PlaitBoard): SVGSVGElement;
|
|
1226
|
+
getRoughSVG(board: PlaitBoard): RoughSVG;
|
|
1227
|
+
getBoardContainer(board: PlaitBoard): HTMLElement;
|
|
1228
|
+
getBoardContext(board: PlaitBoard): PlaitBoardContext;
|
|
1229
|
+
getRectangle(board: PlaitBoard): RectangleClient;
|
|
1230
|
+
getViewportContainer(board: PlaitBoard): HTMLElement;
|
|
1231
|
+
isFocus(board: PlaitBoard): boolean;
|
|
1232
|
+
isReadonly(board: PlaitBoard): boolean | undefined;
|
|
1233
|
+
hasBeenTextEditing(board: PlaitBoard): boolean;
|
|
1234
|
+
getPointer<T = PlaitPointerType>(board: PlaitBoard): T;
|
|
1235
|
+
isPointer<T = PlaitPointerType>(board: PlaitBoard, pointer: T): boolean;
|
|
1236
|
+
isInPointer<T = PlaitPointerType>(board: PlaitBoard, pointers: T[]): boolean;
|
|
1237
|
+
getMovingPointInBoard(board: PlaitBoard): Point | undefined;
|
|
1238
|
+
isMovingPointInBoard(board: PlaitBoard): boolean;
|
|
1239
|
+
getThemeColors<T extends ThemeColor = ThemeColor>(board: PlaitBoard): T[];
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
declare enum Direction {
|
|
1243
|
+
left = "left",
|
|
1244
|
+
top = "top",
|
|
1245
|
+
right = "right",
|
|
1246
|
+
bottom = "bottom"
|
|
1247
|
+
}
|
|
1248
|
+
declare const isHorizontalDirection: (direction: Direction) => direction is Direction.left | Direction.right;
|
|
1249
|
+
declare const isVerticalDirection: (direction: Direction) => direction is Direction.top | Direction.bottom;
|
|
1250
|
+
type Vector = [number, number];
|
|
1251
|
+
type DirectionFactor = -1 | 0 | 1;
|
|
1252
|
+
type DirectionFactors = [DirectionFactor, DirectionFactor];
|
|
1253
|
+
|
|
1254
|
+
interface PlaitGroup extends PlaitElement {
|
|
1255
|
+
type: 'group';
|
|
1256
|
+
}
|
|
1257
|
+
declare const PlaitGroupElement: {
|
|
1258
|
+
isGroup: (value: any) => value is PlaitGroup;
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
interface SVGArcCommand {
|
|
1262
|
+
rx: number;
|
|
1263
|
+
ry: number;
|
|
1264
|
+
xAxisRotation: number;
|
|
1265
|
+
largeArcFlag: 0 | 1;
|
|
1266
|
+
sweepFlag: 0 | 1;
|
|
1267
|
+
endX: number;
|
|
1268
|
+
endY: number;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
interface BeforeContextChange<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard> {
|
|
1272
|
+
beforeContextChange: (value: PlaitPluginElementContext<T>) => void;
|
|
1273
|
+
}
|
|
1274
|
+
interface OnContextChanged<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard> {
|
|
1275
|
+
onContextChanged: (value: PlaitPluginElementContext<T, K>, previous: PlaitPluginElementContext<T, K>) => void;
|
|
1276
|
+
}
|
|
1277
|
+
declare function hasBeforeContextChange<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard>(value: any): value is BeforeContextChange<T, K>;
|
|
1278
|
+
declare function hasOnContextChanged<T extends PlaitElement = PlaitElement, K extends PlaitBoard = PlaitBoard>(value: any): value is OnContextChanged<T, K>;
|
|
1279
|
+
|
|
1280
|
+
interface GeneralTransforms {
|
|
1281
|
+
transform: (board: PlaitBoard, op: PlaitOperation) => void;
|
|
1282
|
+
}
|
|
1283
|
+
declare const GeneralTransforms: GeneralTransforms;
|
|
1284
|
+
|
|
1285
|
+
interface GroupTransforms {
|
|
1286
|
+
addGroup: (board: PlaitBoard, elements?: PlaitElement[]) => void;
|
|
1287
|
+
removeGroup: (board: PlaitBoard, elements?: PlaitElement[]) => void;
|
|
1288
|
+
}
|
|
1289
|
+
declare const GroupTransforms: {
|
|
1290
|
+
addGroup: (board: PlaitBoard, elements?: PlaitElement[]) => void;
|
|
1291
|
+
removeGroup: (board: PlaitBoard, elements?: PlaitElement[]) => void;
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
interface NodeTransforms {
|
|
1295
|
+
insertNode: (board: PlaitBoard, node: PlaitNode, path: Path) => void;
|
|
1296
|
+
setNode: (board: PlaitBoard, node: Partial<PlaitNode>, path: Path) => void;
|
|
1297
|
+
removeNode: (board: PlaitBoard, path: Path) => void;
|
|
1298
|
+
moveNode: (board: PlaitBoard, path: Path, newPath: Path) => void;
|
|
1299
|
+
}
|
|
1300
|
+
declare const NodeTransforms: NodeTransforms;
|
|
1301
|
+
|
|
1302
|
+
interface SelectionTransforms {
|
|
1303
|
+
setSelection: (board: PlaitBoard, selection: Selection | null) => void;
|
|
1304
|
+
addSelectionWithTemporaryElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
1305
|
+
}
|
|
1306
|
+
declare const SelectionTransforms: SelectionTransforms;
|
|
1307
|
+
|
|
1308
|
+
interface ViewportTransforms {
|
|
1309
|
+
setViewport: (board: PlaitBoard, viewport: Viewport) => void;
|
|
1310
|
+
}
|
|
1311
|
+
declare const ViewportTransforms: ViewportTransforms;
|
|
1312
|
+
|
|
1313
|
+
interface ZIndexTransforms {
|
|
1314
|
+
moveUp: (board: PlaitBoard) => void;
|
|
1315
|
+
moveDown: (board: PlaitBoard) => void;
|
|
1316
|
+
moveToTop: (board: PlaitBoard) => void;
|
|
1317
|
+
moveToBottom: (board: PlaitBoard) => void;
|
|
1318
|
+
}
|
|
1319
|
+
declare const ZIndexTransforms: {
|
|
1320
|
+
moveUp: (board: PlaitBoard) => void;
|
|
1321
|
+
moveDown: (board: PlaitBoard) => void;
|
|
1322
|
+
moveToTop: (board: PlaitBoard) => void;
|
|
1323
|
+
moveToBottom: (board: PlaitBoard) => void;
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
declare function updateViewport(board: PlaitBoard, origination: Point, zoom?: number): void;
|
|
1327
|
+
declare function updateZoom(board: PlaitBoard, newZoom: number, center?: Point): void;
|
|
1328
|
+
declare function fitViewport(board: PlaitBoard): void;
|
|
1329
|
+
declare function fitViewportWidth(board: PlaitBoard, options: FitViewportOptions): void;
|
|
1330
|
+
/**
|
|
1331
|
+
* apply theme to every element (remove element custom properties)
|
|
1332
|
+
* invoke applyThemeColor
|
|
1333
|
+
*/
|
|
1334
|
+
declare function updateThemeColor(board: PlaitBoard, mode: ThemeColorMode): void;
|
|
1335
|
+
declare function moveToCenter(board: PlaitBoard, centerPoint: Point): void;
|
|
1336
|
+
declare const BoardTransforms: {
|
|
1337
|
+
updatePointerType: <T extends string = PlaitPointerType>(board: PlaitBoard, pointer: T) => void;
|
|
1338
|
+
updateViewport: typeof updateViewport;
|
|
1339
|
+
fitViewport: typeof fitViewport;
|
|
1340
|
+
updateZoom: typeof updateZoom;
|
|
1341
|
+
updateThemeColor: typeof updateThemeColor;
|
|
1342
|
+
fitViewportWidth: typeof fitViewportWidth;
|
|
1343
|
+
moveToCenter: typeof moveToCenter;
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
declare const CoreTransforms: {
|
|
1347
|
+
removeElements: (board: PlaitBoard, elements: PlaitElement[]) => void;
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
declare const Transforms: GeneralTransforms & ViewportTransforms & SelectionTransforms & NodeTransforms & GroupTransforms & ZIndexTransforms;
|
|
1351
|
+
|
|
1352
|
+
declare function createBoard(children: PlaitElement[], options?: PlaitBoardOptions): PlaitBoard;
|
|
1353
|
+
|
|
1354
|
+
declare function withBoard(board: PlaitBoard): PlaitBoard;
|
|
1355
|
+
|
|
1356
|
+
declare const IS_HAND_MODE: WeakMap<PlaitBoard, boolean>;
|
|
1357
|
+
declare const isHandMode: (board: PlaitBoard) => boolean;
|
|
1358
|
+
declare function withHandPointer<T extends PlaitBoard>(board: T): T;
|
|
1359
|
+
|
|
1360
|
+
declare function withHistory<T extends PlaitBoard>(board: T): T;
|
|
1361
|
+
|
|
1362
|
+
declare const withHotkey: (board: PlaitBoard) => PlaitBoard;
|
|
1363
|
+
|
|
1364
|
+
declare function withMoving(board: PlaitBoard): PlaitBoard;
|
|
1365
|
+
declare function withArrowMoving(board: PlaitBoard): PlaitBoard;
|
|
1366
|
+
declare function getSelectedTargetElements(board: PlaitBoard): PlaitElement[];
|
|
1367
|
+
declare function getValidElements(board: PlaitBoard, activeElements: PlaitElement[]): PlaitElement[];
|
|
1368
|
+
declare function updatePoints(board: PlaitBoard, activeElements: PlaitElement[], offsetX: number, offsetY: number): PlaitElement[];
|
|
1369
|
+
declare function drawPendingNodesG(board: PlaitBoard, activeElements: PlaitElement[], offsetX: number, offsetY: number): null;
|
|
1370
|
+
|
|
1371
|
+
declare function withRelatedFragment(board: PlaitBoard): PlaitBoard;
|
|
1372
|
+
|
|
1373
|
+
declare function withSelection(board: PlaitBoard): PlaitBoard;
|
|
1374
|
+
|
|
1375
|
+
interface PlaitI18nBoard extends PlaitBoard {
|
|
1376
|
+
getI18nValue: (key: string) => string | null;
|
|
1377
|
+
}
|
|
1378
|
+
declare const withI18n: (board: PlaitBoard) => PlaitI18nBoard;
|
|
1379
|
+
declare const getI18nValue: (board: PlaitBoard, key: string, defaultValue?: string) => string;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* 1.create board instance
|
|
1383
|
+
* 2.build fake node weak map
|
|
1384
|
+
*/
|
|
1385
|
+
declare const createTestingBoard: (plugins: PlaitPlugin[], children: PlaitElement[], options?: PlaitBoardOptions) => _plait_core.PlaitBoard;
|
|
1386
|
+
|
|
1387
|
+
declare const fakeNodeWeakMap: (object: PlaitNode | PlaitBoard) => void;
|
|
1388
|
+
declare const clearNodeWeakMap: (object: PlaitNode | PlaitBoard) => void;
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* @license
|
|
1392
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1393
|
+
*
|
|
1394
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1395
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1396
|
+
*/
|
|
1397
|
+
/** Modifier keys that may be held while typing. */
|
|
1398
|
+
interface ModifierKeys {
|
|
1399
|
+
control?: boolean;
|
|
1400
|
+
alt?: boolean;
|
|
1401
|
+
shift?: boolean;
|
|
1402
|
+
meta?: boolean;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* @license
|
|
1407
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1408
|
+
*
|
|
1409
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1410
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1411
|
+
*/
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* Creates a browser MouseEvent with the specified options.
|
|
1415
|
+
* @docs-private
|
|
1416
|
+
*/
|
|
1417
|
+
declare function createMouseEvent(type: string, clientX?: number, clientY?: number, offsetX?: number, offsetY?: number, button?: number, modifiers?: ModifierKeys): MouseEvent;
|
|
1418
|
+
/**
|
|
1419
|
+
* Creates a browser `PointerEvent` with the specified options. Pointer events
|
|
1420
|
+
* by default will appear as if they are the primary pointer of their type.
|
|
1421
|
+
* https://www.w3.org/TR/pointerevents2/#dom-pointerevent-isprimary.
|
|
1422
|
+
*
|
|
1423
|
+
* For example, if pointer events for a multi-touch interaction are created, the non-primary
|
|
1424
|
+
* pointer touches would need to be represented by non-primary pointer events.
|
|
1425
|
+
*
|
|
1426
|
+
* @docs-private
|
|
1427
|
+
*/
|
|
1428
|
+
declare function createPointerEvent(type: string, clientX?: number, clientY?: number, offsetX?: number, offsetY?: number, options?: PointerEventInit): PointerEvent;
|
|
1429
|
+
/**
|
|
1430
|
+
* Creates a browser TouchEvent with the specified pointer coordinates.
|
|
1431
|
+
* @docs-private
|
|
1432
|
+
*/
|
|
1433
|
+
declare function createTouchEvent(type: string, pageX?: number, pageY?: number, clientX?: number, clientY?: number): UIEvent;
|
|
1434
|
+
/**
|
|
1435
|
+
* Creates a keyboard event with the specified key and modifiers.
|
|
1436
|
+
* @docs-private
|
|
1437
|
+
*/
|
|
1438
|
+
declare function createKeyboardEvent(type: string, keyCode?: number, key?: string, modifiers?: ModifierKeys): KeyboardEvent;
|
|
1439
|
+
/**
|
|
1440
|
+
* Creates a fake event object with any desired event type.
|
|
1441
|
+
* @docs-private
|
|
1442
|
+
*/
|
|
1443
|
+
declare function createFakeEvent(type: string, bubbles?: boolean, cancelable?: boolean, composed?: boolean): Event;
|
|
1444
|
+
declare function createModModifierKeys(): {
|
|
1445
|
+
meta: boolean;
|
|
1446
|
+
control?: undefined;
|
|
1447
|
+
} | {
|
|
1448
|
+
control: boolean;
|
|
1449
|
+
meta?: undefined;
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1452
|
+
declare class DebugGenerator {
|
|
1453
|
+
private debugKey;
|
|
1454
|
+
constructor(debugKey: string);
|
|
1455
|
+
isDebug(): boolean;
|
|
1456
|
+
clear(): void;
|
|
1457
|
+
drawPolygon(board: PlaitBoard, points: Point[], options?: Options): SVGGElement | undefined;
|
|
1458
|
+
drawLine(board: PlaitBoard, points: Point[], options?: Options): SVGGElement | undefined;
|
|
1459
|
+
drawRectangle(board: PlaitBoard, data: Point[] | RectangleClient, options?: Options): SVGGElement | undefined;
|
|
1460
|
+
drawCircles(board: PlaitBoard, points: Point[], diameter?: number, isCumulativeDiameter?: boolean, options?: Options): SVGGElement[] | undefined;
|
|
1461
|
+
}
|
|
1462
|
+
declare const createDebugGenerator: (debugKey: string) => DebugGenerator;
|
|
1463
|
+
declare const isDebug: (key?: string) => boolean;
|
|
1464
|
+
|
|
1465
|
+
export { A, ACTIVE_MOVING_CLASS_NAME, ACTIVE_STROKE_WIDTH, ALT, APOSTROPHE, ATTACHED_ELEMENT_CLASS_NAME, AT_SIGN, B, BACKSLASH, BACKSPACE, BOARD_TO_AFTER_CHANGE, BOARD_TO_CONTEXT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_MOVING_POINT_IN_BOARD, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, C, CAPS_LOCK, CLOSE_SQUARE_BRACKET, COMMA, CONTEXT_MENU, CONTROL, ColorfulThemeColor, CoreTransforms, CursorClass, D, DASH, DEFAULT_COLOR, DELETE, DOWN_ARROW, DRAG_SELECTION_PRESS_AND_MOVE_BUFFER, DarkThemeColor, DebugGenerator, DefaultThemeColor, Direction, E, EIGHT, ELEMENT_TO_REF, END, ENTER, EQUALS, ESCAPE, ElementFlavour, F, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, FF_EQUALS, FF_MINUS, FF_MUTE, FF_SEMICOLON, FF_VOLUME_DOWN, FF_VOLUME_UP, FIRST_MEDIA, FIVE, FLUSHING, FOUR, G, H, HISTORY, HIT_DISTANCE_BUFFER, HOME, HOST_CLASS_NAME, I, INSERT, IS_APPLE, IS_BOARD_ALIVE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_DRAGGING, IS_EDGE_LEGACY, IS_FIREFOX, IS_HAND_MODE, IS_IOS, IS_MAC, IS_SAFARI, IS_TEXT_EDITABLE, IS_WINDOWS, J, K, KEY_TO_ELEMENT_MAP, L, LAST_MEDIA, LEFT_ARROW, ListRender, M, MAC_ENTER, MAC_META, MAC_WK_CMD_LEFT, MAC_WK_CMD_RIGHT, MAX_RADIUS, MAX_ZOOM, MERGING, META, MIN_ZOOM, MUTE, N, NINE, NODE_TO_CONTAINER_G, NODE_TO_G, NODE_TO_INDEX, NODE_TO_PARENT, NS, NUMPAD_DIVIDE, NUMPAD_EIGHT, NUMPAD_FIVE, NUMPAD_FOUR, NUMPAD_MINUS, NUMPAD_MULTIPLY, NUMPAD_NINE, NUMPAD_ONE, NUMPAD_PERIOD, NUMPAD_PLUS, NUMPAD_SEVEN, NUMPAD_SIX, NUMPAD_THREE, NUMPAD_TWO, NUMPAD_ZERO, NUM_CENTER, NUM_LOCK, O, ONE, OPEN_SQUARE_BRACKET, P, PAGE_DOWN, PAGE_UP, PATH_REFS, PAUSE, PERIOD, PLUS_SIGN, POINTER_BUTTON, PRESS_AND_MOVE_BUFFER, PRINT_SCREEN, Path, PlaitBoard, PlaitBoardContext, PlaitElement, PlaitGroupElement, PlaitHistoryBoard, PlaitNode, PlaitOperation, PlaitPluginKey, PlaitPointerType, Point, Q, QUESTION_MARK, R, RESIZE_CURSORS, RESIZE_HANDLE_CLASS_NAME, RIGHT_ARROW, ROTATE_HANDLE_CLASS_NAME, RectangleClient, ResizeCursorClass, RetroThemeColor, S, SAVING, SCROLL_BAR_WIDTH, SCROLL_LOCK, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, SELECTION_RECTANGLE_BOUNDING_CLASS_NAME, SELECTION_RECTANGLE_CLASS_NAME, SEMICOLON, SEVEN, SHIFT, SINGLE_QUOTE, SIX, SLASH, SNAPPING_STROKE_WIDTH, SNAP_TOLERANCE, SPACE, SPLITTING_ONCE, Selection, SoftThemeColor, StarryThemeColor, T, TAB, THREE, TILDE, TWO, ThemeColorMode, ThemeColors, Transforms, U, UP_ARROW, V, VIEWPORT_PADDING_RATIO, VOLUME_DOWN, VOLUME_UP, Viewport, W, WritableClipboardOperationType, WritableClipboardType, X, Y, Z, ZERO, ZOOM_STEP, addClipboardContext, addOrCreateClipboardContext, addSelectedElement, approximately, arrowPoints, buildPlaitHtml, cacheClipboardData, cacheMovingElements, cacheSelectedElements, cacheSelectedElementsWithGroup, cacheSelectedElementsWithGroupOnShift, calcNewViewBox, calculateViewBox, canAddGroup, canRemoveGroup, canSetZIndex, catmullRomFitting, ceilToDecimal, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createBoard, createClipboardContext, createDebugGenerator, createFakeEvent, createForeignObject, createG, createGroup, createGroupRectangleG, createKeyboardEvent, createMask, createModModifierKeys, createMouseEvent, createPath, createPointerEvent, createRect, createSVG, createTestingBoard, createText, createTouchEvent, debounce, degreesToRadians, deleteFragment, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, distanceBetweenPointAndSegments, downloadImage, drawArrow, drawBezierPath, drawCircle, drawDashedLines, drawLine, drawLinearPath, drawPendingNodesG, drawPointSnapLines, drawRectangle, drawRoundRectangle, drawSelectionRectangleG, drawSolidLines, duplicateElements, fakeNodeWeakMap, filterSelectedGroups, findElements, findIndex, findLastIndex, getAllElementsInGroup, getAllGroups, getAllMoveOptions, getAngleBetweenPoints, getAngleByElement, getBarPoint, getBoardRectangle, getBoundingRectangleByElements, getCachedClipboardData, getClipboardData, getClipboardFromHtml, getCrossingPointsBetweenEllipseAndSegment, getDataTransferClipboard, getDataTransferClipboardText, getEditingGroup, getElementById, getElementHostBBox, getElementMap, getElementsInGroup, getElementsInGroupByElement, getElementsIndices, getEllipseArcCenter, getEllipseTangentSlope, getGroupByElement, getHighestGroup, getHighestIndexOfElement, getHighestSelectedElements, getHighestSelectedGroup, getHighestSelectedGroups, getHitElementByPoint, getHitElementsByPoint, getHitElementsBySelection, getHitSelectedElements, getI18nValue, getIsRecursionFunc, getMinPointDelta, getMovingElements, getNearestDelta, getNearestPointBetweenPointAndArc, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndEllipse, getNearestPointBetweenPointAndSegment, getNearestPointBetweenPointAndSegments, getNearestPointRectangle, getOffsetAfterRotate, getOneMoveOptions, getPointBetween, getProbablySupportsClipboardRead, getProbablySupportsClipboardWrite, getProbablySupportsClipboardWriteText, getRealScrollBarWidth, getRectangleByAngle, getRectangleByElements, getRectangleByGroup, getRotatedBoundingRectangle, getSelectedElements, getSelectedGroups, getSelectedIsolatedElements, getSelectedIsolatedElementsCanAddToGroup, getSelectedTargetElements, getSelectionAngle, getSelectionOptions, getSnapRectangles, getTemporaryElements, getTemporaryRef, getTripleAxis, getValidElements, getVectorFromPointAndSlope, getViewBox, getViewBoxCenterPoint, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnContextChanged, hasSameAngle, hasSelectedElementsInSameGroup, hasSetSelectionOperation, hasValidAngle, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isAxisChangedByAngle, isContextmenu, isDOMElement, isDOMNode, isDebug, isDragging, isFromScrolling, isFromViewportChange, isHandMode, isHandleSelection, isHitElement, isHitSelectedRectangle, isHorizontalDirection, isInPlaitBoard, isInVisibleViewport, isIndicesContinuous, isLineHitLine, isLineHitRectangle, isLineHitRectangleEdge, isMainPointer, isMobileDeviceEvent, isMouseEvent, isMovingElements, isNullOrUndefined, isPencilEvent, isPointInEllipse, isPointInPolygon, isPointInRoundRectangle, isSecondaryPointer, isSelectedAllElementsInGroup, isSelectedElement, isSelectedElementOrGroup, isSelectionMoving, isSetSelectionOperation, isSetThemeOperation, isSetViewportOperation, isSingleLineHitRectangleEdge, isSnapPoint, isTouchDevice, isTouchEvent, isValidAngle, isVerticalDirection, isWheelPointer, mountElementG, moveElementsToNewPath, moveElementsToNewPathAfterAddGroup, nonGroupInHighestSelectedElements, normalizeAngle, normalizePoint, prepareElementBBox, radiansToDegrees, removeMovingElements, removeSelectedElement, replaceAngleBrackets, replaceSelectedElement, reverseReplaceAngleBrackets, rgbaToHEX, rotate, rotateAntiPointsByElement, rotateElements, rotatePoints, rotatePointsByAngle, rotatePointsByElement, rotatedDataPoints, scrollToVisibleWhenKeyboardOpening, setAngleForG, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setDragging, setFragment, setIsFromScrolling, setIsFromViewportChange, setPathStrokeLinecap, setSVGViewBox, setSelectedElementsWithGroup, setSelectionMoving, setSelectionOptions, setStrokeLinecap, shouldClear, shouldMerge, shouldSave, sortElements, stripHtml, temporaryDisableSelection, throttleRAF, toActivePoint, toActivePointFromViewBoxPoint, toActiveRectangleFromViewBoxRectangle, toDomPrecision, toFixed, toHostPoint, toHostPointFromViewBoxPoint, toImage, toScreenPointFromActivePoint, toScreenPointFromHostPoint, toViewBoxPoint, toViewBoxPoints, uniqueById, updateForeignObject, updateForeignObjectWidth, updatePoints, updateViewBox, updateViewportByScrolling, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withArrowMoving, withBoard, withHandPointer, withHistory, withHotkey, withI18n, withMoving, withOptions, withRelatedFragment, withSelection };
|
|
1466
|
+
export type { Ancestor, BaseViewport, BeforeContextChange, ClipboardData, ComponentType, CustomTypes, DirectionFactor, DirectionFactors, ElementHostBBox, ExtendedType, FitViewportOptions, GapSnapRef, ImageEntry, InsertNodeOperation, MoveNodeOperation, MoveNodeOption, NodeParentsOptions, OnContextChanged, PathLevelsOptions, PlaitBoardMove, PlaitBoardOptions, PlaitChildrenContext, PlaitElementRef, PlaitGroup, PlaitHistory, PlaitI18nBoard, PlaitOperationInterface, PlaitOptionsBoard, PlaitPlugin, PlaitPluginElementContext, PlaitTheme, PointOfRectangle, RemoveNodeOperation, SVGArcCommand, SetNodeOperation, SetSelectionOperation, SetThemeOperation, SetViewportOperation, SnapDelta, SnapRef, ThemeColor, ToImageOptions, TreeNode, Vector, ViewBox, ViewportInterface, WithHandPluginOptions, WithPluginOptions, WithSelectionPluginOptions, WritableClipboardContext, WritableClipboardData, XYPosition };
|