@meta2d/core 1.0.1 → 1.0.3
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 +2 -2
- package/src/canvas/canvas.js +21 -9
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +43 -12
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/core.d.ts +9 -5
- package/src/core.js +98 -43
- package/src/core.js.map +1 -1
- package/src/pen/model.js +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +8 -2
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +8 -2
- package/src/pen/text.js.map +1 -1
- package/src/store/store.d.ts +6 -0
- package/src/store/store.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meta2d/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
|
|
5
|
-
"main": "index.
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"copy": "shx cp package.build.json ../../dist/core/package.json",
|
package/src/canvas/canvas.js
CHANGED
|
@@ -1968,7 +1968,9 @@ var Canvas = /** @class */ (function () {
|
|
|
1968
1968
|
var size = anchor.radius ||
|
|
1969
1969
|
_this.store.hover.anchorRadius ||
|
|
1970
1970
|
_this.store.options.anchorRadius;
|
|
1971
|
-
if (_this.store.hover.type
|
|
1971
|
+
if (_this.store.hover.type &&
|
|
1972
|
+
!anchor.radius &&
|
|
1973
|
+
!_this.store.hover.anchorRadius) {
|
|
1972
1974
|
size = 3;
|
|
1973
1975
|
if (_this.store.hover.calculative.lineWidth > 3) {
|
|
1974
1976
|
size = _this.store.hover.calculative.lineWidth;
|
|
@@ -2187,7 +2189,8 @@ var Canvas = /** @class */ (function () {
|
|
|
2187
2189
|
textRect.x + _this.store.data.x - (pen.textLeft || 0) + 'px'; //+ 5
|
|
2188
2190
|
_this.inputParent.style.top =
|
|
2189
2191
|
textRect.y + _this.store.data.y - (pen.textTop || 0) + 'px'; //+ 5
|
|
2190
|
-
|
|
2192
|
+
var _width = textRect.width + (pen.textLeft || 0);
|
|
2193
|
+
_this.inputParent.style.width = (_width < 0 ? 12 : _width) + 'px'; //(textRect.width < pen.width ? 0 : 10)
|
|
2191
2194
|
_this.inputParent.style.height = textRect.height + (pen.textTop || 0) + 'px'; // (textRect.height < pen.height ? 0 : 10)
|
|
2192
2195
|
_this.inputParent.style.zIndex = '9999';
|
|
2193
2196
|
_this.inputParent.style.background = background;
|
|
@@ -2327,7 +2330,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2327
2330
|
}
|
|
2328
2331
|
else {
|
|
2329
2332
|
if (pen.whiteSpace === undefined || pen.whiteSpace === 'break-all') {
|
|
2330
|
-
var tem = pen.width / scale - (pen.textLeft || 0);
|
|
2333
|
+
var tem = (pen.calculative.worldTextRect.width || 12) / scale; //pen.width / scale - ( pen.textLeft || 0);
|
|
2331
2334
|
if (tem < 0) {
|
|
2332
2335
|
tem = 0;
|
|
2333
2336
|
}
|
|
@@ -2993,7 +2996,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2993
2996
|
var _this = this;
|
|
2994
2997
|
// 鼠标松手才更新,此处是更新前的值
|
|
2995
2998
|
var initPens = deepClone(this.store.active, true);
|
|
2996
|
-
|
|
2999
|
+
// const pens = deepClone(this.store.active, true);
|
|
2997
3000
|
this.store.active.forEach(function (pen, i) {
|
|
2998
3001
|
var _a;
|
|
2999
3002
|
var _b = _this.movingPens[i], x = _b.x, y = _b.y;
|
|
@@ -3033,6 +3036,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3033
3036
|
if (!dockPen && yDock) {
|
|
3034
3037
|
dockPen = this.store.pens[yDock.penId];
|
|
3035
3038
|
}
|
|
3039
|
+
var pens = deepClone(this.store.active, true);
|
|
3036
3040
|
// 移动到连线端点,自动连线
|
|
3037
3041
|
if (readyConnect &&
|
|
3038
3042
|
this.store.active.length === 1 &&
|
|
@@ -3203,7 +3207,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3203
3207
|
pen.name === 'line' &&
|
|
3204
3208
|
anchor.connectTo) {
|
|
3205
3209
|
var connectPen = this.findOne(anchor.connectTo);
|
|
3206
|
-
if (!(connectPen === null || connectPen === void 0 ? void 0 : connectPen.calculative.active)) {
|
|
3210
|
+
if ((connectPen === null || connectPen === void 0 ? void 0 : connectPen.calculative) && !(connectPen === null || connectPen === void 0 ? void 0 : connectPen.calculative.active)) {
|
|
3207
3211
|
pen = connectPen;
|
|
3208
3212
|
var connectAnchor = connectPen.calculative.worldAnchors.find(function (item) { return item.id === anchor.anchorId; });
|
|
3209
3213
|
connectAnchor && (anchor = connectAnchor);
|
|
@@ -3479,7 +3483,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3479
3483
|
Canvas.prototype.activeHistory = function () {
|
|
3480
3484
|
var _this = this;
|
|
3481
3485
|
var before = this.store.histories[this.store.historyIndex];
|
|
3482
|
-
if (before) {
|
|
3486
|
+
if (before && before.type === EditType.Add) {
|
|
3483
3487
|
before.pens.forEach(function (pen) {
|
|
3484
3488
|
if (!pen.calculative) {
|
|
3485
3489
|
return;
|
|
@@ -4373,7 +4377,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4373
4377
|
};
|
|
4374
4378
|
Canvas.prototype.moveLineAnchor = function (pt, keyOptions) {
|
|
4375
4379
|
var _this = this;
|
|
4376
|
-
var _a, _b;
|
|
4380
|
+
var _a, _b, _c;
|
|
4377
4381
|
if (!this.activeRect || this.store.data.locked) {
|
|
4378
4382
|
return;
|
|
4379
4383
|
}
|
|
@@ -4384,6 +4388,14 @@ var Canvas = /** @class */ (function () {
|
|
|
4384
4388
|
var pen = this.store.pens[this.store.activeAnchor.connectTo];
|
|
4385
4389
|
disconnectLine(pen, getAnchor(pen, this.store.activeAnchor.anchorId), this.store.pens[this.store.activeAnchor.penId], this.store.activeAnchor);
|
|
4386
4390
|
}
|
|
4391
|
+
var anchorId = this.store.activeAnchor.id;
|
|
4392
|
+
var connectedLine = (_b = this.store.pens[this.store.activeAnchor.penId].connectedLines) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return item.anchor === anchorId; });
|
|
4393
|
+
if (connectedLine && connectedLine.length > 0) {
|
|
4394
|
+
connectedLine.forEach(function (connected) {
|
|
4395
|
+
var pen = _this.store.pens[connected.lineId];
|
|
4396
|
+
disconnectLine(_this.store.pens[_this.store.activeAnchor.penId], _this.store.activeAnchor, pen, getAnchor(pen, connected.lineAnchor));
|
|
4397
|
+
});
|
|
4398
|
+
}
|
|
4387
4399
|
var line = this.store.active[0];
|
|
4388
4400
|
var from = getFromAnchor(line);
|
|
4389
4401
|
var to = getToAnchor(line);
|
|
@@ -4403,7 +4415,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4403
4415
|
to.prev = undefined;
|
|
4404
4416
|
// 重新自动计算连线
|
|
4405
4417
|
if (line.lineName !== 'polyline') {
|
|
4406
|
-
(
|
|
4418
|
+
(_c = this[line.lineName]) === null || _c === void 0 ? void 0 : _c.call(this, this.store, line);
|
|
4407
4419
|
}
|
|
4408
4420
|
}
|
|
4409
4421
|
}
|
|
@@ -4745,7 +4757,6 @@ var Canvas = /** @class */ (function () {
|
|
|
4745
4757
|
else {
|
|
4746
4758
|
pen.calculative.rotate = pen.rotate;
|
|
4747
4759
|
}
|
|
4748
|
-
pen.calculative.worldRect = pen.calculative.initRect;
|
|
4749
4760
|
//其他回到最初始状态
|
|
4750
4761
|
var originStatus = deepClone(this.store.animateMap.get(pen));
|
|
4751
4762
|
if (originStatus) {
|
|
@@ -4756,6 +4767,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4756
4767
|
history: false,
|
|
4757
4768
|
});
|
|
4758
4769
|
}
|
|
4770
|
+
pen.calculative.worldRect = pen.calculative.initRect;
|
|
4759
4771
|
}
|
|
4760
4772
|
this.updatePenRect(pen, { worldRectIsReady: true });
|
|
4761
4773
|
if (pen.calculative.text !== pen.text) {
|