fabric-vectr 6.7.7 → 6.7.9

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.
Files changed (59) hide show
  1. package/dist/index.js +32 -15
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/dist/index.min.mjs +1 -1
  6. package/dist/index.min.mjs.map +1 -1
  7. package/dist/index.mjs +32 -15
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.node.cjs +32 -15
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.mjs +32 -15
  12. package/dist/index.node.mjs.map +1 -1
  13. package/dist/package.json.min.mjs +1 -1
  14. package/dist/package.json.mjs +1 -1
  15. package/dist/src/Collection.d.ts +1 -1
  16. package/dist/src/Collection.d.ts.map +1 -1
  17. package/dist/src/Collection.min.mjs +1 -1
  18. package/dist/src/Collection.min.mjs.map +1 -1
  19. package/dist/src/Collection.mjs +4 -4
  20. package/dist/src/Collection.mjs.map +1 -1
  21. package/dist/src/canvas/Canvas.d.ts.map +1 -1
  22. package/dist/src/canvas/Canvas.min.mjs +1 -1
  23. package/dist/src/canvas/Canvas.min.mjs.map +1 -1
  24. package/dist/src/canvas/Canvas.mjs +15 -7
  25. package/dist/src/canvas/Canvas.mjs.map +1 -1
  26. package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
  27. package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
  28. package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
  29. package/dist/src/canvas/SelectableCanvas.mjs +3 -1
  30. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  31. package/dist/src/canvas/StaticCanvas.d.ts +1 -1
  32. package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
  33. package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
  34. package/dist/src/canvas/StaticCanvas.mjs +1 -1
  35. package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
  36. package/dist/src/shapes/Group.d.ts +1 -1
  37. package/dist/src/shapes/IText/IText.d.ts.map +1 -1
  38. package/dist/src/shapes/IText/IText.min.mjs +1 -1
  39. package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
  40. package/dist/src/shapes/IText/IText.mjs +7 -0
  41. package/dist/src/shapes/IText/IText.mjs.map +1 -1
  42. package/dist/src/shapes/Textbox.min.mjs +1 -1
  43. package/dist/src/shapes/Textbox.min.mjs.map +1 -1
  44. package/dist/src/shapes/Textbox.mjs +1 -1
  45. package/dist/src/shapes/Textbox.mjs.map +1 -1
  46. package/dist-extensions/src/Collection.d.ts +1 -1
  47. package/dist-extensions/src/Collection.d.ts.map +1 -1
  48. package/dist-extensions/src/canvas/Canvas.d.ts.map +1 -1
  49. package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -1
  50. package/dist-extensions/src/canvas/StaticCanvas.d.ts +1 -1
  51. package/dist-extensions/src/shapes/Group.d.ts +1 -1
  52. package/dist-extensions/src/shapes/IText/IText.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/Collection.ts +3 -2
  55. package/src/canvas/Canvas.ts +15 -6
  56. package/src/canvas/SelectableCanvas.ts +7 -1
  57. package/src/canvas/StaticCanvas.ts +1 -1
  58. package/src/shapes/IText/IText.ts +7 -0
  59. package/src/shapes/Textbox.ts +1 -1
package/dist/index.mjs CHANGED
@@ -360,7 +360,7 @@ class Cache {
360
360
  }
361
361
  const cache = new Cache();
362
362
 
363
- var version = "6.7.7";
363
+ var version = "6.7.9";
364
364
 
365
365
  // use this syntax so babel plugin see this import here
366
366
  const VERSION = version;
