@meta2d/core 1.0.16 → 1.0.17

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.
@@ -86,7 +86,7 @@ import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldR
86
86
  import { calcRotate, distance, hitPoint, PrevNextType, rotatePoint, samePoint, scalePoint, translatePoint, TwoWay, } from '../point';
87
87
  import { calcCenter, calcRightBottom, calcRelativePoint, getRect, getRectOfPoints, pointInRect, pointInSimpleRect, rectInRect, rectToPoints, resizeRect, translateRect, } from '../rect';
88
88
  import { EditType, globalStore, } from '../store';
89
- import { deepClone, fileToBase64, uploadFile, formatPadding, isMobile, rgba, s8, } from '../utils';
89
+ import { deepClone, fileToBase64, uploadFile, formatPadding, rgba, s8, } from '../utils';
90
90
  import { inheritanceProps, defaultCursors, defaultDrawLineFns, HotkeyType, HoverType, MouseRight, rotatedCursors, } from '../data';
91
91
  import { createOffscreen } from './offscreen';
92
92
  import { curve, mind, getLineLength, getLineRect, pointInLine, simplify, smoothLine, lineSegment, getLineR, lineInRect, } from '../diagrams';
@@ -97,6 +97,7 @@ import { CanvasImage } from './canvasImage';
97
97
  import { MagnifierCanvas } from './magnifierCanvas';
98
98
  import { lockedError } from '../utils/error';
99
99
  import { Dialog } from '../dialog';
100
+ import { setter } from '../utils/object';
100
101
  export var movingSuffix = '-moving';
