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