@@ -1386,7 +1386,7 @@ function createCollectionMixin(Base) {
1386
1386
  * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting
1387
1387
  * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise
1388
1388
  */
1389
- collectObjects(_ref) {
1389
+ collectObjects(fromObjects, _ref) {
1390
1390
  let {
1391
1391
  left,
1392
1392
  top,
@@ -1395,14 +1395,14 @@ function createCollectionMixin(Base) {
1395
1395
  } = _ref;
1396
1396
  let {
1397
1397
  includeIntersecting = true
1398
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1398
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1399
1399
  const objects = [],
1400
1400
  tl = new Point(left, top),
1401
1401
  br = tl.add(new Point(width, height));
1402
1402
 
1403
1403
  // we iterate reverse order to collect top first in case of click.
1404
- for (let i = this._objects.length - 1; i >= 0; i--) {
1405
- const object = this._objects[i];
1404
+ for (let i = fromObjects.length - 1; i >= 0; i--) {
1405
+ const object = fromObjects[i];
1406
1406
  if (object.selectable && object.visible && (includeIntersecting && object.intersectsWithRect(tl, br) || object.isContainedWithinRect(tl, br) || includeIntersecting && object.containsPoint(tl) || includeIntersecting && object.containsPoint(br))) {
1407
1407
  objects.push(object);
1408
1408
  }
@@ -3075,7 +3075,7 @@ class StaticCanvas extends createCollectionMixin(CommonMethods) {
3075
3075
  if (!isTextObject(instance) || !instance.path) {
3076
3076
  continue;
3077
3077
  }
3078
- let pathId = `TEXTPATH_${uid()}`;
3078
+ let pathId = `TEXTPATH_${instance.id}`;
3079
3079
  let pathMarkup = instance.path._toSVG();
3080
3080
  let index = pathMarkup.indexOf('COMMON_PARTS');
3081
3081
  // 加上id, 和路径偏移
@@ -14198,7 +14198,9 @@ class SelectableCanvas extends StaticCanvas {
14198
14198
  activeObject = this._activeObject,
14199
14199
  aObjects = this.getActiveObjects();
14200
14200
  this.targets = [];
14201
- if (activeObject && aObjects.length >= 1 && !this._fixedSearchTargets) {
14201
+
14202
+ // valid _fixedSearchTargets is null or _fixedSearchTargets includes activeObject
14203
+ if (activeObject && aObjects.length >= 1 && (!this._fixedSearchTargets || this._fixedSearchTargets.includes(activeObject))) {
14202
14204
  if (activeObject.findControl(pointer, isTouchEvent(e))) {
14203
14205
  // if we hit the corner of the active object, let's return that.
14204
14206
  return activeObject;
@@ -15582,6 +15584,8 @@ class Canvas extends SelectableCanvas {
15582
15584
  } else if (!isClick && !((_this$_activeObject = this._activeObject) !== null && _this$_activeObject !== void 0 && _this$_activeObject.isEditing)) {
15583
15585
  this.renderTop();
15584
15586
  }
15587
+ // 框选不改变locked对象,不框选时如果没有点击到可以锁定组,设置锁定组为null
15588
+ if (isClick && !this.getActiveObject()) this.isolatedObject = null;
15585
15589
  }
15586
15590
  _basicEventHandler(eventType, options) {
15587
15591
  const {
@@ -15721,11 +15725,14 @@ class Canvas extends SelectableCanvas {
15721
15725
  }
15722
15726
  this.setFixedSearchTargets(null);
15723
15727
  }
15724
- this.isolatedObject = isolatedObject;
15725
- // use __onMouseDown select other object immediately after unlocking
15726
- this._resetTransformEventData();
15727
- this.__onMouseDown(e);
15728
- return true;
15728
+ if (isolatedObject) {
15729
+ this.isolatedObject = isolatedObject;
15730
+ // use __onMouseDown select other object immediately after unlocking
15731
+ this._resetTransformEventData();
15732
+ this.__onMouseDown(e);
15733
+ return true;
15734
+ }
15735
+ return false;
15729
15736
  }
15730
15737
 
15731
15738
  /**
@@ -15773,8 +15780,11 @@ class Canvas extends SelectableCanvas {
15773
15780
  grouped = true;
15774
15781
  shouldRender = true;
15775
15782
  } else if (this._shouldClearSelection(e, target)) {
15783
+ const objs = this.getActiveObjects();
15776
15784
  this.discardActiveObject(e);
15777
- if (this.switchIsolateObject(e)) {
15785
+ // 多选取消,重置Coords, 防止无法再次选中
15786
+ objs.forEach(obj => obj.setCoords());
15787
+ if (!target && this.switchIsolateObject(e)) {
15778
15788
  return;
15779
15789
  }
15780
15790
  }
@@ -16180,7 +16190,7 @@ class Canvas extends SelectableCanvas {
16180
16190
  tl = point1.min(point2),
16181
16191
  br = point1.max(point2),
16182
16192
  size = br.subtract(tl);
16183
- const collectedObjects = this.collectObjects({
16193
+ const collectedObjects = this.collectObjects(this.getSearchTargets(), {
16184
16194
  left: tl.x,
16185
16195
  top: tl.y,
16186
16196
  width: size.x,
@@ -23351,6 +23361,13 @@ class IText extends ITextClickBehavior {
23351
23361
  }
23352
23362
  this.canvas.contextTopDirty = true;
23353
23363
  ctx.restore();
23364
+
23365
+ // For grouped objects, ensure selection is rendered after other operations
23366
+ if (this.parent && this.selectionStart !== this.selectionEnd) {
23367
+ setTimeout(() => {
23368
+ this.renderCursorOrSelection();
23369
+ }, 0);
23370
+ }
23354
23371
  }
23355
23372
 
23356
23373
  /**
@@ -24392,7 +24409,7 @@ class Textbox extends IText {
24392
24409
  rightGap = Math.max(rightGap, maxRight - (v.right || 0));
24393
24410
  });
24394
24411
  // 计算中心点位置
24395
- if (maxCenter && minCenter) {
24412
+ if (maxCenter !== null && minCenter !== null) {
24396
24413
  const centerOff = maxCenter - minCenter;
24397
24414
  const onCharWidth = (lines[maxCharIdx].width || 0) / lines[maxCharIdx].text.length;
24398
24415
  // 左边间距大于右边两倍 或者 中心点偏移超过1/2字符且右边间距小于1/3字符