@plait/core 0.1.1 → 0.1.3
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 +8 -21
- package/board/board.component.interface.d.ts +0 -2
- package/constants/selection.d.ts +1 -0
- package/core/element/element.component.d.ts +1 -1
- package/core/element/plugin-element.d.ts +1 -1
- package/core/toolbar/toolbar.component.d.ts +1 -1
- package/esm2020/board/board.component.interface.mjs +1 -1
- package/esm2020/board/board.component.mjs +94 -279
- package/esm2020/constants/selection.mjs +2 -0
- package/esm2020/core/element/element.component.mjs +5 -5
- package/esm2020/core/element/plugin-element.mjs +9 -9
- package/esm2020/core/toolbar/toolbar.component.mjs +4 -4
- package/esm2020/interfaces/board.mjs +11 -2
- package/esm2020/interfaces/point.mjs +6 -2
- package/esm2020/interfaces/viewport.mjs +2 -2
- package/esm2020/plait.module.mjs +5 -5
- package/esm2020/plugins/create-board.mjs +2 -1
- package/esm2020/plugins/with-hand.mjs +6 -6
- package/esm2020/plugins/with-moving.mjs +91 -0
- package/esm2020/plugins/with-selection.mjs +48 -13
- package/esm2020/plugins/with-viewport.mjs +29 -0
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/utils/board.mjs +7 -3
- package/esm2020/utils/common.mjs +15 -0
- package/esm2020/utils/element.mjs +3 -3
- package/esm2020/utils/helper.mjs +14 -1
- package/esm2020/utils/index.mjs +4 -2
- package/esm2020/utils/moving-element.mjs +15 -0
- package/esm2020/utils/selected-element.mjs +14 -1
- package/esm2020/utils/viewport.mjs +207 -0
- package/esm2020/utils/weak-maps.mjs +5 -1
- package/fesm2015/plait-core.mjs +689 -626
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +710 -644
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +4 -10
- package/interfaces/custom-types.d.ts +2 -2
- package/interfaces/node.d.ts +1 -1
- package/interfaces/operation.d.ts +7 -7
- package/interfaces/path.d.ts +1 -1
- package/interfaces/plugin.d.ts +1 -1
- package/interfaces/point.d.ts +4 -1
- package/interfaces/viewport.d.ts +4 -3
- package/package.json +3 -3
- package/plugins/with-moving.d.ts +2 -0
- package/plugins/with-selection.d.ts +4 -1
- package/plugins/with-viewport.d.ts +2 -0
- package/public-api.d.ts +1 -0
- package/styles/styles.scss +3 -1
- package/utils/board.d.ts +2 -2
- package/utils/common.d.ts +1 -0
- package/utils/helper.d.ts +9 -0
- package/utils/index.d.ts +3 -1
- package/utils/moving-element.d.ts +5 -0
- package/utils/selected-element.d.ts +2 -0
- package/utils/viewport.d.ts +36 -0
- package/utils/weak-maps.d.ts +4 -0
- package/esm2020/utils/matrix.mjs +0 -170
- package/utils/matrix.d.ts +0 -82
- /package/{plait-core.d.ts → index.d.ts} +0 -0
package/fesm2020/plait-core.mjs
CHANGED
|
@@ -1,16 +1,104 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
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
|
-
import { Subject, fromEvent } from 'rxjs';
|
|
5
|
-
import { takeUntil, filter } from 'rxjs/operators';
|
|
4
|
+
import { timer, Subject, fromEvent } from 'rxjs';
|
|
5
|
+
import { takeUntil, filter, tap, debounceTime } from 'rxjs/operators';
|
|
6
6
|
import produce, { createDraft, finishDraft, isDraft } from 'immer';
|
|
7
7
|
import { isKeyHotkey, isHotkey } from 'is-hotkey';
|
|
8
8
|
import * as i1 from '@angular/common';
|
|
9
9
|
import { BrowserModule } from '@angular/platform-browser';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
// record richtext type status
|
|
12
|
+
const FLUSHING = new WeakMap();
|
|
13
|
+
const IS_TEXT_EDITABLE = new WeakMap();
|
|
14
|
+
const BOARD_TO_ON_CHANGE = new WeakMap();
|
|
15
|
+
const BOARD_TO_COMPONENT = new WeakMap();
|
|
16
|
+
const BOARD_TO_ROUGH_SVG = new WeakMap();
|
|
17
|
+
const BOARD_TO_HOST = new WeakMap();
|
|
18
|
+
const BOARD_TO_ELEMENT_HOST = new WeakMap();
|
|
19
|
+
const BOARD_TO_SELECTED_ELEMENT = new WeakMap();
|
|
20
|
+
const BOARD_TO_MOVING_POINT = new WeakMap();
|
|
21
|
+
const BOARD_TO_VIEWPORT_ORIGINATION = new WeakMap();
|
|
22
|
+
const BOARD_TO_IS_SELECTION_MOVING = new WeakMap();
|
|
23
|
+
// save no standard selected elements
|
|
24
|
+
const BOARD_TO_TEMPORARY_ELEMENTS = new WeakMap();
|
|
25
|
+
const BOARD_TO_MOVING_ELEMENT = new WeakMap();
|
|
26
|
+
const BOARD_TO_SCROLLING = new WeakMap();
|
|
27
|
+
|
|
28
|
+
function depthFirstRecursion(node, callback) {
|
|
29
|
+
node.children?.forEach(child => {
|
|
30
|
+
depthFirstRecursion(child, callback);
|
|
31
|
+
});
|
|
32
|
+
callback(node);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getRectangleByElements(board, elements, recursion) {
|
|
36
|
+
const boundaryBox = {
|
|
37
|
+
left: Number.MAX_VALUE,
|
|
38
|
+
top: Number.MAX_VALUE,
|
|
39
|
+
right: Number.NEGATIVE_INFINITY,
|
|
40
|
+
bottom: Number.NEGATIVE_INFINITY
|
|
41
|
+
};
|
|
42
|
+
const calcRectangleClient = (node) => {
|
|
43
|
+
const nodeRectangle = board.getRectangle(node);
|
|
44
|
+
if (nodeRectangle) {
|
|
45
|
+
boundaryBox.left = Math.min(boundaryBox.left, nodeRectangle.x);
|
|
46
|
+
boundaryBox.top = Math.min(boundaryBox.top, nodeRectangle.y);
|
|
47
|
+
boundaryBox.right = Math.max(boundaryBox.right, nodeRectangle.x + nodeRectangle.width);
|
|
48
|
+
boundaryBox.bottom = Math.max(boundaryBox.bottom, nodeRectangle.y + nodeRectangle.height);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
elements.forEach(element => {
|
|
52
|
+
if (recursion) {
|
|
53
|
+
depthFirstRecursion(element, node => calcRectangleClient(node));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
calcRectangleClient(element);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
x: boundaryBox.left,
|
|
61
|
+
y: boundaryBox.top,
|
|
62
|
+
width: boundaryBox.right - boundaryBox.left,
|
|
63
|
+
height: boundaryBox.bottom - boundaryBox.top
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getBoardRectangle(board) {
|
|
67
|
+
return getRectangleByElements(board, board.children, true);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const PlaitBoard = {
|
|
71
|
+
getHost(board) {
|
|
72
|
+
return BOARD_TO_HOST.get(board);
|
|
73
|
+
},
|
|
74
|
+
getElementHost(board) {
|
|
75
|
+
return BOARD_TO_ELEMENT_HOST.get(board);
|
|
76
|
+
},
|
|
77
|
+
getRoughSVG(board) {
|
|
78
|
+
return BOARD_TO_ROUGH_SVG.get(board);
|
|
79
|
+
},
|
|
80
|
+
getComponent(board) {
|
|
81
|
+
return BOARD_TO_COMPONENT.get(board);
|
|
82
|
+
},
|
|
83
|
+
getBoardNativeElement(board) {
|
|
84
|
+
return PlaitBoard.getComponent(board).nativeElement;
|
|
85
|
+
},
|
|
86
|
+
getRectangle(board) {
|
|
87
|
+
return getRectangleByElements(board, board.children, true);
|
|
88
|
+
},
|
|
89
|
+
getViewportContainer(board) {
|
|
90
|
+
return PlaitBoard.getHost(board).parentElement;
|
|
91
|
+
},
|
|
92
|
+
isFocus(board) {
|
|
93
|
+
return !!board.selection;
|
|
94
|
+
},
|
|
95
|
+
isReadonly(board) {
|
|
96
|
+
return board.options.readonly;
|
|
97
|
+
},
|
|
98
|
+
hasBeenTextEditing(board) {
|
|
99
|
+
return !!IS_TEXT_EDITABLE.get(board);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
14
102
|
|
|
15
103
|
var PlaitPointerType;
|
|
16
104
|
(function (PlaitPointerType) {
|
|
@@ -21,10 +109,23 @@ var PlaitPointerType;
|
|
|
21
109
|
function isNullOrUndefined(value) {
|
|
22
110
|
return value === null || value === undefined;
|
|
23
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* 规范 point
|
|
114
|
+
* @param point
|
|
115
|
+
* @returns point
|
|
116
|
+
*/
|
|
117
|
+
function normalizePoint(point) {
|
|
118
|
+
return Array.isArray(point)
|
|
119
|
+
? {
|
|
120
|
+
x: point[0],
|
|
121
|
+
y: point[1]
|
|
122
|
+
}
|
|
123
|
+
: point;
|
|
124
|
+
}
|
|
24
125
|
|
|
25
126
|
const Viewport = {
|
|
26
127
|
isViewport: (value) => {
|
|
27
|
-
return
|
|
128
|
+
return !isNullOrUndefined(value.zoom) && !isNullOrUndefined(value.viewBackgroundColor);
|
|
28
129
|
}
|
|
29
130
|
};
|
|
30
131
|
|
|
@@ -355,19 +456,6 @@ const NodeTransforms = {
|
|
|
355
456
|
moveNode
|
|
356
457
|
};
|
|
357
458
|
|
|
358
|
-
// record richtext type status
|
|
359
|
-
const FLUSHING = new WeakMap();
|
|
360
|
-
const IS_TEXT_EDITABLE = new WeakMap();
|
|
361
|
-
const BOARD_TO_ON_CHANGE = new WeakMap();
|
|
362
|
-
const BOARD_TO_COMPONENT = new WeakMap();
|
|
363
|
-
const BOARD_TO_ROUGH_SVG = new WeakMap();
|
|
364
|
-
const BOARD_TO_HOST = new WeakMap();
|
|
365
|
-
const BOARD_TO_ELEMENT_HOST = new WeakMap();
|
|
366
|
-
const BOARD_TO_SELECTED_ELEMENT = new WeakMap();
|
|
367
|
-
const BOARD_TO_MOVING_POINT = new WeakMap();
|
|
368
|
-
// save no standard selected elements
|
|
369
|
-
const BOARD_TO_TEMPORARY_ELEMENTS = new WeakMap();
|
|
370
|
-
|
|
371
459
|
function setSelection(board, selection) {
|
|
372
460
|
const operation = { type: 'set_selection', properties: board.selection, newProperties: selection };
|
|
373
461
|
board.apply(operation);
|
|
@@ -383,79 +471,61 @@ function setSelectionWithTemporaryElements(board, elements) {
|
|
|
383
471
|
});
|
|
384
472
|
}
|
|
385
473
|
|
|
386
|
-
function setViewport(board, viewport) {
|
|
474
|
+
function setViewport$1(board, viewport) {
|
|
387
475
|
const operation = { type: 'set_viewport', properties: board.viewport, newProperties: viewport };
|
|
388
476
|
board.apply(operation);
|
|
389
477
|
}
|
|
390
478
|
const ViewportTransforms = {
|
|
391
|
-
setViewport
|
|
479
|
+
setViewport: setViewport$1
|
|
392
480
|
};
|
|
393
481
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
482
|
+
// https://stackoverflow.com/a/6853926/232122
|
|
483
|
+
function distanceBetweenPointAndSegment(x, y, x1, y1, x2, y2) {
|
|
484
|
+
const A = x - x1;
|
|
485
|
+
const B = y - y1;
|
|
486
|
+
const C = x2 - x1;
|
|
487
|
+
const D = y2 - y1;
|
|
488
|
+
const dot = A * C + B * D;
|
|
489
|
+
const lenSquare = C * C + D * D;
|
|
490
|
+
let param = -1;
|
|
491
|
+
if (lenSquare !== 0) {
|
|
492
|
+
// in case of 0 length line
|
|
493
|
+
param = dot / lenSquare;
|
|
494
|
+
}
|
|
495
|
+
let xx, yy;
|
|
496
|
+
if (param < 0) {
|
|
497
|
+
xx = x1;
|
|
498
|
+
yy = y1;
|
|
499
|
+
}
|
|
500
|
+
else if (param > 1) {
|
|
501
|
+
xx = x2;
|
|
502
|
+
yy = y2;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
xx = x1 + param * C;
|
|
506
|
+
yy = y1 + param * D;
|
|
507
|
+
}
|
|
508
|
+
const dx = x - xx;
|
|
509
|
+
const dy = y - yy;
|
|
510
|
+
return Math.hypot(dx, dy);
|
|
399
511
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
right: Number.MIN_VALUE,
|
|
406
|
-
bottom: Number.MIN_VALUE
|
|
407
|
-
};
|
|
408
|
-
const calcRectangleClient = (node) => {
|
|
409
|
-
const nodeRectangle = board.getRectangle(node);
|
|
410
|
-
if (nodeRectangle) {
|
|
411
|
-
boundaryBox.left = Math.min(boundaryBox.left, nodeRectangle.x);
|
|
412
|
-
boundaryBox.top = Math.min(boundaryBox.top, nodeRectangle.y);
|
|
413
|
-
boundaryBox.right = Math.max(boundaryBox.right, nodeRectangle.x + nodeRectangle.width);
|
|
414
|
-
boundaryBox.bottom = Math.max(boundaryBox.bottom, nodeRectangle.y + nodeRectangle.height);
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
elements.forEach(element => {
|
|
418
|
-
if (recursion) {
|
|
419
|
-
depthFirstRecursion(element, node => calcRectangleClient(node));
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
calcRectangleClient(element);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
return {
|
|
426
|
-
x: boundaryBox.left,
|
|
427
|
-
y: boundaryBox.top,
|
|
428
|
-
width: boundaryBox.right - boundaryBox.left,
|
|
429
|
-
height: boundaryBox.bottom - boundaryBox.top
|
|
430
|
-
};
|
|
512
|
+
function rotate(x1, y1, x2, y2, angle) {
|
|
513
|
+
// 𝑎′𝑥=(𝑎𝑥−𝑐𝑥)cos𝜃−(𝑎𝑦−𝑐𝑦)sin𝜃+𝑐𝑥
|
|
514
|
+
// 𝑎′𝑦=(𝑎𝑥−𝑐𝑥)sin𝜃+(𝑎𝑦−𝑐𝑦)cos𝜃+𝑐𝑦.
|
|
515
|
+
// https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
|
|
516
|
+
return [(x1 - x2) * Math.cos(angle) - (y1 - y2) * Math.sin(angle) + x2, (x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2];
|
|
431
517
|
}
|
|
432
|
-
function
|
|
433
|
-
|
|
518
|
+
function distanceBetweenPointAndPoint(x1, y1, x2, y2) {
|
|
519
|
+
const dx = x1 - x2;
|
|
520
|
+
const dy = y1 - y2;
|
|
521
|
+
return Math.hypot(dx, dy);
|
|
522
|
+
}
|
|
523
|
+
// https://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point
|
|
524
|
+
function distanceBetweenPointAndRectangle(x, y, rect) {
|
|
525
|
+
var dx = Math.max(rect.x - x, 0, x - (rect.x + rect.width));
|
|
526
|
+
var dy = Math.max(rect.y - y, 0, y - (rect.y + rect.height));
|
|
527
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
434
528
|
}
|
|
435
|
-
|
|
436
|
-
const PlaitBoard = {
|
|
437
|
-
getHost(board) {
|
|
438
|
-
return BOARD_TO_HOST.get(board);
|
|
439
|
-
},
|
|
440
|
-
getElementHost(board) {
|
|
441
|
-
return BOARD_TO_ELEMENT_HOST.get(board);
|
|
442
|
-
},
|
|
443
|
-
getRoughSVG(board) {
|
|
444
|
-
return BOARD_TO_ROUGH_SVG.get(board);
|
|
445
|
-
},
|
|
446
|
-
getComponent(board) {
|
|
447
|
-
return BOARD_TO_COMPONENT.get(board);
|
|
448
|
-
},
|
|
449
|
-
getBoardNativeElement(board) {
|
|
450
|
-
return PlaitBoard.getComponent(board).nativeElement;
|
|
451
|
-
},
|
|
452
|
-
getRectangle(board) {
|
|
453
|
-
return getRectangleByElements(board, board.children, true);
|
|
454
|
-
},
|
|
455
|
-
getViewportContainer(board) {
|
|
456
|
-
return PlaitBoard.getHost(board).parentElement;
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
529
|
|
|
460
530
|
function transformPoints(board, points) {
|
|
461
531
|
const newPoints = points.map(point => {
|
|
@@ -471,8 +541,11 @@ function transformPoint(board, point) {
|
|
|
471
541
|
const newPoint = [x, y];
|
|
472
542
|
return newPoint;
|
|
473
543
|
}
|
|
474
|
-
function
|
|
475
|
-
|
|
544
|
+
function isInPlaitBoard(board, x, y) {
|
|
545
|
+
const plaitBoardElement = PlaitBoard.getBoardNativeElement(board);
|
|
546
|
+
const plaitBoardRect = plaitBoardElement.getBoundingClientRect();
|
|
547
|
+
const distances = distanceBetweenPointAndRectangle(x, y, plaitBoardRect);
|
|
548
|
+
return distances === 0;
|
|
476
549
|
}
|
|
477
550
|
|
|
478
551
|
const NS = 'http://www.w3.org/2000/svg';
|
|
@@ -629,6 +702,12 @@ const PlaitOperation = {
|
|
|
629
702
|
inverse
|
|
630
703
|
};
|
|
631
704
|
|
|
705
|
+
const Point = {
|
|
706
|
+
isEquals(point, otherPoint) {
|
|
707
|
+
return point && otherPoint && point[0] === otherPoint[0] && point[1] === otherPoint[1];
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
632
711
|
const SELECTION_BORDER_COLOR = '#6698FF';
|
|
633
712
|
const SELECTION_FILL_COLOR = '#6698FF19'; // 主色 0.1 透明度
|
|
634
713
|
const Selection = {
|
|
@@ -770,263 +849,47 @@ const create = (key) => {
|
|
|
770
849
|
}
|
|
771
850
|
return false;
|
|
772
851
|
};
|
|
773
|
-
};
|
|
774
|
-
/**
|
|
775
|
-
* Hotkeys.
|
|
776
|
-
*/
|
|
777
|
-
const hotkeys = {
|
|
778
|
-
isBold: create('bold'),
|
|
779
|
-
isCompose: create('compose'),
|
|
780
|
-
isMoveBackward: create('moveBackward'),
|
|
781
|
-
isMoveForward: create('moveForward'),
|
|
782
|
-
isMoveUp: create('moveUp'),
|
|
783
|
-
isMoveDown: create('moveDown'),
|
|
784
|
-
isDeleteBackward: create('deleteBackward'),
|
|
785
|
-
isDeleteForward: create('deleteForward'),
|
|
786
|
-
isDeleteLineBackward: create('deleteLineBackward'),
|
|
787
|
-
isDeleteLineForward: create('deleteLineForward'),
|
|
788
|
-
isDeleteWordBackward: create('deleteWordBackward'),
|
|
789
|
-
isDeleteWordForward: create('deleteWordForward'),
|
|
790
|
-
isExtendBackward: create('extendBackward'),
|
|
791
|
-
isExtendForward: create('extendForward'),
|
|
792
|
-
isExtendLineBackward: create('extendLineBackward'),
|
|
793
|
-
isExtendLineForward: create('extendLineForward'),
|
|
794
|
-
isItalic: create('italic'),
|
|
795
|
-
isMoveLineBackward: create('moveLineBackward'),
|
|
796
|
-
isMoveLineForward: create('moveLineForward'),
|
|
797
|
-
isMoveWordBackward: create('moveWordBackward'),
|
|
798
|
-
isMoveWordForward: create('moveWordForward'),
|
|
799
|
-
isRedo: create('redo'),
|
|
800
|
-
isSplitBlock: create('splitBlock'),
|
|
801
|
-
isTransposeCharacter: create('transposeCharacter'),
|
|
802
|
-
isUndo: create('undo')
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
function idCreator(length = 5) {
|
|
806
|
-
// remove numeral
|
|
807
|
-
const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
|
|
808
|
-
const maxPosition = $chars.length;
|
|
809
|
-
let key = '';
|
|
810
|
-
for (let i = 0; i < length; i++) {
|
|
811
|
-
key += $chars.charAt(Math.floor(Math.random() * maxPosition));
|
|
812
|
-
}
|
|
813
|
-
return key;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
// https://stackoverflow.com/a/6853926/232122
|
|
817
|
-
function distanceBetweenPointAndSegment(x, y, x1, y1, x2, y2) {
|
|
818
|
-
const A = x - x1;
|
|
819
|
-
const B = y - y1;
|
|
820
|
-
const C = x2 - x1;
|
|
821
|
-
const D = y2 - y1;
|
|
822
|
-
const dot = A * C + B * D;
|
|
823
|
-
const lenSquare = C * C + D * D;
|
|
824
|
-
let param = -1;
|
|
825
|
-
if (lenSquare !== 0) {
|
|
826
|
-
// in case of 0 length line
|
|
827
|
-
param = dot / lenSquare;
|
|
828
|
-
}
|
|
829
|
-
let xx, yy;
|
|
830
|
-
if (param < 0) {
|
|
831
|
-
xx = x1;
|
|
832
|
-
yy = y1;
|
|
833
|
-
}
|
|
834
|
-
else if (param > 1) {
|
|
835
|
-
xx = x2;
|
|
836
|
-
yy = y2;
|
|
837
|
-
}
|
|
838
|
-
else {
|
|
839
|
-
xx = x1 + param * C;
|
|
840
|
-
yy = y1 + param * D;
|
|
841
|
-
}
|
|
842
|
-
const dx = x - xx;
|
|
843
|
-
const dy = y - yy;
|
|
844
|
-
return Math.hypot(dx, dy);
|
|
845
|
-
}
|
|
846
|
-
function rotate(x1, y1, x2, y2, angle) {
|
|
847
|
-
// 𝑎′𝑥=(𝑎𝑥−𝑐𝑥)cos𝜃−(𝑎𝑦−𝑐𝑦)sin𝜃+𝑐𝑥
|
|
848
|
-
// 𝑎′𝑦=(𝑎𝑥−𝑐𝑥)sin𝜃+(𝑎𝑦−𝑐𝑦)cos𝜃+𝑐𝑦.
|
|
849
|
-
// https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
|
|
850
|
-
return [(x1 - x2) * Math.cos(angle) - (y1 - y2) * Math.sin(angle) + x2, (x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2];
|
|
851
|
-
}
|
|
852
|
-
function distanceBetweenPointAndPoint(x1, y1, x2, y2) {
|
|
853
|
-
const dx = x1 - x2;
|
|
854
|
-
const dy = y1 - y2;
|
|
855
|
-
return Math.hypot(dx, dy);
|
|
856
|
-
}
|
|
857
|
-
// https://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point
|
|
858
|
-
function distanceBetweenPointAndRectangle(x, y, rect) {
|
|
859
|
-
var dx = Math.max(rect.x - x, 0, x - (rect.x + rect.width));
|
|
860
|
-
var dy = Math.max(rect.y - y, 0, y - (rect.y + rect.height));
|
|
861
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
* 逆矩阵
|
|
866
|
-
* [a c e]
|
|
867
|
-
* [b d f]
|
|
868
|
-
* [0 0 1]
|
|
869
|
-
* @param newMatrix 输出返回矩阵
|
|
870
|
-
* @param matrix 新矩阵
|
|
871
|
-
* @returns 逆矩阵
|
|
872
|
-
*/
|
|
873
|
-
function invertMatrix(newMatrix, matrix) {
|
|
874
|
-
const [n, r, a, i, o, c, l, s, u] = matrix;
|
|
875
|
-
const determinant = u * o - c * s;
|
|
876
|
-
const h = -u * i + c * l;
|
|
877
|
-
const f = s * i - o * l;
|
|
878
|
-
const product = n * determinant + r * h + a * f;
|
|
879
|
-
if (!product) {
|
|
880
|
-
return null;
|
|
881
|
-
}
|
|
882
|
-
const reciprocal = 1 / product;
|
|
883
|
-
newMatrix[0] = determinant * reciprocal;
|
|
884
|
-
newMatrix[1] = (-u * r + a * s) * reciprocal;
|
|
885
|
-
newMatrix[2] = (c * r - a * o) * reciprocal;
|
|
886
|
-
newMatrix[3] = h * reciprocal;
|
|
887
|
-
newMatrix[4] = (u * n - a * l) * reciprocal;
|
|
888
|
-
newMatrix[5] = (-c * n + a * i) * reciprocal;
|
|
889
|
-
newMatrix[6] = f * reciprocal;
|
|
890
|
-
newMatrix[7] = (-s * n + r * l) * reciprocal;
|
|
891
|
-
newMatrix[8] = (o * n - r * i) * reciprocal;
|
|
892
|
-
return newMatrix;
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* 将视图坐标与反转矩阵相乘,以得到原始坐标
|
|
896
|
-
* 使用给定的矩阵进行转换
|
|
897
|
-
* 矩阵与向量乘法,3 维向量与3x3矩阵的乘积
|
|
898
|
-
* [m11 m12 m13][v1]
|
|
899
|
-
* [m21 m22 m23][v2]
|
|
900
|
-
* [m31 m32 m33][v3]
|
|
901
|
-
* @param out 输出结果向量
|
|
902
|
-
* @param t 要转换的向量
|
|
903
|
-
* @param n 矩阵转换
|
|
904
|
-
* @returns [v1 * m11 + v2 * m12 + v3 * m13, v1 * m21 + v2 * m22 + v3 * m23, v1 * m31 + v2 * m32 + v3 * m33];
|
|
905
|
-
*/
|
|
906
|
-
function transformMat3(out, vector, matrix) {
|
|
907
|
-
out = [
|
|
908
|
-
vector[0] * matrix[0] + vector[1] * matrix[3] + vector[2] * matrix[6],
|
|
909
|
-
vector[0] * matrix[1] + vector[1] * matrix[4] + vector[2] * matrix[7],
|
|
910
|
-
vector[0] * matrix[2] + vector[1] * matrix[5] + vector[2] * matrix[8]
|
|
911
|
-
];
|
|
912
|
-
return out;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* 规范 point
|
|
916
|
-
* @param point
|
|
917
|
-
* @returns point
|
|
918
|
-
*/
|
|
919
|
-
function normalizePoint(point) {
|
|
920
|
-
return Array.isArray(point)
|
|
921
|
-
? {
|
|
922
|
-
x: point[0],
|
|
923
|
-
y: point[1]
|
|
924
|
-
}
|
|
925
|
-
: point;
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* 将一个点坐标反转回它的原始坐标
|
|
929
|
-
* @param point 表示要反转的点的视图坐标,它是一个长度为 2 的数组,存储点的 x 和 y 坐标
|
|
930
|
-
* @param matrix 表示视图矩阵,是在视图中对图形进行缩放和平移时使用的矩阵
|
|
931
|
-
* @returns 最终结果是一个长度为 3 的数组,存储点的 x,y 和 w 坐标(w 坐标是点的齐次坐标)
|
|
932
|
-
*/
|
|
933
|
-
function invertViewportCoordinates(point, matrix) {
|
|
934
|
-
const { x, y } = normalizePoint(point);
|
|
935
|
-
const invertedMatrix = invertMatrix([], matrix);
|
|
936
|
-
return transformMat3([], [x, y, 1], invertedMatrix);
|
|
937
|
-
}
|
|
938
|
-
function convertToViewportCoordinates(point, matrix) {
|
|
939
|
-
const { x, y } = normalizePoint(point);
|
|
940
|
-
return transformMat3([], [x, y, 1], matrix);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* 获取 contentContainer 的 clientBox
|
|
944
|
-
* @param board
|
|
945
|
-
* @returns
|
|
946
|
-
*/
|
|
947
|
-
function getViewportContainerBox(board) {
|
|
948
|
-
const { hideScrollbar } = board.options;
|
|
949
|
-
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
950
|
-
const container = PlaitBoard.getViewportContainer(board);
|
|
951
|
-
const containerRect = container.getBoundingClientRect();
|
|
952
|
-
const x = containerRect.x || containerRect.left;
|
|
953
|
-
const y = containerRect.y || containerRect.top;
|
|
954
|
-
const width = containerRect.width - scrollBarWidth;
|
|
955
|
-
const height = containerRect.height - scrollBarWidth;
|
|
956
|
-
return {
|
|
957
|
-
minX: x,
|
|
958
|
-
minY: y,
|
|
959
|
-
maxX: x + width,
|
|
960
|
-
maxY: y + height,
|
|
961
|
-
x,
|
|
962
|
-
y,
|
|
963
|
-
width,
|
|
964
|
-
height
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* 获取 board.plait-board 的 clientBox
|
|
969
|
-
* @param board
|
|
970
|
-
* @returns
|
|
971
|
-
*/
|
|
972
|
-
function getBoardClientBox(board) {
|
|
973
|
-
const { hideScrollbar } = board.options;
|
|
974
|
-
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
975
|
-
const viewportRect = PlaitBoard.getViewportContainer(board).getBoundingClientRect();
|
|
976
|
-
return {
|
|
977
|
-
width: viewportRect.width + scrollBarWidth,
|
|
978
|
-
height: viewportRect.height + scrollBarWidth
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* 获取 rootGroup 相对于当前 svg 空间的最小矩阵坐标
|
|
983
|
-
*/
|
|
984
|
-
function getRootGroupBBox(board, zoom) {
|
|
985
|
-
const elementHost = PlaitBoard.getElementHost(board);
|
|
986
|
-
const rootGroupBox = elementHost.getBBox();
|
|
987
|
-
const viewportContainerBox = getViewportContainerBox(board);
|
|
988
|
-
const containerWidth = viewportContainerBox.width / zoom;
|
|
989
|
-
const containerHeight = viewportContainerBox.height / zoom;
|
|
990
|
-
let left;
|
|
991
|
-
let right;
|
|
992
|
-
let top;
|
|
993
|
-
let bottom;
|
|
994
|
-
if (rootGroupBox.width < containerWidth) {
|
|
995
|
-
const offsetX = rootGroupBox.x + rootGroupBox.width / 2;
|
|
996
|
-
const containerX = containerWidth / 2;
|
|
997
|
-
left = offsetX - containerX;
|
|
998
|
-
right = offsetX + containerX;
|
|
999
|
-
}
|
|
1000
|
-
else {
|
|
1001
|
-
left = rootGroupBox.x;
|
|
1002
|
-
right = rootGroupBox.x + rootGroupBox.width;
|
|
1003
|
-
}
|
|
1004
|
-
if (rootGroupBox.height < containerHeight) {
|
|
1005
|
-
const offsetY = rootGroupBox.y + rootGroupBox.height / 2;
|
|
1006
|
-
const containerY = containerHeight / 2;
|
|
1007
|
-
top = offsetY - containerY;
|
|
1008
|
-
bottom = offsetY + containerY;
|
|
1009
|
-
}
|
|
1010
|
-
else {
|
|
1011
|
-
top = rootGroupBox.y;
|
|
1012
|
-
bottom = rootGroupBox.y + rootGroupBox.height;
|
|
1013
|
-
}
|
|
1014
|
-
return {
|
|
1015
|
-
left,
|
|
1016
|
-
right,
|
|
1017
|
-
top,
|
|
1018
|
-
bottom
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
852
|
+
};
|
|
1021
853
|
/**
|
|
1022
|
-
*
|
|
1023
|
-
* @param zoom 缩放比
|
|
1024
|
-
* @param minZoom 最小缩放比
|
|
1025
|
-
* @param maxZoom 最大缩放比
|
|
1026
|
-
* @returns 正确的缩放比
|
|
854
|
+
* Hotkeys.
|
|
1027
855
|
*/
|
|
1028
|
-
|
|
1029
|
-
|
|
856
|
+
const hotkeys = {
|
|
857
|
+
isBold: create('bold'),
|
|
858
|
+
isCompose: create('compose'),
|
|
859
|
+
isMoveBackward: create('moveBackward'),
|
|
860
|
+
isMoveForward: create('moveForward'),
|
|
861
|
+
isMoveUp: create('moveUp'),
|
|
862
|
+
isMoveDown: create('moveDown'),
|
|
863
|
+
isDeleteBackward: create('deleteBackward'),
|
|
864
|
+
isDeleteForward: create('deleteForward'),
|
|
865
|
+
isDeleteLineBackward: create('deleteLineBackward'),
|
|
866
|
+
isDeleteLineForward: create('deleteLineForward'),
|
|
867
|
+
isDeleteWordBackward: create('deleteWordBackward'),
|
|
868
|
+
isDeleteWordForward: create('deleteWordForward'),
|
|
869
|
+
isExtendBackward: create('extendBackward'),
|
|
870
|
+
isExtendForward: create('extendForward'),
|
|
871
|
+
isExtendLineBackward: create('extendLineBackward'),
|
|
872
|
+
isExtendLineForward: create('extendLineForward'),
|
|
873
|
+
isItalic: create('italic'),
|
|
874
|
+
isMoveLineBackward: create('moveLineBackward'),
|
|
875
|
+
isMoveLineForward: create('moveLineForward'),
|
|
876
|
+
isMoveWordBackward: create('moveWordBackward'),
|
|
877
|
+
isMoveWordForward: create('moveWordForward'),
|
|
878
|
+
isRedo: create('redo'),
|
|
879
|
+
isSplitBlock: create('splitBlock'),
|
|
880
|
+
isTransposeCharacter: create('transposeCharacter'),
|
|
881
|
+
isUndo: create('undo')
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
function idCreator(length = 5) {
|
|
885
|
+
// remove numeral
|
|
886
|
+
const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
|
|
887
|
+
const maxPosition = $chars.length;
|
|
888
|
+
let key = '';
|
|
889
|
+
for (let i = 0; i < length; i++) {
|
|
890
|
+
key += $chars.charAt(Math.floor(Math.random() * maxPosition));
|
|
891
|
+
}
|
|
892
|
+
return key;
|
|
1030
893
|
}
|
|
1031
894
|
|
|
1032
895
|
const calcElementIntersectionSelection = (board) => {
|
|
@@ -1041,6 +904,19 @@ const calcElementIntersectionSelection = (board) => {
|
|
|
1041
904
|
});
|
|
1042
905
|
return selectedElements;
|
|
1043
906
|
};
|
|
907
|
+
const isIntersectionElements = (board, elements, ranges) => {
|
|
908
|
+
let isIntersectionElements = false;
|
|
909
|
+
if (elements.length) {
|
|
910
|
+
elements.map(item => {
|
|
911
|
+
if (!isIntersectionElements) {
|
|
912
|
+
isIntersectionElements = ranges.some(range => {
|
|
913
|
+
return board.isIntersectionSelection(item, range);
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
return isIntersectionElements;
|
|
919
|
+
};
|
|
1044
920
|
const cacheSelectedElements = (board, selectedElements) => {
|
|
1045
921
|
BOARD_TO_SELECTED_ELEMENT.set(board, selectedElements);
|
|
1046
922
|
};
|
|
@@ -1061,6 +937,10 @@ const isSelectedElement = (board, element) => {
|
|
|
1061
937
|
return !!selectedElements.find(value => value === element);
|
|
1062
938
|
};
|
|
1063
939
|
|
|
940
|
+
const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
|
|
941
|
+
const SCROLL_BAR_WIDTH = 20;
|
|
942
|
+
const MAX_RADIUS = 16;
|
|
943
|
+
|
|
1064
944
|
/**
|
|
1065
945
|
* drawRoundRectangle
|
|
1066
946
|
* @param rs RoughSVG
|
|
@@ -1113,6 +993,235 @@ function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 4
|
|
|
1113
993
|
return [arrowLineLeft, arrowLineRight];
|
|
1114
994
|
}
|
|
1115
995
|
|
|
996
|
+
function getViewportContainerRect(board) {
|
|
997
|
+
const { hideScrollbar } = board.options;
|
|
998
|
+
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
999
|
+
const viewportRect = PlaitBoard.getBoardNativeElement(board).getBoundingClientRect();
|
|
1000
|
+
return {
|
|
1001
|
+
width: viewportRect.width + scrollBarWidth,
|
|
1002
|
+
height: viewportRect.height + scrollBarWidth
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
function getElementHostBBox(board, zoom) {
|
|
1006
|
+
const childrenRect = getRectangleByElements(board, board.children, true);
|
|
1007
|
+
const viewportContainerRect = getViewportContainerRect(board);
|
|
1008
|
+
const containerWidth = viewportContainerRect.width / zoom;
|
|
1009
|
+
const containerHeight = viewportContainerRect.height / zoom;
|
|
1010
|
+
let left;
|
|
1011
|
+
let right;
|
|
1012
|
+
let top;
|
|
1013
|
+
let bottom;
|
|
1014
|
+
if (childrenRect.width < containerWidth) {
|
|
1015
|
+
const centerX = childrenRect.x + childrenRect.width / 2;
|
|
1016
|
+
const halfContainerWidth = containerWidth / 2;
|
|
1017
|
+
left = centerX - halfContainerWidth;
|
|
1018
|
+
right = centerX + halfContainerWidth;
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
left = childrenRect.x;
|
|
1022
|
+
right = childrenRect.x + childrenRect.width;
|
|
1023
|
+
}
|
|
1024
|
+
if (childrenRect.height < containerHeight) {
|
|
1025
|
+
const centerY = childrenRect.y + childrenRect.height / 2;
|
|
1026
|
+
const halfContainerHeight = containerHeight / 2;
|
|
1027
|
+
top = centerY - halfContainerHeight;
|
|
1028
|
+
bottom = centerY + halfContainerHeight;
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
top = childrenRect.y;
|
|
1032
|
+
bottom = childrenRect.y + childrenRect.height;
|
|
1033
|
+
}
|
|
1034
|
+
return {
|
|
1035
|
+
left,
|
|
1036
|
+
right,
|
|
1037
|
+
top,
|
|
1038
|
+
bottom
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* 验证缩放比是否符合限制,如果超出限制,则返回合适的缩放比
|
|
1043
|
+
* @param zoom 缩放比
|
|
1044
|
+
* @param minZoom 最小缩放比
|
|
1045
|
+
* @param maxZoom 最大缩放比
|
|
1046
|
+
* @returns 正确的缩放比
|
|
1047
|
+
*/
|
|
1048
|
+
function clampZoomLevel(zoom, minZoom = 0.2, maxZoom = 4) {
|
|
1049
|
+
return zoom < minZoom ? minZoom : zoom > maxZoom ? maxZoom : zoom;
|
|
1050
|
+
}
|
|
1051
|
+
function getViewBox(board, zoom) {
|
|
1052
|
+
const { hideScrollbar } = board.options;
|
|
1053
|
+
const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1054
|
+
const viewportContainerRect = getViewportContainerRect(board);
|
|
1055
|
+
const elementHostBBox = getElementHostBBox(board, zoom);
|
|
1056
|
+
const horizontalPadding = viewportContainerRect.width / 2;
|
|
1057
|
+
const verticalPadding = viewportContainerRect.height / 2;
|
|
1058
|
+
const viewportWidth = (elementHostBBox.right - elementHostBBox.left) * zoom + 2 * horizontalPadding + scrollBarWidth;
|
|
1059
|
+
const viewportHeight = (elementHostBBox.bottom - elementHostBBox.top) * zoom + 2 * verticalPadding + scrollBarWidth;
|
|
1060
|
+
const viewBox = [
|
|
1061
|
+
elementHostBBox.left - horizontalPadding / zoom,
|
|
1062
|
+
elementHostBBox.top - verticalPadding / zoom,
|
|
1063
|
+
viewportWidth / zoom,
|
|
1064
|
+
viewportHeight / zoom
|
|
1065
|
+
];
|
|
1066
|
+
return viewBox;
|
|
1067
|
+
}
|
|
1068
|
+
function setSVGViewBox(board, viewBox) {
|
|
1069
|
+
const zoom = board.viewport.zoom;
|
|
1070
|
+
const hostElement = PlaitBoard.getHost(board);
|
|
1071
|
+
hostElement.style.display = 'block';
|
|
1072
|
+
hostElement.style.width = `${viewBox[2] * zoom}px`;
|
|
1073
|
+
hostElement.style.height = `${viewBox[3] * zoom}px`;
|
|
1074
|
+
if (viewBox && viewBox[2] > 0 && viewBox[3] > 0) {
|
|
1075
|
+
hostElement.setAttribute('viewBox', viewBox.join(' '));
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function updateViewportOffset(board) {
|
|
1079
|
+
const origination = getViewportOrigination(board);
|
|
1080
|
+
if (!origination)
|
|
1081
|
+
return;
|
|
1082
|
+
const { zoom } = board.viewport;
|
|
1083
|
+
const viewBox = getViewBox(board, zoom);
|
|
1084
|
+
const scrollLeft = (origination[0] - viewBox[0]) * zoom;
|
|
1085
|
+
const scrollTop = (origination[1] - viewBox[1]) * zoom;
|
|
1086
|
+
updateViewportContainerScroll(board, scrollLeft, scrollTop);
|
|
1087
|
+
}
|
|
1088
|
+
function updateViewportContainerScroll(board, left, top) {
|
|
1089
|
+
const viewportContainer = PlaitBoard.getViewportContainer(board);
|
|
1090
|
+
if (viewportContainer.scrollLeft !== left || viewportContainer.scrollTop !== top) {
|
|
1091
|
+
viewportContainer.scrollLeft = left;
|
|
1092
|
+
viewportContainer.scrollTop = top;
|
|
1093
|
+
setViewportScrolling(board);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
function initializeViewportContainer(board) {
|
|
1097
|
+
const { width, height } = getViewportContainerRect(board);
|
|
1098
|
+
const viewportContainer = PlaitBoard.getViewportContainer(board);
|
|
1099
|
+
viewportContainer.style.width = `${width}px`;
|
|
1100
|
+
viewportContainer.style.height = `${height}px`;
|
|
1101
|
+
}
|
|
1102
|
+
function initializeViewBox(board) {
|
|
1103
|
+
const zoom = board.viewport.zoom;
|
|
1104
|
+
const viewBox = getViewBox(board, zoom);
|
|
1105
|
+
setSVGViewBox(board, viewBox);
|
|
1106
|
+
}
|
|
1107
|
+
function initializeViewportOffset(board) {
|
|
1108
|
+
if (!board.viewport?.origination) {
|
|
1109
|
+
const zoom = board.viewport.zoom;
|
|
1110
|
+
const viewportContainerRect = PlaitBoard.getBoardNativeElement(board).getBoundingClientRect();
|
|
1111
|
+
const viewBox = getViewBox(board, zoom);
|
|
1112
|
+
const centerX = viewBox[0] + viewBox[2] / 2;
|
|
1113
|
+
const centerY = viewBox[1] + viewBox[3] / 2;
|
|
1114
|
+
const origination = [centerX - viewportContainerRect.width / 2 / zoom, centerY - viewportContainerRect.height / 2 / zoom];
|
|
1115
|
+
updateViewportOrigination(board, origination);
|
|
1116
|
+
updateViewportOffset(board);
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
updateViewportOffset(board);
|
|
1120
|
+
}
|
|
1121
|
+
function setViewport(board, origination, zoom) {
|
|
1122
|
+
zoom = zoom ?? board.viewport.zoom;
|
|
1123
|
+
Transforms.setViewport(board, {
|
|
1124
|
+
...board.viewport,
|
|
1125
|
+
zoom,
|
|
1126
|
+
origination
|
|
1127
|
+
});
|
|
1128
|
+
clearViewportOrigination(board);
|
|
1129
|
+
}
|
|
1130
|
+
function changeZoom(board, newZoom, isCenter = true) {
|
|
1131
|
+
newZoom = clampZoomLevel(newZoom);
|
|
1132
|
+
const mousePoint = BOARD_TO_MOVING_POINT.get(board);
|
|
1133
|
+
const nativeElement = PlaitBoard.getBoardNativeElement(board);
|
|
1134
|
+
const rect = nativeElement.getBoundingClientRect();
|
|
1135
|
+
const viewportContainerRect = getViewportContainerRect(board);
|
|
1136
|
+
let focusPoint = [viewportContainerRect.width / 2, viewportContainerRect.height / 2];
|
|
1137
|
+
if (!isCenter && mousePoint && distanceBetweenPointAndRectangle(mousePoint[0], mousePoint[1], rect) === 0) {
|
|
1138
|
+
focusPoint = toPoint(mousePoint[0], mousePoint[1], nativeElement);
|
|
1139
|
+
}
|
|
1140
|
+
const zoom = board.viewport.zoom;
|
|
1141
|
+
const origination = getViewportOrigination(board);
|
|
1142
|
+
const centerX = origination[0] + focusPoint[0] / zoom;
|
|
1143
|
+
const centerY = origination[1] + focusPoint[1] / zoom;
|
|
1144
|
+
const newOrigination = [centerX - focusPoint[0] / newZoom, centerY - focusPoint[1] / newZoom];
|
|
1145
|
+
setViewport(board, newOrigination, newZoom);
|
|
1146
|
+
}
|
|
1147
|
+
function fitViewport(board) {
|
|
1148
|
+
const viewportContainerRect = getViewportContainerRect(board);
|
|
1149
|
+
const elementHostBox = getRectangleByElements(board, board.children, true);
|
|
1150
|
+
const zoom = board.viewport.zoom;
|
|
1151
|
+
const autoFitPadding = 8;
|
|
1152
|
+
const viewportWidth = viewportContainerRect.width - 2 * autoFitPadding;
|
|
1153
|
+
const viewportHeight = viewportContainerRect.height - 2 * autoFitPadding;
|
|
1154
|
+
let newZoom = zoom;
|
|
1155
|
+
if (viewportWidth < elementHostBox.width || viewportHeight < elementHostBox.height) {
|
|
1156
|
+
newZoom = Math.min(viewportWidth / elementHostBox.width, viewportHeight / elementHostBox.height);
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
newZoom = 1;
|
|
1160
|
+
}
|
|
1161
|
+
const viewBox = getViewBox(board, newZoom);
|
|
1162
|
+
const centerX = viewBox[0] + viewBox[2] / 2;
|
|
1163
|
+
const centerY = viewBox[1] + viewBox[3] / 2;
|
|
1164
|
+
const newOrigination = [
|
|
1165
|
+
centerX - viewportContainerRect.width / 2 / newZoom,
|
|
1166
|
+
centerY - viewportContainerRect.height / 2 / newZoom
|
|
1167
|
+
];
|
|
1168
|
+
setViewport(board, newOrigination, newZoom);
|
|
1169
|
+
}
|
|
1170
|
+
const updateViewportOrigination = (board, origination) => {
|
|
1171
|
+
BOARD_TO_VIEWPORT_ORIGINATION.set(board, origination);
|
|
1172
|
+
};
|
|
1173
|
+
const clearViewportOrigination = (board) => {
|
|
1174
|
+
BOARD_TO_VIEWPORT_ORIGINATION.delete(board);
|
|
1175
|
+
};
|
|
1176
|
+
const getViewportOrigination = (board) => {
|
|
1177
|
+
const origination = BOARD_TO_VIEWPORT_ORIGINATION.get(board);
|
|
1178
|
+
if (origination) {
|
|
1179
|
+
return origination;
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
return board.viewport.origination;
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
const isViewportScrolling = (board) => {
|
|
1186
|
+
return !!BOARD_TO_SCROLLING.get(board);
|
|
1187
|
+
};
|
|
1188
|
+
const setViewportScrolling = (board) => {
|
|
1189
|
+
BOARD_TO_SCROLLING.set(board, true);
|
|
1190
|
+
};
|
|
1191
|
+
const clearViewportScrolling = (board) => {
|
|
1192
|
+
BOARD_TO_SCROLLING.delete(board);
|
|
1193
|
+
};
|
|
1194
|
+
function scrollToRectangle(board, client) { }
|
|
1195
|
+
|
|
1196
|
+
let timerId = null;
|
|
1197
|
+
const throttleRAF = (fn) => {
|
|
1198
|
+
const scheduleFunc = () => {
|
|
1199
|
+
timerId = requestAnimationFrame(() => {
|
|
1200
|
+
timerId = null;
|
|
1201
|
+
fn();
|
|
1202
|
+
});
|
|
1203
|
+
};
|
|
1204
|
+
if (timerId !== null) {
|
|
1205
|
+
cancelAnimationFrame(timerId);
|
|
1206
|
+
timerId = null;
|
|
1207
|
+
}
|
|
1208
|
+
scheduleFunc();
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
const getMovingElements = (board) => {
|
|
1212
|
+
return BOARD_TO_MOVING_ELEMENT.get(board) || [];
|
|
1213
|
+
};
|
|
1214
|
+
const addMovingElements = (board, elements) => {
|
|
1215
|
+
const movingElements = getMovingElements(board);
|
|
1216
|
+
cacheMovingElements(board, [...movingElements, ...elements]);
|
|
1217
|
+
};
|
|
1218
|
+
const removeMovingElements = (board) => {
|
|
1219
|
+
BOARD_TO_MOVING_ELEMENT.delete(board);
|
|
1220
|
+
};
|
|
1221
|
+
const cacheMovingElements = (board, elements) => {
|
|
1222
|
+
BOARD_TO_MOVING_ELEMENT.set(board, elements);
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1116
1225
|
const updatePointerType = (board, pointer) => {
|
|
1117
1226
|
board.pointer = pointer;
|
|
1118
1227
|
const boardComponent = BOARD_TO_COMPONENT.get(board);
|
|
@@ -1178,6 +1287,7 @@ function createBoard(children, options) {
|
|
|
1178
1287
|
destroyElement: (context) => { },
|
|
1179
1288
|
isWithinSelection: element => false,
|
|
1180
1289
|
isIntersectionSelection: element => false,
|
|
1290
|
+
isMovable: element => false,
|
|
1181
1291
|
getRectangle: element => null
|
|
1182
1292
|
};
|
|
1183
1293
|
return board;
|
|
@@ -1303,11 +1413,10 @@ function withHandPointer(board) {
|
|
|
1303
1413
|
};
|
|
1304
1414
|
board.mousemove = (event) => {
|
|
1305
1415
|
if (board.pointer === PlaitPointerType.hand && board.selection && isMoving) {
|
|
1306
|
-
const
|
|
1307
|
-
const left = event.x - plaitBoardMove.x;
|
|
1308
|
-
const top = event.y - plaitBoardMove.y;
|
|
1309
|
-
|
|
1310
|
-
boardComponent.setScroll(scrollLeft - left, scrollTop - top);
|
|
1416
|
+
const viewportContainer = PlaitBoard.getViewportContainer(board);
|
|
1417
|
+
const left = viewportContainer.scrollLeft - (event.x - plaitBoardMove.x);
|
|
1418
|
+
const top = viewportContainer.scrollTop - (event.y - plaitBoardMove.y);
|
|
1419
|
+
updateViewportContainerScroll(board, left, top);
|
|
1311
1420
|
plaitBoardMove.x = event.x;
|
|
1312
1421
|
plaitBoardMove.y = event.y;
|
|
1313
1422
|
}
|
|
@@ -1340,6 +1449,8 @@ function withHandPointer(board) {
|
|
|
1340
1449
|
return board;
|
|
1341
1450
|
}
|
|
1342
1451
|
|
|
1452
|
+
const ATTACHED_ELEMENT_CLASS_NAME = 'plait-board-attached';
|
|
1453
|
+
|
|
1343
1454
|
function withSelection(board) {
|
|
1344
1455
|
const { mousedown, globalMousemove, globalMouseup, onChange } = board;
|
|
1345
1456
|
let start = null;
|
|
@@ -1347,12 +1458,26 @@ function withSelection(board) {
|
|
|
1347
1458
|
let selectionMovingG;
|
|
1348
1459
|
let selectionOuterG;
|
|
1349
1460
|
board.mousedown = (event) => {
|
|
1350
|
-
|
|
1461
|
+
if (board.pointer === PlaitPointerType.hand && board.selection) {
|
|
1462
|
+
mousedown(event);
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1351
1465
|
if (event.button === 0) {
|
|
1352
1466
|
start = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
1353
1467
|
}
|
|
1354
1468
|
if (start) {
|
|
1355
|
-
|
|
1469
|
+
const ranges = [{ anchor: start, focus: start }];
|
|
1470
|
+
const selectedElements = getSelectedElements(board);
|
|
1471
|
+
const intersectionSelectedElement = isIntersectionElements(board, selectedElements, ranges);
|
|
1472
|
+
if (intersectionSelectedElement) {
|
|
1473
|
+
start = null;
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
Transforms.setSelection(board, { ranges: ranges });
|
|
1477
|
+
if (calcElementIntersectionSelection(board).length) {
|
|
1478
|
+
start = null;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1356
1481
|
}
|
|
1357
1482
|
mousedown(event);
|
|
1358
1483
|
};
|
|
@@ -1360,13 +1485,11 @@ function withSelection(board) {
|
|
|
1360
1485
|
if (start) {
|
|
1361
1486
|
const movedTarget = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
1362
1487
|
const { x, y, width, height } = RectangleClient.toRectangleClient([start, movedTarget]);
|
|
1488
|
+
selectionMovingG?.remove();
|
|
1363
1489
|
if (Math.hypot(width, height) > 5) {
|
|
1364
1490
|
end = movedTarget;
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
PlaitBoard.getBoardNativeElement(board).classList.add('selection-moving');
|
|
1369
|
-
selectionMovingG?.remove();
|
|
1491
|
+
Transforms.setSelection(board, { ranges: [{ anchor: start, focus: end }] });
|
|
1492
|
+
setSelectionMoving(board);
|
|
1370
1493
|
const rough = PlaitBoard.getRoughSVG(board);
|
|
1371
1494
|
selectionMovingG = rough.rectangle(x, y, width, height, {
|
|
1372
1495
|
stroke: SELECTION_BORDER_COLOR,
|
|
@@ -1381,8 +1504,18 @@ function withSelection(board) {
|
|
|
1381
1504
|
};
|
|
1382
1505
|
board.globalMouseup = (event) => {
|
|
1383
1506
|
if (start && end) {
|
|
1384
|
-
PlaitBoard.getBoardNativeElement(board).classList.remove('selection-moving');
|
|
1385
1507
|
selectionMovingG?.remove();
|
|
1508
|
+
clearSelectionMoving(board);
|
|
1509
|
+
Transforms.setSelection(board, { ranges: [{ anchor: start, focus: end }] });
|
|
1510
|
+
}
|
|
1511
|
+
if (PlaitBoard.isFocus(board)) {
|
|
1512
|
+
const isInBoard = event.target instanceof Node && PlaitBoard.getBoardNativeElement(board).contains(event.target);
|
|
1513
|
+
const isAttachedElement = event.target instanceof HTMLElement && event.target.closest(`.${ATTACHED_ELEMENT_CLASS_NAME}`);
|
|
1514
|
+
// Clear selection when mouse board outside area
|
|
1515
|
+
// The framework needs to determine whether the board is focused through selection
|
|
1516
|
+
if (!isInBoard && !start && !isAttachedElement) {
|
|
1517
|
+
Transforms.setSelection(board, null);
|
|
1518
|
+
}
|
|
1386
1519
|
}
|
|
1387
1520
|
start = null;
|
|
1388
1521
|
end = null;
|
|
@@ -1391,6 +1524,7 @@ function withSelection(board) {
|
|
|
1391
1524
|
board.onChange = () => {
|
|
1392
1525
|
// calc selected elements entry
|
|
1393
1526
|
try {
|
|
1527
|
+
selectionOuterG?.remove();
|
|
1394
1528
|
if (board.operations.find(value => value.type === 'set_selection')) {
|
|
1395
1529
|
const temporaryElements = getTemporaryElements(board);
|
|
1396
1530
|
const elements = temporaryElements ? temporaryElements : calcElementIntersectionSelection(board);
|
|
@@ -1398,12 +1532,12 @@ function withSelection(board) {
|
|
|
1398
1532
|
const { x, y, width, height } = getRectangleByElements(board, elements, false);
|
|
1399
1533
|
if (width > 0 && height > 0) {
|
|
1400
1534
|
const rough = PlaitBoard.getRoughSVG(board);
|
|
1401
|
-
selectionOuterG?.remove();
|
|
1402
1535
|
selectionOuterG = rough.rectangle(x - 2, y - 2, width + 4, height + 4, {
|
|
1403
1536
|
stroke: SELECTION_BORDER_COLOR,
|
|
1404
1537
|
strokeWidth: 1,
|
|
1405
1538
|
fillStyle: 'solid'
|
|
1406
1539
|
});
|
|
1540
|
+
selectionOuterG.classList.add('selection-outer');
|
|
1407
1541
|
PlaitBoard.getHost(board).append(selectionOuterG);
|
|
1408
1542
|
}
|
|
1409
1543
|
}
|
|
@@ -1422,6 +1556,44 @@ function getTemporaryElements(board) {
|
|
|
1422
1556
|
function deleteTemporaryElements(board) {
|
|
1423
1557
|
BOARD_TO_TEMPORARY_ELEMENTS.delete(board);
|
|
1424
1558
|
}
|
|
1559
|
+
function isSelectionMoving(board) {
|
|
1560
|
+
return !!BOARD_TO_IS_SELECTION_MOVING.get(board);
|
|
1561
|
+
}
|
|
1562
|
+
function setSelectionMoving(board) {
|
|
1563
|
+
PlaitBoard.getBoardNativeElement(board).classList.add('selection-moving');
|
|
1564
|
+
BOARD_TO_IS_SELECTION_MOVING.set(board, true);
|
|
1565
|
+
}
|
|
1566
|
+
function clearSelectionMoving(board) {
|
|
1567
|
+
PlaitBoard.getBoardNativeElement(board).classList.remove('selection-moving');
|
|
1568
|
+
BOARD_TO_IS_SELECTION_MOVING.delete(board);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
function withViewport(board) {
|
|
1572
|
+
const { onChange } = board;
|
|
1573
|
+
let timerSubscription;
|
|
1574
|
+
board.onChange = () => {
|
|
1575
|
+
const isSetViewport = board.operations.some(op => op.type === 'set_viewport');
|
|
1576
|
+
const isOnlySetSelection = board.operations.some(op => op.type === 'set_selection');
|
|
1577
|
+
if (isOnlySetSelection) {
|
|
1578
|
+
return onChange();
|
|
1579
|
+
}
|
|
1580
|
+
if (isSetViewport) {
|
|
1581
|
+
initializeViewBox(board);
|
|
1582
|
+
updateViewportOffset(board);
|
|
1583
|
+
}
|
|
1584
|
+
else {
|
|
1585
|
+
if (timerSubscription) {
|
|
1586
|
+
timerSubscription.unsubscribe();
|
|
1587
|
+
}
|
|
1588
|
+
timerSubscription = timer(500).subscribe(() => {
|
|
1589
|
+
initializeViewBox(board);
|
|
1590
|
+
updateViewportOffset(board);
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
onChange();
|
|
1594
|
+
};
|
|
1595
|
+
return board;
|
|
1596
|
+
}
|
|
1425
1597
|
|
|
1426
1598
|
class PlaitElementComponent {
|
|
1427
1599
|
constructor(renderer2, viewContainerRef) {
|
|
@@ -1475,7 +1647,7 @@ class PlaitElementComponent {
|
|
|
1475
1647
|
const current = {
|
|
1476
1648
|
element: this.element,
|
|
1477
1649
|
selection: this.selection,
|
|
1478
|
-
board: this.board
|
|
1650
|
+
board: this.board
|
|
1479
1651
|
};
|
|
1480
1652
|
if (this.context) {
|
|
1481
1653
|
const previous = { ...this.context };
|
|
@@ -1491,9 +1663,9 @@ class PlaitElementComponent {
|
|
|
1491
1663
|
this.board.destroyElement(this.getContext().current);
|
|
1492
1664
|
}
|
|
1493
1665
|
}
|
|
1494
|
-
PlaitElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1495
|
-
PlaitElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1496
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1666
|
+
PlaitElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1667
|
+
PlaitElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitElementComponent, selector: "plait-element", inputs: { index: "index", element: "element", board: "board", viewport: "viewport", selection: "selection" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, decorators: [{
|
|
1497
1669
|
type: Component,
|
|
1498
1670
|
args: [{
|
|
1499
1671
|
selector: 'plait-element',
|
|
@@ -1547,9 +1719,9 @@ class PlaitToolbarComponent {
|
|
|
1547
1719
|
this.resetZoomHandel.emit();
|
|
1548
1720
|
}
|
|
1549
1721
|
}
|
|
1550
|
-
PlaitToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1551
|
-
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': isHand }\" (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 });
|
|
1552
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1722
|
+
PlaitToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1723
|
+
PlaitToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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': isHand }\" (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", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1724
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitToolbarComponent, decorators: [{
|
|
1553
1725
|
type: Component,
|
|
1554
1726
|
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': isHand }\" (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" }]
|
|
1555
1727
|
}], propDecorators: { hostClass: [{
|
|
@@ -1569,27 +1741,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1569
1741
|
|
|
1570
1742
|
const ElementHostClass = 'element-host';
|
|
1571
1743
|
class PlaitBoardComponent {
|
|
1572
|
-
constructor(cdr, renderer2, elementRef) {
|
|
1573
|
-
this.cdr = cdr;
|
|
1574
|
-
this.renderer2 = renderer2;
|
|
1575
|
-
this.elementRef = elementRef;
|
|
1576
|
-
this.hasInitialized = false;
|
|
1577
|
-
this.destroy$ = new Subject();
|
|
1578
|
-
this.viewportState = {
|
|
1579
|
-
zoom: 1,
|
|
1580
|
-
autoFitPadding: 8
|
|
1581
|
-
};
|
|
1582
|
-
this.plaitValue = [];
|
|
1583
|
-
this.plaitPlugins = [];
|
|
1584
|
-
this.plaitChange = new EventEmitter();
|
|
1585
|
-
this.plaitBoardInitialized = new EventEmitter();
|
|
1586
|
-
this.trackBy = (index, element) => {
|
|
1587
|
-
return index;
|
|
1588
|
-
};
|
|
1589
|
-
}
|
|
1590
|
-
get isFocused() {
|
|
1591
|
-
return this.board?.selection;
|
|
1592
|
-
}
|
|
1593
1744
|
get host() {
|
|
1594
1745
|
return this.svg.nativeElement;
|
|
1595
1746
|
}
|
|
@@ -1599,21 +1750,38 @@ class PlaitBoardComponent {
|
|
|
1599
1750
|
get readonly() {
|
|
1600
1751
|
return this.board.options.readonly;
|
|
1601
1752
|
}
|
|
1602
|
-
get
|
|
1603
|
-
return this.
|
|
1753
|
+
get isFocused() {
|
|
1754
|
+
return PlaitBoard.isFocus(this.board);
|
|
1604
1755
|
}
|
|
1605
1756
|
get nativeElement() {
|
|
1606
1757
|
return this.elementRef.nativeElement;
|
|
1607
1758
|
}
|
|
1759
|
+
constructor(cdr, renderer2, elementRef, ngZone) {
|
|
1760
|
+
this.cdr = cdr;
|
|
1761
|
+
this.renderer2 = renderer2;
|
|
1762
|
+
this.elementRef = elementRef;
|
|
1763
|
+
this.ngZone = ngZone;
|
|
1764
|
+
this.hasInitialized = false;
|
|
1765
|
+
this.destroy$ = new Subject();
|
|
1766
|
+
this.plaitValue = [];
|
|
1767
|
+
this.plaitPlugins = [];
|
|
1768
|
+
this.plaitChange = new EventEmitter();
|
|
1769
|
+
this.plaitBoardInitialized = new EventEmitter();
|
|
1770
|
+
this.trackBy = (index, element) => {
|
|
1771
|
+
return index;
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1608
1774
|
ngOnInit() {
|
|
1609
1775
|
const elementHost = this.host.querySelector(`.${ElementHostClass}`);
|
|
1610
1776
|
const roughSVG = rough.svg(this.host, {
|
|
1611
1777
|
options: { roughness: 0, strokeWidth: 1 }
|
|
1612
1778
|
});
|
|
1779
|
+
this.roughSVG = roughSVG;
|
|
1613
1780
|
this.initializePlugins();
|
|
1614
1781
|
this.initializeEvents();
|
|
1615
1782
|
this.viewportScrollListener();
|
|
1616
1783
|
this.elementResizeListener();
|
|
1784
|
+
this.mouseLeaveListener();
|
|
1617
1785
|
BOARD_TO_COMPONENT.set(this.board, this);
|
|
1618
1786
|
BOARD_TO_ROUGH_SVG.set(this.board, roughSVG);
|
|
1619
1787
|
BOARD_TO_HOST.set(this.board, this.host);
|
|
@@ -1630,13 +1798,19 @@ class PlaitBoardComponent {
|
|
|
1630
1798
|
});
|
|
1631
1799
|
this.hasInitialized = true;
|
|
1632
1800
|
}
|
|
1801
|
+
mouseLeaveListener() {
|
|
1802
|
+
fromEvent(this.host, 'mouseleave')
|
|
1803
|
+
.pipe(takeUntil(this.destroy$))
|
|
1804
|
+
.subscribe((event) => {
|
|
1805
|
+
BOARD_TO_MOVING_POINT.delete(this.board);
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1633
1808
|
ngOnChanges(changes) {
|
|
1634
1809
|
if (this.hasInitialized) {
|
|
1635
1810
|
const valueChange = changes['plaitValue'];
|
|
1636
1811
|
const options = changes['plaitOptions'];
|
|
1637
|
-
if (valueChange)
|
|
1812
|
+
if (valueChange)
|
|
1638
1813
|
this.board.children = valueChange.currentValue;
|
|
1639
|
-
}
|
|
1640
1814
|
if (options)
|
|
1641
1815
|
this.board.options = options.currentValue;
|
|
1642
1816
|
this.cdr.markForCheck();
|
|
@@ -1644,21 +1818,18 @@ class PlaitBoardComponent {
|
|
|
1644
1818
|
}
|
|
1645
1819
|
ngAfterViewInit() {
|
|
1646
1820
|
this.plaitBoardInitialized.emit(this.board);
|
|
1647
|
-
this.
|
|
1648
|
-
|
|
1649
|
-
this.
|
|
1821
|
+
initializeViewportContainer(this.board);
|
|
1822
|
+
initializeViewBox(this.board);
|
|
1823
|
+
initializeViewportOffset(this.board);
|
|
1650
1824
|
}
|
|
1651
1825
|
initializePlugins() {
|
|
1652
|
-
let board = withHandPointer(withHistory(withSelection(withBoard(createBoard(this.plaitValue, this.plaitOptions)))));
|
|
1826
|
+
let board = withHandPointer(withHistory(withSelection(withBoard(withViewport(createBoard(this.plaitValue, this.plaitOptions))))));
|
|
1653
1827
|
this.plaitPlugins.forEach(plugin => {
|
|
1654
1828
|
board = plugin(board);
|
|
1655
1829
|
});
|
|
1656
1830
|
this.board = board;
|
|
1657
1831
|
if (this.plaitViewport) {
|
|
1658
1832
|
this.board.viewport = this.plaitViewport;
|
|
1659
|
-
this.updateViewportState({
|
|
1660
|
-
zoom: this.plaitViewport?.zoom ?? 1
|
|
1661
|
-
});
|
|
1662
1833
|
}
|
|
1663
1834
|
}
|
|
1664
1835
|
initializeEvents() {
|
|
@@ -1694,31 +1865,31 @@ class PlaitBoardComponent {
|
|
|
1694
1865
|
this.board.dblclick(event);
|
|
1695
1866
|
});
|
|
1696
1867
|
fromEvent(document, 'keydown')
|
|
1697
|
-
.pipe(takeUntil(this.destroy$), filter(() =>
|
|
1698
|
-
return !IS_TEXT_EDITABLE.get(this.board) && !!this.board.selection;
|
|
1699
|
-
}))
|
|
1868
|
+
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
1700
1869
|
.subscribe((event) => {
|
|
1870
|
+
if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
|
|
1871
|
+
event.preventDefault();
|
|
1872
|
+
this.zoomInHandle(false);
|
|
1873
|
+
}
|
|
1874
|
+
if (isHotkey('mod+-', { byKey: true })(event)) {
|
|
1875
|
+
this.zoomOutHandle();
|
|
1876
|
+
event.preventDefault();
|
|
1877
|
+
}
|
|
1701
1878
|
this.board?.keydown(event);
|
|
1702
1879
|
});
|
|
1703
1880
|
fromEvent(document, 'keyup')
|
|
1704
|
-
.pipe(takeUntil(this.destroy$), filter(() =>
|
|
1705
|
-
return !IS_TEXT_EDITABLE.get(this.board) && !!this.board.selection;
|
|
1706
|
-
}))
|
|
1881
|
+
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
1707
1882
|
.subscribe((event) => {
|
|
1708
1883
|
this.board?.keyup(event);
|
|
1709
1884
|
});
|
|
1710
1885
|
fromEvent(document, 'copy')
|
|
1711
|
-
.pipe(takeUntil(this.destroy$), filter(() =>
|
|
1712
|
-
return !IS_TEXT_EDITABLE.get(this.board) && !!this.board.selection;
|
|
1713
|
-
}))
|
|
1886
|
+
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
1714
1887
|
.subscribe((event) => {
|
|
1715
1888
|
event.preventDefault();
|
|
1716
1889
|
this.board?.setFragment(event.clipboardData);
|
|
1717
1890
|
});
|
|
1718
1891
|
fromEvent(document, 'paste')
|
|
1719
|
-
.pipe(takeUntil(this.destroy$), filter(() =>
|
|
1720
|
-
return !IS_TEXT_EDITABLE.get(this.board) && !!this.board.selection && !this.readonly;
|
|
1721
|
-
}))
|
|
1892
|
+
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.isReadonly(this.board) && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
1722
1893
|
.subscribe((clipboardEvent) => {
|
|
1723
1894
|
const mousePoint = BOARD_TO_MOVING_POINT.get(this.board);
|
|
1724
1895
|
const rect = this.nativeElement.getBoundingClientRect();
|
|
@@ -1728,9 +1899,7 @@ class PlaitBoardComponent {
|
|
|
1728
1899
|
}
|
|
1729
1900
|
});
|
|
1730
1901
|
fromEvent(document, 'cut')
|
|
1731
|
-
.pipe(takeUntil(this.destroy$), filter(() =>
|
|
1732
|
-
return !IS_TEXT_EDITABLE.get(this.board) && !!this.board.selection;
|
|
1733
|
-
}))
|
|
1902
|
+
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.isReadonly(this.board) && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
1734
1903
|
.subscribe((event) => {
|
|
1735
1904
|
event.preventDefault();
|
|
1736
1905
|
this.board?.setFragment(event.clipboardData);
|
|
@@ -1738,209 +1907,55 @@ class PlaitBoardComponent {
|
|
|
1738
1907
|
});
|
|
1739
1908
|
}
|
|
1740
1909
|
viewportScrollListener() {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
this.
|
|
1752
|
-
this.
|
|
1753
|
-
|
|
1910
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1911
|
+
fromEvent(this.viewportContainer.nativeElement, 'scroll')
|
|
1912
|
+
.pipe(takeUntil(this.destroy$), filter(() => {
|
|
1913
|
+
const isScrolling = isViewportScrolling(this.board);
|
|
1914
|
+
if (isScrolling) {
|
|
1915
|
+
clearViewportScrolling(this.board);
|
|
1916
|
+
}
|
|
1917
|
+
return !isScrolling && this.isFocused;
|
|
1918
|
+
}), tap((event) => {
|
|
1919
|
+
const { scrollLeft, scrollTop } = event.target;
|
|
1920
|
+
const zoom = this.board.viewport.zoom;
|
|
1921
|
+
const viewBox = getViewBox(this.board, zoom);
|
|
1922
|
+
const origination = [scrollLeft / zoom + viewBox[0], scrollTop / zoom + viewBox[1]];
|
|
1923
|
+
updateViewportOrigination(this.board, origination);
|
|
1924
|
+
return origination;
|
|
1925
|
+
}), debounceTime(500))
|
|
1926
|
+
.subscribe((event) => {
|
|
1927
|
+
const origination = getViewportOrigination(this.board);
|
|
1928
|
+
if (Point.isEquals(origination, this.board.viewport.origination)) {
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
setViewport(this.board, getViewportOrigination(this.board));
|
|
1932
|
+
});
|
|
1754
1933
|
});
|
|
1755
1934
|
}
|
|
1756
1935
|
elementResizeListener() {
|
|
1757
1936
|
this.resizeObserver = new ResizeObserver(() => {
|
|
1758
|
-
this.
|
|
1759
|
-
|
|
1760
|
-
this.
|
|
1761
|
-
this.updateViewportScrolling();
|
|
1762
|
-
this.setViewport();
|
|
1937
|
+
initializeViewportContainer(this.board);
|
|
1938
|
+
initializeViewBox(this.board);
|
|
1939
|
+
updateViewportOffset(this.board);
|
|
1763
1940
|
});
|
|
1764
1941
|
this.resizeObserver.observe(this.nativeElement);
|
|
1765
1942
|
}
|
|
1766
|
-
updateViewportState(state) {
|
|
1767
|
-
this.viewportState = {
|
|
1768
|
-
...this.viewportState,
|
|
1769
|
-
...state
|
|
1770
|
-
};
|
|
1771
|
-
}
|
|
1772
|
-
initViewportContainer() {
|
|
1773
|
-
const { width, height } = getBoardClientBox(this.board);
|
|
1774
|
-
this.renderer2.setStyle(this.viewportContainer.nativeElement, 'width', `${width}px`);
|
|
1775
|
-
this.renderer2.setStyle(this.viewportContainer.nativeElement, 'height', `${height}px`);
|
|
1776
|
-
}
|
|
1777
|
-
initViewport(viewport = this.board.viewport) {
|
|
1778
|
-
const originationCoord = viewport?.originationCoord;
|
|
1779
|
-
const zoom = viewport?.zoom ?? this.viewportState.zoom;
|
|
1780
|
-
if (originationCoord) {
|
|
1781
|
-
const matrix = this.getMatrix();
|
|
1782
|
-
const [pointX, pointY] = invertViewportCoordinates([0, 0], matrix);
|
|
1783
|
-
const scrollLeft = this.viewportState.scrollLeft;
|
|
1784
|
-
const scrollTop = this.viewportState.scrollTop;
|
|
1785
|
-
const left = scrollLeft + (originationCoord[0] - pointX) * zoom;
|
|
1786
|
-
const top = scrollTop + (originationCoord[1] - pointY) * zoom;
|
|
1787
|
-
this.setScroll(left, top);
|
|
1788
|
-
}
|
|
1789
|
-
else {
|
|
1790
|
-
this.adaptHandle();
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
calcViewBox(zoom = this.viewportState.zoom) {
|
|
1794
|
-
zoom = clampZoomLevel(zoom);
|
|
1795
|
-
const scrollBarWidth = this.plaitOptions?.hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1796
|
-
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1797
|
-
const groupBBox = getRootGroupBBox(this.board, zoom);
|
|
1798
|
-
const horizontalPadding = viewportContainerBox.width / 2;
|
|
1799
|
-
const verticalPadding = viewportContainerBox.height / 2;
|
|
1800
|
-
const viewportWidth = (groupBBox.right - groupBBox.left) * zoom + 2 * horizontalPadding + scrollBarWidth;
|
|
1801
|
-
const viewportHeight = (groupBBox.bottom - groupBBox.top) * zoom + 2 * verticalPadding + scrollBarWidth;
|
|
1802
|
-
const viewBox = [
|
|
1803
|
-
groupBBox.left - horizontalPadding / zoom,
|
|
1804
|
-
groupBBox.top - verticalPadding / zoom,
|
|
1805
|
-
viewportWidth / zoom,
|
|
1806
|
-
viewportHeight / zoom
|
|
1807
|
-
];
|
|
1808
|
-
const matrix = this.getMatrix();
|
|
1809
|
-
let scrollLeft;
|
|
1810
|
-
let scrollTop;
|
|
1811
|
-
if (matrix.length > 0) {
|
|
1812
|
-
// focusPoint
|
|
1813
|
-
const focusX = viewportContainerBox.x + viewportContainerBox.width / 2;
|
|
1814
|
-
const focusY = viewportContainerBox.y + viewportContainerBox.height / 2;
|
|
1815
|
-
const viewportContainerPoint = [focusX - viewportContainerBox.x, focusY - viewportContainerBox.y, 1];
|
|
1816
|
-
const point = invertViewportCoordinates([viewportContainerPoint[0], viewportContainerPoint[1]], matrix);
|
|
1817
|
-
const newMatrix = [zoom, 0, 0, 0, zoom, 0, -zoom * viewBox[0], -zoom * viewBox[1], 1];
|
|
1818
|
-
const newPoint = transformMat3([], point, newMatrix);
|
|
1819
|
-
scrollLeft = newPoint[0] - viewportContainerPoint[0];
|
|
1820
|
-
scrollTop = newPoint[1] - viewportContainerPoint[1];
|
|
1821
|
-
}
|
|
1822
|
-
else {
|
|
1823
|
-
scrollLeft = horizontalPadding;
|
|
1824
|
-
scrollTop = verticalPadding;
|
|
1825
|
-
}
|
|
1826
|
-
this.updateViewportState({
|
|
1827
|
-
viewportWidth,
|
|
1828
|
-
viewportHeight,
|
|
1829
|
-
zoom,
|
|
1830
|
-
viewBox
|
|
1831
|
-
});
|
|
1832
|
-
this.setScrollLeft(scrollLeft);
|
|
1833
|
-
this.setScrollTop(scrollTop);
|
|
1834
|
-
}
|
|
1835
|
-
getMatrix() {
|
|
1836
|
-
const { viewBox, zoom, scrollLeft, scrollTop } = this.viewportState;
|
|
1837
|
-
if (scrollLeft >= 0 && scrollTop >= 0) {
|
|
1838
|
-
return [zoom, 0, 0, 0, zoom, 0, -scrollLeft - zoom * viewBox[0], -scrollTop - zoom * viewBox[1], 1];
|
|
1839
|
-
}
|
|
1840
|
-
return [];
|
|
1841
|
-
}
|
|
1842
|
-
setScrollLeft(left) {
|
|
1843
|
-
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1844
|
-
const scrollBarWidth = this.plaitOptions?.hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1845
|
-
const { viewportWidth } = this.viewportState;
|
|
1846
|
-
const width = viewportWidth - viewportContainerBox.width + scrollBarWidth;
|
|
1847
|
-
this.viewportState.scrollLeft = left < 0 ? 0 : left > width ? width : left;
|
|
1848
|
-
}
|
|
1849
|
-
setScrollTop(top) {
|
|
1850
|
-
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1851
|
-
const scrollBarWidth = this.plaitOptions?.hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1852
|
-
const { viewportHeight } = this.viewportState;
|
|
1853
|
-
const height = viewportHeight - viewportContainerBox.height + scrollBarWidth;
|
|
1854
|
-
this.viewportState.scrollTop = top < 0 ? 0 : top > height ? height : top;
|
|
1855
|
-
}
|
|
1856
|
-
setScroll(left, top) {
|
|
1857
|
-
this.setScrollLeft(left);
|
|
1858
|
-
this.setScrollTop(top);
|
|
1859
|
-
this.updateViewBoxStyles();
|
|
1860
|
-
this.updateViewportScrolling();
|
|
1861
|
-
this.setViewport();
|
|
1862
|
-
}
|
|
1863
|
-
updateViewBoxStyles() {
|
|
1864
|
-
const { host, viewportState } = this;
|
|
1865
|
-
const { viewportWidth, viewportHeight, viewBox } = viewportState;
|
|
1866
|
-
this.renderer2.setStyle(host, 'display', 'block');
|
|
1867
|
-
this.renderer2.setStyle(host, 'width', `${viewportWidth}px`);
|
|
1868
|
-
this.renderer2.setStyle(host, 'height', `${viewportHeight}px`);
|
|
1869
|
-
if (viewBox && viewBox[2] > 0 && viewBox[3] > 0) {
|
|
1870
|
-
this.renderer2.setAttribute(host, 'viewBox', viewBox.join(' '));
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
updateViewportScrolling() {
|
|
1874
|
-
const { viewportContainer, viewportState } = this;
|
|
1875
|
-
const { scrollLeft, scrollTop } = viewportState;
|
|
1876
|
-
viewportContainer.nativeElement.scrollLeft = scrollLeft;
|
|
1877
|
-
viewportContainer.nativeElement.scrollTop = scrollTop;
|
|
1878
|
-
}
|
|
1879
|
-
setViewport() {
|
|
1880
|
-
const viewport = this.board?.viewport;
|
|
1881
|
-
const oldOriginationCoord = viewport?.originationCoord ?? [];
|
|
1882
|
-
const matrix = this.getMatrix();
|
|
1883
|
-
const originationCoord = invertViewportCoordinates([0, 0], matrix);
|
|
1884
|
-
if (!originationCoord.every((item, index) => item === oldOriginationCoord[index])) {
|
|
1885
|
-
Transforms.setViewport(this.board, {
|
|
1886
|
-
...viewport,
|
|
1887
|
-
zoom: this.viewportState.zoom,
|
|
1888
|
-
originationCoord
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
1943
|
adaptHandle() {
|
|
1893
|
-
|
|
1894
|
-
const rootGroup = this.host.firstChild;
|
|
1895
|
-
const matrix = this.getMatrix();
|
|
1896
|
-
const rootGroupBox = rootGroup.getBBox();
|
|
1897
|
-
const centerPoint = [containerBox.width / 2, containerBox.height / 2];
|
|
1898
|
-
const rootGroupCenterX = rootGroupBox.x + rootGroupBox.width / 2;
|
|
1899
|
-
const rootGroupCenterY = rootGroupBox.y + rootGroupBox.height / 2;
|
|
1900
|
-
const transformedPoint = transformMat3([], [rootGroupCenterX, rootGroupCenterY, 1], matrix);
|
|
1901
|
-
const offsetLeft = centerPoint[0] - transformedPoint[0];
|
|
1902
|
-
const offsetTop = centerPoint[1] - transformedPoint[1];
|
|
1903
|
-
const { autoFitPadding, zoom, scrollLeft, scrollTop } = this.viewportState;
|
|
1904
|
-
const viewportWidth = containerBox.width - 2 * autoFitPadding;
|
|
1905
|
-
const viewportHeight = containerBox.height - 2 * autoFitPadding;
|
|
1906
|
-
let newZoom = zoom;
|
|
1907
|
-
if (viewportWidth < rootGroupBox.width || viewportHeight < rootGroupBox.height) {
|
|
1908
|
-
newZoom = Math.min(viewportWidth / rootGroupBox.width, viewportHeight / rootGroupBox.height);
|
|
1909
|
-
}
|
|
1910
|
-
else {
|
|
1911
|
-
newZoom = 1;
|
|
1912
|
-
}
|
|
1913
|
-
this.setScrollLeft(scrollLeft - offsetLeft);
|
|
1914
|
-
this.setScrollTop(scrollTop - offsetTop);
|
|
1915
|
-
this.calcViewBox(newZoom);
|
|
1916
|
-
this.updateViewBoxStyles();
|
|
1917
|
-
this.updateViewportScrolling();
|
|
1918
|
-
this.setViewport();
|
|
1944
|
+
fitViewport(this.board);
|
|
1919
1945
|
}
|
|
1920
|
-
zoomInHandle() {
|
|
1921
|
-
this.
|
|
1922
|
-
this.updateViewBoxStyles();
|
|
1923
|
-
this.updateViewportScrolling();
|
|
1924
|
-
this.setViewport();
|
|
1946
|
+
zoomInHandle(isCenter = true) {
|
|
1947
|
+
changeZoom(this.board, this.board.viewport.zoom + 0.1, isCenter);
|
|
1925
1948
|
}
|
|
1926
1949
|
zoomOutHandle() {
|
|
1927
|
-
this.
|
|
1928
|
-
this.updateViewBoxStyles();
|
|
1929
|
-
this.updateViewportScrolling();
|
|
1930
|
-
this.setViewport();
|
|
1950
|
+
changeZoom(this.board, this.board.viewport.zoom - 0.1);
|
|
1931
1951
|
}
|
|
1932
1952
|
resetZoomHandel() {
|
|
1933
|
-
this.
|
|
1934
|
-
this.updateViewBoxStyles();
|
|
1935
|
-
this.updateViewportScrolling();
|
|
1936
|
-
this.setViewport();
|
|
1953
|
+
changeZoom(this.board, 1);
|
|
1937
1954
|
}
|
|
1938
1955
|
ngOnDestroy() {
|
|
1939
1956
|
this.destroy$.next();
|
|
1940
1957
|
this.destroy$.complete();
|
|
1941
|
-
|
|
1942
|
-
this.resizeObserver.disconnect();
|
|
1943
|
-
}
|
|
1958
|
+
this.resizeObserver && this.resizeObserver?.disconnect();
|
|
1944
1959
|
BOARD_TO_ROUGH_SVG.delete(this.board);
|
|
1945
1960
|
BOARD_TO_COMPONENT.delete(this.board);
|
|
1946
1961
|
BOARD_TO_ROUGH_SVG.delete(this.board);
|
|
@@ -1951,40 +1966,9 @@ class PlaitBoardComponent {
|
|
|
1951
1966
|
markForCheck() {
|
|
1952
1967
|
this.cdr.markForCheck();
|
|
1953
1968
|
}
|
|
1954
|
-
scrollToRectangle(client) {
|
|
1955
|
-
this.calcViewBox();
|
|
1956
|
-
this.updateViewBoxStyles();
|
|
1957
|
-
this.updateViewportScrolling();
|
|
1958
|
-
this.setViewport();
|
|
1959
|
-
const svgRect = this.host.getBoundingClientRect();
|
|
1960
|
-
const viewportContainerBox = getViewportContainerBox(this.board);
|
|
1961
|
-
if (svgRect.width > viewportContainerBox.width || svgRect.height > viewportContainerBox.height) {
|
|
1962
|
-
const scrollBarWidth = this.plaitOptions?.hideScrollbar ? SCROLL_BAR_WIDTH : 0;
|
|
1963
|
-
const matrix = this.getMatrix();
|
|
1964
|
-
const [nodePointX, nodePointY] = convertToViewportCoordinates([client.x, client.y], matrix);
|
|
1965
|
-
const [fullNodePointX, fullNodePointY] = convertToViewportCoordinates([client.x + client.width, client.y + client.height], matrix);
|
|
1966
|
-
let newLeft = this.viewportState.scrollLeft;
|
|
1967
|
-
let newTop = this.viewportState.scrollTop;
|
|
1968
|
-
if (nodePointX < 0) {
|
|
1969
|
-
newLeft -= Math.abs(nodePointX);
|
|
1970
|
-
}
|
|
1971
|
-
if (nodePointX > 0 && fullNodePointX > viewportContainerBox.width) {
|
|
1972
|
-
newLeft += fullNodePointX - viewportContainerBox.width + scrollBarWidth;
|
|
1973
|
-
}
|
|
1974
|
-
if (nodePointY < 0) {
|
|
1975
|
-
newTop -= Math.abs(nodePointY);
|
|
1976
|
-
}
|
|
1977
|
-
if (nodePointY > 0 && fullNodePointY > viewportContainerBox.height) {
|
|
1978
|
-
newTop += fullNodePointY - viewportContainerBox.height + scrollBarWidth;
|
|
1979
|
-
}
|
|
1980
|
-
if (newLeft !== this.viewportState.scrollLeft || newTop !== this.viewportState.scrollTop) {
|
|
1981
|
-
this.setScroll(newLeft, newTop);
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
1969
|
}
|
|
1986
|
-
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1987
|
-
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1970
|
+
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
1971
|
+
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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.focused": "this.isFocused" } }, 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: `
|
|
1988
1972
|
<div class="viewport-container" #viewportContainer>
|
|
1989
1973
|
<svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
|
|
1990
1974
|
<plait-element
|
|
@@ -2004,8 +1988,8 @@ PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", ve
|
|
|
2004
1988
|
(resetZoomHandel)="resetZoomHandel()"
|
|
2005
1989
|
></plait-toolbar>
|
|
2006
1990
|
<ng-content></ng-content>
|
|
2007
|
-
`, isInline: true,
|
|
2008
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1991
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: PlaitElementComponent, selector: "plait-element", inputs: ["index", "element", "board", "viewport", "selection"] }, { kind: "component", type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: ["board"], outputs: ["adaptHandle", "zoomInHandle", "zoomOutHandle", "resetZoomHandel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1992
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, decorators: [{
|
|
2009
1993
|
type: Component,
|
|
2010
1994
|
args: [{
|
|
2011
1995
|
selector: 'plait-board',
|
|
@@ -2032,7 +2016,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
2032
2016
|
`,
|
|
2033
2017
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2034
2018
|
}]
|
|
2035
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { plaitValue: [{
|
|
2019
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { plaitValue: [{
|
|
2036
2020
|
type: Input
|
|
2037
2021
|
}], plaitViewport: [{
|
|
2038
2022
|
type: Input
|
|
@@ -2050,7 +2034,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
2050
2034
|
}], readonly: [{
|
|
2051
2035
|
type: HostBinding,
|
|
2052
2036
|
args: ['class.readonly']
|
|
2053
|
-
}],
|
|
2037
|
+
}], isFocused: [{
|
|
2054
2038
|
type: HostBinding,
|
|
2055
2039
|
args: ['class.focused']
|
|
2056
2040
|
}], svg: [{
|
|
@@ -2072,11 +2056,6 @@ function hasBeforeContextChange(value) {
|
|
|
2072
2056
|
}
|
|
2073
2057
|
|
|
2074
2058
|
class PlaitPluginElementComponent {
|
|
2075
|
-
constructor(cdr) {
|
|
2076
|
-
this.cdr = cdr;
|
|
2077
|
-
this.initialized = false;
|
|
2078
|
-
this.g = createG();
|
|
2079
|
-
}
|
|
2080
2059
|
set context(value) {
|
|
2081
2060
|
if (hasBeforeContextChange(this)) {
|
|
2082
2061
|
this.beforeContextChange(value);
|
|
@@ -2106,6 +2085,11 @@ class PlaitPluginElementComponent {
|
|
|
2106
2085
|
get board() {
|
|
2107
2086
|
return this.context && this.context.board;
|
|
2108
2087
|
}
|
|
2088
|
+
constructor(cdr) {
|
|
2089
|
+
this.cdr = cdr;
|
|
2090
|
+
this.initialized = false;
|
|
2091
|
+
this.g = createG();
|
|
2092
|
+
}
|
|
2109
2093
|
onContextChange() {
|
|
2110
2094
|
if (!this.initialized) {
|
|
2111
2095
|
return;
|
|
@@ -2123,9 +2107,9 @@ class PlaitPluginElementComponent {
|
|
|
2123
2107
|
this.g.remove();
|
|
2124
2108
|
}
|
|
2125
2109
|
}
|
|
2126
|
-
PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2127
|
-
PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
2128
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2110
|
+
PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2111
|
+
PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
|
|
2112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
|
|
2129
2113
|
type: Directive
|
|
2130
2114
|
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
|
|
2131
2115
|
type: Input
|
|
@@ -2135,10 +2119,10 @@ const ELEMENT_TO_PLUGIN_COMPONENT = new WeakMap();
|
|
|
2135
2119
|
const COMPONENTS = [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent];
|
|
2136
2120
|
class PlaitModule {
|
|
2137
2121
|
}
|
|
2138
|
-
PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2139
|
-
PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
2140
|
-
PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
2141
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2122
|
+
PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2123
|
+
PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent], imports: [BrowserModule], exports: [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent] });
|
|
2124
|
+
PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, imports: [BrowserModule] });
|
|
2125
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, decorators: [{
|
|
2142
2126
|
type: NgModule,
|
|
2143
2127
|
args: [{
|
|
2144
2128
|
declarations: [...COMPONENTS],
|
|
@@ -2147,6 +2131,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
2147
2131
|
}]
|
|
2148
2132
|
}] });
|
|
2149
2133
|
|
|
2134
|
+
function withMoving(board) {
|
|
2135
|
+
const { mousedown, mousemove, globalMouseup, globalMousemove } = board;
|
|
2136
|
+
let offsetX = 0;
|
|
2137
|
+
let offsetY = 0;
|
|
2138
|
+
let isPreventDefault = false;
|
|
2139
|
+
let startPoint;
|
|
2140
|
+
let activeElements = [];
|
|
2141
|
+
board.mousedown = event => {
|
|
2142
|
+
const host = BOARD_TO_HOST.get(board);
|
|
2143
|
+
const point = transformPoint(board, toPoint(event.x, event.y, host));
|
|
2144
|
+
const ranges = [{ anchor: point, focus: point }];
|
|
2145
|
+
let movableElements = board.children.filter(item => PlaitElement.isElement(item) && board.isMovable(item));
|
|
2146
|
+
if (movableElements.length) {
|
|
2147
|
+
startPoint = point;
|
|
2148
|
+
const selectedRootElements = getSelectedElements(board).filter(item => movableElements.includes(item));
|
|
2149
|
+
const intersectionSelectedElement = isIntersectionElements(board, selectedRootElements, ranges);
|
|
2150
|
+
if (intersectionSelectedElement) {
|
|
2151
|
+
activeElements = selectedRootElements;
|
|
2152
|
+
}
|
|
2153
|
+
else {
|
|
2154
|
+
activeElements = movableElements.filter(item => ranges.some(range => {
|
|
2155
|
+
return board.isIntersectionSelection(item, range);
|
|
2156
|
+
}));
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
mousedown(event);
|
|
2160
|
+
};
|
|
2161
|
+
board.mousemove = event => {
|
|
2162
|
+
if (startPoint && activeElements?.length) {
|
|
2163
|
+
if (!isPreventDefault) {
|
|
2164
|
+
isPreventDefault = true;
|
|
2165
|
+
}
|
|
2166
|
+
const host = BOARD_TO_HOST.get(board);
|
|
2167
|
+
const endPoint = transformPoint(board, toPoint(event.x, event.y, host));
|
|
2168
|
+
offsetX = endPoint[0] - startPoint[0];
|
|
2169
|
+
offsetY = endPoint[1] - startPoint[1];
|
|
2170
|
+
throttleRAF(() => {
|
|
2171
|
+
const currentElements = activeElements.map(activeElement => {
|
|
2172
|
+
const [x, y] = activeElement?.points[0];
|
|
2173
|
+
const index = board.children.findIndex(item => item.id === activeElement.id);
|
|
2174
|
+
Transforms.setNode(board, {
|
|
2175
|
+
points: [[x + offsetX, y + offsetY]]
|
|
2176
|
+
}, [index]);
|
|
2177
|
+
MERGING.set(board, true);
|
|
2178
|
+
return PlaitNode.get(board, [index]);
|
|
2179
|
+
});
|
|
2180
|
+
addMovingElements(board, currentElements);
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
if (isPreventDefault) {
|
|
2184
|
+
// 阻止 move 过程中触发画布滚动行为
|
|
2185
|
+
event.preventDefault();
|
|
2186
|
+
}
|
|
2187
|
+
mousemove(event);
|
|
2188
|
+
};
|
|
2189
|
+
board.globalMousemove = event => {
|
|
2190
|
+
if (startPoint) {
|
|
2191
|
+
const inPliatBordElement = isInPlaitBoard(board, event.x, event.y);
|
|
2192
|
+
if (!inPliatBordElement) {
|
|
2193
|
+
cancelMove(board);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
globalMousemove(event);
|
|
2197
|
+
};
|
|
2198
|
+
board.globalMouseup = event => {
|
|
2199
|
+
isPreventDefault = false;
|
|
2200
|
+
if (startPoint) {
|
|
2201
|
+
cancelMove(board);
|
|
2202
|
+
}
|
|
2203
|
+
globalMouseup(event);
|
|
2204
|
+
};
|
|
2205
|
+
function cancelMove(board) {
|
|
2206
|
+
startPoint = null;
|
|
2207
|
+
offsetX = 0;
|
|
2208
|
+
offsetY = 0;
|
|
2209
|
+
activeElements = [];
|
|
2210
|
+
removeMovingElements(board);
|
|
2211
|
+
MERGING.set(board, false);
|
|
2212
|
+
}
|
|
2213
|
+
return board;
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2150
2216
|
/*
|
|
2151
2217
|
* Public API Surface of plait
|
|
2152
2218
|
*/
|
|
@@ -2155,5 +2221,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
2155
2221
|
* Generated bundle index. Do not edit.
|
|
2156
2222
|
*/
|
|
2157
2223
|
|
|
2158
|
-
export { BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BoardTransforms, CLIP_BOARD_FORMAT_KEY, ELEMENT_TO_PLUGIN_COMPONENT, FLUSHING, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MAX_RADIUS, MERGING, NS, Path, PlaitBoard, PlaitBoardComponent, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPointerType, PlaitToolbarComponent, RectangleClient, SAVING, SCROLL_BAR_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, Selection, Transforms, Viewport, addSelectedElement, arrowPoints, cacheSelectedElements, calcElementIntersectionSelection, clampZoomLevel,
|
|
2224
|
+
export { BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SCROLLING, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, CLIP_BOARD_FORMAT_KEY, ELEMENT_TO_PLUGIN_COMPONENT, FLUSHING, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MAX_RADIUS, MERGING, NS, Path, PlaitBoard, PlaitBoardComponent, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPointerType, PlaitToolbarComponent, Point, RectangleClient, SAVING, SCROLL_BAR_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, Selection, Transforms, Viewport, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, calcElementIntersectionSelection, changeZoom, clampZoomLevel, clearSelectionMoving, clearViewportOrigination, clearViewportScrolling, createG, createSVG, createText, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, drawArrow, drawRoundRectangle, fitViewport, getBoardRectangle, getElementHostBBox, getMovingElements, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isInPlaitBoard, isIntersectionElements, isNullOrUndefined, isSelectedElement, isSelectionMoving, isSetViewportOperation, isViewportScrolling, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setSVGViewBox, setSelectionMoving, setViewport, setViewportScrolling, shouldClear, shouldMerge, shouldSave, throttleRAF, toPoint, transformPoint, transformPoints, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withSelection };
|
|
2159
2225
|
//# sourceMappingURL=plait-core.mjs.map
|