@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
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
return Mode2;
|
|
37
37
|
})(Mode || {});
|
|
38
38
|
const SELECTED_CLASS = "tmagic-stage-selected-area";
|
|
39
|
+
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
40
|
+
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
41
|
+
AbleActionEventType2["REMOVE"] = "remove";
|
|
42
|
+
return AbleActionEventType2;
|
|
43
|
+
})(AbleActionEventType || {});
|
|
39
44
|
|
|
40
45
|
const getParents = (el, relative) => {
|
|
41
46
|
let cur = el.parentElement;
|
|
@@ -579,33 +584,6 @@
|
|
|
579
584
|
|
|
580
585
|
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";
|
|
581
586
|
|
|
582
|
-
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
583
|
-
ContainerHighlightType2["DEFAULT"] = "default";
|
|
584
|
-
ContainerHighlightType2["ALT"] = "alt";
|
|
585
|
-
return ContainerHighlightType2;
|
|
586
|
-
})(ContainerHighlightType || {});
|
|
587
|
-
var RenderType = /* @__PURE__ */ ((RenderType2) => {
|
|
588
|
-
RenderType2["IFRAME"] = "iframe";
|
|
589
|
-
RenderType2["NATIVE"] = "native";
|
|
590
|
-
return RenderType2;
|
|
591
|
-
})(RenderType || {});
|
|
592
|
-
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
593
|
-
SelectStatus2["SELECT"] = "select";
|
|
594
|
-
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
595
|
-
return SelectStatus2;
|
|
596
|
-
})(SelectStatus || {});
|
|
597
|
-
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
598
|
-
StageDragStatus2["START"] = "start";
|
|
599
|
-
StageDragStatus2["ING"] = "ing";
|
|
600
|
-
StageDragStatus2["END"] = "end";
|
|
601
|
-
return StageDragStatus2;
|
|
602
|
-
})(StageDragStatus || {});
|
|
603
|
-
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
604
|
-
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
605
|
-
AbleActionEventType2["REMOVE"] = "remove";
|
|
606
|
-
return AbleActionEventType2;
|
|
607
|
-
})(AbleActionEventType || {});
|
|
608
|
-
|
|
609
587
|
const MoveableActionsAble = (handler) => ({
|
|
610
588
|
name: "actions",
|
|
611
589
|
props: [],
|
|
@@ -898,6 +876,28 @@
|
|
|
898
876
|
}
|
|
899
877
|
}
|
|
900
878
|
|
|
879
|
+
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
880
|
+
ContainerHighlightType2["DEFAULT"] = "default";
|
|
881
|
+
ContainerHighlightType2["ALT"] = "alt";
|
|
882
|
+
return ContainerHighlightType2;
|
|
883
|
+
})(ContainerHighlightType || {});
|
|
884
|
+
var RenderType = /* @__PURE__ */ ((RenderType2) => {
|
|
885
|
+
RenderType2["IFRAME"] = "iframe";
|
|
886
|
+
RenderType2["NATIVE"] = "native";
|
|
887
|
+
return RenderType2;
|
|
888
|
+
})(RenderType || {});
|
|
889
|
+
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
890
|
+
SelectStatus2["SELECT"] = "select";
|
|
891
|
+
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
892
|
+
return SelectStatus2;
|
|
893
|
+
})(SelectStatus || {});
|
|
894
|
+
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
895
|
+
StageDragStatus2["START"] = "start";
|
|
896
|
+
StageDragStatus2["ING"] = "ing";
|
|
897
|
+
StageDragStatus2["END"] = "end";
|
|
898
|
+
return StageDragStatus2;
|
|
899
|
+
})(StageDragStatus || {});
|
|
900
|
+
|
|
901
901
|
class StageDragResize extends MoveableOptionsManager {
|
|
902
902
|
/** 目标节点 */
|
|
903
903
|
target;
|
|
@@ -1390,6 +1390,8 @@
|
|
|
1390
1390
|
canSelect;
|
|
1391
1391
|
isContainer;
|
|
1392
1392
|
getRenderDocument;
|
|
1393
|
+
disabledMultiSelect = false;
|
|
1394
|
+
config;
|
|
1393
1395
|
mouseMoveHandler = lodashEs.throttle(async (event) => {
|
|
1394
1396
|
if (event.target?.classList?.contains("moveable-direction")) {
|
|
1395
1397
|
return;
|
|
@@ -1404,38 +1406,21 @@
|
|
|
1404
1406
|
}, throttleTime);
|
|
1405
1407
|
constructor(config) {
|
|
1406
1408
|
super();
|
|
1409
|
+
this.config = config;
|
|
1407
1410
|
this.container = config.container;
|
|
1408
1411
|
this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS_NAME;
|
|
1409
1412
|
this.containerHighlightDuration = config.containerHighlightDuration || defaultContainerHighlightDuration;
|
|
1410
1413
|
this.containerHighlightType = config.containerHighlightType;
|
|
1414
|
+
this.disabledMultiSelect = config.disabledMultiSelect ?? false;
|
|
1411
1415
|
this.getTargetElement = config.getTargetElement;
|
|
1412
1416
|
this.getElementsFromPoint = config.getElementsFromPoint;
|
|
1413
1417
|
this.canSelect = config.canSelect || ((el) => !!el.id);
|
|
1414
1418
|
this.getRenderDocument = config.getRenderDocument;
|
|
1415
1419
|
this.isContainer = config.isContainer;
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1420
|
-
this.dr = new StageDragResize({
|
|
1421
|
-
container: config.container,
|
|
1422
|
-
disabledDragStart: config.disabledDragStart,
|
|
1423
|
-
moveableOptions: this.changeCallback(config.moveableOptions, false),
|
|
1424
|
-
dragResizeHelper: createDrHelper(),
|
|
1425
|
-
getRootContainer: config.getRootContainer,
|
|
1426
|
-
getRenderDocument: config.getRenderDocument,
|
|
1427
|
-
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1428
|
-
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1429
|
-
});
|
|
1430
|
-
this.multiDr = new StageMultiDragResize({
|
|
1431
|
-
container: config.container,
|
|
1432
|
-
moveableOptions: this.changeCallback(config.moveableOptions, true),
|
|
1433
|
-
dragResizeHelper: createDrHelper(),
|
|
1434
|
-
getRootContainer: config.getRootContainer,
|
|
1435
|
-
getRenderDocument: config.getRenderDocument,
|
|
1436
|
-
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1437
|
-
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1438
|
-
});
|
|
1420
|
+
this.dr = this.createDr(config);
|
|
1421
|
+
if (!this.disabledMultiSelect) {
|
|
1422
|
+
this.multiDr = this.createMultiDr(config);
|
|
1423
|
+
}
|
|
1439
1424
|
this.highlightLayer = new StageHighlight({
|
|
1440
1425
|
container: config.container,
|
|
1441
1426
|
updateDragEl: config.updateDragEl,
|
|
@@ -1443,7 +1428,19 @@
|
|
|
1443
1428
|
});
|
|
1444
1429
|
this.initMouseEvent();
|
|
1445
1430
|
this.initKeyEvent();
|
|
1446
|
-
|
|
1431
|
+
}
|
|
1432
|
+
disableMultiSelect() {
|
|
1433
|
+
this.disabledMultiSelect = true;
|
|
1434
|
+
if (this.multiDr) {
|
|
1435
|
+
this.multiDr.destroy();
|
|
1436
|
+
this.multiDr = void 0;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
enableMultiSelect() {
|
|
1440
|
+
this.disabledMultiSelect = false;
|
|
1441
|
+
if (!this.multiDr) {
|
|
1442
|
+
this.multiDr = this.createMultiDr(this.config);
|
|
1443
|
+
}
|
|
1447
1444
|
}
|
|
1448
1445
|
/**
|
|
1449
1446
|
* 设置水平/垂直参考线
|
|
@@ -1452,14 +1449,14 @@
|
|
|
1452
1449
|
*/
|
|
1453
1450
|
setGuidelines(type, guidelines) {
|
|
1454
1451
|
this.dr.setGuidelines(type, guidelines);
|
|
1455
|
-
this.multiDr
|
|
1452
|
+
this.multiDr?.setGuidelines(type, guidelines);
|
|
1456
1453
|
}
|
|
1457
1454
|
/**
|
|
1458
1455
|
* 清空所有参考线
|
|
1459
1456
|
*/
|
|
1460
1457
|
clearGuides() {
|
|
1461
1458
|
this.dr.clearGuides();
|
|
1462
|
-
this.multiDr
|
|
1459
|
+
this.multiDr?.clearGuides();
|
|
1463
1460
|
}
|
|
1464
1461
|
/**
|
|
1465
1462
|
* 更新moveable,外部主要调用场景是元素配置变更、页面大小变更
|
|
@@ -1467,7 +1464,7 @@
|
|
|
1467
1464
|
*/
|
|
1468
1465
|
updateMoveable(el) {
|
|
1469
1466
|
this.dr.updateMoveable(el);
|
|
1470
|
-
this.multiDr
|
|
1467
|
+
this.multiDr?.updateMoveable();
|
|
1471
1468
|
}
|
|
1472
1469
|
/**
|
|
1473
1470
|
* 判断是否单选选中的元素
|
|
@@ -1488,7 +1485,7 @@
|
|
|
1488
1485
|
if (this.dr.getTarget()) {
|
|
1489
1486
|
return this.dr.getOption(key);
|
|
1490
1487
|
}
|
|
1491
|
-
if (this.multiDr
|
|
1488
|
+
if (this.multiDr?.targetList.length) {
|
|
1492
1489
|
return this.multiDr.getOption(key);
|
|
1493
1490
|
}
|
|
1494
1491
|
}
|
|
@@ -1538,17 +1535,17 @@
|
|
|
1538
1535
|
if (selectedEl?.className.includes(PAGE_CLASS)) {
|
|
1539
1536
|
return true;
|
|
1540
1537
|
}
|
|
1541
|
-
return this.multiDr
|
|
1538
|
+
return this.multiDr?.canSelect(el, selectedEl) || false;
|
|
1542
1539
|
}
|
|
1543
1540
|
select(el, event) {
|
|
1544
|
-
this.
|
|
1541
|
+
this.setSelectedEl(el);
|
|
1545
1542
|
this.clearSelectStatus(SelectStatus.MULTI_SELECT);
|
|
1546
1543
|
this.dr.select(el, event);
|
|
1547
1544
|
}
|
|
1548
1545
|
multiSelect(idOrElList) {
|
|
1549
1546
|
this.selectedElList = idOrElList.map((idOrEl) => this.getTargetElement(idOrEl));
|
|
1550
1547
|
this.clearSelectStatus(SelectStatus.SELECT);
|
|
1551
|
-
this.multiDr
|
|
1548
|
+
this.multiDr?.multiSelect(this.selectedElList);
|
|
1552
1549
|
}
|
|
1553
1550
|
getHighlightEl() {
|
|
1554
1551
|
return this.highlightedEl;
|
|
@@ -1564,7 +1561,7 @@
|
|
|
1564
1561
|
this.clearHighlight();
|
|
1565
1562
|
return;
|
|
1566
1563
|
}
|
|
1567
|
-
if (el === this.getSelectedEl() || this.multiDr
|
|
1564
|
+
if (el === this.getSelectedEl() || this.multiDr?.dragStatus === StageDragStatus.ING) {
|
|
1568
1565
|
this.clearHighlight();
|
|
1569
1566
|
return;
|
|
1570
1567
|
}
|
|
@@ -1584,7 +1581,7 @@
|
|
|
1584
1581
|
*/
|
|
1585
1582
|
clearSelectStatus(selectType) {
|
|
1586
1583
|
if (selectType === SelectStatus.MULTI_SELECT) {
|
|
1587
|
-
this.multiDr
|
|
1584
|
+
this.multiDr?.clearSelectStatus();
|
|
1588
1585
|
this.selectedElList = [];
|
|
1589
1586
|
} else {
|
|
1590
1587
|
this.dr.clearSelectStatus();
|
|
@@ -1631,9 +1628,67 @@
|
|
|
1631
1628
|
this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
|
|
1632
1629
|
this.container.removeEventListener("wheel", this.mouseWheelHandler);
|
|
1633
1630
|
this.dr.destroy();
|
|
1634
|
-
this.multiDr
|
|
1631
|
+
this.multiDr?.destroy();
|
|
1635
1632
|
this.highlightLayer.destroy();
|
|
1636
1633
|
}
|
|
1634
|
+
createDr(config) {
|
|
1635
|
+
const createDrHelper = () => new DragResizeHelper({
|
|
1636
|
+
container: config.container,
|
|
1637
|
+
updateDragEl: config.updateDragEl
|
|
1638
|
+
});
|
|
1639
|
+
const dr = new StageDragResize({
|
|
1640
|
+
container: config.container,
|
|
1641
|
+
disabledDragStart: config.disabledDragStart,
|
|
1642
|
+
moveableOptions: this.changeCallback(config.moveableOptions, false),
|
|
1643
|
+
dragResizeHelper: createDrHelper(),
|
|
1644
|
+
getRootContainer: config.getRootContainer,
|
|
1645
|
+
getRenderDocument: config.getRenderDocument,
|
|
1646
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1647
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1648
|
+
});
|
|
1649
|
+
dr.on("update", (data) => {
|
|
1650
|
+
setTimeout(() => this.emit("update", data));
|
|
1651
|
+
}).on("sort", (data) => {
|
|
1652
|
+
setTimeout(() => this.emit("sort", data));
|
|
1653
|
+
}).on("select-parent", () => {
|
|
1654
|
+
this.emit("select-parent");
|
|
1655
|
+
}).on("remove", () => {
|
|
1656
|
+
const drTarget = this.dr.getTarget();
|
|
1657
|
+
if (!drTarget)
|
|
1658
|
+
return;
|
|
1659
|
+
const data = {
|
|
1660
|
+
data: [{ el: drTarget }]
|
|
1661
|
+
};
|
|
1662
|
+
this.emit("remove", data);
|
|
1663
|
+
}).on("drag-start", (e) => {
|
|
1664
|
+
this.emit("drag-start", e);
|
|
1665
|
+
});
|
|
1666
|
+
return dr;
|
|
1667
|
+
}
|
|
1668
|
+
createMultiDr(config) {
|
|
1669
|
+
const createDrHelper = () => new DragResizeHelper({
|
|
1670
|
+
container: config.container,
|
|
1671
|
+
updateDragEl: config.updateDragEl
|
|
1672
|
+
});
|
|
1673
|
+
const multiDr = new StageMultiDragResize({
|
|
1674
|
+
container: config.container,
|
|
1675
|
+
moveableOptions: this.changeCallback(config.moveableOptions, true),
|
|
1676
|
+
dragResizeHelper: createDrHelper(),
|
|
1677
|
+
getRootContainer: config.getRootContainer,
|
|
1678
|
+
getRenderDocument: config.getRenderDocument,
|
|
1679
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
1680
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this)
|
|
1681
|
+
});
|
|
1682
|
+
multiDr?.on("update", (data) => {
|
|
1683
|
+
this.emit("multi-update", data);
|
|
1684
|
+
}).on("change-to-select", async (id) => {
|
|
1685
|
+
if (this.isMultiSelectStatus)
|
|
1686
|
+
return false;
|
|
1687
|
+
const el = this.getTargetElement(id);
|
|
1688
|
+
this.emit("change-to-select", el);
|
|
1689
|
+
});
|
|
1690
|
+
return multiDr;
|
|
1691
|
+
}
|
|
1637
1692
|
changeCallback(options, isMulti) {
|
|
1638
1693
|
if (typeof options === "function") {
|
|
1639
1694
|
return () => {
|
|
@@ -1664,7 +1719,7 @@
|
|
|
1664
1719
|
return;
|
|
1665
1720
|
if (this.selectedEl && !this.selectedEl.className.includes(PAGE_CLASS)) {
|
|
1666
1721
|
this.selectedElList.push(this.selectedEl);
|
|
1667
|
-
this.
|
|
1722
|
+
this.setSelectedEl(void 0);
|
|
1668
1723
|
}
|
|
1669
1724
|
const existIndex = this.selectedElList.findIndex((selectedDom) => selectedDom.id === el.id);
|
|
1670
1725
|
if (existIndex !== -1) {
|
|
@@ -1704,14 +1759,20 @@
|
|
|
1704
1759
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
1705
1760
|
KeyController.global.keydown(ctrl, (e) => {
|
|
1706
1761
|
e.inputEvent.preventDefault();
|
|
1707
|
-
this.
|
|
1762
|
+
if (!this.disabledMultiSelect) {
|
|
1763
|
+
this.isMultiSelectStatus = true;
|
|
1764
|
+
}
|
|
1708
1765
|
});
|
|
1709
1766
|
KeyController.global.on("blur", () => {
|
|
1710
|
-
this.
|
|
1767
|
+
if (!this.disabledMultiSelect) {
|
|
1768
|
+
this.isMultiSelectStatus = false;
|
|
1769
|
+
}
|
|
1711
1770
|
});
|
|
1712
1771
|
KeyController.global.keyup(ctrl, (e) => {
|
|
1713
1772
|
e.inputEvent.preventDefault();
|
|
1714
|
-
this.
|
|
1773
|
+
if (!this.disabledMultiSelect) {
|
|
1774
|
+
this.isMultiSelectStatus = false;
|
|
1775
|
+
}
|
|
1715
1776
|
});
|
|
1716
1777
|
KeyController.global.keydown("alt", (e) => {
|
|
1717
1778
|
e.inputEvent.preventDefault();
|
|
@@ -1723,36 +1784,6 @@
|
|
|
1723
1784
|
this.isAltKeydown = false;
|
|
1724
1785
|
});
|
|
1725
1786
|
}
|
|
1726
|
-
/**
|
|
1727
|
-
* 处理单选、多选抛出来的事件
|
|
1728
|
-
*/
|
|
1729
|
-
initActionEvent() {
|
|
1730
|
-
this.dr.on("update", (data) => {
|
|
1731
|
-
setTimeout(() => this.emit("update", data));
|
|
1732
|
-
}).on("sort", (data) => {
|
|
1733
|
-
setTimeout(() => this.emit("sort", data));
|
|
1734
|
-
}).on("select-parent", () => {
|
|
1735
|
-
this.emit("select-parent");
|
|
1736
|
-
}).on("remove", () => {
|
|
1737
|
-
const drTarget = this.dr.getTarget();
|
|
1738
|
-
if (!drTarget)
|
|
1739
|
-
return;
|
|
1740
|
-
const data = {
|
|
1741
|
-
data: [{ el: drTarget }]
|
|
1742
|
-
};
|
|
1743
|
-
this.emit("remove", data);
|
|
1744
|
-
}).on("drag-start", (e) => {
|
|
1745
|
-
this.emit("drag-start", e);
|
|
1746
|
-
});
|
|
1747
|
-
this.multiDr.on("update", (data) => {
|
|
1748
|
-
this.emit("multi-update", data);
|
|
1749
|
-
}).on("change-to-select", async (id) => {
|
|
1750
|
-
if (this.isMultiSelectStatus)
|
|
1751
|
-
return false;
|
|
1752
|
-
const el = this.getTargetElement(id);
|
|
1753
|
-
this.emit("change-to-select", el);
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
1787
|
/**
|
|
1757
1788
|
* 在down事件中集中cpu处理画布中选中操作渲染,在up事件中再通知外面的编辑器更新
|
|
1758
1789
|
*/
|
|
@@ -1819,8 +1850,10 @@
|
|
|
1819
1850
|
container;
|
|
1820
1851
|
containerResizeObserver;
|
|
1821
1852
|
isShowGuides = true;
|
|
1822
|
-
|
|
1853
|
+
guidesOptions;
|
|
1854
|
+
constructor(container, options) {
|
|
1823
1855
|
super();
|
|
1856
|
+
this.guidesOptions = options?.guidesOptions || {};
|
|
1824
1857
|
this.container = container;
|
|
1825
1858
|
this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
|
|
1826
1859
|
this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
|
|
@@ -1919,7 +1952,8 @@
|
|
|
1919
1952
|
lineColor: "#000",
|
|
1920
1953
|
textColor: "#000",
|
|
1921
1954
|
style: this.getGuidesStyle(type),
|
|
1922
|
-
showGuides: this.isShowGuides
|
|
1955
|
+
showGuides: this.isShowGuides,
|
|
1956
|
+
...this.guidesOptions
|
|
1923
1957
|
});
|
|
1924
1958
|
const changEventHandler = {
|
|
1925
1959
|
[GuidesType.HORIZONTAL]: this.hGuidesChangeGuidesHandler,
|
|
@@ -1991,9 +2025,9 @@
|
|
|
1991
2025
|
pageScrollParent = null;
|
|
1992
2026
|
intersectionObserver = null;
|
|
1993
2027
|
wrapperResizeObserver = null;
|
|
1994
|
-
constructor() {
|
|
2028
|
+
constructor(options) {
|
|
1995
2029
|
const wrapper = createWrapper();
|
|
1996
|
-
super(wrapper);
|
|
2030
|
+
super(wrapper, options);
|
|
1997
2031
|
this.wrapper = wrapper;
|
|
1998
2032
|
this.content.addEventListener("wheel", this.mouseWheelHandler);
|
|
1999
2033
|
this.wrapper.appendChild(this.content);
|
|
@@ -2305,12 +2339,6 @@
|
|
|
2305
2339
|
x = x - rect.left;
|
|
2306
2340
|
y = y - rect.top;
|
|
2307
2341
|
}
|
|
2308
|
-
} else if (this.nativeContainer) {
|
|
2309
|
-
const rect = this.nativeContainer.getClientRects()[0];
|
|
2310
|
-
if (rect) {
|
|
2311
|
-
x = x - rect.left;
|
|
2312
|
-
y = y - rect.top;
|
|
2313
|
-
}
|
|
2314
2342
|
}
|
|
2315
2343
|
return this.getDocument()?.elementsFromPoint(x / this.zoom, y / this.zoom);
|
|
2316
2344
|
}
|
|
@@ -2416,7 +2444,9 @@
|
|
|
2416
2444
|
return null;
|
|
2417
2445
|
}
|
|
2418
2446
|
});
|
|
2419
|
-
this.mask = new StageMask(
|
|
2447
|
+
this.mask = new StageMask({
|
|
2448
|
+
guidesOptions: config.guidesOptions
|
|
2449
|
+
});
|
|
2420
2450
|
this.actionManager = new ActionManager(this.getActionManagerConfig(config));
|
|
2421
2451
|
this.initRenderEvent();
|
|
2422
2452
|
this.initActionEvent();
|
|
@@ -2537,6 +2567,12 @@
|
|
|
2537
2567
|
getDragStatus() {
|
|
2538
2568
|
return this.actionManager.getDragStatus();
|
|
2539
2569
|
}
|
|
2570
|
+
disableMultiSelect() {
|
|
2571
|
+
this.actionManager.disableMultiSelect();
|
|
2572
|
+
}
|
|
2573
|
+
enableMultiSelect() {
|
|
2574
|
+
this.actionManager.enableMultiSelect();
|
|
2575
|
+
}
|
|
2540
2576
|
/**
|
|
2541
2577
|
* 销毁实例
|
|
2542
2578
|
*/
|
|
@@ -2569,6 +2605,7 @@
|
|
|
2569
2605
|
moveableOptions: config.moveableOptions,
|
|
2570
2606
|
container: this.mask.content,
|
|
2571
2607
|
disabledDragStart: config.disabledDragStart,
|
|
2608
|
+
disabledMultiSelect: config.disabledMultiSelect,
|
|
2572
2609
|
canSelect: config.canSelect,
|
|
2573
2610
|
isContainer: config.isContainer,
|
|
2574
2611
|
updateDragEl: config.updateDragEl,
|
|
@@ -2586,6 +2623,7 @@
|
|
|
2586
2623
|
this.renderer.on("page-el-update", (el) => {
|
|
2587
2624
|
this.mask?.observe(el);
|
|
2588
2625
|
this.observePageResize(el);
|
|
2626
|
+
this.emit("page-el-update", el);
|
|
2589
2627
|
});
|
|
2590
2628
|
}
|
|
2591
2629
|
initMaskEvent() {
|