@tmagic/stage 1.2.6 → 1.2.8
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/dist/tmagic-stage.js +164 -101
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +168 -104
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +6 -6
- package/src/ActionManager.ts +32 -16
- package/src/DragResizeHelper.ts +40 -2
- package/src/MoveableActionsAble.ts +109 -0
- package/src/MoveableOptionsManager.ts +6 -6
- package/src/StageCore.ts +11 -4
- package/src/StageDragResize.ts +8 -34
- package/src/StageMultiDragResize.ts +28 -14
- package/src/types.ts +16 -2
- package/types/ActionManager.d.ts +1 -1
- package/types/DragResizeHelper.d.ts +2 -1
- package/types/{MoveableSelectParentAble.d.ts → MoveableActionsAble.d.ts} +5 -2
- package/types/MoveableOptionsManager.d.ts +1 -1
- package/types/StageCore.d.ts +2 -2
- package/types/StageDragResize.d.ts +1 -0
- package/types/StageMultiDragResize.d.ts +2 -0
- package/types/types.d.ts +14 -2
- package/src/MoveableSelectParentAble.ts +0 -76
package/dist/tmagic-stage.js
CHANGED
|
@@ -3,8 +3,8 @@ import KeyController from 'keycon';
|
|
|
3
3
|
import { merge, throttle } from 'lodash-es';
|
|
4
4
|
import { Env } from '@tmagic/core';
|
|
5
5
|
import { removeClassName, addClassName, removeClassNameByClassName, getDocument, createDiv, injectStyle, isSameDomain, getHost } from '@tmagic/utils';
|
|
6
|
-
import Moveable from 'moveable';
|
|
7
6
|
import MoveableHelper from 'moveable-helper';
|
|
7
|
+
import Moveable from 'moveable';
|
|
8
8
|
import Guides from '@scena/guides';
|
|
9
9
|
|
|
10
10
|
const GHOST_EL_ID_PREFIX = "ghost_el_";
|
|
@@ -470,6 +470,29 @@ class DragResizeHelper {
|
|
|
470
470
|
});
|
|
471
471
|
this.moveableHelper.onDragGroup(e);
|
|
472
472
|
}
|
|
473
|
+
getUpdatedElRect(el, parentEl, doc) {
|
|
474
|
+
const offset = this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : { left: el.offsetLeft, top: el.offsetTop };
|
|
475
|
+
let left = calcValueByFontsize(doc, offset.left);
|
|
476
|
+
let top = calcValueByFontsize(doc, offset.top);
|
|
477
|
+
const width = calcValueByFontsize(doc, el.clientWidth);
|
|
478
|
+
const height = calcValueByFontsize(doc, el.clientHeight);
|
|
479
|
+
let shadowEl = this.getShadowEl();
|
|
480
|
+
const shadowEls = this.getShadowEls();
|
|
481
|
+
if (shadowEls.length) {
|
|
482
|
+
shadowEl = shadowEls.find((item) => item.id.endsWith(el.id));
|
|
483
|
+
}
|
|
484
|
+
if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
|
|
485
|
+
const targetShadowHtmlEl = shadowEl;
|
|
486
|
+
const targetShadowElOffsetLeft = targetShadowHtmlEl.offsetLeft || 0;
|
|
487
|
+
const targetShadowElOffsetTop = targetShadowHtmlEl.offsetTop || 0;
|
|
488
|
+
const frame = this.getFrame(shadowEl);
|
|
489
|
+
const [translateX, translateY] = frame?.properties.transform.translate.value;
|
|
490
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
491
|
+
left = calcValueByFontsize(doc, targetShadowElOffsetLeft) + parseFloat(translateX) - calcValueByFontsize(doc, parentLeft);
|
|
492
|
+
top = calcValueByFontsize(doc, targetShadowElOffsetTop) + parseFloat(translateY) - calcValueByFontsize(doc, parentTop);
|
|
493
|
+
}
|
|
494
|
+
return { width, height, left, top };
|
|
495
|
+
}
|
|
473
496
|
setFramesSnapShot(events) {
|
|
474
497
|
if (this.framesSnapShot.length > 0)
|
|
475
498
|
return;
|
|
@@ -514,9 +537,33 @@ class DragResizeHelper {
|
|
|
514
537
|
}
|
|
515
538
|
}
|
|
516
539
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
540
|
+
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
541
|
+
ContainerHighlightType2["DEFAULT"] = "default";
|
|
542
|
+
ContainerHighlightType2["ALT"] = "alt";
|
|
543
|
+
return ContainerHighlightType2;
|
|
544
|
+
})(ContainerHighlightType || {});
|
|
545
|
+
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
546
|
+
SelectStatus2["SELECT"] = "select";
|
|
547
|
+
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
548
|
+
return SelectStatus2;
|
|
549
|
+
})(SelectStatus || {});
|
|
550
|
+
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
551
|
+
StageDragStatus2["START"] = "start";
|
|
552
|
+
StageDragStatus2["ING"] = "ing";
|
|
553
|
+
StageDragStatus2["END"] = "end";
|
|
554
|
+
return StageDragStatus2;
|
|
555
|
+
})(StageDragStatus || {});
|
|
556
|
+
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
557
|
+
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
558
|
+
AbleActionEventType2["REMOVE"] = "remove";
|
|
559
|
+
return AbleActionEventType2;
|
|
560
|
+
})(AbleActionEventType || {});
|
|
561
|
+
|
|
562
|
+
const MoveableActionsAble = (handler) => ({
|
|
563
|
+
name: "actions",
|
|
564
|
+
props: {
|
|
565
|
+
selectParent: Boolean
|
|
566
|
+
},
|
|
520
567
|
events: {},
|
|
521
568
|
render(moveable, React) {
|
|
522
569
|
const rect = moveable.getRect();
|
|
@@ -542,6 +589,23 @@ const selectParentAbles = (selectParentHandler) => ({
|
|
|
542
589
|
color: white;
|
|
543
590
|
font-size: 12px;
|
|
544
591
|
font-weight: bold;
|
|
592
|
+
margin-left: 2px;
|
|
593
|
+
position: relative;
|
|
594
|
+
}
|
|
595
|
+
.moveable-remove-button:before, .moveable-remove-button:after {
|
|
596
|
+
content: "";
|
|
597
|
+
position: absolute;
|
|
598
|
+
left: 50%;
|
|
599
|
+
top: 50%;
|
|
600
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
601
|
+
width: 14px;
|
|
602
|
+
height: 2px;
|
|
603
|
+
background: #fff;
|
|
604
|
+
border-radius: 1px;
|
|
605
|
+
cursor: pointer;
|
|
606
|
+
}
|
|
607
|
+
.moveable-remove-button:after {
|
|
608
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
545
609
|
}
|
|
546
610
|
`
|
|
547
611
|
);
|
|
@@ -550,37 +614,49 @@ const selectParentAbles = (selectParentHandler) => ({
|
|
|
550
614
|
{
|
|
551
615
|
className: "moveable-editable",
|
|
552
616
|
style: {
|
|
553
|
-
transform: `translate(${pos2[0] -
|
|
617
|
+
transform: `translate(${pos2[0] - 48}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg) translate(10px)`
|
|
554
618
|
}
|
|
555
619
|
},
|
|
556
|
-
|
|
557
|
-
"button",
|
|
558
|
-
{
|
|
559
|
-
className: "moveable-button",
|
|
560
|
-
title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
|
|
561
|
-
onClick: () => {
|
|
562
|
-
selectParentHandler();
|
|
563
|
-
}
|
|
564
|
-
},
|
|
620
|
+
[
|
|
565
621
|
React.createElement(
|
|
566
|
-
"
|
|
622
|
+
"button",
|
|
567
623
|
{
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
573
|
-
style: {
|
|
574
|
-
transform: "rotate(90deg)"
|
|
624
|
+
className: "moveable-button",
|
|
625
|
+
title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
|
|
626
|
+
onClick: () => {
|
|
627
|
+
handler(AbleActionEventType.SELECT_PARENT);
|
|
575
628
|
}
|
|
576
629
|
},
|
|
577
|
-
React.createElement(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
630
|
+
React.createElement(
|
|
631
|
+
"svg",
|
|
632
|
+
{
|
|
633
|
+
width: "20px",
|
|
634
|
+
height: "20px",
|
|
635
|
+
viewBox: "0 0 16 16",
|
|
636
|
+
fill: "none",
|
|
637
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
638
|
+
style: {
|
|
639
|
+
transform: "rotate(90deg)",
|
|
640
|
+
position: "absolute",
|
|
641
|
+
left: 0,
|
|
642
|
+
top: 0
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
React.createElement("path", {
|
|
646
|
+
d: "M13.0001 4V10H4.20718L5.85363 8.35355L5.14652 7.64645L2.64652 10.1464C2.45126 10.3417 2.45126 10.6583 2.64652 10.8536L5.14652 13.3536L5.85363 12.6464L4.20718 11H13.0001C13.5524 11 14.0001 10.5523 14.0001 10V4H13.0001Z",
|
|
647
|
+
fill: "currentColor",
|
|
648
|
+
fillOpacity: "0.9"
|
|
649
|
+
})
|
|
650
|
+
)
|
|
651
|
+
),
|
|
652
|
+
React.createElement("button", {
|
|
653
|
+
className: "moveable-button moveable-remove-button",
|
|
654
|
+
title: "\u5220\u9664",
|
|
655
|
+
onClick: () => {
|
|
656
|
+
handler(AbleActionEventType.REMOVE);
|
|
657
|
+
}
|
|
658
|
+
})
|
|
659
|
+
]
|
|
584
660
|
);
|
|
585
661
|
}
|
|
586
662
|
});
|
|
@@ -676,9 +752,9 @@ class MoveableOptionsManager extends EventEmitter {
|
|
|
676
752
|
},
|
|
677
753
|
isDisplayInnerSnapDigit: true,
|
|
678
754
|
props: {
|
|
679
|
-
|
|
755
|
+
actions: true
|
|
680
756
|
},
|
|
681
|
-
ables: [
|
|
757
|
+
ables: [MoveableActionsAble(this.actionHandler.bind(this))]
|
|
682
758
|
};
|
|
683
759
|
}
|
|
684
760
|
getMultiOptions() {
|
|
@@ -697,8 +773,8 @@ class MoveableOptionsManager extends EventEmitter {
|
|
|
697
773
|
}
|
|
698
774
|
return this.customizedOptions;
|
|
699
775
|
}
|
|
700
|
-
|
|
701
|
-
this.emit(
|
|
776
|
+
actionHandler(type) {
|
|
777
|
+
this.emit(type);
|
|
702
778
|
}
|
|
703
779
|
createGuidelineElements(selectedElList, allElList) {
|
|
704
780
|
const frame = globalThis.document.createDocumentFragment();
|
|
@@ -723,23 +799,6 @@ class MoveableOptionsManager extends EventEmitter {
|
|
|
723
799
|
}
|
|
724
800
|
}
|
|
725
801
|
|
|
726
|
-
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
727
|
-
ContainerHighlightType2["DEFAULT"] = "default";
|
|
728
|
-
ContainerHighlightType2["ALT"] = "alt";
|
|
729
|
-
return ContainerHighlightType2;
|
|
730
|
-
})(ContainerHighlightType || {});
|
|
731
|
-
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
732
|
-
SelectStatus2["SELECT"] = "select";
|
|
733
|
-
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
734
|
-
return SelectStatus2;
|
|
735
|
-
})(SelectStatus || {});
|
|
736
|
-
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
737
|
-
StageDragStatus2["START"] = "start";
|
|
738
|
-
StageDragStatus2["ING"] = "ing";
|
|
739
|
-
StageDragStatus2["END"] = "end";
|
|
740
|
-
return StageDragStatus2;
|
|
741
|
-
})(StageDragStatus || {});
|
|
742
|
-
|
|
743
802
|
class StageDragResize extends MoveableOptionsManager {
|
|
744
803
|
target;
|
|
745
804
|
moveable;
|
|
@@ -755,16 +814,16 @@ class StageDragResize extends MoveableOptionsManager {
|
|
|
755
814
|
this.markContainerEnd = config.markContainerEnd;
|
|
756
815
|
this.delayedMarkContainer = config.delayedMarkContainer;
|
|
757
816
|
this.disabledDragStart = config.disabledDragStart;
|
|
758
|
-
this.dragResizeHelper =
|
|
759
|
-
container: config.container,
|
|
760
|
-
updateDragEl: config.updateDragEl
|
|
761
|
-
});
|
|
817
|
+
this.dragResizeHelper = config.dragResizeHelper;
|
|
762
818
|
this.on("update-moveable", () => {
|
|
763
819
|
if (this.moveable) {
|
|
764
820
|
this.updateMoveable();
|
|
765
821
|
}
|
|
766
822
|
});
|
|
767
823
|
}
|
|
824
|
+
getTarget() {
|
|
825
|
+
return this.target;
|
|
826
|
+
}
|
|
768
827
|
select(el, event) {
|
|
769
828
|
if (!this.moveable || el !== this.target) {
|
|
770
829
|
this.initMoveable(el);
|
|
@@ -962,27 +1021,12 @@ class StageDragResize extends MoveableOptionsManager {
|
|
|
962
1021
|
const doc = this.getRenderDocument();
|
|
963
1022
|
if (!doc)
|
|
964
1023
|
return;
|
|
965
|
-
const
|
|
966
|
-
let left = calcValueByFontsize(doc, offset.left);
|
|
967
|
-
let top = calcValueByFontsize(doc, offset.top);
|
|
968
|
-
const width = calcValueByFontsize(doc, this.target.clientWidth);
|
|
969
|
-
const height = calcValueByFontsize(doc, this.target.clientHeight);
|
|
970
|
-
const shadowEl = this.dragResizeHelper.getShadowEl();
|
|
971
|
-
if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
|
|
972
|
-
const targetShadowHtmlEl = shadowEl;
|
|
973
|
-
const targetShadowElOffsetLeft = targetShadowHtmlEl.offsetLeft || 0;
|
|
974
|
-
const targetShadowElOffsetTop = targetShadowHtmlEl.offsetTop || 0;
|
|
975
|
-
const frame = this.dragResizeHelper.getFrame(shadowEl);
|
|
976
|
-
const [translateX, translateY] = frame?.properties.transform.translate.value;
|
|
977
|
-
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
978
|
-
left = calcValueByFontsize(doc, targetShadowElOffsetLeft) + parseFloat(translateX) - calcValueByFontsize(doc, parentLeft);
|
|
979
|
-
top = calcValueByFontsize(doc, targetShadowElOffsetTop) + parseFloat(translateY) - calcValueByFontsize(doc, parentTop);
|
|
980
|
-
}
|
|
1024
|
+
const rect = this.dragResizeHelper.getUpdatedElRect(this.target, parentEl, doc);
|
|
981
1025
|
this.emit("update", {
|
|
982
1026
|
data: [
|
|
983
1027
|
{
|
|
984
1028
|
el: this.target,
|
|
985
|
-
style: isResize ?
|
|
1029
|
+
style: isResize ? rect : { left: rect.left, top: rect.top }
|
|
986
1030
|
}
|
|
987
1031
|
],
|
|
988
1032
|
parentEl
|
|
@@ -1039,6 +1083,8 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1039
1083
|
dragStatus = StageDragStatus.END;
|
|
1040
1084
|
dragResizeHelper;
|
|
1041
1085
|
getRenderDocument;
|
|
1086
|
+
delayedMarkContainer;
|
|
1087
|
+
markContainerEnd;
|
|
1042
1088
|
constructor(config) {
|
|
1043
1089
|
const moveableOptionsManagerConfig = {
|
|
1044
1090
|
container: config.container,
|
|
@@ -1046,12 +1092,11 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1046
1092
|
getRootContainer: config.getRootContainer
|
|
1047
1093
|
};
|
|
1048
1094
|
super(moveableOptionsManagerConfig);
|
|
1095
|
+
this.delayedMarkContainer = config.delayedMarkContainer;
|
|
1096
|
+
this.markContainerEnd = config.markContainerEnd;
|
|
1049
1097
|
this.container = config.container;
|
|
1050
1098
|
this.getRenderDocument = config.getRenderDocument;
|
|
1051
|
-
this.dragResizeHelper =
|
|
1052
|
-
container: config.container,
|
|
1053
|
-
updateDragEl: config.updateDragEl
|
|
1054
|
-
});
|
|
1099
|
+
this.dragResizeHelper = config.dragResizeHelper;
|
|
1055
1100
|
this.on("update-moveable", () => {
|
|
1056
1101
|
if (this.moveableForMulti) {
|
|
1057
1102
|
this.updateMoveable();
|
|
@@ -1075,6 +1120,7 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1075
1120
|
target: this.dragResizeHelper.getShadowEls()
|
|
1076
1121
|
})
|
|
1077
1122
|
);
|
|
1123
|
+
let timeout;
|
|
1078
1124
|
this.moveableForMulti.on("resizeGroupStart", (e) => {
|
|
1079
1125
|
this.dragResizeHelper.onResizeGroupStart(e);
|
|
1080
1126
|
this.dragStatus = StageDragStatus.START;
|
|
@@ -1088,10 +1134,16 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1088
1134
|
this.dragResizeHelper.onDragGroupStart(e);
|
|
1089
1135
|
this.dragStatus = StageDragStatus.START;
|
|
1090
1136
|
}).on("dragGroup", (e) => {
|
|
1137
|
+
if (timeout) {
|
|
1138
|
+
globalThis.clearTimeout(timeout);
|
|
1139
|
+
timeout = void 0;
|
|
1140
|
+
}
|
|
1141
|
+
timeout = this.delayedMarkContainer(e.inputEvent, this.targetList);
|
|
1091
1142
|
this.dragResizeHelper.onDragGroup(e);
|
|
1092
1143
|
this.dragStatus = StageDragStatus.ING;
|
|
1093
1144
|
}).on("dragGroupEnd", () => {
|
|
1094
|
-
this.
|
|
1145
|
+
const parentEl = this.markContainerEnd();
|
|
1146
|
+
this.update(false, parentEl);
|
|
1095
1147
|
this.dragStatus = StageDragStatus.END;
|
|
1096
1148
|
}).on("clickGroup", (e) => {
|
|
1097
1149
|
const { inputTarget, targets } = e;
|
|
@@ -1143,23 +1195,20 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1143
1195
|
this.moveableForMulti?.destroy();
|
|
1144
1196
|
this.dragResizeHelper.destroy();
|
|
1145
1197
|
}
|
|
1146
|
-
update(isResize = false) {
|
|
1198
|
+
update(isResize = false, parentEl = null) {
|
|
1147
1199
|
if (this.targetList.length === 0)
|
|
1148
1200
|
return;
|
|
1149
1201
|
const doc = this.getRenderDocument();
|
|
1150
1202
|
if (!doc)
|
|
1151
1203
|
return;
|
|
1152
1204
|
const data = this.targetList.map((targetItem) => {
|
|
1153
|
-
const
|
|
1154
|
-
const top = calcValueByFontsize(doc, targetItem.offsetTop);
|
|
1155
|
-
const width = calcValueByFontsize(doc, targetItem.clientWidth);
|
|
1156
|
-
const height = calcValueByFontsize(doc, targetItem.clientHeight);
|
|
1205
|
+
const rect = this.dragResizeHelper.getUpdatedElRect(targetItem, parentEl, doc);
|
|
1157
1206
|
return {
|
|
1158
1207
|
el: targetItem,
|
|
1159
|
-
style: isResize ?
|
|
1208
|
+
style: isResize ? rect : { left: rect.left, top: rect.top }
|
|
1160
1209
|
};
|
|
1161
1210
|
});
|
|
1162
|
-
this.emit("update", data,
|
|
1211
|
+
this.emit("update", { data, parentEl });
|
|
1163
1212
|
}
|
|
1164
1213
|
}
|
|
1165
1214
|
|
|
@@ -1202,27 +1251,28 @@ class ActionManager extends EventEmitter {
|
|
|
1202
1251
|
this.canSelect = config.canSelect || ((el) => !!el.id);
|
|
1203
1252
|
this.getRenderDocument = config.getRenderDocument;
|
|
1204
1253
|
this.isContainer = config.isContainer;
|
|
1254
|
+
const createDrHelper = () => new DragResizeHelper({
|
|
1255
|
+
container: config.container,
|
|
1256
|
+
updateDragEl: config.updateDragEl
|
|
1257
|
+
});
|
|
1205
1258
|
this.dr = new StageDragResize({
|
|
1206
1259
|
container: config.container,
|
|
1207
1260
|
disabledDragStart: config.disabledDragStart,
|
|
1261
|
+
moveableOptions: this.changeCallback(config.moveableOptions),
|
|
1262
|
+
dragResizeHelper: createDrHelper(),
|
|
1208
1263
|
getRootContainer: config.getRootContainer,
|
|
1209
1264
|
getRenderDocument: config.getRenderDocument,
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
delayedMarkContainer: (event, exclude) => {
|
|
1213
|
-
if (this.canAddToContainer()) {
|
|
1214
|
-
return this.delayedMarkContainer(event, exclude);
|
|
1215
|
-
}
|
|
1216
|
-
return void 0;
|
|
1217
|
-
},
|
|
1218
|
-
moveableOptions: this.changeCallback(config.moveableOptions)
|
|
1265
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1266
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1219
1267
|
});
|
|
1220
1268
|
this.multiDr = new StageMultiDragResize({
|
|
1221
1269
|
container: config.container,
|
|
1222
1270
|
multiMoveableOptions: config.multiMoveableOptions,
|
|
1271
|
+
dragResizeHelper: createDrHelper(),
|
|
1223
1272
|
getRootContainer: config.getRootContainer,
|
|
1224
1273
|
getRenderDocument: config.getRenderDocument,
|
|
1225
|
-
|
|
1274
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1275
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1226
1276
|
});
|
|
1227
1277
|
this.highlightLayer = new StageHighlight({
|
|
1228
1278
|
container: config.container,
|
|
@@ -1348,9 +1398,12 @@ class ActionManager extends EventEmitter {
|
|
|
1348
1398
|
}
|
|
1349
1399
|
}
|
|
1350
1400
|
delayedMarkContainer(event, excludeElList = []) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1401
|
+
if (this.canAddToContainer()) {
|
|
1402
|
+
return globalThis.setTimeout(() => {
|
|
1403
|
+
this.addContainerHighlightClassName(event, excludeElList);
|
|
1404
|
+
}, this.containerHighlightDuration);
|
|
1405
|
+
}
|
|
1406
|
+
return void 0;
|
|
1354
1407
|
}
|
|
1355
1408
|
destroy() {
|
|
1356
1409
|
this.container.removeEventListener("mousedown", this.mouseDownHandler);
|
|
@@ -1437,9 +1490,17 @@ class ActionManager extends EventEmitter {
|
|
|
1437
1490
|
setTimeout(() => this.emit("sort", data));
|
|
1438
1491
|
}).on("select-parent", () => {
|
|
1439
1492
|
this.emit("select-parent");
|
|
1493
|
+
}).on("remove", () => {
|
|
1494
|
+
const drTarget = this.dr.getTarget();
|
|
1495
|
+
if (!drTarget)
|
|
1496
|
+
return;
|
|
1497
|
+
const data = {
|
|
1498
|
+
data: [{ el: drTarget }]
|
|
1499
|
+
};
|
|
1500
|
+
this.emit("remove", data);
|
|
1440
1501
|
});
|
|
1441
|
-
this.multiDr.on("update", (data
|
|
1442
|
-
this.emit("multi-update", data
|
|
1502
|
+
this.multiDr.on("update", (data) => {
|
|
1503
|
+
this.emit("multi-update", data);
|
|
1443
1504
|
}).on("change-to-select", async (id) => {
|
|
1444
1505
|
if (this.isMultiSelectStatus)
|
|
1445
1506
|
return false;
|
|
@@ -2140,14 +2201,16 @@ class StageCore extends EventEmitter$1 {
|
|
|
2140
2201
|
this.emit("sort", data);
|
|
2141
2202
|
}).on("select-parent", () => {
|
|
2142
2203
|
this.emit("select-parent");
|
|
2204
|
+
}).on("remove", (data) => {
|
|
2205
|
+
this.emit("remove", data);
|
|
2143
2206
|
});
|
|
2144
2207
|
}
|
|
2145
2208
|
initMulDrEvent() {
|
|
2146
2209
|
this.actionManager.on("change-to-select", (el) => {
|
|
2147
2210
|
this.select(el);
|
|
2148
2211
|
setTimeout(() => this.emit("select", el));
|
|
2149
|
-
}).on("multi-update", (data
|
|
2150
|
-
this.emit("update",
|
|
2212
|
+
}).on("multi-update", (data) => {
|
|
2213
|
+
this.emit("update", data);
|
|
2151
2214
|
});
|
|
2152
2215
|
}
|
|
2153
2216
|
initHighlightEvent() {
|
|
@@ -2157,5 +2220,5 @@ class StageCore extends EventEmitter$1 {
|
|
|
2157
2220
|
}
|
|
2158
2221
|
}
|
|
2159
2222
|
|
|
2160
|
-
export { CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
2223
|
+
export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
2161
2224
|
//# sourceMappingURL=tmagic-stage.js.map
|