@meta2d/core 1.0.39 → 1.0.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta2d/core",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1036,7 +1036,7 @@ var Canvas = /** @class */ (function () {
1036
1036
  ((_b = _this.drawingLine) === null || _b === void 0 ? void 0 : _b.calculative.worldAnchors.length) >
1037
1037
  _this.store.options.drawingLineLength)) {
1038
1038
  _this.finishDrawline(true);
1039
- if ((_c = _this.store.active[0]) === null || _c === void 0 ? void 0 : _c.anchors[0].connectTo) {
1039
+ if (((_c = _this.store.active[0]) === null || _c === void 0 ? void 0 : _c.anchors[0].connectTo) || _this.store.active.length == 0) {
1040
1040
  _this.drawingLineName = '';
1041
1041
  }
1042
1042
  else {
@@ -2157,7 +2157,7 @@ var Canvas = /** @class */ (function () {
2157
2157
  ctx.translate(-_this.activeRect.center.x, -_this.activeRect.center.y);
2158
2158
  }
2159
2159
  ctx.strokeStyle = _this.store.options.activeColor;
2160
- ctx.globalAlpha = _this.store.options.activeGlobalAlpha || 0.3;
2160
+ ctx.globalAlpha = _this.store.options.activeGlobalAlpha === undefined ? 0.3 : _this.store.options.activeGlobalAlpha;
2161
2161
  ctx.beginPath();
2162
2162
  ctx.lineWidth = _this.store.options.activeLineWidth || 1;
2163
2163
  ctx.setLineDash(_this.store.options.activeLineDash || []);
@@ -2712,6 +2712,9 @@ var Canvas = /** @class */ (function () {
2712
2712
  });
2713
2713
  _this.store.emitter.emit('valueUpdate', pen);
2714
2714
  }
2715
+ else if (pen.text === _this.inputDiv.dataset.value && pen.calculative.textLines.length == 0) {
2716
+ calcTextRect(pen);
2717
+ }
2715
2718
  _this.initTemplateCanvas([pen]);
2716
2719
  }
2717
2720
  _this.inputDiv.dataset.penId = undefined;
@@ -4382,6 +4385,7 @@ var Canvas = /** @class */ (function () {
4382
4385
  Canvas.prototype.finishDrawline = function (end) {
4383
4386
  return __awaiter(this, void 0, void 0, function () {
4384
4387
  var from, to, line, rect, allowAdd, _a;
4388
+ var _this = this;
4385
4389
  return __generator(this, function (_b) {
4386
4390
  switch (_b.label) {
4387
4391
  case 0:
@@ -4406,6 +4410,9 @@ var Canvas = /** @class */ (function () {
4406
4410
  if (!from.connectTo || !to.connectTo) {
4407
4411
  if (this.store.options.disableEmptyLine) {
4408
4412
  // 有一端未连线,且 禁止创建空线条
4413
+ if (from.connectTo) {
4414
+ this.store.pens[from.connectTo].connectedLines = this.store.pens[from.connectTo].connectedLines.filter(function (item) { return item.lineId !== _this.drawingLine.id; });
4415
+ }
4409
4416
  this.drawingLine = undefined;
4410
4417
  this.render();
4411
4418
  return [2 /*return*/];
@@ -4768,7 +4775,6 @@ var Canvas = /** @class */ (function () {
4768
4775
  }, 50);
4769
4776
  };
4770
4777
  Canvas.prototype.translate = function (x, y) {
4771
- var _this = this;
4772
4778
  if (x === void 0) { x = 0; }
4773
4779
  if (y === void 0) { y = 0; }
4774
4780
  this.store.data.x += x * this.store.data.scale;
@@ -4812,12 +4818,13 @@ var Canvas = /** @class */ (function () {
4812
4818
  }
4813
4819
  }
4814
4820
  }
4815
- setTimeout(function () {
4816
- _this.canvasTemplate.init();
4817
- _this.canvasImage.init();
4818
- _this.canvasImageBottom.init();
4819
- _this.render();
4820
- });
4821
+ //TODO 当初为什么加异步
4822
+ // setTimeout(() => {
4823
+ this.canvasTemplate.init();
4824
+ this.canvasImage.init();
4825
+ this.canvasImageBottom.init();
4826
+ this.render();
4827
+ // });
4821
4828
  this.store.emitter.emit('translate', {
4822
4829
  x: this.store.data.x,
4823
4830
  y: this.store.data.y,
@@ -4908,17 +4915,17 @@ var Canvas = /** @class */ (function () {
4908
4915
  _this.execPenResize(pen);
4909
4916
  });
4910
4917
  this.calcActiveRect();
4911
- setTimeout(function () {
4912
- _this.canvasTemplate.init();
4913
- _this.canvasImage.init();
4914
- _this.canvasImageBottom.init();
4915
- var map = _this.parent.map;
4916
- if (map && map.isShow) {
4917
- map.setView();
4918
- }
4919
- _this.render();
4920
- _this.store.emitter.emit('scale', _this.store.data.scale);
4921
- });
4918
+ // setTimeout(() => {
4919
+ this.canvasTemplate.init();
4920
+ this.canvasImage.init();
4921
+ this.canvasImageBottom.init();
4922
+ var map = this.parent.map;
4923
+ if (map && map.isShow) {
4924
+ map.setView();
4925
+ }
4926
+ this.render();
4927
+ this.store.emitter.emit('scale', this.store.data.scale);
4928
+ // });
4922
4929
  };
4923
4930
  Canvas.prototype.templateScale = function (scale, center) {
4924
4931
  var _this = this;