@plait/core 0.0.56 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/board/board.component.d.ts +19 -41
- package/board/board.component.interface.d.ts +5 -0
- package/core/element/before-context-change.d.ts +6 -0
- package/core/element/context.d.ts +7 -0
- package/core/element/element.component.d.ts +11 -3
- package/core/element/plugin-element.d.ts +22 -0
- package/core/toolbar/toolbar.component.d.ts +7 -8
- package/esm2020/board/board.component.interface.mjs +2 -0
- package/esm2020/board/board.component.mjs +217 -230
- package/esm2020/core/element/before-context-change.mjs +7 -0
- package/esm2020/core/element/context.mjs +2 -0
- package/esm2020/core/element/element.component.mjs +48 -12
- package/esm2020/core/element/plugin-element.mjs +60 -0
- package/esm2020/core/toolbar/toolbar.component.mjs +14 -22
- package/esm2020/interfaces/board.mjs +1 -1
- package/esm2020/interfaces/element.mjs +1 -1
- package/esm2020/interfaces/index.mjs +3 -3
- package/esm2020/interfaces/node.mjs +1 -1
- package/esm2020/interfaces/pointer.mjs +6 -0
- package/esm2020/interfaces/viewport.mjs +2 -2
- package/esm2020/plugins/create-board.mjs +6 -7
- package/esm2020/plugins/with-hand.mjs +68 -0
- package/esm2020/plugins/with-selection.mjs +4 -2
- package/esm2020/public-api.mjs +3 -1
- package/esm2020/transforms/board.mjs +7 -0
- package/esm2020/transforms/general.mjs +1 -1
- package/esm2020/utils/board.mjs +1 -9
- package/esm2020/utils/matrix.mjs +131 -78
- package/esm2020/utils/weak-maps.mjs +1 -1
- package/fesm2015/plait-core.mjs +572 -441
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +594 -464
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +19 -8
- package/interfaces/element.d.ts +5 -2
- package/interfaces/index.d.ts +2 -2
- package/interfaces/node.d.ts +0 -1
- package/interfaces/pointer.d.ts +4 -0
- package/interfaces/viewport.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/with-hand.d.ts +2 -0
- package/public-api.d.ts +2 -0
- package/transforms/board.d.ts +3 -0
- package/utils/board.d.ts +2 -3
- package/utils/matrix.d.ts +66 -16
- package/utils/weak-maps.d.ts +2 -2
- package/esm2020/interfaces/cursor.mjs +0 -7
- package/esm2020/interfaces/element-context.mjs +0 -2
- package/esm2020/plugins/with-move.mjs +0 -66
- package/interfaces/cursor.d.ts +0 -6
- package/interfaces/element-context.d.ts +0 -4
- package/plugins/with-move.d.ts +0 -2
package/fesm2020/plait-core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ChangeDetectionStrategy, Input, EventEmitter, HostBinding, Output, ElementRef, ViewChild, ContentChild, NgModule } from '@angular/core';
|
|
2
|
+
import { Component, ChangeDetectionStrategy, Input, EventEmitter, HostBinding, Output, ElementRef, ViewChild, ContentChild, Directive, NgModule } from '@angular/core';
|
|
3
3
|
import rough from 'roughjs/bin/rough';
|
|
4
4
|
import { Subject, fromEvent } from 'rxjs';
|
|
5
5
|
import { takeUntil, filter } from 'rxjs/operators';
|
|
@@ -11,16 +11,21 @@ import { BrowserModule } from '@angular/platform-browser';
|
|
|
11
11
|
const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
|
|
12
12
|
const SCROLL_BAR_WIDTH = 20;
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
(function (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})(BaseCursorStatus || (BaseCursorStatus = {}));
|
|
14
|
+
var PlaitPointerType;
|
|
15
|
+
(function (PlaitPointerType) {
|
|
16
|
+
PlaitPointerType["hand"] = "hand";
|
|
17
|
+
PlaitPointerType["selection"] = "selection";
|
|
18
|
+
})(PlaitPointerType || (PlaitPointerType = {}));
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
function isNullOrUndefined(value) {
|
|
21
|
+
return value === null || value === undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Viewport = {
|
|
25
|
+
isViewport: (value) => {
|
|
26
|
+
return (!isNullOrUndefined(value.zoom) && !isNullOrUndefined(value.viewBackgroundColor) && !isNullOrUndefined(value.originationCoord));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
24
29
|
|
|
25
30
|
const Path = {
|
|
26
31
|
parent(path) {
|
|
@@ -179,102 +184,6 @@ const PlaitNode = {
|
|
|
179
184
|
}
|
|
180
185
|
};
|
|
181
186
|
|
|
182
|
-
const isSetViewportOperation = (value) => {
|
|
183
|
-
return value.type === 'set_viewport';
|
|
184
|
-
};
|
|
185
|
-
const inverse = (op) => {
|
|
186
|
-
switch (op.type) {
|
|
187
|
-
case 'insert_node': {
|
|
188
|
-
return { ...op, type: 'remove_node' };
|
|
189
|
-
}
|
|
190
|
-
case 'remove_node': {
|
|
191
|
-
return { ...op, type: 'insert_node' };
|
|
192
|
-
}
|
|
193
|
-
case 'move_node': {
|
|
194
|
-
const { newPath, path } = op;
|
|
195
|
-
// PERF: in this case the move operation is a no-op anyways.
|
|
196
|
-
if (Path.equals(newPath, path)) {
|
|
197
|
-
return op;
|
|
198
|
-
}
|
|
199
|
-
// when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
|
|
200
|
-
// shoud not return [0,2] -> [0,0] #WIK-8981
|
|
201
|
-
// if (Path.isSibling(path, newPath)) {
|
|
202
|
-
// return { ...op, path: newPath, newPath: path };
|
|
203
|
-
// }
|
|
204
|
-
// If the move does not happen within a single parent it is possible
|
|
205
|
-
// for the move to impact the true path to the location where the node
|
|
206
|
-
// was removed from and where it was inserted. We have to adjust for this
|
|
207
|
-
// and find the original path. We can accomplish this (only in non-sibling)
|
|
208
|
-
// moves by looking at the impact of the move operation on the node
|
|
209
|
-
// after the original move path.
|
|
210
|
-
const inversePath = Path.transform(path, op);
|
|
211
|
-
const inverseNewPath = Path.transform(Path.next(path), op);
|
|
212
|
-
return { ...op, path: inversePath, newPath: inverseNewPath };
|
|
213
|
-
}
|
|
214
|
-
case 'set_node': {
|
|
215
|
-
const { properties, newProperties } = op;
|
|
216
|
-
return { ...op, properties: newProperties, newProperties: properties };
|
|
217
|
-
}
|
|
218
|
-
case 'set_selection': {
|
|
219
|
-
const { properties, newProperties } = op;
|
|
220
|
-
if (properties == null) {
|
|
221
|
-
return {
|
|
222
|
-
...op,
|
|
223
|
-
properties: newProperties,
|
|
224
|
-
newProperties: null
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
else if (newProperties == null) {
|
|
228
|
-
return {
|
|
229
|
-
...op,
|
|
230
|
-
properties: null,
|
|
231
|
-
newProperties: properties
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
return { ...op, properties: newProperties, newProperties: properties };
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
case 'set_viewport': {
|
|
239
|
-
const { properties, newProperties } = op;
|
|
240
|
-
if (properties == null) {
|
|
241
|
-
return {
|
|
242
|
-
...op,
|
|
243
|
-
properties: newProperties,
|
|
244
|
-
newProperties: newProperties
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
else if (newProperties == null) {
|
|
248
|
-
return {
|
|
249
|
-
...op,
|
|
250
|
-
properties: properties,
|
|
251
|
-
newProperties: properties
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
return { ...op, properties: newProperties, newProperties: properties };
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
const PlaitOperation = {
|
|
261
|
-
isSetViewportOperation,
|
|
262
|
-
inverse
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
function isNullOrUndefined(value) {
|
|
266
|
-
return value === null || value === undefined;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const Viewport = {
|
|
270
|
-
isViewport: (value) => {
|
|
271
|
-
return !isNullOrUndefined(value.zoom) && !isNullOrUndefined(value.viewBackgroundColor) && !isNullOrUndefined(value.canvasPoint);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
const SAVING = new WeakMap();
|
|
276
|
-
const MERGING = new WeakMap();
|
|
277
|
-
|
|
278
187
|
const applyToDraft = (board, selection, viewport, op) => {
|
|
279
188
|
switch (op.type) {
|
|
280
189
|
case 'insert_node': {
|
|
@@ -481,8 +390,7 @@ function createBoard(host, children, options) {
|
|
|
481
390
|
host,
|
|
482
391
|
viewport: {
|
|
483
392
|
zoom: 1,
|
|
484
|
-
viewBackgroundColor: '#000'
|
|
485
|
-
canvasPoint: []
|
|
393
|
+
viewBackgroundColor: '#000'
|
|
486
394
|
},
|
|
487
395
|
children,
|
|
488
396
|
operations: [],
|
|
@@ -491,7 +399,7 @@ function createBoard(host, children, options) {
|
|
|
491
399
|
undos: []
|
|
492
400
|
},
|
|
493
401
|
selection: null,
|
|
494
|
-
|
|
402
|
+
pointer: PlaitPointerType.selection,
|
|
495
403
|
options: options || {
|
|
496
404
|
readonly: false,
|
|
497
405
|
allowClearBoard: false,
|
|
@@ -522,8 +430,8 @@ function createBoard(host, children, options) {
|
|
|
522
430
|
insertFragment: (data) => { },
|
|
523
431
|
deleteFragment: (data) => { },
|
|
524
432
|
drawElement: (context) => [],
|
|
525
|
-
redrawElement: (context,
|
|
526
|
-
destroyElement: () => { }
|
|
433
|
+
redrawElement: (context, previousContext) => { },
|
|
434
|
+
destroyElement: (context) => { }
|
|
527
435
|
};
|
|
528
436
|
return board;
|
|
529
437
|
}
|
|
@@ -540,6 +448,96 @@ function withBoard(board) {
|
|
|
540
448
|
return board;
|
|
541
449
|
}
|
|
542
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Extendable Custom Types Interface
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
const isSetViewportOperation = (value) => {
|
|
456
|
+
return value.type === 'set_viewport';
|
|
457
|
+
};
|
|
458
|
+
const inverse = (op) => {
|
|
459
|
+
switch (op.type) {
|
|
460
|
+
case 'insert_node': {
|
|
461
|
+
return { ...op, type: 'remove_node' };
|
|
462
|
+
}
|
|
463
|
+
case 'remove_node': {
|
|
464
|
+
return { ...op, type: 'insert_node' };
|
|
465
|
+
}
|
|
466
|
+
case 'move_node': {
|
|
467
|
+
const { newPath, path } = op;
|
|
468
|
+
// PERF: in this case the move operation is a no-op anyways.
|
|
469
|
+
if (Path.equals(newPath, path)) {
|
|
470
|
+
return op;
|
|
471
|
+
}
|
|
472
|
+
// when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
|
|
473
|
+
// shoud not return [0,2] -> [0,0] #WIK-8981
|
|
474
|
+
// if (Path.isSibling(path, newPath)) {
|
|
475
|
+
// return { ...op, path: newPath, newPath: path };
|
|
476
|
+
// }
|
|
477
|
+
// If the move does not happen within a single parent it is possible
|
|
478
|
+
// for the move to impact the true path to the location where the node
|
|
479
|
+
// was removed from and where it was inserted. We have to adjust for this
|
|
480
|
+
// and find the original path. We can accomplish this (only in non-sibling)
|
|
481
|
+
// moves by looking at the impact of the move operation on the node
|
|
482
|
+
// after the original move path.
|
|
483
|
+
const inversePath = Path.transform(path, op);
|
|
484
|
+
const inverseNewPath = Path.transform(Path.next(path), op);
|
|
485
|
+
return { ...op, path: inversePath, newPath: inverseNewPath };
|
|
486
|
+
}
|
|
487
|
+
case 'set_node': {
|
|
488
|
+
const { properties, newProperties } = op;
|
|
489
|
+
return { ...op, properties: newProperties, newProperties: properties };
|
|
490
|
+
}
|
|
491
|
+
case 'set_selection': {
|
|
492
|
+
const { properties, newProperties } = op;
|
|
493
|
+
if (properties == null) {
|
|
494
|
+
return {
|
|
495
|
+
...op,
|
|
496
|
+
properties: newProperties,
|
|
497
|
+
newProperties: null
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
else if (newProperties == null) {
|
|
501
|
+
return {
|
|
502
|
+
...op,
|
|
503
|
+
properties: null,
|
|
504
|
+
newProperties: properties
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
return { ...op, properties: newProperties, newProperties: properties };
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
case 'set_viewport': {
|
|
512
|
+
const { properties, newProperties } = op;
|
|
513
|
+
if (properties == null) {
|
|
514
|
+
return {
|
|
515
|
+
...op,
|
|
516
|
+
properties: newProperties,
|
|
517
|
+
newProperties: newProperties
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
else if (newProperties == null) {
|
|
521
|
+
return {
|
|
522
|
+
...op,
|
|
523
|
+
properties: properties,
|
|
524
|
+
newProperties: properties
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
return { ...op, properties: newProperties, newProperties: properties };
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
const PlaitOperation = {
|
|
534
|
+
isSetViewportOperation,
|
|
535
|
+
inverse
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
const SAVING = new WeakMap();
|
|
539
|
+
const MERGING = new WeakMap();
|
|
540
|
+
|
|
543
541
|
function transformPoints(board, points) {
|
|
544
542
|
const newPoints = points.map(point => {
|
|
545
543
|
return transformPoint(board, point);
|
|
@@ -554,17 +552,9 @@ function transformPoint(board, point) {
|
|
|
554
552
|
const newPoint = [x, y];
|
|
555
553
|
return newPoint;
|
|
556
554
|
}
|
|
557
|
-
function calculateZoom(zoom, minZoom = 0.2, maxZoom = 4) {
|
|
558
|
-
return zoom < minZoom ? minZoom : zoom > maxZoom ? maxZoom : zoom;
|
|
559
|
-
}
|
|
560
555
|
function isNoSelectionElement(e) {
|
|
561
556
|
return e.target?.closest('.plait-board-attached');
|
|
562
557
|
}
|
|
563
|
-
const updateCursorStatus = (board, cursor) => {
|
|
564
|
-
if (cursor) {
|
|
565
|
-
board.cursor = cursor;
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
558
|
|
|
569
559
|
const NS = 'http://www.w3.org/2000/svg';
|
|
570
560
|
function toPoint(x, y, container) {
|
|
@@ -822,73 +812,98 @@ function distanceBetweenPointAndPoint(x1, y1, x2, y2) {
|
|
|
822
812
|
return Math.hypot(dx, dy);
|
|
823
813
|
}
|
|
824
814
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
815
|
+
/**
|
|
816
|
+
* 逆矩阵
|
|
817
|
+
* [a c e]
|
|
818
|
+
* [b d f]
|
|
819
|
+
* [0 0 1]
|
|
820
|
+
* @param newMatrix 输出返回矩阵
|
|
821
|
+
* @param matrix 新矩阵
|
|
822
|
+
* @returns 逆矩阵
|
|
823
|
+
*/
|
|
824
|
+
function invertMatrix(newMatrix, matrix) {
|
|
825
|
+
const [n, r, a, i, o, c, l, s, u] = matrix;
|
|
826
|
+
const determinant = u * o - c * s;
|
|
827
|
+
const h = -u * i + c * l;
|
|
828
|
+
const f = s * i - o * l;
|
|
829
|
+
const product = n * determinant + r * h + a * f;
|
|
830
|
+
if (!product) {
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
const reciprocal = 1 / product;
|
|
834
|
+
newMatrix[0] = determinant * reciprocal;
|
|
835
|
+
newMatrix[1] = (-u * r + a * s) * reciprocal;
|
|
836
|
+
newMatrix[2] = (c * r - a * o) * reciprocal;
|
|
837
|
+
newMatrix[3] = h * reciprocal;
|
|
838
|
+
newMatrix[4] = (u * n - a * l) * reciprocal;
|
|
839
|
+
newMatrix[5] = (-c * n + a * i) * reciprocal;
|
|
840
|
+
newMatrix[6] = f * reciprocal;
|
|
841
|
+
newMatrix[7] = (-s * n + r * l) * reciprocal;
|
|
842
|
+
newMatrix[8] = (o * n - r * i) * reciprocal;
|
|
843
|
+
return newMatrix;
|
|
840
844
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
845
|
+
/**
|
|
846
|
+
* 将视图坐标与反转矩阵相乘,以得到原始坐标
|
|
847
|
+
* 使用给定的矩阵进行转换
|
|
848
|
+
* 矩阵与向量乘法,3 维向量与3x3矩阵的乘积
|
|
849
|
+
* [m11 m12 m13][v1]
|
|
850
|
+
* [m21 m22 m23][v2]
|
|
851
|
+
* [m31 m32 m33][v3]
|
|
852
|
+
* @param out 输出结果向量
|
|
853
|
+
* @param t 要转换的向量
|
|
854
|
+
* @param n 矩阵转换
|
|
855
|
+
* @returns [v1 * m11 + v2 * m12 + v3 * m13, v1 * m21 + v2 * m22 + v3 * m23, v1 * m31 + v2 * m32 + v3 * m33];
|
|
856
|
+
*/
|
|
857
|
+
function transformMat3(out, vector, matrix) {
|
|
858
|
+
out = [
|
|
859
|
+
vector[0] * matrix[0] + vector[1] * matrix[3] + vector[2] * matrix[6],
|
|
860
|
+
vector[0] * matrix[1] + vector[1] * matrix[4] + vector[2] * matrix[7],
|
|
861
|
+
vector[0] * matrix[2] + vector[1] * matrix[5] + vector[2] * matrix[8]
|
|
862
|
+
];
|
|
863
|
+
return out;
|
|
844
864
|
}
|
|
845
|
-
|
|
846
|
-
|
|
865
|
+
/**
|
|
866
|
+
* 规范 point
|
|
867
|
+
* @param point
|
|
868
|
+
* @returns point
|
|
869
|
+
*/
|
|
870
|
+
function normalizePoint(point) {
|
|
871
|
+
return Array.isArray(point)
|
|
847
872
|
? {
|
|
848
|
-
x:
|
|
849
|
-
y:
|
|
873
|
+
x: point[0],
|
|
874
|
+
y: point[1]
|
|
850
875
|
}
|
|
851
|
-
:
|
|
852
|
-
}
|
|
853
|
-
function invertClient(board, point, matrix) {
|
|
854
|
-
const convert = convertPoint(point);
|
|
855
|
-
const clientBox = getViewportClientBox(board);
|
|
856
|
-
const newPoint = [convert.x - clientBox.x, convert.y - clientBox.y, 1];
|
|
857
|
-
const invertMatrix = invert([], matrix);
|
|
858
|
-
const newMatrix = transformMat3([], [newPoint[0], newPoint[1], 1], invertMatrix);
|
|
859
|
-
return [newMatrix[0], newMatrix[1]];
|
|
876
|
+
: point;
|
|
860
877
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
878
|
+
/**
|
|
879
|
+
* 将一个点坐标反转回它的原始坐标
|
|
880
|
+
* @param point 表示要反转的点的视图坐标,它是一个长度为 2 的数组,存储点的 x 和 y 坐标
|
|
881
|
+
* @param matrix 表示视图矩阵,是在视图中对图形进行缩放和平移时使用的矩阵
|
|
882
|
+
* @returns 最终结果是一个长度为 3 的数组,存储点的 x,y 和 w 坐标(w 坐标是点的齐次坐标)
|
|
883
|
+
*/
|
|
884
|
+
function invertViewportCoordinates(point, matrix) {
|
|
885
|
+
const { x, y } = normalizePoint(point);
|
|
886
|
+
const invertedMatrix = invertMatrix([], matrix);
|
|
887
|
+
return transformMat3([], [x, y, 1], invertedMatrix);
|
|
869
888
|
}
|
|
870
|
-
function
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
const newClient = invertClient(board, [clientBox.maxX, clientBox.maxY], matrix);
|
|
874
|
-
return {
|
|
875
|
-
minX: client[0],
|
|
876
|
-
minY: client[1],
|
|
877
|
-
maxX: newClient[0],
|
|
878
|
-
maxY: newClient[1],
|
|
879
|
-
x: client[0],
|
|
880
|
-
y: client[1],
|
|
881
|
-
width: newClient[0] - client[0],
|
|
882
|
-
height: newClient[1] - client[1]
|
|
883
|
-
};
|
|
889
|
+
function convertToViewportCoordinates(point, matrix) {
|
|
890
|
+
const { x, y } = normalizePoint(point);
|
|
891
|
+
return transformMat3([], [x, y, 1], matrix);
|
|
884
892
|
}
|
|
885
|
-
|
|
893
|
+
/**
|
|
894
|
+
* 获取 contentContainer 的 clientBox
|
|
895
|
+
* @param board
|
|
896
|
+
* @returns
|
|
897
|
+
*/
|
|
898
|
+
function getViewportContainerBox(board) {
|
|
899
|
+
const { hideScrollbar } = board.options;
|
|
900
|
+
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
886
901
|
const container = board.host?.parentElement;
|
|
887
902
|
const containerRect = container?.getBoundingClientRect();
|
|
888
903
|
const x = containerRect.x || containerRect.left;
|
|
889
904
|
const y = containerRect.y || containerRect.top;
|
|
890
|
-
const width = containerRect.width -
|
|
891
|
-
const height = containerRect.height -
|
|
905
|
+
const width = containerRect.width - scrollBarWidth;
|
|
906
|
+
const height = containerRect.height - scrollBarWidth;
|
|
892
907
|
return {
|
|
893
908
|
minX: x,
|
|
894
909
|
minY: y,
|
|
@@ -900,41 +915,70 @@ function getViewportClientBox(board) {
|
|
|
900
915
|
height
|
|
901
916
|
};
|
|
902
917
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
918
|
+
/**
|
|
919
|
+
* 获取 board.plait-board 的 clientBox
|
|
920
|
+
* @param board
|
|
921
|
+
* @returns
|
|
922
|
+
*/
|
|
923
|
+
function getBoardClientBox(board) {
|
|
924
|
+
const { hideScrollbar } = board.options;
|
|
925
|
+
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
926
|
+
const boardEl = board.host?.parentElement?.parentElement;
|
|
927
|
+
const elRect = boardEl?.getBoundingClientRect();
|
|
928
|
+
return {
|
|
929
|
+
width: elRect.width + scrollBarWidth,
|
|
930
|
+
height: elRect.height + scrollBarWidth
|
|
931
|
+
};
|
|
907
932
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
933
|
+
/**
|
|
934
|
+
* 获取 rootGroup 相对于当前 svg 空间的最小矩阵坐标
|
|
935
|
+
*/
|
|
936
|
+
function getRootGroupBBox(board, zoom) {
|
|
911
937
|
const rootGroup = board.host.firstChild;
|
|
912
938
|
const rootGroupBox = rootGroup.getBBox();
|
|
913
|
-
|
|
914
|
-
const containerWidth =
|
|
915
|
-
const containerHeight =
|
|
939
|
+
const viewportContainerBox = getViewportContainerBox(board);
|
|
940
|
+
const containerWidth = viewportContainerBox.width / zoom;
|
|
941
|
+
const containerHeight = viewportContainerBox.height / zoom;
|
|
942
|
+
let left;
|
|
943
|
+
let right;
|
|
944
|
+
let top;
|
|
945
|
+
let bottom;
|
|
916
946
|
if (rootGroupBox.width < containerWidth) {
|
|
917
947
|
const offsetX = rootGroupBox.x + rootGroupBox.width / 2;
|
|
918
948
|
const containerX = containerWidth / 2;
|
|
919
|
-
|
|
920
|
-
|
|
949
|
+
left = offsetX - containerX;
|
|
950
|
+
right = offsetX + containerX;
|
|
921
951
|
}
|
|
922
952
|
else {
|
|
923
|
-
|
|
924
|
-
|
|
953
|
+
left = rootGroupBox.x;
|
|
954
|
+
right = rootGroupBox.x + rootGroupBox.width;
|
|
925
955
|
}
|
|
926
956
|
if (rootGroupBox.height < containerHeight) {
|
|
927
957
|
const offsetY = rootGroupBox.y + rootGroupBox.height / 2;
|
|
928
958
|
const containerY = containerHeight / 2;
|
|
929
|
-
|
|
930
|
-
|
|
959
|
+
top = offsetY - containerY;
|
|
960
|
+
bottom = offsetY + containerY;
|
|
931
961
|
}
|
|
932
962
|
else {
|
|
933
|
-
|
|
934
|
-
|
|
963
|
+
top = rootGroupBox.y;
|
|
964
|
+
bottom = rootGroupBox.y + rootGroupBox.height;
|
|
935
965
|
}
|
|
936
|
-
|
|
937
|
-
|
|
966
|
+
return {
|
|
967
|
+
left,
|
|
968
|
+
right,
|
|
969
|
+
top,
|
|
970
|
+
bottom
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* 验证缩放比是否符合限制,如果超出限制,则返回合适的缩放比
|
|
975
|
+
* @param zoom 缩放比
|
|
976
|
+
* @param minZoom 最小缩放比
|
|
977
|
+
* @param maxZoom 最大缩放比
|
|
978
|
+
* @returns 正确的缩放比
|
|
979
|
+
*/
|
|
980
|
+
function clampZoomLevel(zoom, minZoom = 0.2, maxZoom = 4) {
|
|
981
|
+
return zoom < minZoom ? minZoom : zoom > maxZoom ? maxZoom : zoom;
|
|
938
982
|
}
|
|
939
983
|
|
|
940
984
|
function withHistory(board) {
|
|
@@ -1021,7 +1065,13 @@ function withHistory(board) {
|
|
|
1021
1065
|
return board;
|
|
1022
1066
|
}
|
|
1023
1067
|
|
|
1024
|
-
|
|
1068
|
+
const updatePointerType = (board, pointer) => {
|
|
1069
|
+
board.pointer = pointer;
|
|
1070
|
+
const boardComponent = PLAIT_BOARD_TO_COMPONENT.get(board);
|
|
1071
|
+
boardComponent?.markForCheck();
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
function withHandPointer(board) {
|
|
1025
1075
|
const { mousedown, mousemove, globalMouseup, keydown, keyup } = board;
|
|
1026
1076
|
const plaitBoardMove = {
|
|
1027
1077
|
x: 0,
|
|
@@ -1029,12 +1079,12 @@ function withMove(board) {
|
|
|
1029
1079
|
};
|
|
1030
1080
|
board.mousedown = (event) => {
|
|
1031
1081
|
if (board.options.readonly) {
|
|
1032
|
-
|
|
1082
|
+
updatePointerType(board, PlaitPointerType.hand);
|
|
1033
1083
|
}
|
|
1034
1084
|
else if (!board.selection) {
|
|
1035
|
-
|
|
1085
|
+
updatePointerType(board, PlaitPointerType.selection);
|
|
1036
1086
|
}
|
|
1037
|
-
if (board.
|
|
1087
|
+
if (board.pointer === PlaitPointerType.hand && board.selection) {
|
|
1038
1088
|
const boardComponent = PLAIT_BOARD_TO_COMPONENT.get(board);
|
|
1039
1089
|
boardComponent.movingChange(true);
|
|
1040
1090
|
plaitBoardMove.x = event.x;
|
|
@@ -1045,10 +1095,11 @@ function withMove(board) {
|
|
|
1045
1095
|
};
|
|
1046
1096
|
board.mousemove = (event) => {
|
|
1047
1097
|
const boardComponent = PLAIT_BOARD_TO_COMPONENT.get(board);
|
|
1048
|
-
if (board.
|
|
1098
|
+
if (board.pointer === PlaitPointerType.hand && board.selection && boardComponent.isMoving) {
|
|
1049
1099
|
const left = event.x - plaitBoardMove.x;
|
|
1050
1100
|
const top = event.y - plaitBoardMove.y;
|
|
1051
|
-
|
|
1101
|
+
const { scrollLeft, scrollTop } = boardComponent.viewportState;
|
|
1102
|
+
boardComponent.setScroll(scrollLeft - left, scrollTop - top);
|
|
1052
1103
|
plaitBoardMove.x = event.x;
|
|
1053
1104
|
plaitBoardMove.y = event.y;
|
|
1054
1105
|
}
|
|
@@ -1065,8 +1116,8 @@ function withMove(board) {
|
|
|
1065
1116
|
};
|
|
1066
1117
|
board.keydown = (event) => {
|
|
1067
1118
|
if (board.selection && event.code === 'Space') {
|
|
1068
|
-
if (board.
|
|
1069
|
-
|
|
1119
|
+
if (board.pointer !== PlaitPointerType.hand) {
|
|
1120
|
+
updatePointerType(board, PlaitPointerType.hand);
|
|
1070
1121
|
const boardComponent = PLAIT_BOARD_TO_COMPONENT.get(board);
|
|
1071
1122
|
boardComponent.cdr.markForCheck();
|
|
1072
1123
|
}
|
|
@@ -1076,7 +1127,7 @@ function withMove(board) {
|
|
|
1076
1127
|
};
|
|
1077
1128
|
board.keyup = (event) => {
|
|
1078
1129
|
if (board.selection && !board.options.readonly && event.code === 'Space') {
|
|
1079
|
-
|
|
1130
|
+
updatePointerType(board, PlaitPointerType.selection);
|
|
1080
1131
|
const boardComponent = PLAIT_BOARD_TO_COMPONENT.get(board);
|
|
1081
1132
|
boardComponent.cdr.markForCheck();
|
|
1082
1133
|
}
|
|
@@ -1117,7 +1168,9 @@ function withSelection(board) {
|
|
|
1117
1168
|
Transforms.setSelection(board, { anchor: start, focus: start });
|
|
1118
1169
|
}
|
|
1119
1170
|
else {
|
|
1120
|
-
|
|
1171
|
+
if (board.selection !== null) {
|
|
1172
|
+
Transforms.setSelection(board, null);
|
|
1173
|
+
}
|
|
1121
1174
|
}
|
|
1122
1175
|
start = null;
|
|
1123
1176
|
end = null;
|
|
@@ -1139,24 +1192,60 @@ class PlaitElementComponent {
|
|
|
1139
1192
|
}
|
|
1140
1193
|
initialize() {
|
|
1141
1194
|
this.initialized = true;
|
|
1142
|
-
this.
|
|
1143
|
-
this.renderer2.setAttribute(this.
|
|
1144
|
-
this.host.append(this.
|
|
1195
|
+
this.gGroup = createG();
|
|
1196
|
+
this.renderer2.setAttribute(this.gGroup, 'plait-element-group', this.index.toString());
|
|
1197
|
+
this.host.append(this.gGroup);
|
|
1145
1198
|
}
|
|
1146
1199
|
drawElement() {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1200
|
+
const context = this.getContext();
|
|
1201
|
+
const result = this.board.drawElement(context.current);
|
|
1202
|
+
if (Array.isArray(result)) {
|
|
1203
|
+
result.forEach(g => {
|
|
1204
|
+
this.gGroup.appendChild(g);
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
else {
|
|
1208
|
+
const componentRef = this.viewContainerRef.createComponent(result);
|
|
1209
|
+
const instance = componentRef.instance;
|
|
1210
|
+
instance.context = context.current;
|
|
1211
|
+
this.gGroup.appendChild(instance.g);
|
|
1212
|
+
this.instance = instance;
|
|
1213
|
+
}
|
|
1151
1214
|
}
|
|
1152
|
-
ngOnChanges(
|
|
1215
|
+
ngOnChanges() {
|
|
1153
1216
|
if (this.initialized) {
|
|
1154
|
-
this.
|
|
1217
|
+
const context = this.getContext();
|
|
1218
|
+
if (this.instance) {
|
|
1219
|
+
this.instance.context = context.current;
|
|
1220
|
+
}
|
|
1221
|
+
const result = this.board.redrawElement(context.current, context.previous);
|
|
1222
|
+
if (result && result.length > 0) {
|
|
1223
|
+
this.gGroup.childNodes.forEach(g => g.remove());
|
|
1224
|
+
result.forEach(g => {
|
|
1225
|
+
this.gGroup.appendChild(g);
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
getContext() {
|
|
1231
|
+
const current = {
|
|
1232
|
+
element: this.element,
|
|
1233
|
+
selection: this.selection,
|
|
1234
|
+
board: this.board,
|
|
1235
|
+
host: this.host
|
|
1236
|
+
};
|
|
1237
|
+
if (this.context) {
|
|
1238
|
+
const previous = { ...this.context };
|
|
1239
|
+
this.context = current;
|
|
1240
|
+
return { current, previous };
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
return { current };
|
|
1155
1244
|
}
|
|
1156
1245
|
}
|
|
1157
1246
|
ngOnDestroy() {
|
|
1158
|
-
this.
|
|
1159
|
-
this.
|
|
1247
|
+
this.gGroup.remove();
|
|
1248
|
+
this.board.destroyElement(this.getContext().current);
|
|
1160
1249
|
}
|
|
1161
1250
|
}
|
|
1162
1251
|
PlaitElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitElementComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1184,27 +1273,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1184
1273
|
|
|
1185
1274
|
class PlaitToolbarComponent {
|
|
1186
1275
|
constructor() {
|
|
1187
|
-
this.
|
|
1276
|
+
this.PlaitPointerType = PlaitPointerType;
|
|
1188
1277
|
this.hostClass = `plait-board-toolbar`;
|
|
1189
|
-
this.moveHandle = new EventEmitter();
|
|
1190
1278
|
this.adaptHandle = new EventEmitter();
|
|
1191
1279
|
this.zoomInHandle = new EventEmitter();
|
|
1192
1280
|
this.zoomOutHandle = new EventEmitter();
|
|
1193
1281
|
this.resetZoomHandel = new EventEmitter();
|
|
1194
1282
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1283
|
+
get zoom() {
|
|
1284
|
+
const zoom = this.board?.viewport.zoom || 1;
|
|
1285
|
+
return Number((zoom * 100).toFixed(0));
|
|
1197
1286
|
}
|
|
1198
|
-
get
|
|
1199
|
-
return this.
|
|
1287
|
+
get pointerType() {
|
|
1288
|
+
return this.board.pointer || PlaitPointerType.selection;
|
|
1200
1289
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
this.moveHandle.emit(BaseCursorStatus.move);
|
|
1204
|
-
}
|
|
1205
|
-
else {
|
|
1206
|
-
this.moveHandle.emit(BaseCursorStatus.select);
|
|
1207
|
-
}
|
|
1290
|
+
activeHand() {
|
|
1291
|
+
updatePointerType(this.board, this.pointerType === PlaitPointerType.hand ? PlaitPointerType.selection : PlaitPointerType.hand);
|
|
1208
1292
|
}
|
|
1209
1293
|
// 适应画布
|
|
1210
1294
|
adapt() {
|
|
@@ -1223,19 +1307,15 @@ class PlaitToolbarComponent {
|
|
|
1223
1307
|
}
|
|
1224
1308
|
}
|
|
1225
1309
|
PlaitToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1226
|
-
PlaitToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: { cursorStatus: "cursorStatus", viewZoom: "viewZoom" }, outputs: { moveHandle: "moveHandle", adaptHandle: "adaptHandle", zoomInHandle: "zoomInHandle", zoomOutHandle: "zoomOutHandle", resetZoomHandel: "resetZoomHandel" }, host: { properties: { "class": "this.hostClass" } }, ngImport: i0, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': cursorStatus === 'move' }\" (click)=\"dragMove()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ viewZoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n", directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1310
|
+
PlaitToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: { board: "board" }, outputs: { adaptHandle: "adaptHandle", zoomInHandle: "zoomInHandle", zoomOutHandle: "zoomOutHandle", resetZoomHandel: "resetZoomHandel" }, host: { properties: { "class": "this.hostClass" } }, ngImport: i0, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': pointerType === PlaitPointerType.hand}\" (click)=\"activeHand()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ zoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n", directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1227
1311
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitToolbarComponent, decorators: [{
|
|
1228
1312
|
type: Component,
|
|
1229
|
-
args: [{ selector: 'plait-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': cursorStatus === 'move' }\" (click)=\"dragMove()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ viewZoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n" }]
|
|
1313
|
+
args: [{ selector: 'plait-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': pointerType === PlaitPointerType.hand}\" (click)=\"activeHand()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ zoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n" }]
|
|
1230
1314
|
}], propDecorators: { hostClass: [{
|
|
1231
1315
|
type: HostBinding,
|
|
1232
1316
|
args: ['class']
|
|
1233
|
-
}],
|
|
1234
|
-
type: Input
|
|
1235
|
-
}], viewZoom: [{
|
|
1317
|
+
}], board: [{
|
|
1236
1318
|
type: Input
|
|
1237
|
-
}], moveHandle: [{
|
|
1238
|
-
type: Output
|
|
1239
1319
|
}], adaptHandle: [{
|
|
1240
1320
|
type: Output
|
|
1241
1321
|
}], zoomInHandle: [{
|
|
@@ -1253,13 +1333,12 @@ class PlaitBoardComponent {
|
|
|
1253
1333
|
this.elementRef = elementRef;
|
|
1254
1334
|
this.hasInitialized = false;
|
|
1255
1335
|
this.destroy$ = new Subject();
|
|
1256
|
-
this.
|
|
1336
|
+
this.viewportState = {
|
|
1337
|
+
zoom: 1,
|
|
1338
|
+
autoFitPadding: 8,
|
|
1339
|
+
scrollBarWidth: SCROLL_BAR_WIDTH
|
|
1340
|
+
};
|
|
1257
1341
|
this.isMoving = false;
|
|
1258
|
-
this.zoom = 1;
|
|
1259
|
-
this.viewportCanvasBox = {};
|
|
1260
|
-
this.focusPoint = [0, 0];
|
|
1261
|
-
this.width = 0;
|
|
1262
|
-
this.height = 0;
|
|
1263
1342
|
this.plaitValue = [];
|
|
1264
1343
|
this.plaitPlugins = [];
|
|
1265
1344
|
this.plaitChange = new EventEmitter();
|
|
@@ -1268,9 +1347,6 @@ class PlaitBoardComponent {
|
|
|
1268
1347
|
return index;
|
|
1269
1348
|
};
|
|
1270
1349
|
}
|
|
1271
|
-
get isMoveMode() {
|
|
1272
|
-
return this.board.cursor === BaseCursorStatus.move;
|
|
1273
|
-
}
|
|
1274
1350
|
get host() {
|
|
1275
1351
|
return this.svg.nativeElement;
|
|
1276
1352
|
}
|
|
@@ -1278,19 +1354,21 @@ class PlaitBoardComponent {
|
|
|
1278
1354
|
return this.board?.selection;
|
|
1279
1355
|
}
|
|
1280
1356
|
get hostClass() {
|
|
1281
|
-
return `plait-board-container ${this.board.
|
|
1357
|
+
return `plait-board-container ${this.board.pointer}`;
|
|
1282
1358
|
}
|
|
1283
1359
|
get readonly() {
|
|
1284
1360
|
return this.board.options.readonly;
|
|
1285
1361
|
}
|
|
1286
1362
|
get moving() {
|
|
1287
|
-
return this.board.
|
|
1363
|
+
return this.board.pointer === PlaitPointerType.hand && this.isMoving;
|
|
1288
1364
|
}
|
|
1289
1365
|
get focused() {
|
|
1290
1366
|
return this.isFocused;
|
|
1291
1367
|
}
|
|
1292
1368
|
ngOnInit() {
|
|
1293
|
-
const roughSVG = rough.svg(this.host, {
|
|
1369
|
+
const roughSVG = rough.svg(this.host, {
|
|
1370
|
+
options: { roughness: 0, strokeWidth: 1 }
|
|
1371
|
+
});
|
|
1294
1372
|
HOST_TO_ROUGH_SVG.set(this.host, roughSVG);
|
|
1295
1373
|
this.initializePlugins();
|
|
1296
1374
|
this.initializeEvents();
|
|
@@ -1303,9 +1381,6 @@ class PlaitBoardComponent {
|
|
|
1303
1381
|
viewport: this.board.viewport,
|
|
1304
1382
|
selection: this.board.selection
|
|
1305
1383
|
};
|
|
1306
|
-
if (this.board.operations.length > 0) {
|
|
1307
|
-
this.updateViewport();
|
|
1308
|
-
}
|
|
1309
1384
|
this.plaitChange.emit(changeEvent);
|
|
1310
1385
|
});
|
|
1311
1386
|
this.hasInitialized = true;
|
|
@@ -1324,12 +1399,12 @@ class PlaitBoardComponent {
|
|
|
1324
1399
|
}
|
|
1325
1400
|
ngAfterViewInit() {
|
|
1326
1401
|
this.plaitBoardInitialized.emit(this.board);
|
|
1327
|
-
this.
|
|
1328
|
-
this.
|
|
1329
|
-
this.
|
|
1402
|
+
this.initViewportContainer();
|
|
1403
|
+
this.calcViewBox(this.viewportState.zoom);
|
|
1404
|
+
this.initViewport();
|
|
1330
1405
|
}
|
|
1331
1406
|
initializePlugins() {
|
|
1332
|
-
let board =
|
|
1407
|
+
let board = withHandPointer(withHistory(withSelection(withBoard(createBoard(this.host, this.plaitValue, this.plaitOptions)))));
|
|
1333
1408
|
this.plaitPlugins.forEach(plugin => {
|
|
1334
1409
|
board = plugin(board);
|
|
1335
1410
|
});
|
|
@@ -1337,6 +1412,11 @@ class PlaitBoardComponent {
|
|
|
1337
1412
|
if (this.plaitViewport) {
|
|
1338
1413
|
this.board.viewport = this.plaitViewport;
|
|
1339
1414
|
}
|
|
1415
|
+
const scrollBarWidth = this.plaitOptions?.hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1416
|
+
this.updateViewportState({
|
|
1417
|
+
scrollBarWidth,
|
|
1418
|
+
zoom: this.board.viewport?.zoom ?? 1
|
|
1419
|
+
});
|
|
1340
1420
|
}
|
|
1341
1421
|
initializeEvents() {
|
|
1342
1422
|
fromEvent(this.host, 'mousedown')
|
|
@@ -1397,245 +1477,207 @@ class PlaitBoardComponent {
|
|
|
1397
1477
|
this.board?.setFragment(event.clipboardData);
|
|
1398
1478
|
this.board?.deleteFragment(event.clipboardData);
|
|
1399
1479
|
});
|
|
1400
|
-
fromEvent(this.
|
|
1401
|
-
.pipe(takeUntil(this.destroy$), filter(() => {
|
|
1402
|
-
return !!this.isFocused;
|
|
1403
|
-
}))
|
|
1404
|
-
.subscribe((e) => {
|
|
1405
|
-
this.focusPoint = [e.clientX, e.clientY];
|
|
1406
|
-
});
|
|
1407
|
-
fromEvent(this.contentContainer.nativeElement, 'mouseleave')
|
|
1408
|
-
.pipe(takeUntil(this.destroy$), filter(() => {
|
|
1409
|
-
return !!this.isFocused;
|
|
1410
|
-
}))
|
|
1411
|
-
.subscribe((e) => {
|
|
1412
|
-
this.resetFocusPoint();
|
|
1413
|
-
});
|
|
1414
|
-
fromEvent(this.contentContainer.nativeElement, 'scroll')
|
|
1480
|
+
fromEvent(this.viewportContainer.nativeElement, 'scroll')
|
|
1415
1481
|
.pipe(takeUntil(this.destroy$), filter(() => {
|
|
1416
1482
|
return !!this.isFocused;
|
|
1417
1483
|
}))
|
|
1418
1484
|
.subscribe((event) => {
|
|
1419
|
-
const scrollLeft = event.target
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1422
|
-
|
|
1485
|
+
const { scrollLeft, scrollTop } = event.target;
|
|
1486
|
+
const left = this.viewportState.scrollLeft;
|
|
1487
|
+
const top = this.viewportState.scrollTop;
|
|
1488
|
+
if (Math.abs(left - scrollLeft) >= 1 || Math.abs(top - scrollTop) >= 1) {
|
|
1489
|
+
this.setScrollLeft(scrollLeft);
|
|
1490
|
+
this.setScrollTop(scrollTop);
|
|
1491
|
+
this.setViewport();
|
|
1492
|
+
}
|
|
1423
1493
|
});
|
|
1424
1494
|
this.resizeElement();
|
|
1425
1495
|
}
|
|
1426
1496
|
resizeElement() {
|
|
1427
1497
|
this.resizeObserver = new ResizeObserver(entries => {
|
|
1428
1498
|
for (let entry of entries) {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
this.
|
|
1433
|
-
this.
|
|
1434
|
-
this.changeSize();
|
|
1499
|
+
this.initViewportContainer();
|
|
1500
|
+
this.calcViewBox(this.board.viewport.zoom);
|
|
1501
|
+
this.updateViewBoxStyles();
|
|
1502
|
+
this.updateViewportScrolling();
|
|
1503
|
+
this.setViewport();
|
|
1435
1504
|
}
|
|
1436
1505
|
});
|
|
1437
1506
|
this.resizeObserver.observe(this.elementRef.nativeElement);
|
|
1438
1507
|
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
this.
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
zoom =
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1508
|
+
updateViewportState(state) {
|
|
1509
|
+
this.viewportState = {
|
|
1510
|
+
...this.viewportState,
|
|
1511
|
+
...state
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
initViewportContainer() {
|
|
1515
|
+
const { width, height } = getBoardClientBox(this.board);
|
|
1516
|
+
this.renderer2.setStyle(this.viewportContainer.nativeElement, 'width', `${width}px`);
|
|
1517
|
+
this.renderer2.setStyle(this.viewportContainer.nativeElement, 'height', `${height}px`);
|
|
1518
|
+
}
|
|
1519
|
+
initViewport() {
|
|
1520
|
+
const viewport = this.board.viewport;
|
|
1521
|
+
const originationCoord = viewport?.originationCoord;
|
|
1522
|
+
const zoom = viewport?.zoom ?? this.viewportState.zoom;
|
|
1523
|
+
if (originationCoord) {
|
|
1524
|
+
const matrix = this.getMatrix();
|
|
1525
|
+
const [pointX, pointY] = invertViewportCoordinates([0, 0], matrix);
|
|
1526
|
+
const scrollLeft = this.viewportState.scrollLeft;
|
|
1527
|
+
const scrollTop = this.viewportState.scrollTop;
|
|
1528
|
+
const left = scrollLeft + (originationCoord[0] - pointX) * zoom;
|
|
1529
|
+
const top = scrollTop + (originationCoord[1] - pointY) * zoom;
|
|
1530
|
+
this.setScroll(left, top);
|
|
1531
|
+
}
|
|
1532
|
+
else {
|
|
1533
|
+
this.adaptHandle();
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
calcViewBox(zoom = this.viewportState.zoom) {
|
|
1537
|
+
zoom = clampZoomLevel(zoom);
|
|
1538
|
+
const scrollBarWidth = this.viewportState.scrollBarWidth;
|
|
1539
|
+
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1540
|
+
const groupBBox = getRootGroupBBox(this.board, zoom);
|
|
1541
|
+
const horizontalPadding = viewportContainerBox.width / 2;
|
|
1542
|
+
const verticalPadding = viewportContainerBox.height / 2;
|
|
1543
|
+
const viewportWidth = (groupBBox.right - groupBBox.left) * zoom + 2 * horizontalPadding + scrollBarWidth;
|
|
1544
|
+
const viewportHeight = (groupBBox.bottom - groupBBox.top) * zoom + 2 * verticalPadding + scrollBarWidth;
|
|
1545
|
+
const viewBox = [
|
|
1546
|
+
groupBBox.left - horizontalPadding / zoom,
|
|
1547
|
+
groupBBox.top - verticalPadding / zoom,
|
|
1548
|
+
viewportWidth / zoom,
|
|
1549
|
+
viewportHeight / zoom
|
|
1550
|
+
];
|
|
1551
|
+
const matrix = this.getMatrix();
|
|
1473
1552
|
let scrollLeft;
|
|
1474
1553
|
let scrollTop;
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
const canvasPoint = [focusPoint[0] - clientBox.x, focusPoint[1] - clientBox.y, 1];
|
|
1486
|
-
const invertMatrix = invert([], matrix);
|
|
1487
|
-
const matrix1 = transformMat3([], [canvasPoint[0], canvasPoint[1], 1], invertMatrix);
|
|
1488
|
-
const matrix2 = [zoom, 0, 0, 0, zoom, 0, -zoom * viewBox[0], -zoom * viewBox[1], 1];
|
|
1489
|
-
const newMatrix = transformMat3([], matrix1, matrix2);
|
|
1490
|
-
scrollLeft = newMatrix[0] - canvasPoint[0];
|
|
1491
|
-
scrollTop = newMatrix[1] - canvasPoint[1];
|
|
1554
|
+
if (matrix.length > 0) {
|
|
1555
|
+
// focusPoint
|
|
1556
|
+
const focusX = viewportContainerBox.x + viewportContainerBox.width / 2;
|
|
1557
|
+
const focusY = viewportContainerBox.y + viewportContainerBox.height / 2;
|
|
1558
|
+
const viewportContainerPoint = [focusX - viewportContainerBox.x, focusY - viewportContainerBox.y, 1];
|
|
1559
|
+
const point = invertViewportCoordinates([viewportContainerPoint[0], viewportContainerPoint[1]], matrix);
|
|
1560
|
+
const newMatrix = [zoom, 0, 0, 0, zoom, 0, -zoom * viewBox[0], -zoom * viewBox[1], 1];
|
|
1561
|
+
const newPoint = transformMat3([], point, newMatrix);
|
|
1562
|
+
scrollLeft = newPoint[0] - viewportContainerPoint[0];
|
|
1563
|
+
scrollTop = newPoint[1] - viewportContainerPoint[1];
|
|
1492
1564
|
}
|
|
1493
1565
|
else {
|
|
1494
|
-
scrollLeft =
|
|
1495
|
-
scrollTop =
|
|
1566
|
+
scrollLeft = horizontalPadding;
|
|
1567
|
+
scrollTop = verticalPadding;
|
|
1496
1568
|
}
|
|
1497
|
-
this.
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1569
|
+
this.updateViewportState({
|
|
1570
|
+
viewportWidth,
|
|
1571
|
+
viewportHeight,
|
|
1572
|
+
zoom,
|
|
1573
|
+
viewBox
|
|
1574
|
+
});
|
|
1501
1575
|
this.setScrollLeft(scrollLeft);
|
|
1502
1576
|
this.setScrollTop(scrollTop);
|
|
1503
|
-
|
|
1577
|
+
}
|
|
1578
|
+
getMatrix() {
|
|
1579
|
+
const { viewBox, zoom, scrollLeft, scrollTop } = this.viewportState;
|
|
1580
|
+
if (scrollLeft >= 0 && scrollTop >= 0) {
|
|
1581
|
+
return [zoom, 0, 0, 0, zoom, 0, -scrollLeft - zoom * viewBox[0], -scrollTop - zoom * viewBox[1], 1];
|
|
1582
|
+
}
|
|
1583
|
+
return [];
|
|
1504
1584
|
}
|
|
1505
1585
|
setScrollLeft(left) {
|
|
1506
|
-
const
|
|
1507
|
-
const
|
|
1508
|
-
const width =
|
|
1509
|
-
this.scrollLeft = left < 0 ? 0 : left > width ? width : left;
|
|
1586
|
+
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1587
|
+
const { viewportWidth, scrollBarWidth } = this.viewportState;
|
|
1588
|
+
const width = viewportWidth - viewportContainerBox.width + scrollBarWidth;
|
|
1589
|
+
this.viewportState.scrollLeft = left < 0 ? 0 : left > width ? width : left;
|
|
1510
1590
|
}
|
|
1511
1591
|
setScrollTop(top) {
|
|
1512
|
-
const
|
|
1513
|
-
const
|
|
1514
|
-
const height =
|
|
1515
|
-
this.scrollTop = top < 0 ? 0 : top > height ? height : top;
|
|
1592
|
+
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1593
|
+
const { viewportHeight, scrollBarWidth } = this.viewportState;
|
|
1594
|
+
const height = viewportHeight - viewportContainerBox.height + scrollBarWidth;
|
|
1595
|
+
this.viewportState.scrollTop = top < 0 ? 0 : top > height ? height : top;
|
|
1516
1596
|
}
|
|
1517
1597
|
setScroll(left, top) {
|
|
1518
1598
|
this.setScrollLeft(left);
|
|
1519
1599
|
this.setScrollTop(top);
|
|
1520
|
-
this.
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
const width = this.width;
|
|
1533
|
-
const height = this.height;
|
|
1534
|
-
let left = this.scrollLeft;
|
|
1535
|
-
let top = this.scrollTop;
|
|
1536
|
-
if (fullPoint[0] > width - SCROLL_BAR_WIDTH) {
|
|
1537
|
-
left += fullPoint[0] - width + SCROLL_BAR_WIDTH;
|
|
1538
|
-
}
|
|
1539
|
-
if (fullPoint[1] > height - SCROLL_BAR_WIDTH) {
|
|
1540
|
-
top += fullPoint[1] - height + SCROLL_BAR_WIDTH;
|
|
1541
|
-
}
|
|
1542
|
-
(left === this.scrollLeft && top === this.scrollTop) || this.setScroll(left, top);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
change() {
|
|
1546
|
-
this.resizeViewport();
|
|
1547
|
-
this.renderer2.setStyle(this.host, 'display', 'block');
|
|
1548
|
-
this.renderer2.setStyle(this.host, 'width', `${this.canvasWidth}px`);
|
|
1549
|
-
this.renderer2.setStyle(this.host, 'height', `${this.canvasHeight}px`);
|
|
1550
|
-
if (this.viewBox && this.viewBox[2] > 0 && this.viewBox[3] > 0) {
|
|
1551
|
-
this.renderer2.setAttribute(this.host, 'viewBox', this.viewBox.join(','));
|
|
1600
|
+
this.updateViewBoxStyles();
|
|
1601
|
+
this.updateViewportScrolling();
|
|
1602
|
+
this.setViewport();
|
|
1603
|
+
}
|
|
1604
|
+
updateViewBoxStyles() {
|
|
1605
|
+
const { host, viewportState } = this;
|
|
1606
|
+
const { viewportWidth, viewportHeight, viewBox } = viewportState;
|
|
1607
|
+
this.renderer2.setStyle(host, 'display', 'block');
|
|
1608
|
+
this.renderer2.setStyle(host, 'width', `${viewportWidth}px`);
|
|
1609
|
+
this.renderer2.setStyle(host, 'height', `${viewportHeight}px`);
|
|
1610
|
+
if (viewBox && viewBox[2] > 0 && viewBox[3] > 0) {
|
|
1611
|
+
this.renderer2.setAttribute(host, 'viewBox', viewBox.join(' '));
|
|
1552
1612
|
}
|
|
1553
|
-
this.contentContainer.nativeElement.scrollLeft = this.scrollLeft;
|
|
1554
|
-
this.contentContainer.nativeElement.scrollTop = this.scrollTop;
|
|
1555
|
-
this.setMatrix();
|
|
1556
|
-
this.setViewportSetting();
|
|
1557
|
-
this.viewportCanvasBox = getViewportCanvasBox(this.board, this.matrix);
|
|
1558
1613
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1614
|
+
updateViewportScrolling() {
|
|
1615
|
+
const { viewportContainer, viewportState } = this;
|
|
1616
|
+
const { scrollLeft, scrollTop } = viewportState;
|
|
1617
|
+
viewportContainer.nativeElement.scrollLeft = scrollLeft;
|
|
1618
|
+
viewportContainer.nativeElement.scrollTop = scrollTop;
|
|
1563
1619
|
}
|
|
1564
|
-
|
|
1565
|
-
const canvasPoint = viewport?.canvasPoint;
|
|
1566
|
-
if (canvasPoint) {
|
|
1567
|
-
this.restoreCanvasPoint(canvasPoint, viewport.zoom);
|
|
1568
|
-
}
|
|
1569
|
-
else {
|
|
1570
|
-
this.setViewport(viewport.zoom);
|
|
1571
|
-
this.setScroll(this.scrollLeft, this.scrollTop);
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
focusGraphicCenter() {
|
|
1575
|
-
const rootGroup = this.board.host.firstChild;
|
|
1576
|
-
const rootGroupBox = rootGroup.getBBox();
|
|
1577
|
-
this.focus([rootGroupBox.x + rootGroupBox.width / 2, rootGroupBox.y + rootGroupBox.height / 2]);
|
|
1578
|
-
this.change();
|
|
1579
|
-
this.setViewport(1);
|
|
1580
|
-
}
|
|
1581
|
-
focus(point) {
|
|
1582
|
-
const clientBox = getViewportClientBox(this.board);
|
|
1583
|
-
const matrix = transformMat3([], [point[0], point[1], 1], this.matrix);
|
|
1584
|
-
const newPoint = [clientBox.width / 2, clientBox.height / 2];
|
|
1585
|
-
const scrollLeft = newPoint[0] - matrix[0];
|
|
1586
|
-
const scrollTop = newPoint[1] - matrix[1];
|
|
1587
|
-
this.setScrollLeft(this.scrollLeft - scrollLeft);
|
|
1588
|
-
this.setScrollTop(this.scrollTop - scrollTop);
|
|
1589
|
-
this.setMatrix();
|
|
1590
|
-
}
|
|
1591
|
-
resetFocusPoint() {
|
|
1592
|
-
const clientBox = getViewportClientBox(this.board);
|
|
1593
|
-
this.focusPoint = [clientBox.x + clientBox.width / 2, clientBox.y + clientBox.height / 2];
|
|
1594
|
-
}
|
|
1595
|
-
setViewportSetting() {
|
|
1620
|
+
setViewport() {
|
|
1596
1621
|
const viewport = this.board?.viewport;
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
changeMoveMode(cursorStatus) {
|
|
1608
|
-
updateCursorStatus(this.board, cursorStatus);
|
|
1609
|
-
this.cdr.markForCheck();
|
|
1622
|
+
const oldOriginationCoord = viewport?.originationCoord ?? [];
|
|
1623
|
+
const matrix = this.getMatrix();
|
|
1624
|
+
const originationCoord = invertViewportCoordinates([0, 0], matrix);
|
|
1625
|
+
if (!originationCoord.every((item, index) => item === oldOriginationCoord[index])) {
|
|
1626
|
+
Transforms.setViewport(this.board, {
|
|
1627
|
+
...viewport,
|
|
1628
|
+
zoom: this.viewportState.zoom,
|
|
1629
|
+
originationCoord
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1610
1632
|
}
|
|
1611
|
-
// 适应画布
|
|
1612
1633
|
adaptHandle() {
|
|
1613
|
-
const
|
|
1634
|
+
const containerBox = getViewportContainerBox(this.board);
|
|
1614
1635
|
const rootGroup = this.host.firstChild;
|
|
1636
|
+
const matrix = this.getMatrix();
|
|
1615
1637
|
const rootGroupBox = rootGroup.getBBox();
|
|
1616
|
-
const
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1638
|
+
const centerPoint = [containerBox.width / 2, containerBox.height / 2];
|
|
1639
|
+
const rootGroupCenterX = rootGroupBox.x + rootGroupBox.width / 2;
|
|
1640
|
+
const rootGroupCenterY = rootGroupBox.y + rootGroupBox.height / 2;
|
|
1641
|
+
const transformedPoint = transformMat3([], [rootGroupCenterX, rootGroupCenterY, 1], matrix);
|
|
1642
|
+
const offsetLeft = centerPoint[0] - transformedPoint[0];
|
|
1643
|
+
const offsetTop = centerPoint[1] - transformedPoint[1];
|
|
1644
|
+
const { autoFitPadding, zoom, scrollLeft, scrollTop } = this.viewportState;
|
|
1645
|
+
const viewportWidth = containerBox.width - 2 * autoFitPadding;
|
|
1646
|
+
const viewportHeight = containerBox.height - 2 * autoFitPadding;
|
|
1647
|
+
let newZoom = zoom;
|
|
1619
1648
|
if (viewportWidth < rootGroupBox.width || viewportHeight < rootGroupBox.height) {
|
|
1620
|
-
|
|
1649
|
+
newZoom = Math.min(viewportWidth / rootGroupBox.width, viewportHeight / rootGroupBox.height);
|
|
1621
1650
|
}
|
|
1622
1651
|
else {
|
|
1623
|
-
|
|
1652
|
+
newZoom = 1;
|
|
1624
1653
|
}
|
|
1625
|
-
this.
|
|
1626
|
-
this.
|
|
1627
|
-
this.
|
|
1654
|
+
this.setScrollLeft(scrollLeft - offsetLeft);
|
|
1655
|
+
this.setScrollTop(scrollTop - offsetTop);
|
|
1656
|
+
this.calcViewBox(newZoom);
|
|
1657
|
+
this.updateViewBoxStyles();
|
|
1658
|
+
this.updateViewportScrolling();
|
|
1659
|
+
this.setViewport();
|
|
1628
1660
|
}
|
|
1629
|
-
// 放大
|
|
1630
1661
|
zoomInHandle() {
|
|
1631
|
-
this.
|
|
1662
|
+
this.calcViewBox(this.viewportState.zoom + 0.1);
|
|
1663
|
+
this.updateViewBoxStyles();
|
|
1664
|
+
this.updateViewportScrolling();
|
|
1665
|
+
this.setViewport();
|
|
1632
1666
|
}
|
|
1633
|
-
// 缩小
|
|
1634
1667
|
zoomOutHandle() {
|
|
1635
|
-
this.
|
|
1668
|
+
this.calcViewBox(this.viewportState.zoom - 0.1);
|
|
1669
|
+
this.updateViewBoxStyles();
|
|
1670
|
+
this.updateViewportScrolling();
|
|
1671
|
+
this.setViewport();
|
|
1636
1672
|
}
|
|
1637
1673
|
resetZoomHandel() {
|
|
1638
|
-
this.
|
|
1674
|
+
this.calcViewBox(1);
|
|
1675
|
+
this.updateViewBoxStyles();
|
|
1676
|
+
this.updateViewportScrolling();
|
|
1677
|
+
this.setViewport();
|
|
1678
|
+
}
|
|
1679
|
+
movingChange(isMoving) {
|
|
1680
|
+
this.isMoving = isMoving;
|
|
1639
1681
|
}
|
|
1640
1682
|
ngOnDestroy() {
|
|
1641
1683
|
this.destroy$.next();
|
|
@@ -1645,58 +1687,83 @@ class PlaitBoardComponent {
|
|
|
1645
1687
|
this.resizeObserver.disconnect();
|
|
1646
1688
|
}
|
|
1647
1689
|
}
|
|
1648
|
-
|
|
1649
|
-
this.
|
|
1690
|
+
markForCheck() {
|
|
1691
|
+
this.cdr.markForCheck();
|
|
1692
|
+
}
|
|
1693
|
+
scrollToRectangle(client) {
|
|
1694
|
+
this.calcViewBox();
|
|
1695
|
+
this.updateViewBoxStyles();
|
|
1696
|
+
this.updateViewportScrolling();
|
|
1697
|
+
this.setViewport();
|
|
1698
|
+
const svgRect = this.host.getBoundingClientRect();
|
|
1699
|
+
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1700
|
+
if (svgRect.width > viewportContainerBox.width || svgRect.height > viewportContainerBox.height) {
|
|
1701
|
+
const matrix = this.getMatrix();
|
|
1702
|
+
const scrollBarWidth = this.viewportState.scrollBarWidth;
|
|
1703
|
+
const [nodePointX, nodePointY] = convertToViewportCoordinates([client.x, client.y], matrix);
|
|
1704
|
+
const [fullNodePointX, fullNodePointY] = convertToViewportCoordinates([client.x + client.width, client.y + client.height], matrix);
|
|
1705
|
+
let newLeft = this.viewportState.scrollLeft;
|
|
1706
|
+
let newTop = this.viewportState.scrollTop;
|
|
1707
|
+
if (nodePointX < 0) {
|
|
1708
|
+
newLeft -= Math.abs(nodePointX);
|
|
1709
|
+
}
|
|
1710
|
+
if (nodePointX > 0 && fullNodePointX > viewportContainerBox.width) {
|
|
1711
|
+
newLeft += fullNodePointX - viewportContainerBox.width + scrollBarWidth;
|
|
1712
|
+
}
|
|
1713
|
+
if (nodePointY < 0) {
|
|
1714
|
+
newTop -= Math.abs(nodePointY);
|
|
1715
|
+
}
|
|
1716
|
+
if (nodePointY > 0 && fullNodePointY > viewportContainerBox.height) {
|
|
1717
|
+
newTop += fullNodePointY - viewportContainerBox.height + scrollBarWidth;
|
|
1718
|
+
}
|
|
1719
|
+
if (newLeft !== this.viewportState.scrollLeft || newTop !== this.viewportState.scrollTop) {
|
|
1720
|
+
this.setScroll(newLeft, newTop);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1650
1723
|
}
|
|
1651
1724
|
}
|
|
1652
1725
|
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1653
|
-
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitOptions: "plaitOptions" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.readonly": "this.readonly", "class.moving": "this.moving", "class.focused": "this.focused" } }, queries: [{ propertyName: "toolbarTemplateRef", first: true, predicate: ["plaitToolbar"], descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }, { propertyName: "
|
|
1654
|
-
<div class="viewport-container" #
|
|
1726
|
+
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitOptions: "plaitOptions" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.readonly": "this.readonly", "class.moving": "this.moving", "class.focused": "this.focused" } }, queries: [{ propertyName: "toolbarTemplateRef", first: true, predicate: ["plaitToolbar"], descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }, { propertyName: "viewportContainer", first: true, predicate: ["viewportContainer"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
1727
|
+
<div class="viewport-container" #viewportContainer>
|
|
1655
1728
|
<svg #svg width="100%" height="100%" style="position: relative;"></svg>
|
|
1656
1729
|
<plait-element
|
|
1657
1730
|
*ngFor="let item of board.children; let index = index; trackBy: trackBy"
|
|
1658
1731
|
[index]="index"
|
|
1659
1732
|
[element]="item"
|
|
1660
1733
|
[board]="board"
|
|
1661
|
-
[viewport]="board.viewport"
|
|
1662
1734
|
[selection]="board.selection"
|
|
1663
1735
|
[host]="host"
|
|
1664
1736
|
></plait-element>
|
|
1665
1737
|
</div>
|
|
1666
1738
|
<plait-toolbar
|
|
1667
1739
|
*ngIf="isFocused && !toolbarTemplateRef"
|
|
1668
|
-
[
|
|
1669
|
-
[viewZoom]="board.viewport!.zoom"
|
|
1670
|
-
(moveHandle)="changeMoveMode($event)"
|
|
1740
|
+
[board]="board"
|
|
1671
1741
|
(adaptHandle)="adaptHandle()"
|
|
1672
1742
|
(zoomInHandle)="zoomInHandle()"
|
|
1673
1743
|
(zoomOutHandle)="zoomOutHandle()"
|
|
1674
1744
|
(resetZoomHandel)="resetZoomHandel()"
|
|
1675
1745
|
></plait-toolbar>
|
|
1676
1746
|
<ng-content></ng-content>
|
|
1677
|
-
`, isInline: true, components: [{ type: PlaitElementComponent, selector: "plait-element", inputs: ["index", "element", "board", "viewport", "selection", "host"] }, { type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: ["
|
|
1747
|
+
`, isInline: true, components: [{ type: PlaitElementComponent, selector: "plait-element", inputs: ["index", "element", "board", "viewport", "selection", "host"] }, { type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: ["board"], outputs: ["adaptHandle", "zoomInHandle", "zoomOutHandle", "resetZoomHandel"] }], directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1678
1748
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitBoardComponent, decorators: [{
|
|
1679
1749
|
type: Component,
|
|
1680
1750
|
args: [{
|
|
1681
1751
|
selector: 'plait-board',
|
|
1682
1752
|
template: `
|
|
1683
|
-
<div class="viewport-container" #
|
|
1753
|
+
<div class="viewport-container" #viewportContainer>
|
|
1684
1754
|
<svg #svg width="100%" height="100%" style="position: relative;"></svg>
|
|
1685
1755
|
<plait-element
|
|
1686
1756
|
*ngFor="let item of board.children; let index = index; trackBy: trackBy"
|
|
1687
1757
|
[index]="index"
|
|
1688
1758
|
[element]="item"
|
|
1689
1759
|
[board]="board"
|
|
1690
|
-
[viewport]="board.viewport"
|
|
1691
1760
|
[selection]="board.selection"
|
|
1692
1761
|
[host]="host"
|
|
1693
1762
|
></plait-element>
|
|
1694
1763
|
</div>
|
|
1695
1764
|
<plait-toolbar
|
|
1696
1765
|
*ngIf="isFocused && !toolbarTemplateRef"
|
|
1697
|
-
[
|
|
1698
|
-
[viewZoom]="board.viewport!.zoom"
|
|
1699
|
-
(moveHandle)="changeMoveMode($event)"
|
|
1766
|
+
[board]="board"
|
|
1700
1767
|
(adaptHandle)="adaptHandle()"
|
|
1701
1768
|
(zoomInHandle)="zoomInHandle()"
|
|
1702
1769
|
(zoomOutHandle)="zoomOutHandle()"
|
|
@@ -1736,10 +1803,73 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1736
1803
|
}], toolbarTemplateRef: [{
|
|
1737
1804
|
type: ContentChild,
|
|
1738
1805
|
args: ['plaitToolbar']
|
|
1739
|
-
}],
|
|
1806
|
+
}], viewportContainer: [{
|
|
1740
1807
|
type: ViewChild,
|
|
1741
|
-
args: ['
|
|
1808
|
+
args: ['viewportContainer', { read: ElementRef, static: true }]
|
|
1809
|
+
}] } });
|
|
1810
|
+
|
|
1811
|
+
function hasBeforeContextChange(value) {
|
|
1812
|
+
if (value.beforeContextChange) {
|
|
1813
|
+
return true;
|
|
1814
|
+
}
|
|
1815
|
+
return false;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
class PlaitPluginElementComponent {
|
|
1819
|
+
constructor(cdr) {
|
|
1820
|
+
this.cdr = cdr;
|
|
1821
|
+
this.initialized = false;
|
|
1822
|
+
this.g = createG();
|
|
1823
|
+
}
|
|
1824
|
+
set context(value) {
|
|
1825
|
+
if (hasBeforeContextChange(this)) {
|
|
1826
|
+
this.beforeContextChange(value);
|
|
1827
|
+
}
|
|
1828
|
+
this._context = value;
|
|
1829
|
+
if (this.element) {
|
|
1830
|
+
ELEMENT_TO_PLUGIN_COMPONENT.set(this.element, this);
|
|
1831
|
+
}
|
|
1832
|
+
this.onContextChange();
|
|
1833
|
+
}
|
|
1834
|
+
get context() {
|
|
1835
|
+
return this._context;
|
|
1836
|
+
}
|
|
1837
|
+
get element() {
|
|
1838
|
+
return this.context && this.context.element;
|
|
1839
|
+
}
|
|
1840
|
+
get selection() {
|
|
1841
|
+
return this.context && this.context.selection;
|
|
1842
|
+
}
|
|
1843
|
+
get board() {
|
|
1844
|
+
return this.context && this.context.board;
|
|
1845
|
+
}
|
|
1846
|
+
get host() {
|
|
1847
|
+
return this.context && this.context.host;
|
|
1848
|
+
}
|
|
1849
|
+
onContextChange() {
|
|
1850
|
+
if (!this.initialized) {
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
this.cdr.markForCheck();
|
|
1854
|
+
}
|
|
1855
|
+
ngOnInit() {
|
|
1856
|
+
const type = this.element?.type || 'default-plugin-element';
|
|
1857
|
+
this.g.setAttribute(`plait-${type}`, 'true');
|
|
1858
|
+
this.initialized = true;
|
|
1859
|
+
}
|
|
1860
|
+
ngOnDestroy() {
|
|
1861
|
+
ELEMENT_TO_PLUGIN_COMPONENT.delete(this.element);
|
|
1862
|
+
this.g.remove();
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1866
|
+
PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
|
|
1867
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
|
|
1868
|
+
type: Directive
|
|
1869
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
|
|
1870
|
+
type: Input
|
|
1742
1871
|
}] } });
|
|
1872
|
+
const ELEMENT_TO_PLUGIN_COMPONENT = new WeakMap();
|
|
1743
1873
|
|
|
1744
1874
|
const COMPONENTS = [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent];
|
|
1745
1875
|
class PlaitModule {
|
|
@@ -1764,5 +1894,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1764
1894
|
* Generated bundle index. Do not edit.
|
|
1765
1895
|
*/
|
|
1766
1896
|
|
|
1767
|
-
export { BOARD_TO_ON_CHANGE,
|
|
1897
|
+
export { BOARD_TO_ON_CHANGE, CLIP_BOARD_FORMAT_KEY, ELEMENT_TO_PLUGIN_COMPONENT, FLUSHING, HOST_TO_ROUGH_SVG, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MERGING, NS, PLAIT_BOARD_TO_COMPONENT, Path, PlaitBoardComponent, PlaitElementComponent, PlaitHistoryBoard, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPointerType, PlaitToolbarComponent, SAVING, SCROLL_BAR_WIDTH, Transforms, Viewport, clampZoomLevel, convertToViewportCoordinates, createG, createSVG, createText, distanceBetweenPointAndPoint, distanceBetweenPointAndSegment, getBoardClientBox, getRootGroupBBox, getViewportContainerBox, hasBeforeContextChange, hotkeys, idCreator, inverse, invertMatrix, invertViewportCoordinates, isNoSelectionElement, isNullOrUndefined, isSetViewportOperation, normalizePoint, rotate, shouldClear, shouldMerge, shouldSave, toPoint, toRectangleClient, transformMat3, transformPoint, transformPoints };
|
|
1768
1898
|
//# sourceMappingURL=plait-core.mjs.map
|