@tmagic/stage 1.3.6 → 1.3.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/LICENSE +5432 -0
- package/dist/tmagic-stage.js +144 -106
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +144 -106
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/ActionManager.ts +121 -81
- package/src/MoveableActionsAble.ts +1 -1
- package/src/MoveableOptionsManager.ts +2 -2
- package/src/Rule.ts +7 -2
- package/src/StageCore.ts +14 -1
- package/src/StageMask.ts +3 -2
- package/src/StageRender.ts +0 -6
- package/src/const.ts +5 -0
- package/src/index.ts +1 -0
- package/src/types.ts +6 -3
- package/types/ActionManager.d.ts +8 -6
- package/types/MoveableActionsAble.d.ts +1 -1
- package/types/MoveableOptionsManager.d.ts +1 -1
- package/types/Rule.d.ts +3 -1
- package/types/StageCore.d.ts +2 -0
- package/types/StageMask.d.ts +2 -1
- package/types/const.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/types.d.ts +6 -3
package/dist/tmagic-stage.js
CHANGED
|
@@ -39,6 +39,11 @@ var Mode = /* @__PURE__ */ ((Mode2) => {
|
|
|
39
39
|
return Mode2;
|
|
40
40
|
})(Mode || {});
|
|
41
41
|
const SELECTED_CLASS = "tmagic-stage-selected-area";
|
|
42
|
+
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
43
|
+
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
44
|
+
AbleActionEventType2["REMOVE"] = "remove";
|
|
45
|
+
return AbleActionEventType2;
|
|
46
|
+
})(AbleActionEventType || {});
|
|
42
47
|
|
|
43
48
|
const getParents = (el, relative) => {
|
|
44
49
|
let cur = el.parentElement;
|
|
@@ -582,33 +587,6 @@ class DragResizeHelper {
|
|
|
582
587
|
|
|
583
588
|
const ableCss = ".moveable-button {\n width: 20px;\n height: 20px;\n background: #4af;\n border-radius: 4px;\n appearance: none;\n border: 0;\n color: white;\n font-size: 12px;\n font-weight: bold;\n margin-left: 2px;\n position: relative;\n}\n.moveable-remove-button:before, .moveable-remove-button:after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(45deg);\n width: 14px;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n cursor: pointer;\n}\n.moveable-remove-button:after {\n transform: translate(-50%, -50%) rotate(-45deg);\n}\n\n.moveable-select-parent-arrow-top-icon {\n transform: rotateZ(-45deg);\n width: 4px;\n height: 4px;\n border-color: #fff;\n border-width: 2px 2px 0 0;\n border-style: solid;\n position: absolute;\n left: 4px;\n top: 4px;\n}\n\n.moveable-select-parent-arrow-body-icon {\n width: 7px;\n height: 11px;\n border-color: #fff;\n border-width: 0 0 2px 2px;\n border-style: solid;\n}\n\n.moveable-drag-area-button {\n cursor: move;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon {\n width: 2px;\n height: 2px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-top {\n transform: rotateZ(-45deg) translateX(-50%);\n left: 50%;\n top: 3px;\n transform-origin: left;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-bottom {\n transform: rotateZ(135deg) translateX(-50%);\n transform-origin: left;\n left: 50%;\n top: auto;\n bottom: 3px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-right {\n transform: rotateZ(45deg) translateY(-50%);\n transform-origin: top;\n right: 3px;\n left: auto;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-left {\n transform: rotateZ(235deg) translateY(-50%);\n transform-origin: top;\n left: 3px;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-horizontal {\n width: 2px;\n height: 11px;\n background-color: #fff;\n position: absolute;\n transform: translateX(-50%);\n left: 50%;\n top: 4px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-vertical {\n width: 11px;\n height: 2px;\n background-color: #fff;\n position: absolute;\n transform: translateY(-50%);\n left: 4px;\n top: 50%;;\n}\n\n";
|
|
584
589
|
|
|
585
|
-
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
586
|
-
ContainerHighlightType2["DEFAULT"] = "default";
|
|
587
|
-
ContainerHighlightType2["ALT"] = "alt";
|
|
588
|
-
return ContainerHighlightType2;
|
|
589
|
-
})(ContainerHighlightType || {});
|
|
590
|
-
var RenderType = /* @__PURE__ */ ((RenderType2) => {
|
|
591
|
-
RenderType2["IFRAME"] = "iframe";
|
|
592
|
-
RenderType2["NATIVE"] = "native";
|
|
593
|
-
return RenderType2;
|
|
594
|
-
})(RenderType || {});
|
|
595
|
-
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
596
|
-
SelectStatus2["SELECT"] = "select";
|
|
597
|
-
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
598
|
-
return SelectStatus2;
|
|
599
|
-
})(SelectStatus || {});
|
|
600
|
-
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
601
|
-
StageDragStatus2["START"] = "start";
|
|
602
|
-
StageDragStatus2["ING"] = "ing";
|
|
603
|
-
StageDragStatus2["END"] = "end";
|
|
604
|
-
return StageDragStatus2;
|
|
605
|
-
})(StageDragStatus || {});
|
|
606
|
-
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
607
|
-
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
608
|
-
AbleActionEventType2["REMOVE"] = "remove";
|
|
609
|
-
return AbleActionEventType2;
|
|
610
|
-
})(AbleActionEventType || {});
|
|
611
|
-
|
|
612
590
|
const MoveableActionsAble = (handler) => ({
|
|
613
591
|
name: "actions",
|
|
614
592
|
props: [],
|
|
@@ -901,6 +879,28 @@ class MoveableOptionsManager extends EventEmitter {
|
|
|
901
879
|
}
|
|
902
880
|
}
|
|
903
881
|
|
|
882
|
+
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
883
|
+
ContainerHighlightType2["DEFAULT"] = "default";
|
|
884
|
+
ContainerHighlightType2["ALT"] = "alt";
|
|
885
|
+
return ContainerHighlightType2;
|
|
886
|
+
})(ContainerHighlightType || {});
|
|
887
|
+
var RenderType = /* @__PURE__ */ ((RenderType2) => {
|
|
888
|
+
RenderType2["IFRAME"] = "iframe";
|
|
889
|
+
RenderType2["NATIVE"] = "native";
|
|
890
|
+
return RenderType2;
|
|
891
|
+
})(RenderType || {});
|
|
892
|
+
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
893
|
+
SelectStatus2["SELECT"] = "select";
|
|
894
|
+
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
895
|
+
return SelectStatus2;
|
|
896
|
+
})(SelectStatus || {});
|
|
897
|
+
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
898
|
+
StageDragStatus2["START"] = "start";
|
|
899
|
+
StageDragStatus2["ING"] = "ing";
|
|
900
|
+
StageDragStatus2["END"] = "end";
|
|
901
|
+
return StageDragStatus2;
|
|
902
|
+
})(StageDragStatus || {});
|
|
903
|
+
|
|
904
904
|
class StageDragResize extends MoveableOptionsManager {
|
|
905
905
|
/** 目标节点 */
|
|
906
906
|
target;
|
|
@@ -1393,6 +1393,8 @@ class ActionManager extends EventEmitter {
|
|
|
1393
1393
|
canSelect;
|
|
1394
1394
|
isContainer;
|
|
1395
1395
|
getRenderDocument;
|
|
1396
|
+
disabledMultiSelect = false;
|
|
1397
|
+
config;
|
|
1396
1398
|
mouseMoveHandler = throttle(async (event) => {
|
|
1397
1399
|
if (event.target?.classList?.contains("moveable-direction")) {
|
|
1398
1400
|
return;
|
|
@@ -1407,38 +1409,21 @@ class ActionManager extends EventEmitter {
|
|
|
1407
1409
|
}, throttleTime);
|
|
1408
1410
|
constructor(config) {
|
|
1409
1411
|
super();
|
|
1412
|
+
this.config = config;
|
|
1410
1413
|
this.container = config.container;
|
|
1411
1414
|
this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS_NAME;
|
|
1412
1415
|
this.containerHighlightDuration = config.containerHighlightDuration || defaultContainerHighlightDuration;
|
|
1413
1416
|
this.containerHighlightType = config.containerHighlightType;
|
|
1417
|
+
this.disabledMultiSelect = config.disabledMultiSelect ?? false;
|
|
1414
1418
|
this.getTargetElement = config.getTargetElement;
|
|
1415
1419
|
this.getElementsFromPoint = config.getElementsFromPoint;
|
|
1416
1420
|
this.canSelect = config.canSelect || ((el) => !!el.id);
|
|
1417
1421
|
this.getRenderDocument = config.getRenderDocument;
|
|
1418
1422
|
this.isContainer = config.isContainer;
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
this.dr = new StageDragResize({
|
|
1424
|
-
container: config.container,
|
|
1425
|
-
disabledDragStart: config.disabledDragStart,
|
|
1426
|
-
moveableOptions: this.changeCallback(config.moveableOptions, false),
|
|
1427
|
-
dragResizeHelper: createDrHelper(),
|
|
1428
|
-
getRootContainer: config.getRootContainer,
|
|
1429
|
-
getRenderDocument: config.getRenderDocument,
|
|
1430
|
-
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1431
|
-
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1432
|
-
});
|
|
1433
|
-
this.multiDr = new StageMultiDragResize({
|
|
1434
|
-
container: config.container,
|
|
1435
|
-
moveableOptions: this.changeCallback(config.moveableOptions, true),
|
|
1436
|
-
dragResizeHelper: createDrHelper(),
|
|
1437
|
-
getRootContainer: config.getRootContainer,
|
|
1438
|
-
getRenderDocument: config.getRenderDocument,
|
|
1439
|
-
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1440
|
-
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1441
|
-
});
|
|
1423
|
+
this.dr = this.createDr(config);
|
|
1424
|
+
if (!this.disabledMultiSelect) {
|
|
1425
|
+
this.multiDr = this.createMultiDr(config);
|
|
1426
|
+
}
|
|
1442
1427
|
this.highlightLayer = new StageHighlight({
|
|
1443
1428
|
container: config.container,
|
|
1444
1429
|
updateDragEl: config.updateDragEl,
|
|
@@ -1446,7 +1431,19 @@ class ActionManager extends EventEmitter {
|
|
|
1446
1431
|
});
|
|
1447
1432
|
this.initMouseEvent();
|
|
1448
1433
|
this.initKeyEvent();
|
|
1449
|
-
|
|
1434
|
+
}
|
|
1435
|
+
disableMultiSelect() {
|
|
1436
|
+
this.disabledMultiSelect = true;
|
|
1437
|
+
if (this.multiDr) {
|
|
1438
|
+
this.multiDr.destroy();
|
|
1439
|
+
this.multiDr = void 0;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
enableMultiSelect() {
|
|
1443
|
+
this.disabledMultiSelect = false;
|
|
1444
|
+
if (!this.multiDr) {
|
|
1445
|
+
this.multiDr = this.createMultiDr(this.config);
|
|
1446
|
+
}
|
|
1450
1447
|
}
|
|
1451
1448
|
/**
|
|
1452
1449
|
* 设置水平/垂直参考线
|
|
@@ -1455,14 +1452,14 @@ class ActionManager extends EventEmitter {
|
|
|
1455
1452
|
*/
|
|
1456
1453
|
setGuidelines(type, guidelines) {
|
|
1457
1454
|
this.dr.setGuidelines(type, guidelines);
|
|
1458
|
-
this.multiDr
|
|
1455
|
+
this.multiDr?.setGuidelines(type, guidelines);
|
|
1459
1456
|
}
|
|
1460
1457
|
/**
|
|
1461
1458
|
* 清空所有参考线
|
|
1462
1459
|
*/
|
|
1463
1460
|
clearGuides() {
|
|
1464
1461
|
this.dr.clearGuides();
|
|
1465
|
-
this.multiDr
|
|
1462
|
+
this.multiDr?.clearGuides();
|
|
1466
1463
|
}
|
|
1467
1464
|
/**
|
|
1468
1465
|
* 更新moveable,外部主要调用场景是元素配置变更、页面大小变更
|
|
@@ -1470,7 +1467,7 @@ class ActionManager extends EventEmitter {
|
|
|
1470
1467
|
*/
|
|
1471
1468
|
updateMoveable(el) {
|
|
1472
1469
|
this.dr.updateMoveable(el);
|
|
1473
|
-
this.multiDr
|
|
1470
|
+
this.multiDr?.updateMoveable();
|
|
1474
1471
|
}
|
|
1475
1472
|
/**
|
|
1476
1473
|
* 判断是否单选选中的元素
|
|
@@ -1491,7 +1488,7 @@ class ActionManager extends EventEmitter {
|
|
|
1491
1488
|
if (this.dr.getTarget()) {
|
|
1492
1489
|
return this.dr.getOption(key);
|
|
1493
1490
|
}
|
|
1494
|
-
if (this.multiDr
|
|
1491
|
+
if (this.multiDr?.targetList.length) {
|
|
1495
1492
|
return this.multiDr.getOption(key);
|
|
1496
1493
|
}
|
|
1497
1494
|
}
|
|
@@ -1541,17 +1538,17 @@ class ActionManager extends EventEmitter {
|
|
|
1541
1538
|
if (selectedEl?.className.includes(PAGE_CLASS)) {
|
|
1542
1539
|
return true;
|
|
1543
1540
|
}
|
|
1544
|
-
return this.multiDr
|
|
1541
|
+
return this.multiDr?.canSelect(el, selectedEl) || false;
|
|
1545
1542
|
}
|
|
1546
1543
|
select(el, event) {
|
|
1547
|
-
this.
|
|
1544
|
+
this.setSelectedEl(el);
|
|
1548
1545
|
this.clearSelectStatus(SelectStatus.MULTI_SELECT);
|
|
1549
1546
|
this.dr.select(el, event);
|
|
1550
1547
|
}
|
|
1551
1548
|
multiSelect(idOrElList) {
|
|
1552
1549
|
this.selectedElList = idOrElList.map((idOrEl) => this.getTargetElement(idOrEl));
|
|
1553
1550
|
this.clearSelectStatus(SelectStatus.SELECT);
|
|
1554
|
-
this.multiDr
|
|
1551
|
+
this.multiDr?.multiSelect(this.selectedElList);
|
|
1555
1552
|
}
|
|
1556
1553
|
getHighlightEl() {
|
|
1557
1554
|
return this.highlightedEl;
|
|
@@ -1567,7 +1564,7 @@ class ActionManager extends EventEmitter {
|
|
|
1567
1564
|
this.clearHighlight();
|
|
1568
1565
|
return;
|
|
1569
1566
|
}
|
|
1570
|
-
if (el === this.getSelectedEl() || this.multiDr
|
|
1567
|
+
if (el === this.getSelectedEl() || this.multiDr?.dragStatus === StageDragStatus.ING) {
|
|
1571
1568
|
this.clearHighlight();
|
|
1572
1569
|
return;
|
|
1573
1570
|
}
|
|
@@ -1587,7 +1584,7 @@ class ActionManager extends EventEmitter {
|
|
|
1587
1584
|
*/
|
|
1588
1585
|
clearSelectStatus(selectType) {
|
|
1589
1586
|
if (selectType === SelectStatus.MULTI_SELECT) {
|
|
1590
|
-
this.multiDr
|
|
1587
|
+
this.multiDr?.clearSelectStatus();
|
|
1591
1588
|
this.selectedElList = [];
|
|
1592
1589
|
} else {
|
|
1593
1590
|
this.dr.clearSelectStatus();
|
|
@@ -1634,9 +1631,67 @@ class ActionManager extends EventEmitter {
|
|
|
1634
1631
|
this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
|
|
1635
1632
|
this.container.removeEventListener("wheel", this.mouseWheelHandler);
|
|
1636
1633
|
this.dr.destroy();
|
|
1637
|
-
this.multiDr
|
|
1634
|
+
this.multiDr?.destroy();
|
|
1638
1635
|
this.highlightLayer.destroy();
|
|
1639
1636
|
}
|
|
1637
|
+
createDr(config) {
|
|
1638
|
+
const createDrHelper = () => new DragResizeHelper({
|
|
1639
|
+
container: config.container,
|
|
1640
|
+
updateDragEl: config.updateDragEl
|
|
1641
|
+
});
|
|
1642
|
+
const dr = new StageDragResize({
|
|
1643
|
+
container: config.container,
|
|
1644
|
+
disabledDragStart: config.disabledDragStart,
|
|
1645
|
+
moveableOptions: this.changeCallback(config.moveableOptions, false),
|
|
1646
|
+
dragResizeHelper: createDrHelper(),
|
|
1647
|
+
getRootContainer: config.getRootContainer,
|
|
1648
|
+
getRenderDocument: config.getRenderDocument,
|
|
1649
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1650
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1651
|
+
});
|
|
1652
|
+
dr.on("update", (data) => {
|
|
1653
|
+
setTimeout(() => this.emit("update", data));
|
|
1654
|
+
}).on("sort", (data) => {
|
|
1655
|
+
setTimeout(() => this.emit("sort", data));
|
|
1656
|
+
}).on("select-parent", () => {
|
|
1657
|
+
this.emit("select-parent");
|
|
1658
|
+
}).on("remove", () => {
|
|
1659
|
+
const drTarget = this.dr.getTarget();
|
|
1660
|
+
if (!drTarget)
|
|
1661
|
+
return;
|
|
1662
|
+
const data = {
|
|
1663
|
+
data: [{ el: drTarget }]
|
|
1664
|
+
};
|
|
1665
|
+
this.emit("remove", data);
|
|
1666
|
+
}).on("drag-start", (e) => {
|
|
1667
|
+
this.emit("drag-start", e);
|
|
1668
|
+
});
|
|
1669
|
+
return dr;
|
|
1670
|
+
}
|
|
1671
|
+
createMultiDr(config) {
|
|
1672
|
+
const createDrHelper = () => new DragResizeHelper({
|
|
1673
|
+
container: config.container,
|
|
1674
|
+
updateDragEl: config.updateDragEl
|
|
1675
|
+
});
|
|
1676
|
+
const multiDr = new StageMultiDragResize({
|
|
1677
|
+
container: config.container,
|
|
1678
|
+
moveableOptions: this.changeCallback(config.moveableOptions, true),
|
|
1679
|
+
dragResizeHelper: createDrHelper(),
|
|
1680
|
+
getRootContainer: config.getRootContainer,
|
|
1681
|
+
getRenderDocument: config.getRenderDocument,
|
|
1682
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1683
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1684
|
+
});
|
|
1685
|
+
multiDr?.on("update", (data) => {
|
|
1686
|
+
this.emit("multi-update", data);
|
|
1687
|
+
}).on("change-to-select", async (id) => {
|
|
1688
|
+
if (this.isMultiSelectStatus)
|
|
1689
|
+
return false;
|
|
1690
|
+
const el = this.getTargetElement(id);
|
|
1691
|
+
this.emit("change-to-select", el);
|
|
1692
|
+
});
|
|
1693
|
+
return multiDr;
|
|
1694
|
+
}
|
|
1640
1695
|
changeCallback(options, isMulti) {
|
|
1641
1696
|
if (typeof options === "function") {
|
|
1642
1697
|
return () => {
|
|
@@ -1667,7 +1722,7 @@ class ActionManager extends EventEmitter {
|
|
|
1667
1722
|
return;
|
|
1668
1723
|
if (this.selectedEl && !this.selectedEl.className.includes(PAGE_CLASS)) {
|
|
1669
1724
|
this.selectedElList.push(this.selectedEl);
|
|
1670
|
-
this.
|
|
1725
|
+
this.setSelectedEl(void 0);
|
|
1671
1726
|
}
|
|
1672
1727
|
const existIndex = this.selectedElList.findIndex((selectedDom) => selectedDom.id === el.id);
|
|
1673
1728
|
if (existIndex !== -1) {
|
|
@@ -1707,14 +1762,20 @@ class ActionManager extends EventEmitter {
|
|
|
1707
1762
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
1708
1763
|
KeyController.global.keydown(ctrl, (e) => {
|
|
1709
1764
|
e.inputEvent.preventDefault();
|
|
1710
|
-
this.
|
|
1765
|
+
if (!this.disabledMultiSelect) {
|
|
1766
|
+
this.isMultiSelectStatus = true;
|
|
1767
|
+
}
|
|
1711
1768
|
});
|
|
1712
1769
|
KeyController.global.on("blur", () => {
|
|
1713
|
-
this.
|
|
1770
|
+
if (!this.disabledMultiSelect) {
|
|
1771
|
+
this.isMultiSelectStatus = false;
|
|
1772
|
+
}
|
|
1714
1773
|
});
|
|
1715
1774
|
KeyController.global.keyup(ctrl, (e) => {
|
|
1716
1775
|
e.inputEvent.preventDefault();
|
|
1717
|
-
this.
|
|
1776
|
+
if (!this.disabledMultiSelect) {
|
|
1777
|
+
this.isMultiSelectStatus = false;
|
|
1778
|
+
}
|
|
1718
1779
|
});
|
|
1719
1780
|
KeyController.global.keydown("alt", (e) => {
|
|
1720
1781
|
e.inputEvent.preventDefault();
|
|
@@ -1726,36 +1787,6 @@ class ActionManager extends EventEmitter {
|
|
|
1726
1787
|
this.isAltKeydown = false;
|
|
1727
1788
|
});
|
|
1728
1789
|
}
|
|
1729
|
-
/**
|
|
1730
|
-
* 处理单选、多选抛出来的事件
|
|
1731
|
-
*/
|
|
1732
|
-
initActionEvent() {
|
|
1733
|
-
this.dr.on("update", (data) => {
|
|
1734
|
-
setTimeout(() => this.emit("update", data));
|
|
1735
|
-
}).on("sort", (data) => {
|
|
1736
|
-
setTimeout(() => this.emit("sort", data));
|
|
1737
|
-
}).on("select-parent", () => {
|
|
1738
|
-
this.emit("select-parent");
|
|
1739
|
-
}).on("remove", () => {
|
|
1740
|
-
const drTarget = this.dr.getTarget();
|
|
1741
|
-
if (!drTarget)
|
|
1742
|
-
return;
|
|
1743
|
-
const data = {
|
|
1744
|
-
data: [{ el: drTarget }]
|
|
1745
|
-
};
|
|
1746
|
-
this.emit("remove", data);
|
|
1747
|
-
}).on("drag-start", (e) => {
|
|
1748
|
-
this.emit("drag-start", e);
|
|
1749
|
-
});
|
|
1750
|
-
this.multiDr.on("update", (data) => {
|
|
1751
|
-
this.emit("multi-update", data);
|
|
1752
|
-
}).on("change-to-select", async (id) => {
|
|
1753
|
-
if (this.isMultiSelectStatus)
|
|
1754
|
-
return false;
|
|
1755
|
-
const el = this.getTargetElement(id);
|
|
1756
|
-
this.emit("change-to-select", el);
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
1790
|
/**
|
|
1760
1791
|
* 在down事件中集中cpu处理画布中选中操作渲染,在up事件中再通知外面的编辑器更新
|
|
1761
1792
|
*/
|
|
@@ -1822,8 +1853,10 @@ class Rule extends EventEmitter {
|
|
|
1822
1853
|
container;
|
|
1823
1854
|
containerResizeObserver;
|
|
1824
1855
|
isShowGuides = true;
|
|
1825
|
-
|
|
1856
|
+
guidesOptions;
|
|
1857
|
+
constructor(container, options) {
|
|
1826
1858
|
super();
|
|
1859
|
+
this.guidesOptions = options?.guidesOptions || {};
|
|
1827
1860
|
this.container = container;
|
|
1828
1861
|
this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
|
|
1829
1862
|
this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
|
|
@@ -1922,7 +1955,8 @@ class Rule extends EventEmitter {
|
|
|
1922
1955
|
lineColor: "#000",
|
|
1923
1956
|
textColor: "#000",
|
|
1924
1957
|
style: this.getGuidesStyle(type),
|
|
1925
|
-
showGuides: this.isShowGuides
|
|
1958
|
+
showGuides: this.isShowGuides,
|
|
1959
|
+
...this.guidesOptions
|
|
1926
1960
|
});
|
|
1927
1961
|
const changEventHandler = {
|
|
1928
1962
|
[GuidesType.HORIZONTAL]: this.hGuidesChangeGuidesHandler,
|
|
@@ -1994,9 +2028,9 @@ class StageMask extends Rule {
|
|
|
1994
2028
|
pageScrollParent = null;
|
|
1995
2029
|
intersectionObserver = null;
|
|
1996
2030
|
wrapperResizeObserver = null;
|
|
1997
|
-
constructor() {
|
|
2031
|
+
constructor(options) {
|
|
1998
2032
|
const wrapper = createWrapper();
|
|
1999
|
-
super(wrapper);
|
|
2033
|
+
super(wrapper, options);
|
|
2000
2034
|
this.wrapper = wrapper;
|
|
2001
2035
|
this.content.addEventListener("wheel", this.mouseWheelHandler);
|
|
2002
2036
|
this.wrapper.appendChild(this.content);
|
|
@@ -2308,12 +2342,6 @@ class StageRender extends EventEmitter$1 {
|
|
|
2308
2342
|
x = x - rect.left;
|
|
2309
2343
|
y = y - rect.top;
|
|
2310
2344
|
}
|
|
2311
|
-
} else if (this.nativeContainer) {
|
|
2312
|
-
const rect = this.nativeContainer.getClientRects()[0];
|
|
2313
|
-
if (rect) {
|
|
2314
|
-
x = x - rect.left;
|
|
2315
|
-
y = y - rect.top;
|
|
2316
|
-
}
|
|
2317
2345
|
}
|
|
2318
2346
|
return this.getDocument()?.elementsFromPoint(x / this.zoom, y / this.zoom);
|
|
2319
2347
|
}
|
|
@@ -2419,7 +2447,9 @@ class StageCore extends EventEmitter$1 {
|
|
|
2419
2447
|
return null;
|
|
2420
2448
|
}
|
|
2421
2449
|
});
|
|
2422
|
-
this.mask = new StageMask(
|
|
2450
|
+
this.mask = new StageMask({
|
|
2451
|
+
guidesOptions: config.guidesOptions
|
|
2452
|
+
});
|
|
2423
2453
|
this.actionManager = new ActionManager(this.getActionManagerConfig(config));
|
|
2424
2454
|
this.initRenderEvent();
|
|
2425
2455
|
this.initActionEvent();
|
|
@@ -2540,6 +2570,12 @@ class StageCore extends EventEmitter$1 {
|
|
|
2540
2570
|
getDragStatus() {
|
|
2541
2571
|
return this.actionManager.getDragStatus();
|
|
2542
2572
|
}
|
|
2573
|
+
disableMultiSelect() {
|
|
2574
|
+
this.actionManager.disableMultiSelect();
|
|
2575
|
+
}
|
|
2576
|
+
enableMultiSelect() {
|
|
2577
|
+
this.actionManager.enableMultiSelect();
|
|
2578
|
+
}
|
|
2543
2579
|
/**
|
|
2544
2580
|
* 销毁实例
|
|
2545
2581
|
*/
|
|
@@ -2572,6 +2608,7 @@ class StageCore extends EventEmitter$1 {
|
|
|
2572
2608
|
moveableOptions: config.moveableOptions,
|
|
2573
2609
|
container: this.mask.content,
|
|
2574
2610
|
disabledDragStart: config.disabledDragStart,
|
|
2611
|
+
disabledMultiSelect: config.disabledMultiSelect,
|
|
2575
2612
|
canSelect: config.canSelect,
|
|
2576
2613
|
isContainer: config.isContainer,
|
|
2577
2614
|
updateDragEl: config.updateDragEl,
|
|
@@ -2589,6 +2626,7 @@ class StageCore extends EventEmitter$1 {
|
|
|
2589
2626
|
this.renderer.on("page-el-update", (el) => {
|
|
2590
2627
|
this.mask?.observe(el);
|
|
2591
2628
|
this.observePageResize(el);
|
|
2629
|
+
this.emit("page-el-update", el);
|
|
2592
2630
|
});
|
|
2593
2631
|
}
|
|
2594
2632
|
initMaskEvent() {
|