fabric-vectr 6.7.1 → 6.7.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.
Files changed (47) hide show
  1. package/dist/index.js +66 -28
  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 +66 -28
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.node.cjs +66 -28
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.mjs +66 -28
  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/canvas/Canvas.d.ts +8 -1
  16. package/dist/src/canvas/Canvas.d.ts.map +1 -1
  17. package/dist/src/canvas/Canvas.min.mjs +1 -1
  18. package/dist/src/canvas/Canvas.min.mjs.map +1 -1
  19. package/dist/src/canvas/Canvas.mjs +49 -14
  20. package/dist/src/canvas/Canvas.mjs.map +1 -1
  21. package/dist/src/canvas/CanvasOptions.d.ts +3 -1
  22. package/dist/src/canvas/CanvasOptions.d.ts.map +1 -1
  23. package/dist/src/canvas/CanvasOptions.min.mjs.map +1 -1
  24. package/dist/src/canvas/CanvasOptions.mjs.map +1 -1
  25. package/dist/src/canvas/SelectableCanvas.d.ts +8 -7
  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 +14 -12
  30. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  31. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
  32. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +1 -1
  33. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
  34. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +2 -1
  35. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
  36. package/dist-extensions/src/canvas/Canvas.d.ts +8 -1
  37. package/dist-extensions/src/canvas/Canvas.d.ts.map +1 -1
  38. package/dist-extensions/src/canvas/CanvasOptions.d.ts +3 -1
  39. package/dist-extensions/src/canvas/CanvasOptions.d.ts.map +1 -1
  40. package/dist-extensions/src/canvas/SelectableCanvas.d.ts +8 -7
  41. package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -1
  42. package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/src/canvas/Canvas.ts +49 -14
  45. package/src/canvas/CanvasOptions.ts +3 -1
  46. package/src/canvas/SelectableCanvas.ts +14 -12
  47. package/src/shapes/Object/FabricObjectSVGExportMixin.ts +4 -1
package/dist/index.js CHANGED
@@ -366,7 +366,7 @@
366
366
  }
367
367
  const cache = new Cache();
368
368
 
369
- var version = "6.7.1";
369
+ var version = "6.7.3";
370
370
 
371
371
  // use this syntax so babel plugin see this import here
372
372
  const VERSION = version;
@@ -5002,8 +5002,9 @@
5002
5002
  withShadow,
5003
5003
  additionalTransform
5004
5004
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5005
+ var skipShadow = true;
5005
5006
  let clipPath = this.clipPath;
5006
- const styleInfo = noStyle ? '' : `style="${this.getSvgStyles()}" `,
5007
+ const styleInfo = noStyle ? '' : `style="${this.getSvgStyles(skipShadow)}" `,
5007
5008
  shadowInfo = withShadow ? `style="${this.getSvgFilter()}" ` : '',
5008
5009
  vectorEffect = this.strokeUniform ? 'vector-effect="non-scaling-stroke" ' : '',
5009
5010
  absoluteClipPath = clipPath && clipPath.absolutePositioned,
@@ -13710,18 +13711,20 @@
13710
13711
  * @default
13711
13712
  */
13712
13713
  /**
13713
- * 启用双击锁定组对象,锁定后只能选择对象的子节点,无论group中interative和subTargetCheck是否启用
13714
+ * Enable double-click to lock the group node. After locking,
13715
+ * you can select the child nodes in the group node,
13716
+ * regardless of whether interative and subTargetCheck are enabled in the group.
13714
13717
  * @type Boolean
13715
13718
  * @default
13716
13719
  */
13717
13720
  /**
13718
- * 双击锁定的节点, 目前只支持组节点
13721
+ * Double-click the locked node. Currently only group nodes are supported.
13719
13722
  * @type Group | null
13720
13723
  * @default
13721
13724
  */
13722
13725
  _defineProperty(this, "isolatedObject", void 0);
13723
13726
  /**
13724
- * 指定的搜索对象
13727
+ * Specified search objects
13725
13728
  * @type Boolean
13726
13729
  * @default null
13727
13730
  */
@@ -14131,7 +14134,7 @@
14131
14134
  }
14132
14135
 
14133
14136
  /**
14134
- * 双击选择
14137
+ * Double-click to lock the group
14135
14138
  * @param e
14136
14139
  * @returns
14137
14140
  */
@@ -14142,19 +14145,20 @@
14142
14145
  const obj = this.searchPossibleTargets(objects, pointer);
14143
14146
  if (obj) {
14144
14147
  if (obj instanceof Group) {
14145
- // 组才修改锁定
14148
+ // Let text in group can be edited after isolation
14149
+ obj.interactive = true;
14146
14150
  this.isolatedObject = obj;
14147
14151
  this.discardActiveObject();
14148
- // 新创建的组对象,子节点coords初始化,否则无法选中
14152
+ // The newly created group object has its child node coords initialized, otherwise it cannot be selected.
14149
14153
  obj._objects.forEach(o => {
14150
14154
  o.setCoords();
14151
14155
  });
14152
14156
  } else {
14153
- // 非组对象不处理锁定,返回false继续对象自己的双击事件
14157
+ // Non-group objects do not handle locking, return false to continue the object's own double-click event
14154
14158
  return false;
14155
14159
  }
14156
14160
  } else {
14157
- // 取消锁定
14161
+ // cancel isolation
14158
14162
  this.isolatedObject = null;
14159
14163
  this.discardActiveObject();
14160
14164
  }
