fabric-vectr 6.7.1 → 6.7.2

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 (39) hide show
  1. package/dist/index.js +62 -27
  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 +62 -27
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.node.cjs +62 -27
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.mjs +62 -27
  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.map +1 -1
  28. package/dist/src/canvas/SelectableCanvas.mjs +12 -12
  29. package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
  30. package/dist-extensions/src/canvas/Canvas.d.ts +8 -1
  31. package/dist-extensions/src/canvas/Canvas.d.ts.map +1 -1
  32. package/dist-extensions/src/canvas/CanvasOptions.d.ts +3 -1
  33. package/dist-extensions/src/canvas/CanvasOptions.d.ts.map +1 -1
  34. package/dist-extensions/src/canvas/SelectableCanvas.d.ts +8 -7
  35. package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/src/canvas/Canvas.ts +49 -14
  38. package/src/canvas/CanvasOptions.ts +3 -1
  39. package/src/canvas/SelectableCanvas.ts +12 -12
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.2";
370
370
 
371
371
  // use this syntax so babel plugin see this import here
372
372
  const VERSION = version;
@@ -13710,18 +13710,20 @@
13710
13710
  * @default
13711
13711
  */
13712
13712
  /**
13713
- * 启用双击锁定组对象,锁定后只能选择对象的子节点,无论group中interative和subTargetCheck是否启用
13713
+ * Enable double-click to lock the group node. After locking,
13714
+ * you can select the child nodes in the group node,
13715
+ * regardless of whether interative and subTargetCheck are enabled in the group.
13714
13716
  * @type Boolean
13715
13717
  * @default
13716
13718
  */
13717
13719
  /**
13718
- * 双击锁定的节点, 目前只支持组节点
13720
+ * Double-click the locked node. Currently only group nodes are supported.
13719
13721
  * @type Group | null
13720
13722
  * @default
13721
13723
  */
13722
13724
  _defineProperty(this, "isolatedObject", void 0);
13723
13725
  /**
13724
- * 指定的搜索对象
13726
+ * Specified search objects
13725
13727
  * @type Boolean
13726
13728
  * @default null
13727
13729
  */
@@ -14131,7 +14133,7 @@
14131
14133
  }
14132
14134
 
14133
14135
  /**
14134
- * 双击选择
14136
+ * Double-click to lock the group
14135
14137
  * @param e
14136
14138
  * @returns
14137
14139
  */
@@ -14142,19 +14144,18 @@
14142
14144
  const obj = this.searchPossibleTargets(objects, pointer);
14143
14145
  if (obj) {
14144
14146
  if (obj instanceof Group) {
14145
- // 组才修改锁定
14146
14147
  this.isolatedObject = obj;
14147
14148
  this.discardActiveObject();
14148
- // 新创建的组对象,子节点coords初始化,否则无法选中
14149
+ // The newly created group object has its child node coords initialized, otherwise it cannot be selected.
14149
14150
  obj._objects.forEach(o => {
14150
14151
  o.setCoords();
14151
14152
  });
14152
14153
  } else {
14153
- // 非组对象不处理锁定,返回false继续对象自己的双击事件
14154
+ // Non-group objects do not handle locking, return false to continue the object's own double-click event
14154
14155
  return false;
14155
14156
  }
14156
14157
  } else {
14157
- // 取消锁定
14158
+ // cancel isolation
14158
14159
  this.isolatedObject = null;
14159
14160
  this.discardActiveObject();
14160
14161
  }
@@ -14164,8 +14165,7 @@
14164
14165
  }
14165
14166
 
14166
14167
  /**
14167
- * 设置搜索对象
14168
- * 如当编辑path时,设置点为可搜索对象
14168
+ * Manually set the search object
14169
14169
  * @param objects
14170
14170
  */
14171
14171
  setSearchTargets(objects) {
@@ -14173,7 +14173,7 @@
14173
14173
  }
14174
14174
 
14175
14175
  /**
14176
- * 返回搜索对象
14176
+ * Returns the search object
14177
14177
  * @returns
14178
14178
  */
14179
14179
  getSearchTargets() {
@@ -14296,7 +14296,7 @@
14296
14296
  while (i--) {
14297
14297
  const target = objects[i];
14298
14298
  if (this._checkTarget(target, pointer)) {
14299
- // 没有开启双击锁定节点才搜索子节点
14299
+ // Double-clicking to lock a node before searching for its child nodes is not enabled
14300
14300
  if (!this.dblClickIsolateObject && isCollection(target) && target.subTargetCheck) {
14301
14301
  const subTarget = this._searchPossibleTargets(target._objects, pointer);
14302
14302
  subTarget && this.targets.push(subTarget);
@@ -15320,12 +15320,13 @@
15320
15320
  }
15321
15321
 
15322
15322
  /**
15323
- * 双击选择锁定组的子节点
15323
+ * Double-click to select the child nodes of the locked group
15324
15324
  * @param e
15325
15325
  */
15326
15326
  _onDblClick(e) {
15327
15327
  if (this.dblClickLock(e)) {
15328
- // 锁定后立即选中点击子对象
15328
+ // Immediately select the clicked child object after locking
15329
+ this._resetTransformEventData();
15329
15330
  this.__onMouseDown(e);
15330
15331
  this.__onMouseUp(e);
15331
15332
  return;
@@ -15679,6 +15680,51 @@
15679
15680
  this._handleEvent(e, 'up');
15680
15681
  }
15681
15682
 
15683
+ /**
15684
+ * Change to other isolated object when click on current group's parent
15685
+ * When click empty space or other object, cancel isolated state
15686
+ * @param e
15687
+ * @returns
15688
+ */
15689
+ switchIsolateObject(e) {
15690
+ if (!this.isolatedObject || this._searchTargets) return false;
15691
+ let isolatedObject = null;
15692
+ if (this.isolatedObject.parent) {
15693
+ const parents = [];
15694
+ let currentObj = this.isolatedObject;
15695
+ while (currentObj.parent) {
15696
+ parents.push(currentObj.parent);
15697
+ currentObj = currentObj.parent;
15698
+ }
15699
+ // check topmost parent, if it was clicked, find the nearest child object to isolate
15700
+ const topmostParent = parents[parents.length - 1];
15701
+ this.setSearchTargets([topmostParent]);
15702
+ let target = this.findTarget(e);
15703
+ // parent was clicked
15704
+ if (target) {
15705
+ parents.some(parent => {
15706
+ this.setSearchTargets(parent.getObjects());
15707
+ target = this.findTarget(e);
15708
+ if (target) {
15709
+ isolatedObject = parent;
15710
+ // The newly created group object has its child node coords initialized, otherwise it cannot be selected.
15711
+ parent.getObjects().forEach(o => {
15712
+ o.setCoords();
15713
+ });
15714
+ return true;
15715
+ }
15716
+ return false;
15717
+ });
15718
+ }
15719
+ this.setSearchTargets(null);
15720
+ }
15721
+ this.isolatedObject = isolatedObject;
15722
+ // use __onMouseDown select other object immediately after unlocking
15723
+ this._resetTransformEventData();
15724
+ this.__onMouseDown(e);
15725
+ return true;
15726
+ }
15727
+
15682
15728
  /**
15683
15729
  * Method that defines the actions when mouse is clicked on canvas.
15684
15730
  * The method inits the currentTransform parameters and renders all the
@@ -15725,18 +15771,7 @@
15725
15771
  shouldRender = true;
15726
15772
  } else if (this._shouldClearSelection(e, target)) {
15727
15773
  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);
15774
+ if (this.switchIsolateObject(e)) {
15740
15775
  return;
15741
15776
  }
15742
15777
  }