@tmagic/stage 1.0.0-beta.5 → 1.0.0-beta.6
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 +38 -27
- package/dist/tmagic-stage.es.js.map +1 -1
- package/dist/tmagic-stage.umd.js +38 -27
- 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 +4 -4
- package/src/StageCore.ts +1 -2
- package/src/StageDragResize.ts +7 -12
- package/src/StageMask.ts +36 -15
package/dist/tmagic-stage.umd.js
CHANGED
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
container;
|
|
101
101
|
target;
|
|
102
102
|
moveable;
|
|
103
|
+
horizontalGuidelines = [];
|
|
104
|
+
verticalGuidelines = [];
|
|
103
105
|
dragStatus = "end" /* END */;
|
|
104
106
|
elObserver;
|
|
105
107
|
ghostEl;
|
|
106
|
-
horizontalGuidelines = [];
|
|
107
|
-
verticalGuidelines = [];
|
|
108
108
|
mode = Mode.ABSOLUTE;
|
|
109
109
|
constructor(config) {
|
|
110
110
|
super();
|
|
@@ -249,10 +249,9 @@
|
|
|
249
249
|
const { renderer } = this.core;
|
|
250
250
|
const getSnapElements = (await renderer.getRuntime())?.getSnapElements || (() => {
|
|
251
251
|
const doc = renderer.contentWindow?.document;
|
|
252
|
-
|
|
253
|
-
return elementGuidelines;
|
|
252
|
+
return doc ? Array.from(doc.querySelectorAll("[id]")) : [];
|
|
254
253
|
});
|
|
255
|
-
return getSnapElements(el);
|
|
254
|
+
return getSnapElements(el).filter((element) => element !== this.target && !this.target?.contains(element));
|
|
256
255
|
}
|
|
257
256
|
sort() {
|
|
258
257
|
if (!this.target || !this.ghostEl)
|
|
@@ -332,11 +331,8 @@
|
|
|
332
331
|
resizable: true,
|
|
333
332
|
snappable: !isSortable,
|
|
334
333
|
snapGap: !isSortable,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
snapHorizontal: !isSortable,
|
|
338
|
-
snapCenter: !isSortable,
|
|
339
|
-
container: renderer.contentWindow?.document.body,
|
|
334
|
+
snapDirections: { center: !isSortable, middle: !isSortable },
|
|
335
|
+
elementSnapDirections: { center: !isSortable, middle: !isSortable },
|
|
340
336
|
elementGuidelines: isSortable ? [] : await this.getSnapElements(this.target),
|
|
341
337
|
horizontalGuidelines: this.horizontalGuidelines,
|
|
342
338
|
verticalGuidelines: this.verticalGuidelines,
|
|
@@ -17690,8 +17686,8 @@
|
|
|
17690
17686
|
this.core = config.core;
|
|
17691
17687
|
const { config: coreConfig } = config.core;
|
|
17692
17688
|
this.canSelect = coreConfig.canSelect || ((el) => !!el.id);
|
|
17693
|
-
this.content.addEventListener("mousedown", this.mouseDownHandler
|
|
17694
|
-
this.content.addEventListener("contextmenu", this.contextmenuHandler
|
|
17689
|
+
this.content.addEventListener("mousedown", this.mouseDownHandler);
|
|
17690
|
+
this.content.addEventListener("contextmenu", this.contextmenuHandler);
|
|
17695
17691
|
this.wrapper.appendChild(this.content);
|
|
17696
17692
|
this.hGuides = this.createGuides("horizontal");
|
|
17697
17693
|
this.vGuides = this.createGuides("vertical");
|
|
@@ -17749,16 +17745,23 @@
|
|
|
17749
17745
|
});
|
|
17750
17746
|
}
|
|
17751
17747
|
showRule(show = true) {
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17748
|
+
if (show) {
|
|
17749
|
+
this.hGuides.destroy();
|
|
17750
|
+
this.hGuides = this.createGuides("horizontal", this.core.dr.horizontalGuidelines);
|
|
17751
|
+
this.vGuides.destroy();
|
|
17752
|
+
this.vGuides = this.createGuides("vertical", this.core.dr.verticalGuidelines);
|
|
17753
|
+
} else {
|
|
17754
|
+
this.hGuides.setState({
|
|
17755
|
+
rulerStyle: {
|
|
17756
|
+
visibility: "hidden"
|
|
17757
|
+
}
|
|
17758
|
+
});
|
|
17759
|
+
this.vGuides.setState({
|
|
17760
|
+
rulerStyle: {
|
|
17761
|
+
visibility: "hidden"
|
|
17762
|
+
}
|
|
17763
|
+
});
|
|
17764
|
+
}
|
|
17762
17765
|
}
|
|
17763
17766
|
clearGuides() {
|
|
17764
17767
|
this.vGuides.setState({
|
|
@@ -17780,13 +17783,21 @@
|
|
|
17780
17783
|
if (event.target.className.indexOf("moveable-control") !== -1) {
|
|
17781
17784
|
return;
|
|
17782
17785
|
}
|
|
17786
|
+
this.content.addEventListener("mousemove", this.mouseMoveHandler);
|
|
17783
17787
|
this.select(event);
|
|
17784
17788
|
};
|
|
17785
17789
|
mouseUpHandler = () => {
|
|
17786
|
-
this.content
|
|
17790
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17791
|
+
this.content.removeEventListener("mouseup", this.mouseUpHandler);
|
|
17787
17792
|
this.emit("selected", this.target);
|
|
17788
17793
|
this.target = null;
|
|
17789
17794
|
};
|
|
17795
|
+
mouseMoveHandler = (event) => {
|
|
17796
|
+
if (event.buttons) {
|
|
17797
|
+
this.core.dr.moveable?.dragStart(event);
|
|
17798
|
+
}
|
|
17799
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17800
|
+
};
|
|
17790
17801
|
contextmenuHandler = async (event) => {
|
|
17791
17802
|
await this.select(event);
|
|
17792
17803
|
this.mouseUpHandler();
|
|
@@ -17812,7 +17823,7 @@
|
|
|
17812
17823
|
break;
|
|
17813
17824
|
this.emit("select", el, event);
|
|
17814
17825
|
this.target = el;
|
|
17815
|
-
this.content
|
|
17826
|
+
this.content.addEventListener("mouseup", this.mouseUpHandler);
|
|
17816
17827
|
break;
|
|
17817
17828
|
}
|
|
17818
17829
|
}
|
|
@@ -17824,8 +17835,9 @@
|
|
|
17824
17835
|
width: type === "horizontal" ? "100%" : "30px",
|
|
17825
17836
|
height: type === "horizontal" ? "30px" : "100%"
|
|
17826
17837
|
});
|
|
17827
|
-
createGuides = (type) => new Guides__default["default"](this.wrapper, {
|
|
17838
|
+
createGuides = (type, defaultGuides = []) => new Guides__default["default"](this.wrapper, {
|
|
17828
17839
|
type,
|
|
17840
|
+
defaultGuides,
|
|
17829
17841
|
displayDragPos: true,
|
|
17830
17842
|
backgroundColor: "#fff",
|
|
17831
17843
|
lineColor: "#000",
|
|
@@ -17922,9 +17934,8 @@
|
|
|
17922
17934
|
this.dr = new StageDragResize({ core: this, container: this.mask.content });
|
|
17923
17935
|
this.renderer.on("runtime-ready", (runtime) => this.emit("runtime-ready", runtime));
|
|
17924
17936
|
this.renderer.on("page-el-update", (el) => this.mask?.observe(el));
|
|
17925
|
-
this.mask.on("select", async (el
|
|
17937
|
+
this.mask.on("select", async (el) => {
|
|
17926
17938
|
await this.dr?.select(el);
|
|
17927
|
-
setTimeout(() => this.dr?.moveable?.dragStart(event));
|
|
17928
17939
|
});
|
|
17929
17940
|
this.mask.on("selected", (el) => {
|
|
17930
17941
|
this.select(el);
|