101
102
  var Canvas = /** @class */ (function () {
102
103
  function Canvas(parent, parentElement, store) {
@@ -123,6 +124,7 @@ var Canvas = /** @class */ (function () {
123
124
  this.animateRendering = false;
124
125
  this.pointSize = 8;
125
126
  this.pasteOffset = 10;
127
+ this.opening = false;
126
128
  this.inputParent = document.createElement('div');
127
129
  // input = document.createElement('textarea');
128
130
  this.inputDiv = document.createElement('div');
@@ -247,57 +249,25 @@ var Canvas = /** @class */ (function () {
247
249
  return;
248
250
  if (_this.store.data.locked === LockState.DisableMoveScale)
249
251
  return;
250
- //禁止触摸屏双指缩放操作
251
- if (_this.store.options.disableTouchPadScale &&
252
- e.ctrlKey &&
253
- e.deltaY !== 0) {
254
- return;
255
- }
256
- //window触控板只允许平移 触摸屏一般不超过100
257
- var isWin = navigator.userAgent.indexOf('Win') !== -1;
258
- if (isWin && !e.ctrlKey && Math.abs(e.deltaY) < 100) {
259
- _this.translate(-e.deltaX, -e.deltaY);
260
- return;
261
- }
262
- //mac触控板只允许平移(排除普通鼠标的情况)
263
- var isMac = /macintosh|mac os x/i.test(navigator.userAgent) ||
264
- navigator.platform.indexOf('Mac') !== -1;
265
- if (isMac && !e.ctrlKey && e.wheelDeltaY % 240 !== 0) {
252
+ // e.ctrlKey: false - 平移; true - 缩放。老windows触摸板不支持
253
+ if (!e.ctrlKey) {
254
+ if (_this.store.options.scroll && !e.metaKey && _this.scroll) {
255
+ _this.scroll.wheel(e.deltaY < 0);
256
+ return;
257
+ }
266
258
  _this.translate(-e.deltaX, -e.deltaY);
267
259
  return;
268
260
  }
269
- if (_this.store.options.scroll && !e.ctrlKey && !e.metaKey && _this.scroll) {
270
- _this.scroll.wheel(e.deltaY < 0);
271
- return;
272
- }
273
- // 触摸板平移
274
- var isTouchPad = !(!e.deltaX && e.deltaY);
275
- var now = performance.now();
276
- var _scale = 0.1;
277
- if (now - _this.touchStart < 50) {
261
+ //禁止触摸屏双指缩放操作
262
+ if (_this.store.options.disableTouchPadScale) {
278
263
  return;
279
264
  }
280
- if (now - _this.touchStart < 100) {
281
- _scale = 0.5;
282
- }
283
- else if (now - _this.touchStart < 200) {
284
- _scale = 0.3;
285
- }
286
- else {
287
- _scale = 0.1;
288
- }
289
- _this.touchStart = now;
290
265
  var x = e.offsetX, y = e.offsetY;
291
- if (isTouchPad) {
292
- _this.translate(e.deltaX, e.deltaY);
266
+ if (e.deltaY < 0) {
267
+ _this.scale(_this.store.data.scale + 0.015, { x: x, y: y });
293
268
  }
294
269
  else {
295
- if (e.deltaY < 0) {
296
- _this.scale(_this.store.data.scale + _scale, { x: x, y: y });
297
- }
298
- else {
299
- _this.scale(_this.store.data.scale - _scale, { x: x, y: y });
300
- }
270
+ _this.scale(_this.store.data.scale - 0.015, { x: x, y: y });
301
271
  }
302
272
  _this.externalElements.focus(); // 聚焦
303
273
  };
@@ -782,7 +752,9 @@ var Canvas = /** @class */ (function () {
782
752
  altKey: event.altKey,
783
753
  buttons: 1,
784
754
  });
785
- _this.render();
755
+ setTimeout(function () {
756
+ _this.render();
757
+ }, 20);
786
758
  };
787
759
  this.onGesturestart = function (e) {
788
760
  e.preventDefault();
@@ -1461,6 +1433,7 @@ var Canvas = /** @class */ (function () {
1461
1433
  _this.clearDock();
1462
1434
  _this.dragRect = undefined;
1463
1435
  _this.initActiveRect = undefined;
1436
+ _this.render();
1464
1437
  };
1465
1438
  this.clearDock = function () {
1466
1439
  var _a, _b, _c, _d;
@@ -1809,6 +1782,12 @@ var Canvas = /** @class */ (function () {
1809
1782
  }
1810
1783
  };
1811
1784
  this.render = function (patchFlags) {
1785
+ if (patchFlags) {
1786
+ _this.opening = false;
1787
+ }
1788
+ if (_this.opening) {
1789
+ return;
1790
+ }
1812
1791
  var now;
1813
1792
  if (patchFlags == null || patchFlags === true || patchFlags === Infinity) {
1814
1793
  now = performance.now();
@@ -2322,7 +2301,7 @@ var Canvas = /** @class */ (function () {
2322
2301
  var _textWidth = null;
2323
2302
  if (pen.textWidth) {
2324
2303
  _textWidth =
2325
- (pen.textWidth < 1 && pen.textWidth) > -1
2304
+ pen.textWidth < 1 && pen.textWidth > -1
2326
2305
  ? pen.textWidth * pen.calculative.worldRect.width
2327
2306
  : pen.textWidth;
2328
2307
  if (pen.whiteSpace !== 'pre-line') {
@@ -2563,66 +2542,62 @@ var Canvas = /** @class */ (function () {
2563
2542
  this.externalElements.ondragover = function (e) { return e.preventDefault(); };
2564
2543
  this.externalElements.ondrop = this.ondrop;
2565
2544
  this.externalElements.oncontextmenu = function (e) { return e.preventDefault(); };
2566
- if (isMobile()) {
2567
- this.store.options.interval = 50;
2568
- this.externalElements.ontouchstart = this.ontouchstart;
2569
- this.externalElements.ontouchmove = this.ontouchmove;
2570
- this.externalElements.ontouchend = this.ontouchend;
2571
- }
2572
- else {
2573
- this.externalElements.onmousedown = function (e) {
2574
- _this.onMouseDown({
2575
- x: e.offsetX,
2576
- y: e.offsetY,
2577
- clientX: e.clientX,
2578
- clientY: e.clientY,
2579
- pageX: e.pageX,
2580
- pageY: e.pageY,
2581
- ctrlKey: e.ctrlKey || e.metaKey,
2582
- shiftKey: e.shiftKey,
2583
- altKey: e.altKey,
2584
- buttons: e.buttons,
2585
- });
2586
- };
2587
- this.externalElements.onmousemove = function (e) {
2588
- if (e.target !== _this.externalElements) {
2589
- return;
2590
- }
2591
- _this.onMouseMove({
2592
- x: e.offsetX,
2593
- y: e.offsetY,
2594
- clientX: e.clientX,
2595
- clientY: e.clientY,
2596
- pageX: e.pageX,
2597
- pageY: e.pageY,
2598
- ctrlKey: e.ctrlKey || e.metaKey,
2599
- shiftKey: e.shiftKey,
2600
- altKey: e.altKey,
2601
- buttons: e.buttons,
2602
- });
2603
- };
2604
- this.externalElements.onmouseup = function (e) {
2605
- _this.onMouseUp({
2606
- x: e.offsetX,
2607
- y: e.offsetY,
2608
- clientX: e.clientX,
2609
- clientY: e.clientY,
2610
- pageX: e.pageX,
2611
- pageY: e.pageY,
2612
- ctrlKey: e.ctrlKey || e.metaKey,
2613
- shiftKey: e.shiftKey,
2614
- altKey: e.altKey,
2615
- buttons: e.buttons,
2616
- button: e.button,
2617
- });
2618
- };
2619
- this.externalElements.onmouseleave = function (e) {
2620
- if (e.toElement !== _this.tooltip.box) {
2621
- _this.tooltip.hide();
2622
- _this.store.lastHover = undefined;
2623
- }
2624
- };
2625
- }
2545
+ this.store.options.interval = 50;
2546
+ this.externalElements.ontouchstart = this.ontouchstart;
2547
+ this.externalElements.ontouchmove = this.ontouchmove;
2548
+ this.externalElements.ontouchend = this.ontouchend;
2549
+ this.externalElements.onmousedown = function (e) {
2550
+ _this.onMouseDown({
2551
+ x: e.offsetX,
2552
+ y: e.offsetY,
2553
+ clientX: e.clientX,
2554
+ clientY: e.clientY,
2555
+ pageX: e.pageX,
2556
+ pageY: e.pageY,
2557
+ ctrlKey: e.ctrlKey || e.metaKey,
2558
+ shiftKey: e.shiftKey,
2559
+ altKey: e.altKey,
2560
+ buttons: e.buttons,
2561
+ });
2562
+ };
2563
+ this.externalElements.onmousemove = function (e) {
2564
+ if (e.target !== _this.externalElements) {
2565
+ return;
2566
+ }
2567
+ _this.onMouseMove({
2568
+ x: e.offsetX,
2569
+ y: e.offsetY,
2570
+ clientX: e.clientX,
2571
+ clientY: e.clientY,
2572
+ pageX: e.pageX,
2573
+ pageY: e.pageY,
2574
+ ctrlKey: e.ctrlKey || e.metaKey,
2575
+ shiftKey: e.shiftKey,
2576
+ altKey: e.altKey,
2577
+ buttons: e.buttons,
2578
+ });
2579
+ };
2580
+ this.externalElements.onmouseup = function (e) {
2581
+ _this.onMouseUp({
2582
+ x: e.offsetX,
2583
+ y: e.offsetY,
2584
+ clientX: e.clientX,
2585
+ clientY: e.clientY,
2586
+ pageX: e.pageX,
2587
+ pageY: e.pageY,
2588
+ ctrlKey: e.ctrlKey || e.metaKey,
2589
+ shiftKey: e.shiftKey,
2590
+ altKey: e.altKey,
2591
+ buttons: e.buttons,
2592
+ button: e.button,
2593
+ });
2594
+ };
2595
+ this.externalElements.onmouseleave = function (e) {
2596
+ if (e.toElement !== _this.tooltip.box) {
2597
+ _this.tooltip.hide();
2598
+ _this.store.lastHover = undefined;
2599
+ }
2600
+ };
2626
2601
  this.externalElements.ondblclick = this.ondblclick;
2627
2602
  this.externalElements.tabIndex = 0;
2628
2603
  this.externalElements.onblur = function () {
@@ -2759,10 +2734,10 @@ var Canvas = /** @class */ (function () {
2759
2734
  };
2760
2735
  Canvas.prototype.dropPens = function (pens, e) {
2761
2736
  return __awaiter(this, void 0, void 0, function () {
2762
- var pens_2, pens_2_1, pen, pens_3, pens_3_1, pen, pens_4, pens_4_1, pen;
2763
- var e_8, _a, e_9, _b, e_10, _c;
2764
- return __generator(this, function (_d) {
2765
- switch (_d.label) {
2737
+ var pens_2, pens_2_1, pen, pens_3, pens_3_1, pen, pens_4, pens_4_1, pen, width, height, rect_1, flag, pens_5, pens_5_1, pen, points;
2738
+ var e_8, _a, e_9, _b, e_10, _c, e_11, _d;
2739
+ return __generator(this, function (_e) {
2740
+ switch (_e.label) {
2766
2741
  case 0:
2767
2742
  try {
2768
2743
  for (pens_2 = __values(pens), pens_2_1 = pens_2.next(); !pens_2_1.done; pens_2_1 = pens_2.next()) {
@@ -2819,9 +2794,48 @@ var Canvas = /** @class */ (function () {
2819
2794
  }
2820
2795
  finally { if (e_10) throw e_10.error; }
2821
2796
  }
2797
+ width = this.store.data.width || this.store.options.width;
2798
+ height = this.store.data.height || this.store.options.height;
2799
+ if (width && height) {
2800
+ rect_1 = {
2801
+ x: this.store.data.origin.x,
2802
+ y: this.store.data.origin.y,
2803
+ width: width * this.store.data.scale,
2804
+ height: height * this.store.data.scale,
2805
+ };
2806
+ flag = true;
2807
+ try {
2808
+ for (pens_5 = __values(pens), pens_5_1 = pens_5.next(); !pens_5_1.done; pens_5_1 = pens_5.next()) {
2809
+ pen = pens_5_1.value;
2810
+ if (!pen.parentId) {
2811
+ points = [
2812
+ { x: pen.x, y: pen.y },
2813
+ { x: pen.x + pen.width, y: pen.y },
2814
+ { x: pen.x, y: pen.y + pen.height },
2815
+ { x: pen.x + pen.width, y: pen.y + pen.height },
2816
+ ];
2817
+ if (points.some(function (point) { return pointInRect(point, rect_1); })) {
2818
+ flag = false;
2819
+ break;
2820
+ }
2821
+ }
2822
+ }
2823
+ }
2824
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
2825
+ finally {
2826
+ try {
2827
+ if (pens_5_1 && !pens_5_1.done && (_d = pens_5.return)) _d.call(pens_5);
2828
+ }
2829
+ finally { if (e_11) throw e_11.error; }
2830
+ }
2831
+ if (flag) {
2832
+ console.info('画笔在大屏范围外');
2833
+ return [2 /*return*/];
2834
+ }
2835
+ }
2822
2836
  return [4 /*yield*/, this.addPens(pens, true)];
2823
2837
  case 1:
2824
- _d.sent();
2838
+ _e.sent();
2825
2839
  this.active(pens.filter(function (pen) { return !pen.parentId; }));
2826
2840
  this.render();
2827
2841
  this.externalElements.focus(); // 聚焦
@@ -2831,7 +2845,7 @@ var Canvas = /** @class */ (function () {
2831
2845
  });
2832
2846
  };
2833
2847
  Canvas.prototype.randomCombineId = function (pen, pens, parentId) {
2834
- var e_11, _a;
2848
+ var e_12, _a;
2835
2849
  randomId(pen);
2836
2850
  pen.parentId = parentId;
2837
2851
  var newChildren = [];
@@ -2848,12 +2862,12 @@ var Canvas = /** @class */ (function () {
2848
2862
  _loop_4(childId);
2849
2863
  }
2850
2864
  }
2851
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
2865
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
2852
2866
  finally {
2853
2867
  try {
2854
2868
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2855
2869
  }
2856
- finally { if (e_11) throw e_11.error; }
2870
+ finally { if (e_12) throw e_12.error; }
2857
2871
  }
2858
2872
  }
2859
2873
  pen.children = newChildren;
@@ -2861,8 +2875,8 @@ var Canvas = /** @class */ (function () {
2861
2875
  };
2862
2876
  Canvas.prototype.addPens = function (pens, history) {
2863
2877
  return __awaiter(this, void 0, void 0, function () {
2864
- var _a, list, pens_5, pens_5_1, pen;
2865
- var e_12, _b;
2878
+ var _a, list, pens_6, pens_6_1, pen;
2879
+ var e_13, _b;
2866
2880
  return __generator(this, function (_c) {
2867
2881
  switch (_c.label) {
2868
2882
  case 0:
@@ -2878,8 +2892,8 @@ var Canvas = /** @class */ (function () {
2878
2892
  }
2879
2893
  list = [];
2880
2894
  try {
2881
- for (pens_5 = __values(pens), pens_5_1 = pens_5.next(); !pens_5_1.done; pens_5_1 = pens_5.next()) {
2882
- pen = pens_5_1.value;
2895
+ for (pens_6 = __values(pens), pens_6_1 = pens_6.next(); !pens_6_1.done; pens_6_1 = pens_6.next()) {
2896
+ pen = pens_6_1.value;
2883
2897
  if (this.beforeAddPen && this.beforeAddPen(pen) != true) {
2884
2898
  continue;
2885
2899
  }
@@ -2887,12 +2901,12 @@ var Canvas = /** @class */ (function () {
2887
2901
  list.push(pen);
2888
2902
  }
2889
2903
  }
2890
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
2904
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
2891
2905
  finally {
2892
2906
  try {
2893
- if (pens_5_1 && !pens_5_1.done && (_b = pens_5.return)) _b.call(pens_5);
2907
+ if (pens_6_1 && !pens_6_1.done && (_b = pens_6.return)) _b.call(pens_6);
2894
2908
  }
2895
- finally { if (e_12) throw e_12.error; }
2909
+ finally { if (e_13) throw e_13.error; }
2896
2910
  }
2897
2911
  this.render();
2898
2912
  this.store.emitter.emit('add', list);
@@ -3158,7 +3172,7 @@ var Canvas = /** @class */ (function () {
3158
3172
  this.patchFlags = true;
3159
3173
  };
3160
3174
  Canvas.prototype.active = function (pens, emit) {
3161
- var e_13, _a, _b;
3175
+ var e_14, _a, _b;
3162
3176
  if (emit === void 0) { emit = true; }
3163
3177
  if (this.store.active) {
3164
3178
  try {
@@ -3168,12 +3182,12 @@ var Canvas = /** @class */ (function () {
3168
3182
  setChildrenActive(pen, false);
3169
3183
  }
3170
3184
  }
3171
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
3185
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
3172
3186
  finally {
3173
3187
  try {
3174
3188
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
3175
3189
  }
3176
- finally { if (e_13) throw e_13.error; }
3190
+ finally { if (e_14) throw e_14.error; }
3177
3191
  }
3178
3192
  }
3179
3193
  this.store.active = [];
@@ -3312,18 +3326,6 @@ var Canvas = /** @class */ (function () {
3312
3326
  }
3313
3327
  this.store.hoverAnchor = anchor;
3314
3328
  this.store.hover = pen;
3315
- // if (pen.name === 'line' && anchor.connectTo) {
3316
- // const connectPen = this.findOne(anchor.connectTo);
3317
- // if (!connectPen.calculative.active) {
3318
- // this.store.hover = connectPen;
3319
- // const connectAnchor = connectPen.calculative.worldAnchors.find(
3320
- // (item) => item.id === anchor.anchorId
3321
- // );
3322
- // this.store.hoverAnchor = connectAnchor;
3323
- // console.log('hover', connectAnchor);
3324
- // }
3325
- // }
3326
- // console.log('hover', pen, anchor);
3327
3329
  if (pen.type) {
3328
3330
  if (anchor.connectTo && !pen.calculative.active) {
3329
3331
  this.store.hover = this.store.pens[anchor.connectTo];
@@ -3371,7 +3373,7 @@ var Canvas = /** @class */ (function () {
3371
3373
  return HoverType.None;
3372
3374
  };
3373
3375
  Canvas.prototype.resize = function (w, h) {
3374
- var e_14, _a;
3376
+ var e_15, _a;
3375
3377
  w = w || this.parentElement.clientWidth;
3376
3378
  h = h || this.parentElement.clientHeight;
3377
3379
  this.width = w;
@@ -3412,12 +3414,12 @@ var Canvas = /** @class */ (function () {
3412
3414
  calcInView(pen);
3413
3415
  }
3414
3416
  }
3415
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
3417
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
3416
3418
  finally {
3417
3419
  try {
3418
3420
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3419
3421
  }
3420
- finally { if (e_14) throw e_14.error; }
3422
+ finally { if (e_15) throw e_15.error; }
3421
3423
  }
3422
3424
  };
3423
3425
  Canvas.prototype.clearCanvas = function () {
@@ -3482,7 +3484,7 @@ var Canvas = /** @class */ (function () {
3482
3484
  this.store.histories.splice(this.store.historyIndex + 1, this.store.histories.length - this.store.historyIndex - 1);
3483
3485
  }
3484
3486
  (_a = action.pens) === null || _a === void 0 ? void 0 : _a.forEach(function (pen) {
3485
- var e_15, _a;
3487
+ var e_16, _a;
3486
3488
  var found;
3487
3489
  if (action.initPens) {
3488
3490
  try {
@@ -3493,12 +3495,12 @@ var Canvas = /** @class */ (function () {
3493
3495
  }
3494
3496
  }
3495
3497
  }
3496
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
3498
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
3497
3499
  finally {
3498
3500
  try {
3499
3501
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3500
3502
  }
3501
- finally { if (e_15) throw e_15.error; }
3503
+ finally { if (e_16) throw e_16.error; }
3502
3504
  }
3503
3505
  }
3504
3506
  if (found) {
@@ -3556,11 +3558,11 @@ var Canvas = /** @class */ (function () {
3556
3558
  var _this = this;
3557
3559
  var before = this.store.histories[this.store.historyIndex];
3558
3560
  if (before && before.type === EditType.Add) {
3559
- var pens_6 = [];
3561
+ var pens_7 = [];
3560
3562
  before.pens.forEach(function (pen) {
3561
- pens_6.push(_this.store.pens[pen.id]);
3563
+ pens_7.push(_this.store.pens[pen.id]);
3562
3564
  });
3563
- this.active(pens_6);
3565
+ this.active(pens_7);
3564
3566
  }
3565
3567
  };
3566
3568
  Canvas.prototype.doEditAction = function (action, undo) {
@@ -3953,7 +3955,10 @@ var Canvas = /** @class */ (function () {
3953
3955
  }
3954
3956
  else {
3955
3957
  var img_1 = new Image();
3956
- img_1.crossOrigin = 'anonymous';
3958
+ img_1.crossOrigin =
3959
+ pen.crossOrigin === 'undefined'
3960
+ ? undefined
3961
+ : pen.crossOrigin || 'anonymous';
3957
3962
  img_1.src = pen.image;
3958
3963
  if (this.store.options.cdn &&
3959
3964
  !(pen.image.startsWith('http') ||
@@ -3962,6 +3967,7 @@ var Canvas = /** @class */ (function () {
3962
3967
  img_1.src = this.store.options.cdn + pen.image;
3963
3968
  }
3964
3969
  img_1.onload = function () {
3970
+ // TODO: 连续的加载两张图片,若后开始加载 的图片先加载完成,可能会导致展示的是 先开始加载的图片
3965
3971
  pen.calculative.img = img_1;
3966
3972
  pen.calculative.imgNaturalWidth =
3967
3973
  img_1.naturalWidth || pen.iconWidth;
@@ -4142,7 +4148,7 @@ var Canvas = /** @class */ (function () {
4142
4148
  this.onMovePens();
4143
4149
  };
4144
4150
  Canvas.prototype.onMovePens = function () {
4145
- var e_16, _a;
4151
+ var e_17, _a;
4146
4152
  var _b;
4147
4153
  var map = this.parent.map;
4148
4154
  if (map && map.isShow) {
@@ -4167,12 +4173,12 @@ var Canvas = /** @class */ (function () {
4167
4173
  }
4168
4174
  }
4169
4175
  }
4170
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
4176
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
4171
4177
  finally {
4172
4178
  try {
4173
4179
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
4174
4180
  }
4175
- finally { if (e_16) throw e_16.error; }
4181
+ finally { if (e_17) throw e_17.error; }
4176
4182
  }
4177
4183
  };
4178
4184
  /**
@@ -4232,7 +4238,7 @@ var Canvas = /** @class */ (function () {
4232
4238
  });
4233
4239
  };
4234
4240
  Canvas.prototype.rotatePens = function (e) {
4235
- var e_17, _a;
4241
+ var e_18, _a;
4236
4242
  var _this = this;
4237
4243
  if (!this.initPens) {
4238
4244
  this.initPens = deepClone(this.getAllByPens(this.store.active));
@@ -4259,12 +4265,12 @@ var Canvas = /** @class */ (function () {
4259
4265
  this.updateLines(pen);
4260
4266
  }
4261
4267
  }
4262
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
4268
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
4263
4269
  finally {
4264
4270
  try {
4265
4271
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4266
4272
  }
4267
- finally { if (e_17) throw e_17.error; }
4273
+ finally { if (e_18) throw e_18.error; }
4268
4274
  }
4269
4275
  this.lastRotate = this.activeRect.rotate;
4270
4276
  this.getSizeCPs();
@@ -5128,7 +5134,7 @@ var Canvas = /** @class */ (function () {
5128
5134
  return;
5129
5135
  }
5130
5136
  requestAnimationFrame(function () {
5131
- var e_18, _a;
5137
+ var e_19, _a;
5132
5138
  var now = Date.now();
5133
5139
  if (now - _this.lastAnimateRender < _this.store.options.animateInterval) {
5134
5140
  if (_this.store.animates.size > 0) {
@@ -5213,12 +5219,12 @@ var Canvas = /** @class */ (function () {
5213
5219
  _loop_5(pen);
5214
5220
  }
5215
5221
  }
5216
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
5222
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
5217
5223
  finally {
5218
5224
  try {
5219
5225
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
5220
5226
  }
5221
- finally { if (e_18) throw e_18.error; }
5227
+ finally { if (e_19) throw e_19.error; }
5222
5228
  }
5223
5229
  if (active) {
5224
5230
  _this.calcActiveRect();
@@ -5301,7 +5307,7 @@ var Canvas = /** @class */ (function () {
5301
5307
  var _a;
5302
5308
  return __awaiter(this, void 0, void 0, function () {
5303
5309
  var clipboardText, clipboard, _b, _c, offset, pos, curPage, rootPens, rootPens_1, rootPens_1_1, pen;
5304
- var e_19, _d;
5310
+ var e_20, _d;
5305
5311
  return __generator(this, function (_e) {
5306
5312
  switch (_e.label) {
5307
5313
  case 0:
@@ -5370,12 +5376,12 @@ var Canvas = /** @class */ (function () {
5370
5376
  this.pastePen(pen, undefined);
5371
5377
  }
5372
5378
  }
5373
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
5379
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
5374
5380
  finally {
5375
5381
  try {
5376
5382
  if (rootPens_1_1 && !rootPens_1_1.done && (_d = rootPens_1.return)) _d.call(rootPens_1);
5377
5383
  }
5378
- finally { if (e_19) throw e_19.error; }
5384
+ finally { if (e_20) throw e_20.error; }
5379
5385
  }
5380
5386
  sessionStorage.setItem('page', clipboard.page);
5381
5387
  this.active(rootPens);
@@ -5392,20 +5398,20 @@ var Canvas = /** @class */ (function () {
5392
5398
  * @param pens 不包含子节点
5393
5399
  */
5394
5400
  Canvas.prototype.getAllByPens = function (pens) {
5395
- var e_20, _a;
5401
+ var e_21, _a;
5396
5402
  var retPens = [];
5397
5403
  try {
5398
- for (var pens_7 = __values(pens), pens_7_1 = pens_7.next(); !pens_7_1.done; pens_7_1 = pens_7.next()) {
5399
- var pen = pens_7_1.value;
5404
+ for (var pens_8 = __values(pens), pens_8_1 = pens_8.next(); !pens_8_1.done; pens_8_1 = pens_8.next()) {
5405
+ var pen = pens_8_1.value;
5400
5406
  retPens.push.apply(retPens, __spreadArray([], __read(deepClone(getAllChildren(pen, this.store), true)), false));
5401
5407
  }
5402
5408
  }
5403
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
5409
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
5404
5410
  finally {
5405
5411
  try {
5406
- if (pens_7_1 && !pens_7_1.done && (_a = pens_7.return)) _a.call(pens_7);
5412
+ if (pens_8_1 && !pens_8_1.done && (_a = pens_8.return)) _a.call(pens_8);
5407
5413
  }
5408
- finally { if (e_20) throw e_20.error; }
5414
+ finally { if (e_21) throw e_21.error; }
5409
5415
  }
5410
5416
  return retPens.concat(pens);
5411
5417
  };
@@ -5448,7 +5454,7 @@ var Canvas = /** @class */ (function () {
5448
5454
  * @param pastePens 此处复制的全部 pens (包含子节点)
5449
5455
  */
5450
5456
  Canvas.prototype.changeNodeConnectedLine = function (oldId, line, pastePens) {
5451
- var e_21, _a;
5457
+ var e_22, _a;
5452
5458
  var _b;
5453
5459
  var from = line.anchors[0];
5454
5460
  var to = line.anchors[line.anchors.length - 1];
@@ -5484,12 +5490,12 @@ var Canvas = /** @class */ (function () {
5484
5490
  _loop_7(anchor);
5485
5491
  }
5486
5492
  }
5487
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
5493
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
5488
5494
  finally {
5489
5495
  try {
5490
5496
  if (anchors_1_1 && !anchors_1_1.done && (_a = anchors_1.return)) _a.call(anchors_1);
5491
5497
  }
5492
- finally { if (e_21) throw e_21.error; }
5498
+ finally { if (e_22) throw e_22.error; }
5493
5499
  }
5494
5500
  };
5495
5501
  Canvas.prototype.delete = function (pens, canDelLocked, history) {
@@ -5871,6 +5877,10 @@ var Canvas = /** @class */ (function () {
5871
5877
  if (k === 'image') {
5872
5878
  willRenderImage = true;
5873
5879
  }
5880
+ if (k.indexOf('.') !== -1) {
5881
+ delete pen[k];
5882
+ setter(pen, k, data[k]);
5883
+ }
5874
5884
  }
5875
5885
  this.setCalculativeByScale(pen); // 该方法计算量并不大,所以每次修改都计算一次
5876
5886
  if (isChangedName) {
@@ -5999,7 +6009,7 @@ var Canvas = /** @class */ (function () {
5999
6009
  };
6000
6010
  };
6001
6011
  Canvas.prototype.toPng = function (padding, callback, containBkImg) {
6002
- var e_22, _a;
6012
+ var e_23, _a;
6003
6013
  if (padding === void 0) { padding = 2; }
6004
6014
  if (containBkImg === void 0) { containBkImg = false; }
6005
6015
  var rect = getRect(this.store.data.pens);
@@ -6087,12 +6097,12 @@ var Canvas = /** @class */ (function () {
6087
6097
  pen.calculative.active = active;
6088
6098
  }
6089
6099
  }
6090
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
6100
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
6091
6101
  finally {
6092
6102
  try {
6093
6103
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
6094
6104
  }
6095
- finally { if (e_22) throw e_22.error; }
6105
+ finally { if (e_23) throw e_23.error; }
6096
6106
  }
6097
6107
  if (callback) {
6098
6108
  canvas.toBlob(callback);
@@ -6232,17 +6242,13 @@ var Canvas = /** @class */ (function () {
6232
6242
  this.externalElements.removeEventListener('gesturestart', this.onGesturestart);
6233
6243
  this.externalElements.ondragover = function (e) { return e.preventDefault(); };
6234
6244
  this.externalElements.ondrop = undefined;
6235
- if (isMobile()) {
6236
- this.externalElements.ontouchstart = undefined;
6237
- this.externalElements.ontouchmove = undefined;
6238
- this.externalElements.ontouchend = undefined;
6239
- }
6240
- else {
6241
- this.externalElements.onmousedown = undefined;
6242
- this.externalElements.onmousemove = undefined;
6243
- this.externalElements.onmouseup = undefined;
6244
- this.externalElements.onmouseleave = undefined;
6245
- }
6245
+ this.externalElements.ontouchstart = undefined;
6246
+ this.externalElements.ontouchmove = undefined;
6247
+ this.externalElements.ontouchend = undefined;
6248
+ this.externalElements.onmousedown = undefined;
6249
+ this.externalElements.onmousemove = undefined;
6250
+ this.externalElements.onmouseup = undefined;
6251
+ this.externalElements.onmouseleave = undefined;
6246
6252
  this.externalElements.ondblclick = undefined;
6247
6253
  switch (this.store.options.keydown) {
6248
6254
  case KeydownType.Document: