@tmagic/stage 1.0.0-beta.4 → 1.0.0-beta.7
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.es.js +34 -22
- package/dist/tmagic-stage.es.js.map +1 -1
- package/dist/tmagic-stage.umd.js +34 -22
- package/dist/tmagic-stage.umd.js.map +1 -1
- package/dist/types/src/StageDragResize.d.ts +2 -2
- package/dist/types/src/StageMask.d.ts +1 -0
- package/package.json +3 -3
- package/src/StageCore.ts +1 -2
- package/src/StageDragResize.ts +2 -5
- package/src/StageMask.ts +36 -15
package/dist/tmagic-stage.es.js
CHANGED
|
@@ -93,11 +93,11 @@ class StageDragResize extends EventEmitter {
|
|
|
93
93
|
container;
|
|
94
94
|
target;
|
|
95
95
|
moveable;
|
|
96
|
+
horizontalGuidelines = [];
|
|
97
|
+
verticalGuidelines = [];
|
|
96
98
|
dragStatus = "end" /* END */;
|
|
97
99
|
elObserver;
|
|
98
100
|
ghostEl;
|
|
99
|
-
horizontalGuidelines = [];
|
|
100
|
-
verticalGuidelines = [];
|
|
101
101
|
mode = Mode.ABSOLUTE;
|
|
102
102
|
constructor(config) {
|
|
103
103
|
super();
|
|
@@ -325,9 +325,6 @@ class StageDragResize extends EventEmitter {
|
|
|
325
325
|
resizable: true,
|
|
326
326
|
snappable: !isSortable,
|
|
327
327
|
snapGap: !isSortable,
|
|
328
|
-
snapElement: !isSortable,
|
|
329
|
-
snapVertical: !isSortable,
|
|
330
|
-
snapHorizontal: !isSortable,
|
|
331
328
|
snapCenter: !isSortable,
|
|
332
329
|
container: renderer.contentWindow?.document.body,
|
|
333
330
|
elementGuidelines: isSortable ? [] : await this.getSnapElements(this.target),
|
|
@@ -17683,8 +17680,8 @@ class StageMask extends EventEmitter {
|
|
|
17683
17680
|
this.core = config.core;
|
|
17684
17681
|
const { config: coreConfig } = config.core;
|
|
17685
17682
|
this.canSelect = coreConfig.canSelect || ((el) => !!el.id);
|
|
17686
|
-
this.content.addEventListener("mousedown", this.mouseDownHandler
|
|
17687
|
-
this.content.addEventListener("contextmenu", this.contextmenuHandler
|
|
17683
|
+
this.content.addEventListener("mousedown", this.mouseDownHandler);
|
|
17684
|
+
this.content.addEventListener("contextmenu", this.contextmenuHandler);
|
|
17688
17685
|
this.wrapper.appendChild(this.content);
|
|
17689
17686
|
this.hGuides = this.createGuides("horizontal");
|
|
17690
17687
|
this.vGuides = this.createGuides("vertical");
|
|
@@ -17742,16 +17739,23 @@ class StageMask extends EventEmitter {
|
|
|
17742
17739
|
});
|
|
17743
17740
|
}
|
|
17744
17741
|
showRule(show = true) {
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17742
|
+
if (show) {
|
|
17743
|
+
this.hGuides.destroy();
|
|
17744
|
+
this.hGuides = this.createGuides("horizontal", this.core.dr.horizontalGuidelines);
|
|
17745
|
+
this.vGuides.destroy();
|
|
17746
|
+
this.vGuides = this.createGuides("vertical", this.core.dr.verticalGuidelines);
|
|
17747
|
+
} else {
|
|
17748
|
+
this.hGuides.setState({
|
|
17749
|
+
rulerStyle: {
|
|
17750
|
+
visibility: "hidden"
|
|
17751
|
+
}
|
|
17752
|
+
});
|
|
17753
|
+
this.vGuides.setState({
|
|
17754
|
+
rulerStyle: {
|
|
17755
|
+
visibility: "hidden"
|
|
17756
|
+
}
|
|
17757
|
+
});
|
|
17758
|
+
}
|
|
17755
17759
|
}
|
|
17756
17760
|
clearGuides() {
|
|
17757
17761
|
this.vGuides.setState({
|
|
@@ -17773,13 +17777,21 @@ class StageMask extends EventEmitter {
|
|
|
17773
17777
|
if (event.target.className.indexOf("moveable-control") !== -1) {
|
|
17774
17778
|
return;
|
|
17775
17779
|
}
|
|
17780
|
+
this.content.addEventListener("mousemove", this.mouseMoveHandler);
|
|
17776
17781
|
this.select(event);
|
|
17777
17782
|
};
|
|
17778
17783
|
mouseUpHandler = () => {
|
|
17779
|
-
this.content
|
|
17784
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17785
|
+
this.content.removeEventListener("mouseup", this.mouseUpHandler);
|
|
17780
17786
|
this.emit("selected", this.target);
|
|
17781
17787
|
this.target = null;
|
|
17782
17788
|
};
|
|
17789
|
+
mouseMoveHandler = (event) => {
|
|
17790
|
+
if (event.buttons) {
|
|
17791
|
+
this.core.dr.moveable?.dragStart(event);
|
|
17792
|
+
}
|
|
17793
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17794
|
+
};
|
|
17783
17795
|
contextmenuHandler = async (event) => {
|
|
17784
17796
|
await this.select(event);
|
|
17785
17797
|
this.mouseUpHandler();
|
|
@@ -17805,7 +17817,7 @@ class StageMask extends EventEmitter {
|
|
|
17805
17817
|
break;
|
|
17806
17818
|
this.emit("select", el, event);
|
|
17807
17819
|
this.target = el;
|
|
17808
|
-
this.content
|
|
17820
|
+
this.content.addEventListener("mouseup", this.mouseUpHandler);
|
|
17809
17821
|
break;
|
|
17810
17822
|
}
|
|
17811
17823
|
}
|
|
@@ -17817,8 +17829,9 @@ class StageMask extends EventEmitter {
|
|
|
17817
17829
|
width: type === "horizontal" ? "100%" : "30px",
|
|
17818
17830
|
height: type === "horizontal" ? "30px" : "100%"
|
|
17819
17831
|
});
|
|
17820
|
-
createGuides = (type) => new Guides(this.wrapper, {
|
|
17832
|
+
createGuides = (type, defaultGuides = []) => new Guides(this.wrapper, {
|
|
17821
17833
|
type,
|
|
17834
|
+
defaultGuides,
|
|
17822
17835
|
displayDragPos: true,
|
|
17823
17836
|
backgroundColor: "#fff",
|
|
17824
17837
|
lineColor: "#000",
|
|
@@ -17915,9 +17928,8 @@ class StageCore extends EventEmitter {
|
|
|
17915
17928
|
this.dr = new StageDragResize({ core: this, container: this.mask.content });
|
|
17916
17929
|
this.renderer.on("runtime-ready", (runtime) => this.emit("runtime-ready", runtime));
|
|
17917
17930
|
this.renderer.on("page-el-update", (el) => this.mask?.observe(el));
|
|
17918
|
-
this.mask.on("select", async (el
|
|
17931
|
+
this.mask.on("select", async (el) => {
|
|
17919
17932
|
await this.dr?.select(el);
|
|
17920
|
-
setTimeout(() => this.dr?.moveable?.dragStart(event));
|
|
17921
17933
|
});
|
|
17922
17934
|
this.mask.on("selected", (el) => {
|
|
17923
17935
|
this.select(el);
|