@meta2d/core 1.0.8 → 1.0.10
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.js +41 -16
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +12 -0
- package/src/core.js +124 -15
- package/src/core.js.map +1 -1
- package/src/diagrams/gif.js +6 -0
- package/src/diagrams/gif.js.map +1 -1
- package/src/diagrams/line/polyline.js +1 -1
- package/src/diagrams/line/polyline.js.map +1 -1
- package/src/options.d.ts +1 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/render.d.ts +6 -0
- package/src/pen/render.js +18 -0
- package/src/pen/render.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -337,7 +337,7 @@ var Canvas = /** @class */ (function () {
|
|
|
337
337
|
}
|
|
338
338
|
break;
|
|
339
339
|
case 'Alt':
|
|
340
|
-
if (_this.drawingLine) {
|
|
340
|
+
if (!e.ctrlKey && !e.shiftKey && _this.drawingLine) {
|
|
341
341
|
var to = getToAnchor(_this.drawingLine);
|
|
342
342
|
if (to !== _this.drawingLine.calculative.activeAnchor) {
|
|
343
343
|
deleteTempAnchor(_this.drawingLine);
|
|
@@ -812,10 +812,13 @@ var Canvas = /** @class */ (function () {
|
|
|
812
812
|
}
|
|
813
813
|
//shift 快捷添加锚点并连线
|
|
814
814
|
if (!_this.store.options.autoAnchor && !_this.drawingLine) {
|
|
815
|
-
if (e.shiftKey &&
|
|
815
|
+
if (e.shiftKey && e.ctrlKey && e.altKey) {
|
|
816
816
|
_this.setAnchor(_this.store.pointAt);
|
|
817
817
|
_this.drawingLineName = _this.store.options.drawingLineName;
|
|
818
818
|
var anchor = _this.store.activeAnchor;
|
|
819
|
+
if (!anchor) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
819
822
|
var pt = {
|
|
820
823
|
id: s8(),
|
|
821
824
|
x: anchor.x,
|
|
@@ -849,10 +852,13 @@ var Canvas = /** @class */ (function () {
|
|
|
849
852
|
}
|
|
850
853
|
//shift快捷添加锚点并完成连线
|
|
851
854
|
if (!_this.store.options.autoAnchor) {
|
|
852
|
-
if (e.shiftKey) {
|
|
855
|
+
if (e.shiftKey && e.altKey && e.ctrlKey) {
|
|
853
856
|
_this.setAnchor(_this.store.pointAt);
|
|
854
857
|
var to_2 = getToAnchor(_this.drawingLine);
|
|
855
858
|
var anchor = _this.store.activeAnchor;
|
|
859
|
+
if (!anchor) {
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
856
862
|
to_2.x = anchor.x;
|
|
857
863
|
to_2.y = anchor.y;
|
|
858
864
|
connectLine(_this.store.hover, anchor, _this.drawingLine, to_2);
|
|
@@ -3615,6 +3621,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3615
3621
|
};
|
|
3616
3622
|
Canvas.prototype.makePen = function (pen) {
|
|
3617
3623
|
var _this = this;
|
|
3624
|
+
var _a;
|
|
3618
3625
|
if (!pen.id) {
|
|
3619
3626
|
pen.id = s8();
|
|
3620
3627
|
}
|
|
@@ -3631,14 +3638,14 @@ var Canvas = /** @class */ (function () {
|
|
|
3631
3638
|
if (pen.lineWidth == undefined) {
|
|
3632
3639
|
pen.lineWidth = 1;
|
|
3633
3640
|
}
|
|
3634
|
-
var
|
|
3641
|
+
var _b = this.store.options, fontSize = _b.fontSize, lineHeight = _b.lineHeight;
|
|
3635
3642
|
if (!pen.fontSize) {
|
|
3636
3643
|
pen.fontSize = fontSize;
|
|
3637
3644
|
}
|
|
3638
3645
|
if (!pen.lineHeight) {
|
|
3639
3646
|
pen.lineHeight = lineHeight;
|
|
3640
3647
|
}
|
|
3641
|
-
pen.calculative = { canvas: this };
|
|
3648
|
+
pen.calculative = { canvas: this, singleton: (_a = pen.calculative) === null || _a === void 0 ? void 0 : _a.singleton };
|
|
3642
3649
|
if (pen.video || pen.audio) {
|
|
3643
3650
|
pen.calculative.onended = function (pen) {
|
|
3644
3651
|
_this.nextAnimate(pen);
|
|
@@ -3915,6 +3922,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3915
3922
|
var img_1 = new Image();
|
|
3916
3923
|
img_1.crossOrigin = 'anonymous';
|
|
3917
3924
|
img_1.src = pen.image;
|
|
3925
|
+
if (this.store.options.cdn &&
|
|
3926
|
+
!(pen.image.startsWith('http') ||
|
|
3927
|
+
pen.image.startsWith('//') ||
|
|
3928
|
+
pen.image.startsWith('data:image'))) {
|
|
3929
|
+
img_1.src = this.store.options.cdn + pen.image;
|
|
3930
|
+
}
|
|
3918
3931
|
img_1.onload = function () {
|
|
3919
3932
|
pen.calculative.img = img_1;
|
|
3920
3933
|
pen.calculative.imgNaturalWidth =
|
|
@@ -3940,6 +3953,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3940
3953
|
var img_2 = new Image();
|
|
3941
3954
|
img_2.crossOrigin = 'anonymous';
|
|
3942
3955
|
img_2.src = pen.backgroundImage;
|
|
3956
|
+
if (this.store.options.cdn &&
|
|
3957
|
+
!(pen.backgroundImage.startsWith('http') ||
|
|
3958
|
+
pen.backgroundImage.startsWith('//') ||
|
|
3959
|
+
pen.backgroundImage.startsWith('data:image'))) {
|
|
3960
|
+
img_2.src = this.store.options.cdn + pen.backgroundImage;
|
|
3961
|
+
}
|
|
3943
3962
|
img_2.onload = function () {
|
|
3944
3963
|
pen.calculative.backgroundImg = img_2;
|
|
3945
3964
|
globalStore.htmlElements[pen.backgroundImage] = img_2;
|
|
@@ -3960,6 +3979,12 @@ var Canvas = /** @class */ (function () {
|
|
|
3960
3979
|
var img_3 = new Image();
|
|
3961
3980
|
img_3.crossOrigin = 'anonymous';
|
|
3962
3981
|
img_3.src = pen.strokeImage;
|
|
3982
|
+
if (this.store.options.cdn &&
|
|
3983
|
+
!(pen.strokeImage.startsWith('http') ||
|
|
3984
|
+
pen.strokeImage.startsWith('//') ||
|
|
3985
|
+
pen.strokeImage.startsWith('data:image'))) {
|
|
3986
|
+
img_3.src = this.store.options.cdn + pen.strokeImage;
|
|
3987
|
+
}
|
|
3963
3988
|
img_3.onload = function () {
|
|
3964
3989
|
pen.calculative.strokeImg = img_3;
|
|
3965
3990
|
globalStore.htmlElements[pen.strokeImage] = img_3;
|
|
@@ -4236,10 +4261,6 @@ var Canvas = /** @class */ (function () {
|
|
|
4236
4261
|
var x = p2.x - p1.x;
|
|
4237
4262
|
var y = p2.y - p1.y;
|
|
4238
4263
|
var rect = deepClone(this.initActiveRect);
|
|
4239
|
-
if (e.shiftKey ||
|
|
4240
|
-
(this.initPens.length == 1 && this.initPens[0].ratio)) {
|
|
4241
|
-
x = (rect.width / rect.height) * y;
|
|
4242
|
-
}
|
|
4243
4264
|
// 得到最准确的 rect 即 resize 后的
|
|
4244
4265
|
resizeRect(rect, x, y, this.resizeIndex);
|
|
4245
4266
|
calcCenter(rect);
|
|
@@ -4265,7 +4286,8 @@ var Canvas = /** @class */ (function () {
|
|
|
4265
4286
|
var offsetY = y - this.lastOffsetY;
|
|
4266
4287
|
this.lastOffsetX = x;
|
|
4267
4288
|
this.lastOffsetY = y;
|
|
4268
|
-
if (e.ctrlKey
|
|
4289
|
+
if (e.ctrlKey ||
|
|
4290
|
+
(this.initPens.length === 1 && this.initPens[0].ratio)) {
|
|
4269
4291
|
// 1,3 是右上角和左上角的点,此时的 offsetY 符号与 offsetX 是相反的
|
|
4270
4292
|
var sign = [1, 3].includes(this.resizeIndex) ? -1 : 1;
|
|
4271
4293
|
offsetY = (sign * (offsetX * h)) / w;
|
|
@@ -4641,11 +4663,13 @@ var Canvas = /** @class */ (function () {
|
|
|
4641
4663
|
case 6:
|
|
4642
4664
|
this.hotkeyType = HotkeyType.None;
|
|
4643
4665
|
this.render();
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4666
|
+
if (hoverPen) {
|
|
4667
|
+
this.pushHistory({
|
|
4668
|
+
type: EditType.Update,
|
|
4669
|
+
pens: [deepClone(hoverPen, true)],
|
|
4670
|
+
initPens: initPens,
|
|
4671
|
+
});
|
|
4672
|
+
}
|
|
4649
4673
|
return [2 /*return*/];
|
|
4650
4674
|
}
|
|
4651
4675
|
});
|
|
@@ -5434,6 +5458,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5434
5458
|
pens.forEach(function (pen) {
|
|
5435
5459
|
if (!pen.parentId) {
|
|
5436
5460
|
if (pen.locked) {
|
|
5461
|
+
// TODO: canDelLocked 是 true , locked 仍然删不掉
|
|
5437
5462
|
return;
|
|
5438
5463
|
}
|
|
5439
5464
|
else {
|
|
@@ -5450,7 +5475,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5450
5475
|
return;
|
|
5451
5476
|
}
|
|
5452
5477
|
else {
|
|
5453
|
-
var parentPen =
|
|
5478
|
+
var parentPen = getParent(pen);
|
|
5454
5479
|
var _index = parentPen.children.indexOf(pen.id);
|
|
5455
5480
|
parentPen.children.splice(_index, 1);
|
|
5456
5481
|
if (delPens) {
|