@@ -14164,8 +14168,7 @@
14164
14168
  }
14165
14169
 
14166
14170
  /**
14167
- * 设置搜索对象
14168
- * 如当编辑path时,设置点为可搜索对象
14171
+ * Manually set the search object
14169
14172
  * @param objects
14170
14173
  */
14171
14174
  setSearchTargets(objects) {
@@ -14173,7 +14176,7 @@
14173
14176
  }
14174
14177
 
14175
14178
  /**
14176
- * 返回搜索对象
14179
+ * Returns the search object
14177
14180
  * @returns
14178
14181
  */
14179
14182
  getSearchTargets() {
@@ -14296,7 +14299,7 @@
14296
14299
  while (i--) {
14297
14300
  const target = objects[i];
14298
14301
  if (this._checkTarget(target, pointer)) {
14299
- // 没有开启双击锁定节点才搜索子节点
14302
+ // Double-clicking to lock a node before searching for its child nodes is not enabled
14300
14303
  if (!this.dblClickIsolateObject && isCollection(target) && target.subTargetCheck) {
14301
14304
  const subTarget = this._searchPossibleTargets(target._objects, pointer);
14302
14305
  subTarget && this.targets.push(subTarget);
@@ -15320,12 +15323,13 @@
15320
15323
  }
15321
15324
 
15322
15325
  /**
15323
- * 双击选择锁定组的子节点
15326
+ * Double-click to select the child nodes of the locked group
15324
15327
  * @param e
15325
15328
  */
15326
15329
  _onDblClick(e) {
15327
15330
  if (this.dblClickLock(e)) {
15328
- // 锁定后立即选中点击子对象
15331
+ // Immediately select the clicked child object after locking
15332
+ this._resetTransformEventData();
15329
15333
  this.__onMouseDown(e);
15330
15334
  this.__onMouseUp(e);
15331
15335
  return;
@@ -15679,6 +15683,51 @@
15679
15683
  this._handleEvent(e, 'up');
15680
15684
  }
15681
15685
 
15686
+ /**
15687
+ * Change to other isolated object when click on current group's parent
15688
+ * When click empty space or other object, cancel isolated state
15689
+ * @param e
15690
+ * @returns
15691
+ */
15692
+ switchIsolateObject(e) {
15693
+ if (!this.isolatedObject || this._searchTargets) return false;
15694
+ let isolatedObject = null;
15695
+ if (this.isolatedObject.parent) {
15696
+ const parents = [];
15697
+ let currentObj = this.isolatedObject;
15698
+ while (currentObj.parent) {
15699
+ parents.push(currentObj.parent);
15700
+ currentObj = currentObj.parent;
15701
+ }
15702
+ // check topmost parent, if it was clicked, find the nearest child object to isolate
15703
+ const topmostParent = parents[parents.length - 1];
15704
+ this.setSearchTargets([topmostParent]);
15705
+ let target = this.findTarget(e);
15706
+ // parent was clicked
15707
+ if (target) {
15708
+ parents.some(parent => {
15709
+ this.setSearchTargets(parent.getObjects());
15710
+ target = this.findTarget(e);
15711
+ if (target) {
15712
+ isolatedObject = parent;
15713
+ // The newly created group object has its child node coords initialized, otherwise it cannot be selected.
15714
+ parent.getObjects().forEach(o => {
15715
+ o.setCoords();
15716
+ });
15717
+ return true;
15718
+ }
15719
+ return false;
15720
+ });
15721
+ }
15722
+ this.setSearchTargets(null);
15723
+ }
15724
+ this.isolatedObject = isolatedObject;
15725
+ // use __onMouseDown select other object immediately after unlocking
15726
+ this._resetTransformEventData();
15727
+ this.__onMouseDown(e);
15728
+ return true;
15729
+ }
15730
+
15682
15731
  /**
15683
15732
  * Method that defines the actions when mouse is clicked on canvas.
15684
15733
  * The method inits the currentTransform parameters and renders all the
@@ -15725,18 +15774,7 @@
15725
15774
  shouldRender = true;
15726
15775
  } else if (this._shouldClearSelection(e, target)) {
15727
15776
  this.discardActiveObject(e);
15728
-
15729
- // 锁定对象时且没有指定选中时,如果点击组外空白或对象,取消锁定
15730
- if (this.isolatedObject && !this._searchTargets) {
15731
- this.setSearchTargets([this.isolatedObject]);
15732
- const target = this.findTarget(e);
15733
- // 没有选中任何对象,或者选中的是锁定对象以外的对象
15734
- if (target !== this.isolatedObject) {
15735
- this.isolatedObject = null;
15736
- }
15737
- this.setSearchTargets(null);
15738
- // 在此执行__onMouseDown选中对象
15739
- this.__onMouseDown(e);
15777
+ if (this.switchIsolateObject(e)) {
15740
15778
  return;
15741
15779
  }
15742
15780
  }