@tmagic/stage 1.0.0-beta.11 → 1.0.0-beta.14

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # [文档](https://tencent.github.io/tmagic-editor/docs/)
@@ -6,6 +6,7 @@ import Guides from '@scena/guides';
6
6
 
7
7
  const GHOST_EL_ID_PREFIX = "ghost_el_";
8
8
  const DRAG_EL_ID_PREFIX = "drag_el_";
9
+ const HIGHLIGHT_EL_ID_PREFIX = "highlight_el_";
9
10
  const DEFAULT_ZOOM = 1;
10
11
  var GuidesType = /* @__PURE__ */ ((GuidesType2) => {
11
12
  GuidesType2["HORIZONTAL"] = "horizontal";
@@ -163,21 +164,14 @@ const addSelectedClassName = (el) => {
163
164
  };
164
165
 
165
166
  class StageDragResize extends EventEmitter {
166
- core;
167
- container;
168
- target;
169
- dragEl;
170
- moveable;
171
- horizontalGuidelines = [];
172
- verticalGuidelines = [];
173
- elementGuidelines = [];
174
- moveableOptions = {};
175
- dragStatus = "end" /* END */;
176
- ghostEl;
177
- mode = Mode.ABSOLUTE;
178
- moveableHelper;
179
167
  constructor(config) {
180
168
  super();
169
+ this.horizontalGuidelines = [];
170
+ this.verticalGuidelines = [];
171
+ this.elementGuidelines = [];
172
+ this.mode = Mode.ABSOLUTE;
173
+ this.moveableOptions = {};
174
+ this.dragStatus = "end" /* END */;
181
175
  this.core = config.core;
182
176
  this.container = config.container;
183
177
  this.dragEl = globalThis.document.createElement("div");
@@ -399,6 +393,7 @@ class StageDragResize extends EventEmitter {
399
393
  top: ${offset.top}px;
400
394
  width: ${width}px;
401
395
  height: ${height}px;
396
+ z-index: 9;
402
397
  `;
403
398
  this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
404
399
  }
@@ -409,6 +404,7 @@ class StageDragResize extends EventEmitter {
409
404
  if (!this.target)
410
405
  return {};
411
406
  const isAbsolute = this.mode === Mode.ABSOLUTE;
407
+ const isFixed = this.mode === Mode.FIXED;
412
408
  let { moveableOptions = {} } = this.core.config;
413
409
  if (typeof moveableOptions === "function") {
414
410
  moveableOptions = moveableOptions(this.core);
@@ -420,8 +416,8 @@ class StageDragResize extends EventEmitter {
420
416
  dragArea: false,
421
417
  draggable: true,
422
418
  resizable: true,
423
- snappable: isAbsolute,
424
- snapGap: isAbsolute,
419
+ snappable: isAbsolute || isFixed,
420
+ snapGap: isAbsolute || isFixed,
425
421
  snapThreshold: 5,
426
422
  snapDigit: 0,
427
423
  throttleDrag: 0,
@@ -512,15 +508,97 @@ const up = (deltaTop, target) => {
512
508
  };
513
509
  };
514
510
 
511
+ class TargetCalibrate extends EventEmitter {
512
+ constructor(config) {
513
+ super();
514
+ this.parent = config.parent;
515
+ this.mask = config.mask;
516
+ this.dr = config.dr;
517
+ this.operationEl = globalThis.document.createElement("div");
518
+ this.parent.append(this.operationEl);
519
+ }
520
+ update(el, prefix) {
521
+ const { width, height } = el.getBoundingClientRect();
522
+ const { left, top } = this.getOffset(el);
523
+ this.operationEl.style.cssText = `
524
+ position: absolute;
525
+ left: ${left}px;
526
+ top: ${top}px;
527
+ width: ${width}px;
528
+ height: ${height}px;
529
+ `;
530
+ this.operationEl.id = `${prefix}${el.id}`;
531
+ return this.operationEl;
532
+ }
533
+ destroy() {
534
+ this.operationEl?.remove();
535
+ }
536
+ getOffset(el) {
537
+ const { transform } = getComputedStyle(el);
538
+ const { offsetParent } = el;
539
+ let left = el.offsetLeft;
540
+ let top = el.offsetTop;
541
+ if (transform.indexOf("matrix") > -1) {
542
+ let a = 1;
543
+ let b = 1;
544
+ let c = 1;
545
+ let d = 1;
546
+ let e = 0;
547
+ let f = 0;
548
+ transform.replace(/matrix\((.+), (.+), (.+), (.+), (.+), (.+)\)/, ($0, $1, $2, $3, $4, $5, $6) => {
549
+ a = +$1;
550
+ b = +$2;
551
+ c = +$3;
552
+ d = +$4;
553
+ e = +$5;
554
+ f = +$6;
555
+ return transform;
556
+ });
557
+ left = a * left + c * top + e;
558
+ top = b * left + d * top + f;
559
+ }
560
+ if (offsetParent) {
561
+ const parentOffset = this.getOffset(offsetParent);
562
+ return {
563
+ left: left + parentOffset.left,
564
+ top: top + parentOffset.top
565
+ };
566
+ }
567
+ if (this.dr.mode === Mode.FIXED) {
568
+ if (getMode(el) === Mode.FIXED) {
569
+ return {
570
+ left,
571
+ top
572
+ };
573
+ }
574
+ return {
575
+ left: left - this.mask.scrollLeft,
576
+ top: top - this.mask.scrollTop
577
+ };
578
+ }
579
+ if (getMode(el) === Mode.FIXED) {
580
+ return {
581
+ left: left + this.mask.scrollLeft,
582
+ top: top + this.mask.scrollTop
583
+ };
584
+ }
585
+ return {
586
+ left,
587
+ top
588
+ };
589
+ }
590
+ }
591
+
515
592
  class StageHighlight extends EventEmitter {
516
- core;
517
- container;
518
- target;
519
- moveable;
520
593
  constructor(config) {
521
594
  super();
522
595
  this.core = config.core;
523
596
  this.container = config.container;
597
+ this.calibrationTarget = new TargetCalibrate({
598
+ parent: this.core.mask.content,
599
+ mask: this.core.mask,
600
+ dr: this.core.dr
601
+ });
524
602
  }
525
603
  highlight(el) {
526
604
  if (!el || el === this.target)
@@ -528,31 +606,61 @@ class StageHighlight extends EventEmitter {
528
606
  this.target = el;
529
607
  this.moveable?.destroy();
530
608
  this.moveable = new Moveable(this.container, {
531
- target: this.target,
532
- scrollable: true,
533
- origin: false
609
+ target: this.calibrationTarget.update(el, HIGHLIGHT_EL_ID_PREFIX),
610
+ origin: false,
611
+ rootContainer: this.core.container,
612
+ zoom: 1
534
613
  });
535
614
  }
536
615
  clearHighlight() {
537
616
  if (!this.moveable)
538
617
  return;
618
+ this.target = void 0;
539
619
  this.moveable.target = null;
540
620
  this.moveable.updateTarget();
541
621
  }
542
622
  destroy() {
543
623
  this.moveable?.destroy();
624
+ this.calibrationTarget.destroy();
544
625
  }
545
626
  }
546
627
 
547
628
  class Rule extends EventEmitter$1 {
548
- hGuides;
549
- vGuides;
550
- horizontalGuidelines = [];
551
- verticalGuidelines = [];
552
- container;
553
- containerResizeObserver;
554
629
  constructor(container) {
555
630
  super();
631
+ this.horizontalGuidelines = [];
632
+ this.verticalGuidelines = [];
633
+ this.getGuidesStyle = (type) => ({
634
+ position: "fixed",
635
+ zIndex: 1,
636
+ left: type === GuidesType.HORIZONTAL ? 0 : "-30px",
637
+ top: type === GuidesType.HORIZONTAL ? "-30px" : 0,
638
+ width: type === GuidesType.HORIZONTAL ? "100%" : "30px",
639
+ height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
640
+ });
641
+ this.createGuides = (type, defaultGuides = []) => new Guides(this.container, {
642
+ type,
643
+ defaultGuides,
644
+ displayDragPos: true,
645
+ backgroundColor: "#fff",
646
+ lineColor: "#000",
647
+ textColor: "#000",
648
+ style: this.getGuidesStyle(type)
649
+ });
650
+ this.hGuidesChangeGuidesHandler = (e) => {
651
+ this.horizontalGuidelines = e.guides;
652
+ this.emit("changeGuides", {
653
+ type: GuidesType.HORIZONTAL,
654
+ guides: this.horizontalGuidelines
655
+ });
656
+ };
657
+ this.vGuidesChangeGuidesHandler = (e) => {
658
+ this.verticalGuidelines = e.guides;
659
+ this.emit("changeGuides", {
660
+ type: GuidesType.VERTICAL,
661
+ guides: this.verticalGuidelines
662
+ });
663
+ };
556
664
  this.container = container;
557
665
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL);
558
666
  this.vGuides = this.createGuides(GuidesType.VERTICAL);
@@ -621,41 +729,10 @@ class Rule extends EventEmitter$1 {
621
729
  this.containerResizeObserver.disconnect();
622
730
  this.removeAllListeners();
623
731
  }
624
- getGuidesStyle = (type) => ({
625
- position: "fixed",
626
- zIndex: 1,
627
- left: type === GuidesType.HORIZONTAL ? 0 : "-30px",
628
- top: type === GuidesType.HORIZONTAL ? "-30px" : 0,
629
- width: type === GuidesType.HORIZONTAL ? "100%" : "30px",
630
- height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
631
- });
632
- createGuides = (type, defaultGuides = []) => new Guides(this.container, {
633
- type,
634
- defaultGuides,
635
- displayDragPos: true,
636
- backgroundColor: "#fff",
637
- lineColor: "#000",
638
- textColor: "#000",
639
- style: this.getGuidesStyle(type)
640
- });
641
- hGuidesChangeGuidesHandler = (e) => {
642
- this.horizontalGuidelines = e.guides;
643
- this.emit("changeGuides", {
644
- type: GuidesType.HORIZONTAL,
645
- guides: this.horizontalGuidelines
646
- });
647
- };
648
- vGuidesChangeGuidesHandler = (e) => {
649
- this.verticalGuidelines = e.guides;
650
- this.emit("changeGuides", {
651
- type: GuidesType.VERTICAL,
652
- guides: this.verticalGuidelines
653
- });
654
- };
655
732
  }
656
733
 
657
734
  const wrapperClassName = "editor-mask-wrapper";
658
- const throttleTime = 300;
735
+ const throttleTime = 100;
659
736
  const hideScrollbar = () => {
660
737
  const style = globalThis.document.createElement("style");
661
738
  style.innerHTML = `
@@ -689,32 +766,73 @@ const createWrapper = () => {
689
766
  return el;
690
767
  };
691
768
  class StageMask extends Rule {
692
- content = createContent();
693
- wrapper;
694
- core;
695
- page = null;
696
- pageScrollParent = null;
697
- scrollTop = 0;
698
- scrollLeft = 0;
699
- width = 0;
700
- height = 0;
701
- wrapperHeight = 0;
702
- wrapperWidth = 0;
703
- mode = Mode.ABSOLUTE;
704
- pageResizeObserver = null;
705
- wrapperResizeObserver = null;
706
- highlightHandler = throttle((event) => {
707
- this.emit("highlight", event);
708
- }, throttleTime);
709
769
  constructor(config) {
710
770
  const wrapper = createWrapper();
711
771
  super(wrapper);
772
+ this.content = createContent();
773
+ this.page = null;
774
+ this.pageScrollParent = null;
775
+ this.scrollTop = 0;
776
+ this.scrollLeft = 0;
777
+ this.width = 0;
778
+ this.height = 0;
779
+ this.wrapperHeight = 0;
780
+ this.wrapperWidth = 0;
781
+ this.maxScrollTop = 0;
782
+ this.maxScrollLeft = 0;
783
+ this.mode = Mode.ABSOLUTE;
784
+ this.pageResizeObserver = null;
785
+ this.wrapperResizeObserver = null;
786
+ this.highlightHandler = throttle((event) => {
787
+ this.emit("highlight", event);
788
+ }, throttleTime);
789
+ this.mouseDownHandler = (event) => {
790
+ this.emit("clearHighlight");
791
+ event.stopImmediatePropagation();
792
+ event.stopPropagation();
793
+ if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
794
+ return;
795
+ if (event.target.className.indexOf("moveable-control") !== -1) {
796
+ return;
797
+ }
798
+ this.content.removeEventListener("mousemove", this.highlightHandler);
799
+ this.emit("beforeSelect", event);
800
+ globalThis.document.addEventListener("mouseup", this.mouseUpHandler);
801
+ };
802
+ this.mouseUpHandler = () => {
803
+ globalThis.document.removeEventListener("mouseup", this.mouseUpHandler);
804
+ this.content.addEventListener("mousemove", this.highlightHandler);
805
+ this.emit("select");
806
+ };
807
+ this.mouseWheelHandler = (event) => {
808
+ this.emit("clearHighlight");
809
+ if (!this.page)
810
+ throw new Error("page \u672A\u521D\u59CB\u5316");
811
+ const { deltaY, deltaX } = event;
812
+ if (this.page.clientHeight < this.wrapperHeight && deltaY)
813
+ return;
814
+ if (this.page.clientWidth < this.wrapperWidth && deltaX)
815
+ return;
816
+ if (this.maxScrollTop > 0) {
817
+ this.scrollTop = this.scrollTop + deltaY;
818
+ }
819
+ if (this.maxScrollLeft > 0) {
820
+ this.scrollLeft = this.scrollLeft + deltaX;
821
+ }
822
+ this.fixScrollValue();
823
+ this.scroll();
824
+ this.emit("scroll", event);
825
+ };
826
+ this.mouseLeaveHandler = () => {
827
+ setTimeout(() => this.emit("clearHighlight"), throttleTime);
828
+ };
712
829
  this.wrapper = wrapper;
713
830
  this.core = config.core;
714
831
  this.content.addEventListener("mousedown", this.mouseDownHandler);
715
832
  this.wrapper.appendChild(this.content);
716
833
  this.content.addEventListener("wheel", this.mouseWheelHandler);
717
834
  this.content.addEventListener("mousemove", this.highlightHandler);
835
+ this.content.addEventListener("mouseleave", this.mouseLeaveHandler);
718
836
  }
719
837
  setMode(mode) {
720
838
  this.mode = mode;
@@ -739,6 +857,9 @@ class StageMask extends Rule {
739
857
  const { clientHeight, clientWidth } = entry.target;
740
858
  this.setHeight(clientHeight);
741
859
  this.setWidth(clientWidth);
860
+ this.fixScrollValue();
861
+ this.scroll();
862
+ this.core.dr.updateMoveable();
742
863
  });
743
864
  this.pageResizeObserver.observe(page);
744
865
  this.wrapperResizeObserver = new ResizeObserver((entries) => {
@@ -746,6 +867,8 @@ class StageMask extends Rule {
746
867
  const { clientHeight, clientWidth } = entry.target;
747
868
  this.wrapperHeight = clientHeight;
748
869
  this.wrapperWidth = clientWidth;
870
+ this.setMaxScrollLeft();
871
+ this.setMaxScrollTop();
749
872
  });
750
873
  this.wrapperResizeObserver.observe(this.wrapper);
751
874
  }
@@ -764,10 +887,17 @@ class StageMask extends Rule {
764
887
  this.pageScrollParent = null;
765
888
  this.pageResizeObserver?.disconnect();
766
889
  this.wrapperResizeObserver?.disconnect();
890
+ this.content.removeEventListener("mouseleave", this.mouseLeaveHandler);
767
891
  super.destroy();
768
892
  }
769
893
  scroll() {
770
894
  let { scrollLeft, scrollTop } = this;
895
+ if (this.pageScrollParent) {
896
+ this.pageScrollParent.scrollTo({
897
+ top: scrollTop,
898
+ left: scrollLeft
899
+ });
900
+ }
771
901
  if (this.mode === Mode.FIXED) {
772
902
  scrollLeft = 0;
773
903
  scrollTop = 0;
@@ -780,75 +910,75 @@ class StageMask extends Rule {
780
910
  }
781
911
  setHeight(height) {
782
912
  this.height = height;
913
+ this.setMaxScrollTop();
783
914
  this.content.style.height = `${height}px`;
784
915
  }
785
916
  setWidth(width) {
786
917
  this.width = width;
918
+ this.setMaxScrollLeft();
787
919
  this.content.style.width = `${width}px`;
788
920
  }
789
- mouseDownHandler = (event) => {
790
- this.emit("clearHighlight");
791
- event.stopImmediatePropagation();
792
- event.stopPropagation();
793
- if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
794
- return;
795
- if (event.target.className.indexOf("moveable-control") !== -1) {
796
- return;
797
- }
798
- this.content.removeEventListener("mousemove", this.highlightHandler);
799
- this.emit("beforeSelect", event);
800
- globalThis.document.addEventListener("mouseup", this.mouseUpHandler);
801
- };
802
- mouseUpHandler = () => {
803
- globalThis.document.removeEventListener("mouseup", this.mouseUpHandler);
804
- this.content.addEventListener("mousemove", this.highlightHandler);
805
- this.emit("select");
806
- };
807
- mouseWheelHandler = (event) => {
808
- this.emit("clearHighlight");
809
- if (!this.page)
810
- throw new Error("page \u672A\u521D\u59CB\u5316");
811
- const { deltaY, deltaX } = event;
812
- const { height, wrapperHeight, width, wrapperWidth } = this;
813
- const maxScrollTop = height - wrapperHeight;
814
- const maxScrollLeft = width - wrapperWidth;
815
- if (maxScrollTop > 0) {
816
- if (deltaY > 0) {
817
- this.scrollTop = this.scrollTop + Math.min(maxScrollTop - this.scrollTop, deltaY);
818
- } else {
819
- this.scrollTop = Math.max(this.scrollTop + deltaY, 0);
820
- }
821
- }
822
- if (width > wrapperWidth) {
823
- if (deltaX > 0) {
824
- this.scrollLeft = this.scrollLeft + Math.min(maxScrollLeft - this.scrollLeft, deltaX);
825
- } else {
826
- this.scrollLeft = Math.max(this.scrollLeft + deltaX, 0);
827
- }
828
- }
829
- if (this.mode !== Mode.FIXED) {
830
- this.scrollTo(this.scrollLeft, this.scrollTop);
831
- }
832
- if (this.pageScrollParent) {
833
- this.pageScrollParent.scrollTo({
834
- top: this.scrollTop,
835
- left: this.scrollLeft
836
- });
837
- }
838
- this.scroll();
839
- this.emit("scroll", event);
840
- };
921
+ setMaxScrollLeft() {
922
+ this.maxScrollLeft = this.width - this.wrapperWidth;
923
+ }
924
+ setMaxScrollTop() {
925
+ this.maxScrollTop = this.height - this.wrapperHeight;
926
+ }
927
+ fixScrollValue() {
928
+ if (this.scrollTop < 0)
929
+ this.scrollTop = 0;
930
+ if (this.scrollLeft < 0)
931
+ this.scrollLeft = 0;
932
+ if (this.maxScrollTop < this.scrollTop)
933
+ this.scrollTop = this.maxScrollTop;
934
+ if (this.maxScrollLeft < this.scrollLeft)
935
+ this.scrollLeft = this.maxScrollLeft;
936
+ }
841
937
  }
842
938
 
843
939
  class StageRender extends EventEmitter {
844
- contentWindow = null;
845
- runtime = null;
846
- iframe;
847
- runtimeUrl;
848
- core;
849
- render;
850
940
  constructor({ core }) {
851
941
  super();
942
+ this.contentWindow = null;
943
+ this.runtime = null;
944
+ this.getMagicApi = () => ({
945
+ onPageElUpdate: (el) => this.emit("page-el-update", el),
946
+ onRuntimeReady: (runtime) => {
947
+ this.runtime = runtime;
948
+ globalThis.runtime = runtime;
949
+ this.emit("runtime-ready", runtime);
950
+ }
951
+ });
952
+ this.getRuntime = () => {
953
+ if (this.runtime)
954
+ return Promise.resolve(this.runtime);
955
+ return new Promise((resolve) => {
956
+ const listener = (runtime) => {
957
+ this.off("runtime-ready", listener);
958
+ resolve(runtime);
959
+ };
960
+ this.on("runtime-ready", listener);
961
+ });
962
+ };
963
+ this.loadHandler = async () => {
964
+ this.emit("onload");
965
+ if (this.render) {
966
+ const el = await this.render(this.core);
967
+ if (el) {
968
+ this.iframe?.contentDocument?.body?.appendChild(el);
969
+ }
970
+ }
971
+ if (this.contentWindow) {
972
+ const style = this.contentWindow.document.createElement("style");
973
+ style.id = "tmagic-stage-render";
974
+ style.innerHTML = `
975
+ .${SELECTED_CLASS}, .${SELECTED_CLASS}-parent {
976
+ z-index: ${ZIndex.SELECTED_EL};
977
+ }
978
+ `;
979
+ this.contentWindow.document.head.appendChild(style);
980
+ }
981
+ };
852
982
  this.core = core;
853
983
  this.runtimeUrl = core.config.runtimeUrl || "";
854
984
  this.render = core.config.render;
@@ -861,14 +991,6 @@ class StageRender extends EventEmitter {
861
991
  `;
862
992
  this.iframe.addEventListener("load", this.loadHandler);
863
993
  }
864
- getMagicApi = () => ({
865
- onPageElUpdate: (el) => this.emit("page-el-update", el),
866
- onRuntimeReady: (runtime) => {
867
- this.runtime = runtime;
868
- globalThis.runtime = runtime;
869
- this.emit("runtime-ready", runtime);
870
- }
871
- });
872
994
  async mount(el) {
873
995
  if (this.iframe) {
874
996
  if (!isSameDomain(this.runtimeUrl) && this.runtimeUrl) {
@@ -885,17 +1007,6 @@ class StageRender extends EventEmitter {
885
1007
  throw Error("mount \u5931\u8D25");
886
1008
  }
887
1009
  }
888
- getRuntime = () => {
889
- if (this.runtime)
890
- return Promise.resolve(this.runtime);
891
- return new Promise((resolve) => {
892
- const listener = (runtime) => {
893
- this.off("runtime-ready", listener);
894
- resolve(runtime);
895
- };
896
- this.on("runtime-ready", listener);
897
- });
898
- };
899
1010
  destroy() {
900
1011
  this.iframe?.removeEventListener("load", this.loadHandler);
901
1012
  this.contentWindow = null;
@@ -903,40 +1014,12 @@ class StageRender extends EventEmitter {
903
1014
  this.iframe = void 0;
904
1015
  this.removeAllListeners();
905
1016
  }
906
- loadHandler = async () => {
907
- this.emit("onload");
908
- if (this.render) {
909
- const el = await this.render(this.core);
910
- if (el) {
911
- this.iframe?.contentDocument?.body?.appendChild(el);
912
- }
913
- }
914
- if (this.contentWindow) {
915
- const style = this.contentWindow.document.createElement("style");
916
- style.id = "tmagic-stage-render";
917
- style.innerHTML = `
918
- .${SELECTED_CLASS}, .${SELECTED_CLASS}-parent {
919
- z-index: ${ZIndex.SELECTED_EL};
920
- }
921
- `;
922
- this.contentWindow.document.head.appendChild(style);
923
- }
924
- };
925
1017
  }
926
1018
 
927
1019
  class StageCore extends EventEmitter {
928
- selectedDom;
929
- highlightedDom;
930
- renderer;
931
- mask;
932
- dr;
933
- highlightLayer;
934
- config;
935
- zoom = DEFAULT_ZOOM;
936
- container;
937
- canSelect;
938
1020
  constructor(config) {
939
1021
  super();
1022
+ this.zoom = DEFAULT_ZOOM;
940
1023
  this.config = config;
941
1024
  this.setZoom(config.zoom);
942
1025
  this.canSelect = config.canSelect || ((el) => !!el.id);
@@ -1023,7 +1106,7 @@ class StageCore extends EventEmitter {
1023
1106
  }
1024
1107
  update(data) {
1025
1108
  const { config } = data;
1026
- this.renderer?.getRuntime().then((runtime) => {
1109
+ return this.renderer?.getRuntime().then((runtime) => {
1027
1110
  runtime?.update?.(data);
1028
1111
  setTimeout(() => {
1029
1112
  const el = this.renderer.contentWindow?.document.getElementById(`${config.id}`);
@@ -1049,13 +1132,13 @@ class StageCore extends EventEmitter {
1049
1132
  this.highlightedDom = el;
1050
1133
  }
1051
1134
  sortNode(data) {
1052
- this.renderer?.getRuntime().then((runtime) => runtime?.sortNode?.(data));
1135
+ return this.renderer?.getRuntime().then((runtime) => runtime?.sortNode?.(data));
1053
1136
  }
1054
1137
  add(data) {
1055
- this.renderer?.getRuntime().then((runtime) => runtime?.add?.(data));
1138
+ return this.renderer?.getRuntime().then((runtime) => runtime?.add?.(data));
1056
1139
  }
1057
1140
  remove(data) {
1058
- this.renderer?.getRuntime().then((runtime) => runtime?.remove?.(data));
1141
+ return this.renderer?.getRuntime().then((runtime) => runtime?.remove?.(data));
1059
1142
  }
1060
1143
  setZoom(zoom = DEFAULT_ZOOM) {
1061
1144
  this.zoom = zoom;