@tmagic/stage 1.3.3 → 1.3.4

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.
@@ -733,15 +733,15 @@
733
733
  /**
734
734
  * 设置有哪些元素要辅助对齐
735
735
  * @param selectedElList 选中的元素列表,需要排除在对齐元素之外
736
- * @param allElList 全部元素列表
737
736
  */
738
- setElementGuidelines(selectedElList, allElList) {
737
+ setElementGuidelines(selectedElList) {
739
738
  this.elementGuidelines.forEach((node) => {
740
739
  node.remove();
741
740
  });
742
741
  this.elementGuidelines = [];
742
+ const elementGuidelines = this.getCustomizeOptions()?.elementGuidelines || Array.from(selectedElList[0]?.parentElement?.children || []);
743
743
  if (this.mode === Mode.ABSOLUTE) {
744
- this.container.append(this.createGuidelineElements(selectedElList, allElList));
744
+ this.container.append(this.createGuidelineElements(selectedElList, elementGuidelines));
745
745
  }
746
746
  }
747
747
  /**
@@ -858,10 +858,18 @@
858
858
  */
859
859
  createGuidelineElements(selectedElList, allElList) {
860
860
  const frame = globalThis.document.createDocumentFragment();
861
- for (const node of allElList) {
862
- const { width, height } = node.getBoundingClientRect();
861
+ for (const element of allElList) {
862
+ let node = element.element || element;
863
+ if (!node || typeof node === "string")
864
+ continue;
865
+ if (typeof node === "function") {
866
+ node = node();
867
+ }
863
868
  if (this.isInElementList(node, selectedElList))
864
869
  continue;
870
+ const { width, height } = node.getBoundingClientRect();
871
+ if (!width || !height)
872
+ continue;
865
873
  const { left, top } = getOffset(node);
866
874
  const elementGuideline = globalThis.document.createElement("div");
867
875
  elementGuideline.style.cssText = `position: absolute;width: ${width}px;height: ${height}px;top: ${top}px;left: ${left}px`;
@@ -970,8 +978,7 @@
970
978
  this.mode = getMode(el);
971
979
  this.dragResizeHelper.updateShadowEl(el);
972
980
  this.dragResizeHelper.setMode(this.mode);
973
- const elementGuidelines = Array.from(this.target?.parentElement?.children || []);
974
- this.setElementGuidelines([this.target], elementGuidelines);
981
+ this.setElementGuidelines([this.target]);
975
982
  return this.getOptions(false, {
976
983
  target: this.dragResizeHelper.getShadowEl()
977
984
  });
@@ -1239,8 +1246,7 @@
1239
1246
  this.mode = getMode(els[0]);
1240
1247
  this.targetList = els;
1241
1248
  this.dragResizeHelper.updateGroup(els);
1242
- const elementGuidelines = Array.from(this.targetList[0].parentElement?.children || []);
1243
- this.setElementGuidelines(this.targetList, elementGuidelines);
1249
+ this.setElementGuidelines(this.targetList);
1244
1250
  this.moveableForMulti?.destroy();
1245
1251
  this.dragResizeHelper.clear();
1246
1252
  this.moveableForMulti = new Moveable(
@@ -1632,7 +1638,8 @@
1632
1638
  targetElId: this.selectedEl?.id,
1633
1639
  targetEls: this.selectedElList,
1634
1640
  targetElIds: this.selectedElList?.map((item) => item.id),
1635
- isMulti
1641
+ isMulti,
1642
+ document: this.getRenderDocument()
1636
1643
  };
1637
1644
  return options(cfg);
1638
1645
  }