@meta2d/core 1.0.4 → 1.0.5
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 +50 -30
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +1 -1
- package/src/core.js +47 -10
- package/src/core.js.map +1 -1
- package/src/event/event.d.ts +1 -0
- package/src/event/event.js.map +1 -1
- package/src/pen/model.d.ts +49 -0
- package/src/pen/model.js +2 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +218 -5
- package/src/pen/render.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -237,6 +237,15 @@ var Canvas = /** @class */ (function () {
|
|
|
237
237
|
}
|
|
238
238
|
e.preventDefault();
|
|
239
239
|
e.stopPropagation();
|
|
240
|
+
if (_this.store.options.disableScale) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (_this.store.data.locked === LockState.Disable)
|
|
244
|
+
return;
|
|
245
|
+
if (_this.store.data.locked === LockState.DisableScale)
|
|
246
|
+
return;
|
|
247
|
+
if (_this.store.data.locked === LockState.DisableMoveScale)
|
|
248
|
+
return;
|
|
240
249
|
//禁止触摸屏双指缩放操作
|
|
241
250
|
if (_this.store.options.disableTouchPadScale &&
|
|
242
251
|
e.ctrlKey &&
|
|
@@ -260,15 +269,6 @@ var Canvas = /** @class */ (function () {
|
|
|
260
269
|
_this.scroll.wheel(e.deltaY < 0);
|
|
261
270
|
return;
|
|
262
271
|
}
|
|
263
|
-
if (_this.store.options.disableScale) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (_this.store.data.locked === LockState.Disable)
|
|
267
|
-
return;
|
|
268
|
-
if (_this.store.data.locked === LockState.DisableScale)
|
|
269
|
-
return;
|
|
270
|
-
if (_this.store.data.locked === LockState.DisableMoveScale)
|
|
271
|
-
return;
|
|
272
272
|
// 触摸板平移
|
|
273
273
|
var isTouchPad = !(!e.deltaX && e.deltaY);
|
|
274
274
|
var now = performance.now();
|
|
@@ -2349,15 +2349,20 @@ var Canvas = /** @class */ (function () {
|
|
|
2349
2349
|
}
|
|
2350
2350
|
style += "height:" + (pen.fontSize * scale < 12 ? tem * font_scale : tem * scale * font_scale) + "px;";
|
|
2351
2351
|
}
|
|
2352
|
+
var _textWidth = null;
|
|
2352
2353
|
if (pen.textWidth) {
|
|
2354
|
+
_textWidth =
|
|
2355
|
+
(pen.textWidth < 1 && pen.textWidth) > -1
|
|
2356
|
+
? pen.textWidth * pen.calculative.worldRect.width
|
|
2357
|
+
: pen.textWidth;
|
|
2353
2358
|
if (pen.whiteSpace !== 'pre-line') {
|
|
2354
|
-
if (
|
|
2359
|
+
if (_textWidth < pen.fontSize) {
|
|
2355
2360
|
style += "width:" + pen.fontSize * 1.2 * font_scale + "px;";
|
|
2356
2361
|
}
|
|
2357
2362
|
else {
|
|
2358
2363
|
style += "width:" + (scale > 1
|
|
2359
|
-
?
|
|
2360
|
-
:
|
|
2364
|
+
? _textWidth * font_scale * scale
|
|
2365
|
+
: _textWidth * font_scale) + "px;";
|
|
2361
2366
|
}
|
|
2362
2367
|
}
|
|
2363
2368
|
}
|
|
@@ -2390,7 +2395,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2390
2395
|
}
|
|
2391
2396
|
if (pen.whiteSpace !== 'nowrap') {
|
|
2392
2397
|
var textWidth = pen.fontSize * 1.2 * pen.text.length;
|
|
2393
|
-
var contentWidth = (
|
|
2398
|
+
var contentWidth = (_textWidth || pen.calculative.worldRect.width / scale) *
|
|
2394
2399
|
Math.floor(pen.calculative.worldRect.height /
|
|
2395
2400
|
scale /
|
|
2396
2401
|
(pen.lineHeight * pen.fontSize));
|
|
@@ -3519,13 +3524,11 @@ var Canvas = /** @class */ (function () {
|
|
|
3519
3524
|
var _this = this;
|
|
3520
3525
|
var before = this.store.histories[this.store.historyIndex];
|
|
3521
3526
|
if (before && before.type === EditType.Add) {
|
|
3527
|
+
var pens_6 = [];
|
|
3522
3528
|
before.pens.forEach(function (pen) {
|
|
3523
|
-
|
|
3524
|
-
return;
|
|
3525
|
-
}
|
|
3526
|
-
pen.calculative.canvas = _this;
|
|
3529
|
+
pens_6.push(_this.store.pens[pen.id]);
|
|
3527
3530
|
});
|
|
3528
|
-
this.active(
|
|
3531
|
+
this.active(pens_6);
|
|
3529
3532
|
}
|
|
3530
3533
|
};
|
|
3531
3534
|
Canvas.prototype.doEditAction = function (action, undo) {
|
|
@@ -4040,6 +4043,22 @@ var Canvas = /** @class */ (function () {
|
|
|
4040
4043
|
});
|
|
4041
4044
|
}
|
|
4042
4045
|
pen.type && this.initLineRect(pen);
|
|
4046
|
+
if (pen.calculative.gradientTimer) {
|
|
4047
|
+
clearTimeout(pen.calculative.gradientTimer);
|
|
4048
|
+
}
|
|
4049
|
+
pen.calculative.gradientTimer = setTimeout(function () {
|
|
4050
|
+
if (pen.calculative.lineGradient) {
|
|
4051
|
+
pen.calculative.lineGradient = null;
|
|
4052
|
+
}
|
|
4053
|
+
if (pen.calculative.gradient) {
|
|
4054
|
+
pen.calculative.gradient = null;
|
|
4055
|
+
}
|
|
4056
|
+
if (pen.calculative.radialGradient) {
|
|
4057
|
+
pen.calculative.radialGradient = null;
|
|
4058
|
+
}
|
|
4059
|
+
_this.patchFlags = true;
|
|
4060
|
+
pen.calculative.gradientTimer = undefined;
|
|
4061
|
+
}, 50);
|
|
4043
4062
|
};
|
|
4044
4063
|
Canvas.prototype.translate = function (x, y) {
|
|
4045
4064
|
if (x === void 0) { x = 0; }
|
|
@@ -4288,6 +4307,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4288
4307
|
}, 200);
|
|
4289
4308
|
};
|
|
4290
4309
|
Canvas.prototype.movePens = function (e) {
|
|
4310
|
+
var _a, _b;
|
|
4291
4311
|
if (!this.activeRect || this.store.data.locked) {
|
|
4292
4312
|
return;
|
|
4293
4313
|
}
|
|
@@ -4297,9 +4317,8 @@ var Canvas = /** @class */ (function () {
|
|
|
4297
4317
|
}
|
|
4298
4318
|
if (!this.store.options.moveConnectedLine &&
|
|
4299
4319
|
this.store.active.length === 1 &&
|
|
4300
|
-
(this.store.active[0].anchors[0].connectTo ||
|
|
4301
|
-
this.store.active[0].anchors[this.store.active[0].anchors.length - 1]
|
|
4302
|
-
.connectTo)) {
|
|
4320
|
+
(((_a = this.store.active[0].anchors[0]) === null || _a === void 0 ? void 0 : _a.connectTo) ||
|
|
4321
|
+
((_b = this.store.active[0].anchors[this.store.active[0].anchors.length - 1]) === null || _b === void 0 ? void 0 : _b.connectTo))) {
|
|
4303
4322
|
return;
|
|
4304
4323
|
}
|
|
4305
4324
|
if (!this.movingPens) {
|
|
@@ -4323,7 +4342,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4323
4342
|
this.clearDock();
|
|
4324
4343
|
var moveDock = this.customMoveDock || calcMoveDock;
|
|
4325
4344
|
this.dock = moveDock(this.store, rect, this.movingPens, offset);
|
|
4326
|
-
var
|
|
4345
|
+
var _c = this.dock, xDock = _c.xDock, yDock = _c.yDock;
|
|
4327
4346
|
var dockPen = void 0;
|
|
4328
4347
|
if (xDock) {
|
|
4329
4348
|
offset.x += xDock.step;
|
|
@@ -4376,11 +4395,12 @@ var Canvas = /** @class */ (function () {
|
|
|
4376
4395
|
*/
|
|
4377
4396
|
Canvas.prototype.initMovingPens = function () {
|
|
4378
4397
|
var _this = this;
|
|
4398
|
+
var _a, _b;
|
|
4379
4399
|
if (!this.store.options.moveConnectedLine) {
|
|
4380
4400
|
for (var i = 0; i < this.store.active.length; i++) {
|
|
4381
4401
|
var pen = this.store.active[i];
|
|
4382
|
-
if (pen.anchors[0].connectTo ||
|
|
4383
|
-
pen.anchors[pen.anchors.length - 1].connectTo) {
|
|
4402
|
+
if (((_a = pen.anchors[0]) === null || _a === void 0 ? void 0 : _a.connectTo) ||
|
|
4403
|
+
((_b = pen.anchors[pen.anchors.length - 1]) === null || _b === void 0 ? void 0 : _b.connectTo)) {
|
|
4384
4404
|
this.store.active.splice(i, 1);
|
|
4385
4405
|
pen.calculative.active = undefined;
|
|
4386
4406
|
--i;
|
|
@@ -4412,7 +4432,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4412
4432
|
};
|
|
4413
4433
|
Canvas.prototype.moveLineAnchor = function (pt, keyOptions) {
|
|
4414
4434
|
var _this = this;
|
|
4415
|
-
var _a, _b, _c;
|
|
4435
|
+
var _a, _b, _c, _d;
|
|
4416
4436
|
if (!this.activeRect || this.store.data.locked) {
|
|
4417
4437
|
return;
|
|
4418
4438
|
}
|
|
@@ -4424,7 +4444,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4424
4444
|
disconnectLine(pen, getAnchor(pen, this.store.activeAnchor.anchorId), this.store.pens[this.store.activeAnchor.penId], this.store.activeAnchor);
|
|
4425
4445
|
}
|
|
4426
4446
|
var anchorId = this.store.activeAnchor.id;
|
|
4427
|
-
var connectedLine = (_b = this.store.pens[this.store.activeAnchor.penId]
|
|
4447
|
+
var connectedLine = (_c = (_b = this.store.pens[this.store.activeAnchor.penId]) === null || _b === void 0 ? void 0 : _b.connectedLines) === null || _c === void 0 ? void 0 : _c.filter(function (item) { return item.anchor === anchorId; });
|
|
4428
4448
|
if (connectedLine && connectedLine.length > 0) {
|
|
4429
4449
|
connectedLine.forEach(function (connected) {
|
|
4430
4450
|
var pen = _this.store.pens[connected.lineId];
|
|
@@ -4450,7 +4470,7 @@ var Canvas = /** @class */ (function () {
|
|
|
4450
4470
|
to.prev = undefined;
|
|
4451
4471
|
// 重新自动计算连线
|
|
4452
4472
|
if (line.lineName !== 'polyline') {
|
|
4453
|
-
(
|
|
4473
|
+
(_d = this[line.lineName]) === null || _d === void 0 ? void 0 : _d.call(this, this.store, line);
|
|
4454
4474
|
}
|
|
4455
4475
|
}
|
|
4456
4476
|
}
|
|
@@ -5248,15 +5268,15 @@ var Canvas = /** @class */ (function () {
|
|
|
5248
5268
|
var e_20, _a;
|
|
5249
5269
|
var retPens = [];
|
|
5250
5270
|
try {
|
|
5251
|
-
for (var
|
|
5252
|
-
var pen =
|
|
5271
|
+
for (var pens_7 = __values(pens), pens_7_1 = pens_7.next(); !pens_7_1.done; pens_7_1 = pens_7.next()) {
|
|
5272
|
+
var pen = pens_7_1.value;
|
|
5253
5273
|
retPens.push.apply(retPens, __spreadArray([], __read(deepClone(getAllChildren(pen, this.store), true)), false));
|
|
5254
5274
|
}
|
|
5255
5275
|
}
|
|
5256
5276
|
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
5257
5277
|
finally {
|
|
5258
5278
|
try {
|
|
5259
|
-
if (
|
|
5279
|
+
if (pens_7_1 && !pens_7_1.done && (_a = pens_7.return)) _a.call(pens_7);
|
|
5260
5280
|
}
|
|
5261
5281
|
finally { if (e_20) throw e_20.error; }
|
|
5262
5282
|
}
|