@meta2d/core 1.0.27 → 1.0.29
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +17 -0
- package/src/canvas/canvas.js +150 -8
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.d.ts +0 -1
- package/src/canvas/canvasImage.js +94 -65
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/canvas/canvasTemplate.d.ts +19 -0
- package/src/canvas/canvasTemplate.js +194 -0
- package/src/canvas/canvasTemplate.js.map +1 -0
- package/src/core.d.ts +10 -1
- package/src/core.js +84 -10
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.js +97 -5
- package/src/diagrams/iframe.js.map +1 -1
- package/src/diagrams/line/polyline.js +1 -0
- package/src/diagrams/line/polyline.js.map +1 -1
- package/src/pen/model.d.ts +2 -1
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +1 -1
- package/src/store/store.d.ts +7 -2
- package/src/store/store.js +36 -1
- package/src/store/store.js.map +1 -1
- package/src/utils/index.d.ts +2 -0
- package/src/utils/index.js +2 -0
- package/src/utils/index.js.map +1 -1
- package/src/utils/url.d.ts +1 -0
- package/src/utils/url.js +20 -0
- package/src/utils/url.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { MagnifierCanvas } from './magnifierCanvas';
|
|
|
13
13
|
import { Meta2d } from '../core';
|
|
14
14
|
import { Dialog } from '../dialog';
|
|
15
15
|
import { Title } from '../title';
|
|
16
|
+
import { CanvasTemplate } from './canvasTemplate';
|
|
16
17
|
export declare const movingSuffix: "-moving";
|
|
17
18
|
export declare class Canvas {
|
|
18
19
|
parent: Meta2d;
|
|
@@ -104,6 +105,7 @@ export declare class Canvas {
|
|
|
104
105
|
mousePos: Point;
|
|
105
106
|
scroll: Scroll;
|
|
106
107
|
movingAnchor: Point;
|
|
108
|
+
canvasTemplate: CanvasTemplate;
|
|
107
109
|
canvasImage: CanvasImage;
|
|
108
110
|
canvasImageBottom: CanvasImage;
|
|
109
111
|
magnifierCanvas: MagnifierCanvas;
|
|
@@ -200,6 +202,7 @@ export declare class Canvas {
|
|
|
200
202
|
* @param pens 本次改变的 pens
|
|
201
203
|
*/
|
|
202
204
|
initImageCanvas(pens: Pen[]): void;
|
|
205
|
+
initTemplateCanvas(pens: Pen[]): void;
|
|
203
206
|
private hasImage;
|
|
204
207
|
private clearDock;
|
|
205
208
|
inactive(drawing?: boolean): void;
|
|
@@ -238,6 +241,8 @@ export declare class Canvas {
|
|
|
238
241
|
loadImage(pen: Pen): void;
|
|
239
242
|
private imageTimer;
|
|
240
243
|
imageLoaded(): void;
|
|
244
|
+
private templateImageTimer;
|
|
245
|
+
templateImageLoaded(): void;
|
|
241
246
|
setCalculativeByScale(pen: Pen): void;
|
|
242
247
|
updatePenRect(pen: Pen, { worldRectIsReady, playingAnimate, }?: {
|
|
243
248
|
worldRectIsReady?: boolean;
|
|
@@ -260,6 +265,10 @@ export declare class Canvas {
|
|
|
260
265
|
x: number;
|
|
261
266
|
y: number;
|
|
262
267
|
}): void;
|
|
268
|
+
templateScale(scale: number, center?: {
|
|
269
|
+
x: number;
|
|
270
|
+
y: number;
|
|
271
|
+
}): void;
|
|
263
272
|
rotatePens(e: Point): void;
|
|
264
273
|
resizePens(e: Point): void;
|
|
265
274
|
movePens(e: {
|
|
@@ -315,6 +324,14 @@ export declare class Canvas {
|
|
|
315
324
|
* @param doing 是否持续移动
|
|
316
325
|
*/
|
|
317
326
|
translatePens(pens: Pen[], x: number, y: number, doing?: boolean): void;
|
|
327
|
+
/**
|
|
328
|
+
* 移动 画笔们
|
|
329
|
+
* @param pens 画笔们,不包含子节点
|
|
330
|
+
* @param x 偏移 x
|
|
331
|
+
* @param y 偏移 y
|
|
332
|
+
* @param doing 是否持续移动
|
|
333
|
+
*/
|
|
334
|
+
templateTranslatePens(pens: Pen[], x: number, y: number): void;
|
|
318
335
|
private calcAutoAnchor;
|
|
319
336
|
restoreNodeAnimate(pen: Pen): void;
|
|
320
337
|
updateLines(pen: Pen, change?: boolean): void;
|
package/src/canvas/canvas.js
CHANGED
|
@@ -99,6 +99,7 @@ import { lockedError } from '../utils/error';
|
|
|
99
99
|
import { Dialog } from '../dialog';
|
|
100
100
|
import { setter } from '../utils/object';
|
|
101
101
|
import { Title } from '../title';
|
|
102
|
+
import { CanvasTemplate } from './canvasTemplate';
|
|
102
103
|
export var movingSuffix = '-moving';
|
|
103
104
|
var Canvas = /** @class */ (function () {
|
|
104
105
|
function Canvas(parent, parentElement, store) {
|
|
@@ -126,7 +127,7 @@ var Canvas = /** @class */ (function () {
|
|
|
126
127
|
this.pointSize = 8;
|
|
127
128
|
this.pasteOffset = true;
|
|
128
129
|
this.opening = false;
|
|
129
|
-
this.maxZindex =
|
|
130
|
+
this.maxZindex = 5;
|
|
130
131
|
this.canMoveLine = false; //moveConnectedLine=false
|
|
131
132
|
this.inputParent = document.createElement('div');
|
|
132
133
|
// input = document.createElement('textarea');
|
|
@@ -637,7 +638,7 @@ var Canvas = /** @class */ (function () {
|
|
|
637
638
|
}
|
|
638
639
|
}
|
|
639
640
|
catch (e) { }
|
|
640
|
-
if (
|
|
641
|
+
if (!(!obj && !(this.addCaches && this.addCaches.length))) return [3 /*break*/, 3];
|
|
641
642
|
files = event.dataTransfer.files;
|
|
642
643
|
if (!(files.length && files[0].type.match('image.*'))) return [3 /*break*/, 2];
|
|
643
644
|
isGif = files[0].type === 'image/gif';
|
|
@@ -1950,6 +1951,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1950
1951
|
var ctx = _this.canvas.getContext('2d');
|
|
1951
1952
|
ctx.clearRect(0, 0, _this.canvas.width, _this.canvas.height);
|
|
1952
1953
|
ctx.drawImage(_this.offscreen, 0, 0, _this.width, _this.height);
|
|
1954
|
+
_this.canvasTemplate.render();
|
|
1953
1955
|
_this.canvasImageBottom.render();
|
|
1954
1956
|
_this.canvasImage.render();
|
|
1955
1957
|
_this.patchFlags = false;
|
|
@@ -1964,6 +1966,9 @@ var Canvas = /** @class */ (function () {
|
|
|
1964
1966
|
if (!isFinite(pen.x)) {
|
|
1965
1967
|
continue;
|
|
1966
1968
|
}
|
|
1969
|
+
if (pen.template) {
|
|
1970
|
+
continue;
|
|
1971
|
+
}
|
|
1967
1972
|
if (pen.calculative.inView) {
|
|
1968
1973
|
renderPen(ctx, pen);
|
|
1969
1974
|
}
|
|
@@ -2361,6 +2366,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2361
2366
|
_this.inputDiv.scrollTop = _this.inputDiv.scrollHeight;
|
|
2362
2367
|
_this.inputDiv.scrollLeft = _this.inputDiv.scrollWidth;
|
|
2363
2368
|
pen.calculative.text = undefined;
|
|
2369
|
+
_this.initTemplateCanvas([pen]);
|
|
2364
2370
|
_this.render();
|
|
2365
2371
|
};
|
|
2366
2372
|
this.setInputStyle = function (pen) {
|
|
@@ -2551,6 +2557,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2551
2557
|
});
|
|
2552
2558
|
_this.store.emitter.emit('valueUpdate', pen);
|
|
2553
2559
|
}
|
|
2560
|
+
_this.initTemplateCanvas([pen]);
|
|
2554
2561
|
}
|
|
2555
2562
|
_this.inputDiv.dataset.penId = undefined;
|
|
2556
2563
|
_this.dropdown.style.display = 'none';
|
|
@@ -2653,23 +2660,25 @@ var Canvas = /** @class */ (function () {
|
|
|
2653
2660
|
_this.render();
|
|
2654
2661
|
_this.store.emitter.emit('valueUpdate', pen);
|
|
2655
2662
|
};
|
|
2663
|
+
this.canvasTemplate = new CanvasTemplate(parentElement, store);
|
|
2664
|
+
this.canvasTemplate.canvas.style.zIndex = '1';
|
|
2656
2665
|
this.canvasImageBottom = new CanvasImage(parentElement, store, true);
|
|
2657
|
-
this.canvasImageBottom.canvas.style.zIndex = '
|
|
2666
|
+
this.canvasImageBottom.canvas.style.zIndex = '2';
|
|
2658
2667
|
parentElement.appendChild(this.canvas);
|
|
2659
2668
|
this.canvas.style.position = 'absolute';
|
|
2660
2669
|
this.canvas.style.backgroundRepeat = 'no-repeat';
|
|
2661
2670
|
this.canvas.style.backgroundSize = '100% 100%';
|
|
2662
|
-
this.canvas.style.zIndex = '
|
|
2671
|
+
this.canvas.style.zIndex = '3';
|
|
2663
2672
|
this.canvasImage = new CanvasImage(parentElement, store);
|
|
2664
|
-
this.canvasImage.canvas.style.zIndex = '
|
|
2673
|
+
this.canvasImage.canvas.style.zIndex = '4';
|
|
2665
2674
|
this.magnifierCanvas = new MagnifierCanvas(this, parentElement, store);
|
|
2666
|
-
this.magnifierCanvas.canvas.style.zIndex = '
|
|
2675
|
+
this.magnifierCanvas.canvas.style.zIndex = '5';
|
|
2667
2676
|
this.externalElements.style.position = 'absolute';
|
|
2668
2677
|
this.externalElements.style.left = '0';
|
|
2669
2678
|
this.externalElements.style.top = '0';
|
|
2670
2679
|
this.externalElements.style.outline = 'none';
|
|
2671
2680
|
this.externalElements.style.background = 'transparent';
|
|
2672
|
-
this.externalElements.style.zIndex = '
|
|
2681
|
+
this.externalElements.style.zIndex = '5';
|
|
2673
2682
|
parentElement.style.position = 'relative';
|
|
2674
2683
|
parentElement.appendChild(this.externalElements);
|
|
2675
2684
|
this.createInput();
|
|
@@ -3241,6 +3250,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3241
3250
|
// active 消息表示拖拽结束
|
|
3242
3251
|
// this.store.emitter.emit('active', this.store.active);
|
|
3243
3252
|
this.initImageCanvas(this.store.active);
|
|
3253
|
+
this.initTemplateCanvas(this.store.active);
|
|
3244
3254
|
// 避免选中图元的出错情况,this.dock为undefined
|
|
3245
3255
|
if (!this.dock)
|
|
3246
3256
|
return;
|
|
@@ -3328,6 +3338,10 @@ var Canvas = /** @class */ (function () {
|
|
|
3328
3338
|
pens.some(function (pen) { return _this.hasImage(pen, true); }) &&
|
|
3329
3339
|
this.canvasImageBottom.init();
|
|
3330
3340
|
};
|
|
3341
|
+
Canvas.prototype.initTemplateCanvas = function (pens) {
|
|
3342
|
+
pens.some(function (pen) { return pen.template !== undefined; }) &&
|
|
3343
|
+
this.canvasTemplate.init();
|
|
3344
|
+
};
|
|
3331
3345
|
Canvas.prototype.hasImage = function (pen, isBottom) {
|
|
3332
3346
|
var _this = this;
|
|
3333
3347
|
var _a;
|
|
@@ -3576,6 +3590,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3576
3590
|
this.canvas.style.height = h + 'px';
|
|
3577
3591
|
this.externalElements.style.width = w + 'px';
|
|
3578
3592
|
this.externalElements.style.height = h + 'px';
|
|
3593
|
+
this.canvasTemplate.resize(w, h);
|
|
3579
3594
|
this.canvasImage.resize(w, h);
|
|
3580
3595
|
this.canvasImageBottom.resize(w, h);
|
|
3581
3596
|
this.magnifierCanvas.resize(w, h);
|
|
@@ -3618,6 +3633,9 @@ var Canvas = /** @class */ (function () {
|
|
|
3618
3633
|
this.offscreen
|
|
3619
3634
|
.getContext('2d')
|
|
3620
3635
|
.clearRect(0, 0, this.offscreen.width, this.offscreen.height);
|
|
3636
|
+
if (!this.store.data.template) {
|
|
3637
|
+
this.canvasTemplate.clear();
|
|
3638
|
+
}
|
|
3621
3639
|
this.canvasImage.clear();
|
|
3622
3640
|
this.canvasImageBottom.clear();
|
|
3623
3641
|
};
|
|
@@ -3833,10 +3851,13 @@ var Canvas = /** @class */ (function () {
|
|
|
3833
3851
|
break;
|
|
3834
3852
|
}
|
|
3835
3853
|
if (action.type === EditType.Update) {
|
|
3836
|
-
|
|
3854
|
+
var pens = __spreadArray(__spreadArray([], __read(action.pens), false), __read(action.initPens), false);
|
|
3855
|
+
this.initImageCanvas(pens);
|
|
3856
|
+
this.initTemplateCanvas(pens);
|
|
3837
3857
|
}
|
|
3838
3858
|
else {
|
|
3839
3859
|
this.initImageCanvas(action.pens);
|
|
3860
|
+
this.initTemplateCanvas(action.pens);
|
|
3840
3861
|
}
|
|
3841
3862
|
this.parent.onSizeUpdate();
|
|
3842
3863
|
this.render();
|
|
@@ -3848,6 +3869,15 @@ var Canvas = /** @class */ (function () {
|
|
|
3848
3869
|
if (!pen.id) {
|
|
3849
3870
|
pen.id = s8();
|
|
3850
3871
|
}
|
|
3872
|
+
if (Math.abs(this.store.lastScale - this.store.data.scale) < 0.0001 &&
|
|
3873
|
+
this.store.sameTemplate &&
|
|
3874
|
+
this.store.templatePens[pen.id] &&
|
|
3875
|
+
pen.template) {
|
|
3876
|
+
pen = this.store.templatePens[pen.id];
|
|
3877
|
+
this.store.data.pens.push(pen);
|
|
3878
|
+
this.updatePenRect(pen);
|
|
3879
|
+
return;
|
|
3880
|
+
}
|
|
3851
3881
|
this.store.data.pens.push(pen);
|
|
3852
3882
|
this.store.pens[pen.id] = pen;
|
|
3853
3883
|
// 集中存储path,避免数据冗余过大
|
|
@@ -4117,6 +4147,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4117
4147
|
pen.calculative.imgNaturalHeight = img.naturalHeight || pen.iconHeight;
|
|
4118
4148
|
globalStore.htmlElements[pen.image] = img;
|
|
4119
4149
|
_this.imageLoaded();
|
|
4150
|
+
if (pen.template) {
|
|
4151
|
+
_this.templateImageLoaded();
|
|
4152
|
+
}
|
|
4120
4153
|
};
|
|
4121
4154
|
};
|
|
4122
4155
|
// send the request
|
|
@@ -4134,6 +4167,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4134
4167
|
pen.calculative.imgNaturalHeight =
|
|
4135
4168
|
img.naturalHeight || pen.iconHeight;
|
|
4136
4169
|
this.imageLoaded(); // TODO: 重绘图片层 有延时器,可能卡顿
|
|
4170
|
+
if (pen.template) {
|
|
4171
|
+
this.templateImageLoaded();
|
|
4172
|
+
}
|
|
4137
4173
|
}
|
|
4138
4174
|
else {
|
|
4139
4175
|
if (navigator.userAgent.includes('Firefox') &&
|
|
@@ -4163,6 +4199,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4163
4199
|
img_1.naturalHeight || pen.iconHeight;
|
|
4164
4200
|
globalStore.htmlElements[pen.image] = img_1;
|
|
4165
4201
|
_this.imageLoaded();
|
|
4202
|
+
if (pen.template) {
|
|
4203
|
+
_this.templateImageLoaded();
|
|
4204
|
+
}
|
|
4166
4205
|
};
|
|
4167
4206
|
}
|
|
4168
4207
|
}
|
|
@@ -4190,6 +4229,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4190
4229
|
pen.calculative.backgroundImg = img_2;
|
|
4191
4230
|
globalStore.htmlElements[pen.backgroundImage] = img_2;
|
|
4192
4231
|
_this.imageLoaded();
|
|
4232
|
+
if (pen.template) {
|
|
4233
|
+
_this.templateImageLoaded();
|
|
4234
|
+
}
|
|
4193
4235
|
};
|
|
4194
4236
|
}
|
|
4195
4237
|
}
|
|
@@ -4216,6 +4258,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4216
4258
|
pen.calculative.strokeImg = img_3;
|
|
4217
4259
|
globalStore.htmlElements[pen.strokeImage] = img_3;
|
|
4218
4260
|
_this.imageLoaded();
|
|
4261
|
+
if (pen.template && pen.name !== 'gif') {
|
|
4262
|
+
_this.templateImageLoaded();
|
|
4263
|
+
}
|
|
4219
4264
|
};
|
|
4220
4265
|
}
|
|
4221
4266
|
}
|
|
@@ -4233,6 +4278,16 @@ var Canvas = /** @class */ (function () {
|
|
|
4233
4278
|
_this.render();
|
|
4234
4279
|
}, 100);
|
|
4235
4280
|
};
|
|
4281
|
+
// 避免初始化图片加载重复调用 render,此处防抖
|
|
4282
|
+
Canvas.prototype.templateImageLoaded = function () {
|
|
4283
|
+
var _this = this;
|
|
4284
|
+
this.templateImageTimer && clearTimeout(this.templateImageTimer);
|
|
4285
|
+
this.templateImageTimer = setTimeout(function () {
|
|
4286
|
+
// 加载完图片,重新渲染一次图片层
|
|
4287
|
+
_this.canvasTemplate.init();
|
|
4288
|
+
_this.render();
|
|
4289
|
+
}, 100);
|
|
4290
|
+
};
|
|
4236
4291
|
Canvas.prototype.setCalculativeByScale = function (pen) {
|
|
4237
4292
|
var scale = this.store.data.scale;
|
|
4238
4293
|
pen.calculative.lineWidth = pen.lineWidth * scale;
|
|
@@ -4321,6 +4376,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4321
4376
|
this.store.data.x = Math.round(this.store.data.x);
|
|
4322
4377
|
this.store.data.y = Math.round(this.store.data.y);
|
|
4323
4378
|
setTimeout(function () {
|
|
4379
|
+
_this.canvasTemplate.init();
|
|
4324
4380
|
_this.canvasImage.init();
|
|
4325
4381
|
_this.canvasImageBottom.init();
|
|
4326
4382
|
_this.render();
|
|
@@ -4416,6 +4472,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4416
4472
|
});
|
|
4417
4473
|
this.calcActiveRect();
|
|
4418
4474
|
setTimeout(function () {
|
|
4475
|
+
_this.canvasTemplate.init();
|
|
4419
4476
|
_this.canvasImage.init();
|
|
4420
4477
|
_this.canvasImageBottom.init();
|
|
4421
4478
|
var map = _this.parent.map;
|
|
@@ -4426,6 +4483,42 @@ var Canvas = /** @class */ (function () {
|
|
|
4426
4483
|
_this.store.emitter.emit('scale', _this.store.data.scale);
|
|
4427
4484
|
});
|
|
4428
4485
|
};
|
|
4486
|
+
Canvas.prototype.templateScale = function (scale, center) {
|
|
4487
|
+
var _this = this;
|
|
4488
|
+
if (center === void 0) { center = { x: 0, y: 0 }; }
|
|
4489
|
+
var _a = this.store.options, minScale = _a.minScale, maxScale = _a.maxScale;
|
|
4490
|
+
if (!(scale >= minScale && scale <= maxScale)) {
|
|
4491
|
+
return;
|
|
4492
|
+
}
|
|
4493
|
+
var s = scale / this.store.data.scale;
|
|
4494
|
+
this.store.data.scale = scale;
|
|
4495
|
+
this.store.data.center = { x: 0, y: 0 };
|
|
4496
|
+
this.store.data.origin = { x: 0, y: 0 };
|
|
4497
|
+
this.store.data.pens.forEach(function (pen) {
|
|
4498
|
+
if (pen.parentId) {
|
|
4499
|
+
return;
|
|
4500
|
+
}
|
|
4501
|
+
scalePen(pen, s, center);
|
|
4502
|
+
pen.onScale && pen.onScale(pen);
|
|
4503
|
+
if (pen.isRuleLine) {
|
|
4504
|
+
// 扩大线的比例,若是放大,即不缩小,若是缩小,会放大
|
|
4505
|
+
var lineScale = s > 1 ? 1 : 1 / s / s;
|
|
4506
|
+
// 中心点即为线的中心
|
|
4507
|
+
var lineCenter = pen.calculative.worldRect.center;
|
|
4508
|
+
if (!pen.width) {
|
|
4509
|
+
// 垂直线
|
|
4510
|
+
scalePen(pen, lineScale, lineCenter);
|
|
4511
|
+
}
|
|
4512
|
+
else if (!pen.height) {
|
|
4513
|
+
// 水平线
|
|
4514
|
+
scalePen(pen, lineScale, lineCenter);
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
// this.updatePenRect(pen, { worldRectIsReady: true });
|
|
4518
|
+
_this.execPenResize(pen);
|
|
4519
|
+
});
|
|
4520
|
+
this.calcActiveRect();
|
|
4521
|
+
};
|
|
4429
4522
|
Canvas.prototype.rotatePens = function (e) {
|
|
4430
4523
|
var e_17, _a;
|
|
4431
4524
|
var _this = this;
|
|
@@ -4464,6 +4557,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4464
4557
|
this.lastRotate = this.activeRect.rotate;
|
|
4465
4558
|
this.getSizeCPs();
|
|
4466
4559
|
this.initImageCanvas(this.store.active);
|
|
4560
|
+
this.initTemplateCanvas(this.store.active);
|
|
4467
4561
|
this.render();
|
|
4468
4562
|
this.store.emitter.emit('rotatePens', this.store.active);
|
|
4469
4563
|
if (this.timer) {
|
|
@@ -4548,6 +4642,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4548
4642
|
});
|
|
4549
4643
|
this.getSizeCPs();
|
|
4550
4644
|
this.initImageCanvas(this.store.active);
|
|
4645
|
+
this.initTemplateCanvas(this.store.active);
|
|
4551
4646
|
this.render();
|
|
4552
4647
|
this.store.emitter.emit('resizePens', this.store.active);
|
|
4553
4648
|
if (this.timer) {
|
|
@@ -5053,10 +5148,52 @@ var Canvas = /** @class */ (function () {
|
|
|
5053
5148
|
initPens: initPens,
|
|
5054
5149
|
});
|
|
5055
5150
|
this.initImageCanvas(pens);
|
|
5151
|
+
this.initTemplateCanvas(pens);
|
|
5056
5152
|
this.store.emitter.emit('translatePens', pens);
|
|
5057
5153
|
}
|
|
5058
5154
|
this.store.emitter.emit('translatingPens', pens);
|
|
5059
5155
|
};
|
|
5156
|
+
/**
|
|
5157
|
+
* 移动 画笔们
|
|
5158
|
+
* @param pens 画笔们,不包含子节点
|
|
5159
|
+
* @param x 偏移 x
|
|
5160
|
+
* @param y 偏移 y
|
|
5161
|
+
* @param doing 是否持续移动
|
|
5162
|
+
*/
|
|
5163
|
+
Canvas.prototype.templateTranslatePens = function (pens, x, y) {
|
|
5164
|
+
var _this = this;
|
|
5165
|
+
if (pens === void 0) { pens = this.store.active; }
|
|
5166
|
+
if (!pens || !pens.length) {
|
|
5167
|
+
return;
|
|
5168
|
+
}
|
|
5169
|
+
var containChildPens = this.getAllByPens(pens);
|
|
5170
|
+
pens.forEach(function (pen) {
|
|
5171
|
+
var _a;
|
|
5172
|
+
if (pen.type === PenType.Line) {
|
|
5173
|
+
if (!_this.store.options.moveConnectedLine && !_this.canMoveLine) {
|
|
5174
|
+
return;
|
|
5175
|
+
}
|
|
5176
|
+
translateLine(pen, x, y);
|
|
5177
|
+
_this.checkDisconnect(pen, containChildPens);
|
|
5178
|
+
_this.store.path2dMap.set(pen, globalStore.path2dDraws[pen.name](pen));
|
|
5179
|
+
}
|
|
5180
|
+
else {
|
|
5181
|
+
translateRect(pen.calculative.worldRect, x, y);
|
|
5182
|
+
_this.updatePenRect(pen, { worldRectIsReady: true });
|
|
5183
|
+
pen.calculative.x = pen.x;
|
|
5184
|
+
pen.calculative.y = pen.y;
|
|
5185
|
+
if (pen.calculative.initRect) {
|
|
5186
|
+
pen.calculative.initRect.x = pen.calculative.x;
|
|
5187
|
+
pen.calculative.initRect.y = pen.calculative.y;
|
|
5188
|
+
pen.calculative.initRect.ex =
|
|
5189
|
+
pen.calculative.x + pen.calculative.width;
|
|
5190
|
+
pen.calculative.initRect.ey =
|
|
5191
|
+
pen.calculative.y + pen.calculative.height;
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
(_a = pen.onMove) === null || _a === void 0 ? void 0 : _a.call(pen, pen);
|
|
5195
|
+
});
|
|
5196
|
+
};
|
|
5060
5197
|
Canvas.prototype.calcAutoAnchor = function (line, lineAnchor, pen, penConnection) {
|
|
5061
5198
|
var from = getFromAnchor(line);
|
|
5062
5199
|
var to = getToAnchor(line);
|
|
@@ -5759,6 +5896,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5759
5896
|
deletePens = [];
|
|
5760
5897
|
this._del(pens, deletePens);
|
|
5761
5898
|
this.initImageCanvas(deletePens);
|
|
5899
|
+
this.initTemplateCanvas(deletePens);
|
|
5762
5900
|
this.inactive();
|
|
5763
5901
|
this.clearHover();
|
|
5764
5902
|
this.render();
|
|
@@ -6186,6 +6324,9 @@ var Canvas = /** @class */ (function () {
|
|
|
6186
6324
|
else {
|
|
6187
6325
|
this.initImageCanvas([pen]);
|
|
6188
6326
|
}
|
|
6327
|
+
if (data.template !== undefined || pen.template) {
|
|
6328
|
+
this.initTemplateCanvas([pen]);
|
|
6329
|
+
}
|
|
6189
6330
|
};
|
|
6190
6331
|
/**
|
|
6191
6332
|
* 执行 pen ,以及 pen 的子孙节点的 onResize 生命周期函数
|
|
@@ -6502,6 +6643,7 @@ var Canvas = /** @class */ (function () {
|
|
|
6502
6643
|
this.store.data.x = this.canvas.clientWidth / 2 - x * rect.width - rect.x;
|
|
6503
6644
|
this.store.data.y = this.canvas.clientHeight / 2 - y * rect.height - rect.y;
|
|
6504
6645
|
this.onMovePens();
|
|
6646
|
+
this.canvasTemplate.init();
|
|
6505
6647
|
this.canvasImage.init();
|
|
6506
6648
|
this.canvasImageBottom.init();
|
|
6507
6649
|
this.render();
|