@meta2d/core 1.0.19 → 1.0.21
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 +106 -20
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +7 -0
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/core.d.ts +3 -0
- package/src/core.js +70 -7
- package/src/core.js.map +1 -1
- package/src/diagrams/gif.js +4 -2
- package/src/diagrams/gif.js.map +1 -1
- package/src/options.d.ts +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +20 -11
- package/src/pen/render.js.map +1 -1
- package/src/point/point.d.ts +11 -1
- package/src/point/point.js +65 -5
- package/src/point/point.js.map +1 -1
- package/src/store/store.d.ts +9 -2
- package/src/store/store.js +1 -0
- package/src/store/store.js.map +1 -1
- package/src/utils/time.d.ts +1 -0
- package/src/utils/time.js +17 -0
- package/src/utils/time.js.map +1 -0
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -83,7 +83,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
83
83
|
};
|
|
84
84
|
import { KeydownType } from '../options';
|
|
85
85
|
import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, getGlobalColor, clearLifeCycle, rotatePen, } from '../pen';
|
|
86
|
-
import { calcRotate, distance, hitPoint, PrevNextType, rotatePoint, samePoint, scalePoint, translatePoint, TwoWay, } from '../point';
|
|
86
|
+
import { calcRotate, distance, getDistance, hitPoint, PointType, 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
89
|
import { deepClone, fileToBase64, uploadFile, formatPadding, rgba, s8, } from '../utils';
|
|
@@ -246,6 +246,10 @@ var Canvas = /** @class */ (function () {
|
|
|
246
246
|
}
|
|
247
247
|
e.preventDefault();
|
|
248
248
|
e.stopPropagation();
|
|
249
|
+
//移动画笔过程中不允许缩放
|
|
250
|
+
if (_this.mouseDown &&
|
|
251
|
+
(_this.hoverType === HoverType.Node || _this.hoverType === HoverType.Line))
|
|
252
|
+
return;
|
|
249
253
|
if (_this.store.data.locked === LockState.Disable)
|
|
250
254
|
return;
|
|
251
255
|
if (_this.store.data.locked === LockState.DisableScale)
|
|
@@ -626,7 +630,7 @@ var Canvas = /** @class */ (function () {
|
|
|
626
630
|
obj = _a.sent();
|
|
627
631
|
return [3 /*break*/, 3];
|
|
628
632
|
case 2:
|
|
629
|
-
if (this.addCaches.length) {
|
|
633
|
+
if (this.addCaches && this.addCaches.length) {
|
|
630
634
|
obj = this.addCaches;
|
|
631
635
|
this.addCaches = [];
|
|
632
636
|
}
|
|
@@ -860,8 +864,13 @@ var Canvas = /** @class */ (function () {
|
|
|
860
864
|
// 单击在锚点上,完成绘画
|
|
861
865
|
if (_this.store.hoverAnchor) {
|
|
862
866
|
var to_1 = getToAnchor(_this.drawingLine);
|
|
863
|
-
|
|
864
|
-
|
|
867
|
+
if (_this.store.hoverAnchor.type === PointType.Line) {
|
|
868
|
+
getDistance(to_1, _this.store.hoverAnchor, _this.store);
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
to_1.x = _this.store.hoverAnchor.x;
|
|
872
|
+
to_1.y = _this.store.hoverAnchor.y;
|
|
873
|
+
}
|
|
865
874
|
connectLine(_this.store.hover, _this.store.hoverAnchor, _this.drawingLine, to_1);
|
|
866
875
|
_this.drawline();
|
|
867
876
|
_this.finishDrawline(true);
|
|
@@ -1245,8 +1254,10 @@ var Canvas = /** @class */ (function () {
|
|
|
1245
1254
|
}
|
|
1246
1255
|
if (_this.hoverType === HoverType.NodeAnchor ||
|
|
1247
1256
|
_this.hoverType === HoverType.LineAnchor) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1257
|
+
if (_this.store.hoverAnchor.type !== PointType.Line) {
|
|
1258
|
+
to.x = _this.store.hoverAnchor.x;
|
|
1259
|
+
to.y = _this.store.hoverAnchor.y;
|
|
1260
|
+
}
|
|
1250
1261
|
to.connectTo = _this.store.hoverAnchor.penId;
|
|
1251
1262
|
if (_this.drawingLineName === 'polyline') {
|
|
1252
1263
|
to.isTemp = false;
|
|
@@ -1305,8 +1316,13 @@ var Canvas = /** @class */ (function () {
|
|
|
1305
1316
|
// 在锚点上,完成绘画
|
|
1306
1317
|
if (_this.store.hoverAnchor) {
|
|
1307
1318
|
var to = getToAnchor(_this.drawingLine);
|
|
1308
|
-
|
|
1309
|
-
|
|
1319
|
+
if (_this.store.hoverAnchor.type === PointType.Line) {
|
|
1320
|
+
getDistance(to, _this.store.hoverAnchor, _this.store);
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
to.x = _this.store.hoverAnchor.x;
|
|
1324
|
+
to.y = _this.store.hoverAnchor.y;
|
|
1325
|
+
}
|
|
1310
1326
|
connectLine(_this.store.hover, _this.store.hoverAnchor, _this.drawingLine, to);
|
|
1311
1327
|
_this.drawline();
|
|
1312
1328
|
_this.finishDrawline(true);
|
|
@@ -1372,8 +1388,16 @@ var Canvas = /** @class */ (function () {
|
|
|
1372
1388
|
else {
|
|
1373
1389
|
// 连接连线
|
|
1374
1390
|
if (_this.store.activeAnchor) {
|
|
1375
|
-
|
|
1376
|
-
|
|
1391
|
+
/**
|
|
1392
|
+
* 线的锚点需要存所连接锚点的位置
|
|
1393
|
+
*/
|
|
1394
|
+
if (_this.store.hoverAnchor.type === PointType.Line) {
|
|
1395
|
+
getDistance(_this.store.activeAnchor, _this.store.hoverAnchor, _this.store);
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
_this.store.activeAnchor.x = _this.store.hoverAnchor.x;
|
|
1399
|
+
_this.store.activeAnchor.y = _this.store.hoverAnchor.y;
|
|
1400
|
+
}
|
|
1377
1401
|
connectLine(_this.store.hover, _this.store.hoverAnchor, line_1, _this.store.activeAnchor);
|
|
1378
1402
|
}
|
|
1379
1403
|
}
|
|
@@ -1394,7 +1418,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1394
1418
|
}
|
|
1395
1419
|
}
|
|
1396
1420
|
// Add pen
|
|
1397
|
-
if (_this.addCaches) {
|
|
1421
|
+
if (_this.addCaches && _this.addCaches.length) {
|
|
1398
1422
|
if (!_this.store.data.locked) {
|
|
1399
1423
|
_this.dropPens(_this.addCaches, e);
|
|
1400
1424
|
}
|
|
@@ -1635,7 +1659,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1635
1659
|
try {
|
|
1636
1660
|
for (var _d = (e_1 = void 0, __values(pen.calculative.worldAnchors)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1637
1661
|
var anchor = _e.value;
|
|
1638
|
-
if (hitPoint(pt, anchor, _this.pointSize)) {
|
|
1662
|
+
if (hitPoint(pt, anchor, _this.pointSize, anchor.penId ? _this.store.pens[anchor.penId] : undefined)) {
|
|
1639
1663
|
_this.title.show(anchor);
|
|
1640
1664
|
if (anchor.title) {
|
|
1641
1665
|
return "break-outer";
|
|
@@ -2026,7 +2050,32 @@ var Canvas = /** @class */ (function () {
|
|
|
2026
2050
|
size = _this.store.hover.calculative.lineWidth;
|
|
2027
2051
|
}
|
|
2028
2052
|
}
|
|
2029
|
-
|
|
2053
|
+
if (anchor.type === PointType.Line) {
|
|
2054
|
+
//旋转的情况
|
|
2055
|
+
var _rotate = _this.store.pens[anchor.penId].rotate;
|
|
2056
|
+
if (_this.store.pens[anchor.penId].calculative.flipX) {
|
|
2057
|
+
_rotate *= -1;
|
|
2058
|
+
}
|
|
2059
|
+
if (_this.store.pens[anchor.penId].calculative.flipY) {
|
|
2060
|
+
_rotate *= -1;
|
|
2061
|
+
}
|
|
2062
|
+
var rotate = anchor.rotate + _rotate;
|
|
2063
|
+
if (_this.store.pens[anchor.penId].calculative.flipX) {
|
|
2064
|
+
rotate *= -1;
|
|
2065
|
+
}
|
|
2066
|
+
if (_this.store.pens[anchor.penId].calculative.flipY) {
|
|
2067
|
+
rotate *= -1;
|
|
2068
|
+
}
|
|
2069
|
+
ctx.save();
|
|
2070
|
+
ctx.translate(anchor.x, anchor.y);
|
|
2071
|
+
ctx.rotate((rotate * Math.PI) / 180);
|
|
2072
|
+
ctx.translate(-anchor.x, -anchor.y);
|
|
2073
|
+
ctx.rect(anchor.x - (anchor.length * _this.store.data.scale) / 2, anchor.y - size, anchor.length * _this.store.data.scale, size * 2);
|
|
2074
|
+
ctx.restore();
|
|
2075
|
+
}
|
|
2076
|
+
else {
|
|
2077
|
+
ctx.arc(anchor.x, anchor.y, size, 0, Math.PI * 2);
|
|
2078
|
+
}
|
|
2030
2079
|
if (_this.store.hover.type && _this.store.hoverAnchor === anchor) {
|
|
2031
2080
|
ctx.save();
|
|
2032
2081
|
ctx.strokeStyle =
|
|
@@ -2853,6 +2902,10 @@ var Canvas = /** @class */ (function () {
|
|
|
2853
2902
|
pen.height *= this.store.data.scale;
|
|
2854
2903
|
pen.x = e.x - pen.width / 2;
|
|
2855
2904
|
pen.y = e.y - pen.height / 2;
|
|
2905
|
+
if (pen.tags && pen.tags.includes('meta3d')) {
|
|
2906
|
+
pen.x = this.store.data.origin.x;
|
|
2907
|
+
pen.y = this.store.data.origin.y;
|
|
2908
|
+
}
|
|
2856
2909
|
}
|
|
2857
2910
|
}
|
|
2858
2911
|
}
|
|
@@ -2883,7 +2936,11 @@ var Canvas = /** @class */ (function () {
|
|
|
2883
2936
|
{ x: pen.x, y: pen.y + pen.height },
|
|
2884
2937
|
{ x: pen.x + pen.width, y: pen.y + pen.height },
|
|
2885
2938
|
];
|
|
2886
|
-
if (
|
|
2939
|
+
if ((pen.x === rect_1.x &&
|
|
2940
|
+
pen.y === rect_1.y &&
|
|
2941
|
+
pen.width === rect_1.width &&
|
|
2942
|
+
pen.height === rect_1.height) ||
|
|
2943
|
+
points.some(function (point) { return pointInRect(point, rect_1); })) {
|
|
2887
2944
|
flag = false;
|
|
2888
2945
|
break;
|
|
2889
2946
|
}
|
|
@@ -3392,7 +3449,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3392
3449
|
return HoverType.None;
|
|
3393
3450
|
}
|
|
3394
3451
|
}
|
|
3395
|
-
if (hitPoint(pt, anchor, this.pointSize)) {
|
|
3452
|
+
if (hitPoint(pt, anchor, this.pointSize, anchor.penId ? this.store.pens[anchor.penId] : undefined)) {
|
|
3396
3453
|
if (anchor !== this.store.hoverAnchor) {
|
|
3397
3454
|
this.patchFlags = true;
|
|
3398
3455
|
}
|
|
@@ -4009,7 +4066,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4009
4066
|
};
|
|
4010
4067
|
Canvas.prototype.loadImage = function (pen) {
|
|
4011
4068
|
var _this = this;
|
|
4012
|
-
if (pen.image !== pen.calculative.image) {
|
|
4069
|
+
if (pen.image !== pen.calculative.image || !pen.calculative.img) {
|
|
4013
4070
|
pen.calculative.img = undefined;
|
|
4014
4071
|
if (pen.image) {
|
|
4015
4072
|
if (globalStore.htmlElements[pen.image]) {
|
|
@@ -4643,8 +4700,15 @@ var Canvas = /** @class */ (function () {
|
|
|
4643
4700
|
if (this.store.hover &&
|
|
4644
4701
|
this.store.hoverAnchor &&
|
|
4645
4702
|
this.store.hoverAnchor.penId !== this.store.activeAnchor.penId) {
|
|
4646
|
-
|
|
4647
|
-
|
|
4703
|
+
if (this.store.hoverAnchor.type === PointType.Line) {
|
|
4704
|
+
offsetX = pt.x - this.store.activeAnchor.x;
|
|
4705
|
+
offsetY = pt.y - this.store.activeAnchor.y;
|
|
4706
|
+
getDistance(this.store.activeAnchor, this.store.hoverAnchor, this.store);
|
|
4707
|
+
}
|
|
4708
|
+
else {
|
|
4709
|
+
offsetX = this.store.hoverAnchor.x - this.store.activeAnchor.x;
|
|
4710
|
+
offsetY = this.store.hoverAnchor.y - this.store.activeAnchor.y;
|
|
4711
|
+
}
|
|
4648
4712
|
translatePoint(this.store.activeAnchor, offsetX, offsetY);
|
|
4649
4713
|
to.prev = undefined;
|
|
4650
4714
|
// 重新自动计算连线
|
|
@@ -4717,7 +4781,9 @@ var Canvas = /** @class */ (function () {
|
|
|
4717
4781
|
};
|
|
4718
4782
|
Canvas.prototype.moveLineAnchorNext = function (e) {
|
|
4719
4783
|
var _this = this;
|
|
4720
|
-
if (!this.activeRect ||
|
|
4784
|
+
if (!this.activeRect ||
|
|
4785
|
+
this.store.data.locked ||
|
|
4786
|
+
!this.store.activeAnchor) {
|
|
4721
4787
|
return;
|
|
4722
4788
|
}
|
|
4723
4789
|
if (!this.initPens) {
|
|
@@ -5054,9 +5120,29 @@ var Canvas = /** @class */ (function () {
|
|
|
5054
5120
|
if (!penAnchor) {
|
|
5055
5121
|
return;
|
|
5056
5122
|
}
|
|
5057
|
-
|
|
5123
|
+
var rotate = pen.rotate;
|
|
5124
|
+
if (pen.flipX) {
|
|
5125
|
+
rotate *= -1;
|
|
5126
|
+
}
|
|
5127
|
+
if (pen.flipY) {
|
|
5128
|
+
rotate *= -1;
|
|
5129
|
+
}
|
|
5130
|
+
var offsetX = lineAnchor.distance *
|
|
5131
|
+
_this.store.data.scale *
|
|
5132
|
+
Math.cos(((rotate + penAnchor.rotate) / 180) * Math.PI) || 0;
|
|
5133
|
+
var offsetY = lineAnchor.distance *
|
|
5134
|
+
_this.store.data.scale *
|
|
5135
|
+
Math.sin(((rotate + penAnchor.rotate) / 180) * Math.PI) || 0;
|
|
5136
|
+
if (pen.flipX) {
|
|
5137
|
+
offsetX = -offsetX;
|
|
5138
|
+
}
|
|
5139
|
+
if (pen.flipY) {
|
|
5140
|
+
offsetY = -offsetY;
|
|
5141
|
+
}
|
|
5142
|
+
translatePoint(lineAnchor, penAnchor.x - lineAnchor.x + offsetX, penAnchor.y - lineAnchor.y + offsetY);
|
|
5058
5143
|
if (_this.store.options.autoPolyline &&
|
|
5059
5144
|
line.autoPolyline !== false &&
|
|
5145
|
+
line.calculative.autoPolylineFlag === true &&
|
|
5060
5146
|
line.lineName === 'polyline') {
|
|
5061
5147
|
var from = getFromAnchor(line);
|
|
5062
5148
|
var to = getToAnchor(line);
|