mce 0.15.24 → 0.15.25
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/index.js +277 -143
- package/dist/mixins/zoom.d.ts +1 -1
- package/dist/plugins/ui.d.ts +12 -7
- package/dist/plugins/zoom.d.ts +0 -2
- package/dist/utils/helper.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1515,6 +1515,14 @@ function findChildrenWithProvide(key, vnode) {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
return [];
|
|
1517
1517
|
}
|
|
1518
|
+
function isInputElement(target) {
|
|
1519
|
+
const { tagName } = target;
|
|
1520
|
+
const isInput = tagName === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(target.type);
|
|
1521
|
+
if (target.isContentEditable || (isInput || tagName === "TEXTAREA" || tagName === "SELECT") && !target.readOnly) {
|
|
1522
|
+
return true;
|
|
1523
|
+
}
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1518
1526
|
function isInputEvent(event) {
|
|
1519
1527
|
if (!event)
|
|
1520
1528
|
return false;
|
|
@@ -1522,10 +1530,8 @@ function isInputEvent(event) {
|
|
|
1522
1530
|
if (!path && event.composedPath)
|
|
1523
1531
|
path = event.composedPath();
|
|
1524
1532
|
if (!path)
|
|
1525
|
-
return
|
|
1526
|
-
return path?.some(
|
|
1527
|
-
(el) => ["INPUT", "TEXTAREA", "SELECT"].includes(el?.tagName) || el?.contentEditable === "true"
|
|
1528
|
-
);
|
|
1533
|
+
return isInputElement(event.target || event.srcElement);
|
|
1534
|
+
return path?.some((el) => isInputElement(el));
|
|
1529
1535
|
}
|
|
1530
1536
|
function toKebabCase$1(str = "") {
|
|
1531
1537
|
if (toKebabCase$1.cache.has(str))
|
|
@@ -1561,6 +1567,146 @@ const uuidv4Template = "10000000-1000-4000-8000" + -1e11;
|
|
|
1561
1567
|
function uuidv4() {
|
|
1562
1568
|
return uuidv4Template.replace(/[018]/g, (c) => (c ^ uint32() & 15 >> c / 4).toString(16));
|
|
1563
1569
|
}
|
|
1570
|
+
const isff = typeof navigator !== "undefined" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false;
|
|
1571
|
+
const _keyMap = {
|
|
1572
|
+
"backspace": 8,
|
|
1573
|
+
"⌫": 8,
|
|
1574
|
+
"tab": 9,
|
|
1575
|
+
"clear": 12,
|
|
1576
|
+
"enter": 13,
|
|
1577
|
+
"↩": 13,
|
|
1578
|
+
"return": 13,
|
|
1579
|
+
"esc": 27,
|
|
1580
|
+
"escape": 27,
|
|
1581
|
+
"space": 32,
|
|
1582
|
+
"left": 37,
|
|
1583
|
+
"up": 38,
|
|
1584
|
+
"right": 39,
|
|
1585
|
+
"down": 40,
|
|
1586
|
+
/// https://w3c.github.io/uievents/#events-keyboard-key-location
|
|
1587
|
+
"arrowup": 38,
|
|
1588
|
+
"arrowdown": 40,
|
|
1589
|
+
"arrowleft": 37,
|
|
1590
|
+
"arrowright": 39,
|
|
1591
|
+
"del": 46,
|
|
1592
|
+
"delete": 46,
|
|
1593
|
+
"ins": 45,
|
|
1594
|
+
"insert": 45,
|
|
1595
|
+
"home": 36,
|
|
1596
|
+
"end": 35,
|
|
1597
|
+
"pageup": 33,
|
|
1598
|
+
"pagedown": 34,
|
|
1599
|
+
"capslock": 20,
|
|
1600
|
+
"num_0": 96,
|
|
1601
|
+
"num_1": 97,
|
|
1602
|
+
"num_2": 98,
|
|
1603
|
+
"num_3": 99,
|
|
1604
|
+
"num_4": 100,
|
|
1605
|
+
"num_5": 101,
|
|
1606
|
+
"num_6": 102,
|
|
1607
|
+
"num_7": 103,
|
|
1608
|
+
"num_8": 104,
|
|
1609
|
+
"num_9": 105,
|
|
1610
|
+
"num_multiply": 106,
|
|
1611
|
+
"num_add": 107,
|
|
1612
|
+
"num_enter": 108,
|
|
1613
|
+
"num_subtract": 109,
|
|
1614
|
+
"num_decimal": 110,
|
|
1615
|
+
"num_divide": 111,
|
|
1616
|
+
"⇪": 20,
|
|
1617
|
+
",": 188,
|
|
1618
|
+
".": 190,
|
|
1619
|
+
"/": 191,
|
|
1620
|
+
"`": 192,
|
|
1621
|
+
"-": isff ? 173 : 189,
|
|
1622
|
+
"=": isff ? 61 : 187,
|
|
1623
|
+
";": isff ? 59 : 186,
|
|
1624
|
+
"'": 222,
|
|
1625
|
+
"{": 219,
|
|
1626
|
+
"}": 221,
|
|
1627
|
+
"[": 219,
|
|
1628
|
+
"]": 221,
|
|
1629
|
+
"\\": 220
|
|
1630
|
+
};
|
|
1631
|
+
const _modifier = {
|
|
1632
|
+
// shiftKey
|
|
1633
|
+
"⇧": 16,
|
|
1634
|
+
"shift": 16,
|
|
1635
|
+
// altKey
|
|
1636
|
+
"⌥": 18,
|
|
1637
|
+
"alt": 18,
|
|
1638
|
+
"option": 18,
|
|
1639
|
+
// ctrlKey
|
|
1640
|
+
"⌃": 17,
|
|
1641
|
+
"ctrl": 17,
|
|
1642
|
+
"control": 17,
|
|
1643
|
+
// metaKey
|
|
1644
|
+
"⌘": 91,
|
|
1645
|
+
"cmd": 91,
|
|
1646
|
+
"meta": 91,
|
|
1647
|
+
"command": 91
|
|
1648
|
+
};
|
|
1649
|
+
const kbdMap = {
|
|
1650
|
+
ArrowUp: "↑",
|
|
1651
|
+
ArrowDown: "↓",
|
|
1652
|
+
ArrowLeft: "←",
|
|
1653
|
+
ArrowRight: "→",
|
|
1654
|
+
Slash: "/",
|
|
1655
|
+
Semicolon: ";",
|
|
1656
|
+
BracketLeft: "[",
|
|
1657
|
+
BracketRight: "]",
|
|
1658
|
+
Backslash: "\\",
|
|
1659
|
+
Quote: "'",
|
|
1660
|
+
Comma: ",",
|
|
1661
|
+
Minus: "-",
|
|
1662
|
+
Equal: "=",
|
|
1663
|
+
Backspace: "⌫",
|
|
1664
|
+
Enter: "⏎",
|
|
1665
|
+
Escape: "Esc",
|
|
1666
|
+
Dead: "N"
|
|
1667
|
+
};
|
|
1668
|
+
function getCharCode(x) {
|
|
1669
|
+
let code = _keyMap[x.toLowerCase()] || _modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0);
|
|
1670
|
+
if (code === 93 || code === 224) {
|
|
1671
|
+
code = 91;
|
|
1672
|
+
}
|
|
1673
|
+
if (code === 229) {
|
|
1674
|
+
return 0;
|
|
1675
|
+
}
|
|
1676
|
+
return code;
|
|
1677
|
+
}
|
|
1678
|
+
function parseKey(key) {
|
|
1679
|
+
return key.split("+").map((v) => {
|
|
1680
|
+
switch (v) {
|
|
1681
|
+
case "Meta":
|
|
1682
|
+
case "Control":
|
|
1683
|
+
case "CommandOrControl":
|
|
1684
|
+
return "CmdOrCtrl";
|
|
1685
|
+
case "Alt":
|
|
1686
|
+
case "Shift":
|
|
1687
|
+
case "CmdOrCtrl":
|
|
1688
|
+
return v;
|
|
1689
|
+
default:
|
|
1690
|
+
return String.fromCharCode(getCharCode(v));
|
|
1691
|
+
}
|
|
1692
|
+
}).filter(Boolean).map((v) => v.toLowerCase()).sort().join("+");
|
|
1693
|
+
}
|
|
1694
|
+
function parseKeyboardEvent(event) {
|
|
1695
|
+
if (event.key.toLowerCase() === "capslock") {
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
const { code } = event;
|
|
1699
|
+
let key = event.keyCode || event.which || event.charCode;
|
|
1700
|
+
if (code && /^Key[A-Z]$/.test(code)) {
|
|
1701
|
+
key = code.charCodeAt(3);
|
|
1702
|
+
}
|
|
1703
|
+
return [
|
|
1704
|
+
(event.metaKey || event.ctrlKey) && "CmdOrCtrl",
|
|
1705
|
+
event.altKey && "Alt",
|
|
1706
|
+
event.shiftKey && "Shift",
|
|
1707
|
+
!["Meta", "Control", "Alt", "Shift"].includes(event.key) && String.fromCharCode(key)
|
|
1708
|
+
].filter(Boolean).map((v) => v.toLowerCase()).sort().join("+");
|
|
1709
|
+
}
|
|
1564
1710
|
const _1_hotkey = defineMixin((editor) => {
|
|
1565
1711
|
const {
|
|
1566
1712
|
registerConfig
|
|
@@ -1589,29 +1735,6 @@ const _1_hotkey = defineMixin((editor) => {
|
|
|
1589
1735
|
function unregisterHotkey(command) {
|
|
1590
1736
|
hotkeysData.value = hotkeysData.value.filter((v) => v.command !== command);
|
|
1591
1737
|
}
|
|
1592
|
-
const kbdMap = {
|
|
1593
|
-
"ArrowUp": "↑",
|
|
1594
|
-
"ArrowDown": "↓",
|
|
1595
|
-
"ArrowLeft": "←",
|
|
1596
|
-
"ArrowRight": "→",
|
|
1597
|
-
"Slash": "/",
|
|
1598
|
-
"Semicolon": ";",
|
|
1599
|
-
"BracketLeft": "[",
|
|
1600
|
-
"BracketRight": "]",
|
|
1601
|
-
"Backslash": "\\",
|
|
1602
|
-
"Quote": "'",
|
|
1603
|
-
"Comma": ",",
|
|
1604
|
-
"Minus": "-",
|
|
1605
|
-
"Equal": "=",
|
|
1606
|
-
"Backspace": "⌫",
|
|
1607
|
-
"Enter": "⏎",
|
|
1608
|
-
"Escape": "Esc",
|
|
1609
|
-
"=": "+",
|
|
1610
|
-
"º": "0",
|
|
1611
|
-
"¡": "1",
|
|
1612
|
-
"™": "2",
|
|
1613
|
-
"Dead": "N"
|
|
1614
|
-
};
|
|
1615
1738
|
function getKbd(command) {
|
|
1616
1739
|
if (!command) {
|
|
1617
1740
|
return "";
|
|
@@ -1661,30 +1784,17 @@ const _1_hotkey = defineMixin((editor) => {
|
|
|
1661
1784
|
if (isInputEvent(e)) {
|
|
1662
1785
|
return;
|
|
1663
1786
|
}
|
|
1664
|
-
const eKey =
|
|
1665
|
-
(e.metaKey || e.ctrlKey) && "CmdOrCtrl",
|
|
1666
|
-
e.altKey && "Alt",
|
|
1667
|
-
e.shiftKey && "Shift",
|
|
1668
|
-
!["Meta", "Control", "Alt", "Shift"].includes(e.key) && e.key
|
|
1669
|
-
].filter(Boolean).map((v) => v.toLowerCase()).sort().join("+");
|
|
1787
|
+
const eKey = parseKeyboardEvent(e);
|
|
1670
1788
|
hotkeysData.value.forEach((hotkeyData) => {
|
|
1671
1789
|
const command = hotkeyData.command;
|
|
1672
1790
|
const hotkey = hotkeys.get(command);
|
|
1673
1791
|
const keys = Array.isArray(hotkeyData.key) ? hotkeyData.key : [hotkeyData.key];
|
|
1674
1792
|
keys.forEach((key) => {
|
|
1675
|
-
const tKey = key
|
|
1676
|
-
switch (v) {
|
|
1677
|
-
case "Meta":
|
|
1678
|
-
case "Control":
|
|
1679
|
-
case "CommandOrControl":
|
|
1680
|
-
return "CmdOrCtrl";
|
|
1681
|
-
default:
|
|
1682
|
-
return v;
|
|
1683
|
-
}
|
|
1684
|
-
}).filter(Boolean).map((v) => v.toLowerCase()).sort().join("+");
|
|
1793
|
+
const tKey = parseKey(key);
|
|
1685
1794
|
if (eKey === tKey && (!hotkey?.when || hotkey.when(e))) {
|
|
1686
1795
|
if (hotkey?.preventDefault !== false) {
|
|
1687
1796
|
e.preventDefault();
|
|
1797
|
+
e.stopPropagation();
|
|
1688
1798
|
}
|
|
1689
1799
|
if (hotkey?.handle) {
|
|
1690
1800
|
hotkey.handle(e);
|
|
@@ -3391,6 +3501,49 @@ const _4_2_frame = defineMixin((editor) => {
|
|
|
3391
3501
|
findFrame,
|
|
3392
3502
|
handleDragOutReparent
|
|
3393
3503
|
});
|
|
3504
|
+
return () => {
|
|
3505
|
+
const {
|
|
3506
|
+
on,
|
|
3507
|
+
getGlobalPointer
|
|
3508
|
+
} = editor;
|
|
3509
|
+
const startContext = ref({});
|
|
3510
|
+
on("selectionTransformStart", ({ elements }) => {
|
|
3511
|
+
const ctx = {};
|
|
3512
|
+
elements.forEach((el) => {
|
|
3513
|
+
ctx[el.instanceId] = {
|
|
3514
|
+
parent: el.getParent(),
|
|
3515
|
+
index: el.getIndex()
|
|
3516
|
+
};
|
|
3517
|
+
});
|
|
3518
|
+
startContext.value = ctx;
|
|
3519
|
+
});
|
|
3520
|
+
on("selectionTransforming", ({ handle, startEvent, elements }) => {
|
|
3521
|
+
if (handle === "move" && !startEvent?.__FROM__) {
|
|
3522
|
+
const idSet = /* @__PURE__ */ new Set();
|
|
3523
|
+
elements.forEach((el) => {
|
|
3524
|
+
if (isTopFrame(el)) {
|
|
3525
|
+
idSet.add(el.instanceId);
|
|
3526
|
+
} else {
|
|
3527
|
+
idSet.add(el.findAncestor(isTopFrame)?.instanceId ?? 0);
|
|
3528
|
+
}
|
|
3529
|
+
});
|
|
3530
|
+
if (idSet.size === 1) {
|
|
3531
|
+
elements.forEach((element) => {
|
|
3532
|
+
handleDragOutReparent(
|
|
3533
|
+
element,
|
|
3534
|
+
{
|
|
3535
|
+
...startContext.value[element.instanceId],
|
|
3536
|
+
pointer: getGlobalPointer()
|
|
3537
|
+
}
|
|
3538
|
+
);
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
});
|
|
3543
|
+
on("selectionTransformEnd", () => {
|
|
3544
|
+
startContext.value = {};
|
|
3545
|
+
});
|
|
3546
|
+
};
|
|
3394
3547
|
});
|
|
3395
3548
|
const _4_3_element = defineMixin((editor) => {
|
|
3396
3549
|
const {
|
|
@@ -3978,10 +4131,7 @@ const _zoom$1 = defineMixin((editor) => {
|
|
|
3978
4131
|
const { width, height } = drawboardAabb.value;
|
|
3979
4132
|
const tw = width - (offset2.left + offset2.right);
|
|
3980
4133
|
const th = height - (offset2.top + offset2.bottom);
|
|
3981
|
-
const sx = aabb.
|
|
3982
|
-
const sy = aabb.top;
|
|
3983
|
-
const sw = aabb.width;
|
|
3984
|
-
const sh = aabb.height;
|
|
4134
|
+
const [sx, sy, sw, sh] = aabb.toArray();
|
|
3985
4135
|
if (!sw || !sh)
|
|
3986
4136
|
return;
|
|
3987
4137
|
const zw = tw / sw;
|
|
@@ -3990,10 +4140,22 @@ const _zoom$1 = defineMixin((editor) => {
|
|
|
3990
4140
|
let targetZoom;
|
|
3991
4141
|
if (typeof target === "number") {
|
|
3992
4142
|
targetZoom = target;
|
|
3993
|
-
} else if (mode === "cover") {
|
|
3994
|
-
targetZoom = Math.max(zw, zh);
|
|
3995
4143
|
} else {
|
|
3996
|
-
|
|
4144
|
+
switch (mode) {
|
|
4145
|
+
case "width":
|
|
4146
|
+
targetZoom = zw;
|
|
4147
|
+
break;
|
|
4148
|
+
case "height":
|
|
4149
|
+
targetZoom = zh;
|
|
4150
|
+
break;
|
|
4151
|
+
case "cover":
|
|
4152
|
+
targetZoom = Math.max(zw, zh);
|
|
4153
|
+
break;
|
|
4154
|
+
case "contain":
|
|
4155
|
+
default:
|
|
4156
|
+
targetZoom = Math.min(zw, zh);
|
|
4157
|
+
break;
|
|
4158
|
+
}
|
|
3997
4159
|
}
|
|
3998
4160
|
const oldZoom = Math.min(_camera.zoom.x, _camera.zoom.y);
|
|
3999
4161
|
const newZoom = Math.min(
|
|
@@ -4196,12 +4358,12 @@ const _arrange = definePlugin((editor) => {
|
|
|
4196
4358
|
{ command: "sendBackward", key: "CmdOrCtrl+[" },
|
|
4197
4359
|
{ command: "bringToFront", key: "]" },
|
|
4198
4360
|
{ command: "sendToBack", key: "[" },
|
|
4199
|
-
{ command: "alignLeft", key: "Alt+
|
|
4200
|
-
{ command: "alignRight", key: "Alt+
|
|
4201
|
-
{ command: "alignTop", key: "Alt+
|
|
4202
|
-
{ command: "alignBottom", key: "Alt+
|
|
4203
|
-
{ command: "alignHorizontalCenter", key: "Alt+
|
|
4204
|
-
{ command: "alignVerticalCenter", key: "Alt+
|
|
4361
|
+
{ command: "alignLeft", key: "Alt+A" },
|
|
4362
|
+
{ command: "alignRight", key: "Alt+D" },
|
|
4363
|
+
{ command: "alignTop", key: "Alt+W" },
|
|
4364
|
+
{ command: "alignBottom", key: "Alt+S" },
|
|
4365
|
+
{ command: "alignHorizontalCenter", key: "Alt+H" },
|
|
4366
|
+
{ command: "alignVerticalCenter", key: "Alt+V" }
|
|
4205
4367
|
]
|
|
4206
4368
|
};
|
|
4207
4369
|
});
|
|
@@ -4539,10 +4701,10 @@ const _edit = definePlugin((editor, options) => {
|
|
|
4539
4701
|
{ command: "duplicate", handle: duplicate }
|
|
4540
4702
|
],
|
|
4541
4703
|
hotkeys: [
|
|
4542
|
-
{ command: "copy", key: "CmdOrCtrl+
|
|
4543
|
-
{ command: "cut", key: "CmdOrCtrl+
|
|
4544
|
-
{ command: "paste", key: "CmdOrCtrl+
|
|
4545
|
-
{ command: "duplicate", key: "CmdOrCtrl+
|
|
4704
|
+
{ command: "copy", key: "CmdOrCtrl+C", editable: false },
|
|
4705
|
+
{ command: "cut", key: "CmdOrCtrl+X", editable: false },
|
|
4706
|
+
{ command: "paste", key: "CmdOrCtrl+V", editable: false, preventDefault: false },
|
|
4707
|
+
{ command: "duplicate", key: "CmdOrCtrl+D", editable: false }
|
|
4546
4708
|
],
|
|
4547
4709
|
setup: () => {
|
|
4548
4710
|
if (useClipboard) {
|
|
@@ -5287,8 +5449,8 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5287
5449
|
const cloend = renderEngine.value.input._clonePointerEvent(event);
|
|
5288
5450
|
cloend.srcElement = drawboardDom.value;
|
|
5289
5451
|
cloend.target = frame.value;
|
|
5290
|
-
cloend.
|
|
5291
|
-
exec("
|
|
5452
|
+
cloend.__FROM__ = event.target;
|
|
5453
|
+
exec("pointerDown", cloend, {
|
|
5292
5454
|
allowTopFrame: true
|
|
5293
5455
|
});
|
|
5294
5456
|
}
|
|
@@ -5392,7 +5554,7 @@ const _frame = definePlugin((editor) => {
|
|
|
5392
5554
|
}
|
|
5393
5555
|
],
|
|
5394
5556
|
hotkeys: [
|
|
5395
|
-
{ command: "setActiveDrawingTool:frame", key: "
|
|
5557
|
+
{ command: "setActiveDrawingTool:frame", key: "F" }
|
|
5396
5558
|
]
|
|
5397
5559
|
};
|
|
5398
5560
|
});
|
|
@@ -5510,8 +5672,8 @@ const _group = definePlugin((editor) => {
|
|
|
5510
5672
|
{ command: "ungroup", handle: ungroup }
|
|
5511
5673
|
],
|
|
5512
5674
|
hotkeys: [
|
|
5513
|
-
{ command: "groupSelection", key: "CmdOrCtrl+
|
|
5514
|
-
{ command: "frameSelection", key: "Alt+CmdOrCtrl+
|
|
5675
|
+
{ command: "groupSelection", key: "CmdOrCtrl+G" },
|
|
5676
|
+
{ command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
|
|
5515
5677
|
{ command: "ungroup", key: "CmdOrCtrl+Backspace" }
|
|
5516
5678
|
]
|
|
5517
5679
|
};
|
|
@@ -5548,8 +5710,8 @@ const _history = definePlugin((editor) => {
|
|
|
5548
5710
|
{ command: "redo", handle: redo }
|
|
5549
5711
|
],
|
|
5550
5712
|
hotkeys: [
|
|
5551
|
-
{ command: "undo", key: "CmdOrCtrl+
|
|
5552
|
-
{ command: "redo", key: "Shift+CmdOrCtrl+
|
|
5713
|
+
{ command: "undo", key: "CmdOrCtrl+Z" },
|
|
5714
|
+
{ command: "redo", key: "Shift+CmdOrCtrl+Z" }
|
|
5553
5715
|
]
|
|
5554
5716
|
};
|
|
5555
5717
|
});
|
|
@@ -5703,8 +5865,8 @@ const _image = definePlugin((editor) => {
|
|
|
5703
5865
|
{ name: "image", handle: (position) => exec("import", { position }) }
|
|
5704
5866
|
],
|
|
5705
5867
|
hotkeys: [
|
|
5706
|
-
{ command: "copyAs:png", key: "Shift+CmdOrCtrl+
|
|
5707
|
-
{ command: "setActiveDrawingTool:image", key: "Shift+CmdOrCtrl+
|
|
5868
|
+
{ command: "copyAs:png", key: "Shift+CmdOrCtrl+C" },
|
|
5869
|
+
{ command: "setActiveDrawingTool:image", key: "Shift+CmdOrCtrl+K" }
|
|
5708
5870
|
]
|
|
5709
5871
|
};
|
|
5710
5872
|
});
|
|
@@ -5735,7 +5897,7 @@ const _import = definePlugin((editor) => {
|
|
|
5735
5897
|
{ command: "import", handle: _import2 }
|
|
5736
5898
|
],
|
|
5737
5899
|
hotkeys: [
|
|
5738
|
-
{ command: "import", key: "CmdOrCtrl+
|
|
5900
|
+
{ command: "import", key: "CmdOrCtrl+I" }
|
|
5739
5901
|
],
|
|
5740
5902
|
setup: () => {
|
|
5741
5903
|
const {
|
|
@@ -6275,7 +6437,7 @@ const _lock = definePlugin((editor) => {
|
|
|
6275
6437
|
{ command: "lock/unlock", handle: () => selection.value.forEach((el) => setLock(el, !isLock(el))) }
|
|
6276
6438
|
],
|
|
6277
6439
|
hotkeys: [
|
|
6278
|
-
{ command: "lock/unlock", key: "Shift+CmdOrCtrl+
|
|
6440
|
+
{ command: "lock/unlock", key: "Shift+CmdOrCtrl+L" }
|
|
6279
6441
|
]
|
|
6280
6442
|
};
|
|
6281
6443
|
});
|
|
@@ -7217,7 +7379,7 @@ const _open = definePlugin((editor) => {
|
|
|
7217
7379
|
{ command: "open", handle: open }
|
|
7218
7380
|
],
|
|
7219
7381
|
hotkeys: [
|
|
7220
|
-
{ command: "open", key: "CmdOrCtrl+
|
|
7382
|
+
{ command: "open", key: "CmdOrCtrl+O" }
|
|
7221
7383
|
]
|
|
7222
7384
|
};
|
|
7223
7385
|
});
|
|
@@ -7231,7 +7393,7 @@ const _panels = definePlugin((editor) => {
|
|
|
7231
7393
|
{ command: "panels", handle: (panel) => config.value[panel] = !config.value[panel] }
|
|
7232
7394
|
],
|
|
7233
7395
|
hotkeys: [
|
|
7234
|
-
{ command: "panels:layers", key: "Alt
|
|
7396
|
+
{ command: "panels:layers", key: "Alt+1" }
|
|
7235
7397
|
]
|
|
7236
7398
|
};
|
|
7237
7399
|
});
|
|
@@ -11304,8 +11466,8 @@ const _pen = definePlugin((editor) => {
|
|
|
11304
11466
|
}
|
|
11305
11467
|
],
|
|
11306
11468
|
hotkeys: [
|
|
11307
|
-
{ command: "setActiveDrawingTool:pen", key: "
|
|
11308
|
-
{ command: "setActiveDrawingTool:pencil", key: "Shift+
|
|
11469
|
+
{ command: "setActiveDrawingTool:pen", key: "P" },
|
|
11470
|
+
{ command: "setActiveDrawingTool:pencil", key: "Shift+P" }
|
|
11309
11471
|
]
|
|
11310
11472
|
};
|
|
11311
11473
|
});
|
|
@@ -12022,8 +12184,8 @@ const _selection = definePlugin((editor) => {
|
|
|
12022
12184
|
{ command: "selectNextSibling", handle: () => selectSibling("next") }
|
|
12023
12185
|
],
|
|
12024
12186
|
hotkeys: [
|
|
12025
|
-
{ command: "selectAll", key: "CmdOrCtrl+
|
|
12026
|
-
{ command: "deselectAll", key: "Shift+CmdOrCtrl+
|
|
12187
|
+
{ command: "selectAll", key: "CmdOrCtrl+A" },
|
|
12188
|
+
{ command: "deselectAll", key: "Shift+CmdOrCtrl+A" },
|
|
12027
12189
|
{ command: "selectChildren", key: "Enter" },
|
|
12028
12190
|
{ command: "selectParent", key: "\\" },
|
|
12029
12191
|
{ command: "selectPreviousSibling", key: "Shift+Tab" },
|
|
@@ -12198,10 +12360,10 @@ const _shape = definePlugin((editor) => {
|
|
|
12198
12360
|
}
|
|
12199
12361
|
],
|
|
12200
12362
|
hotkeys: [
|
|
12201
|
-
{ command: "setActiveDrawingTool:rectangle", key: "
|
|
12202
|
-
{ command: "setActiveDrawingTool:line", key: "
|
|
12203
|
-
{ command: "setActiveDrawingTool:arrow", key: "Shift+
|
|
12204
|
-
{ command: "setActiveDrawingTool:ellipse", key: "
|
|
12363
|
+
{ command: "setActiveDrawingTool:rectangle", key: "R" },
|
|
12364
|
+
{ command: "setActiveDrawingTool:line", key: "L" },
|
|
12365
|
+
{ command: "setActiveDrawingTool:arrow", key: "Shift+L" },
|
|
12366
|
+
{ command: "setActiveDrawingTool:ellipse", key: "O" }
|
|
12205
12367
|
]
|
|
12206
12368
|
};
|
|
12207
12369
|
});
|
|
@@ -13548,8 +13710,8 @@ const _state = definePlugin((editor) => {
|
|
|
13548
13710
|
{ command: "setState", handle: (val) => state.value = val }
|
|
13549
13711
|
],
|
|
13550
13712
|
hotkeys: [
|
|
13551
|
-
{ command: "setState:move", key: "
|
|
13552
|
-
{ command: "setState:hand", key: "
|
|
13713
|
+
{ command: "setState:move", key: "V" },
|
|
13714
|
+
{ command: "setState:hand", key: "H" }
|
|
13553
13715
|
]
|
|
13554
13716
|
};
|
|
13555
13717
|
});
|
|
@@ -13780,7 +13942,7 @@ const _text = definePlugin((editor) => {
|
|
|
13780
13942
|
}
|
|
13781
13943
|
],
|
|
13782
13944
|
hotkeys: [
|
|
13783
|
-
{ command: "setActiveDrawingTool:text", key: "
|
|
13945
|
+
{ command: "setActiveDrawingTool:text", key: "T" }
|
|
13784
13946
|
]
|
|
13785
13947
|
};
|
|
13786
13948
|
});
|
|
@@ -14111,7 +14273,7 @@ const _timeline = definePlugin((editor) => {
|
|
|
14111
14273
|
}
|
|
14112
14274
|
],
|
|
14113
14275
|
hotkeys: [
|
|
14114
|
-
{ command: "panels:timeline", key: "Alt
|
|
14276
|
+
{ command: "panels:timeline", key: "Alt+2" }
|
|
14115
14277
|
]
|
|
14116
14278
|
};
|
|
14117
14279
|
});
|
|
@@ -14327,25 +14489,14 @@ const _transform = definePlugin((editor) => {
|
|
|
14327
14489
|
{ command: "flipVertical", handle: flipVertical }
|
|
14328
14490
|
],
|
|
14329
14491
|
hotkeys: [
|
|
14330
|
-
{ command: "flipHorizontal", key: "Shift+
|
|
14331
|
-
{ command: "flipVertical", key: "Shift+
|
|
14492
|
+
{ command: "flipHorizontal", key: "Shift+H" },
|
|
14493
|
+
{ command: "flipVertical", key: "Shift+V" }
|
|
14332
14494
|
]
|
|
14333
14495
|
};
|
|
14334
14496
|
});
|
|
14335
|
-
const _ui = definePlugin((
|
|
14336
|
-
const {
|
|
14337
|
-
selectionAabbInDrawboard,
|
|
14338
|
-
emit
|
|
14339
|
-
} = editor;
|
|
14497
|
+
const _ui = definePlugin(() => {
|
|
14340
14498
|
return {
|
|
14341
|
-
name: "mce:ui"
|
|
14342
|
-
setup: () => {
|
|
14343
|
-
watch(
|
|
14344
|
-
selectionAabbInDrawboard,
|
|
14345
|
-
(aabb) => emit("setTransform", { aabb }),
|
|
14346
|
-
{ deep: true }
|
|
14347
|
-
);
|
|
14348
|
-
}
|
|
14499
|
+
name: "mce:ui"
|
|
14349
14500
|
};
|
|
14350
14501
|
});
|
|
14351
14502
|
const _url = definePlugin((editor) => {
|
|
@@ -14417,7 +14568,7 @@ const _visibility = definePlugin((editor) => {
|
|
|
14417
14568
|
{ command: "hide/show", handle: hideOrShow }
|
|
14418
14569
|
],
|
|
14419
14570
|
hotkeys: [
|
|
14420
|
-
{ command: "hide/show", key: "Shift+CmdOrCtrl+
|
|
14571
|
+
{ command: "hide/show", key: "Shift+CmdOrCtrl+H" }
|
|
14421
14572
|
]
|
|
14422
14573
|
};
|
|
14423
14574
|
});
|
|
@@ -14427,7 +14578,6 @@ const _zoom = definePlugin((editor) => {
|
|
|
14427
14578
|
camera,
|
|
14428
14579
|
drawboardAabb,
|
|
14429
14580
|
zoomTo,
|
|
14430
|
-
elementSelection,
|
|
14431
14581
|
exec,
|
|
14432
14582
|
config,
|
|
14433
14583
|
findFrame,
|
|
@@ -14447,7 +14597,6 @@ const _zoom = definePlugin((editor) => {
|
|
|
14447
14597
|
{ command: "zoomIn", handle: () => camera.value.addZoom(0.25) },
|
|
14448
14598
|
{ command: "zoomOut", handle: () => camera.value.addZoom(-0.25) },
|
|
14449
14599
|
{ command: "zoomTo100", handle: () => camera.value.setZoom(1) },
|
|
14450
|
-
{ command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
|
|
14451
14600
|
{ command: "zoomToFit", handle: () => zoomTo("root", { mode: config.value.zoomToFit }) },
|
|
14452
14601
|
{ command: "zoomToSelection", handle: (options) => zoomTo("selection", options) },
|
|
14453
14602
|
{ command: "zoomToNextFrame", handle: (options) => zoomToFrame("next", options) },
|
|
@@ -14457,20 +14606,13 @@ const _zoom = definePlugin((editor) => {
|
|
|
14457
14606
|
{ command: "zoomIn", key: "CmdOrCtrl+=" },
|
|
14458
14607
|
{ command: "zoomOut", key: "CmdOrCtrl+-" },
|
|
14459
14608
|
{ command: "zoomTo100", key: "CmdOrCtrl+0" },
|
|
14460
|
-
{ command: "zoomToFit", key: "Shift
|
|
14461
|
-
{ command: "zoomToSelection", key: "Shift
|
|
14462
|
-
{ command: "zoomToNextFrame", key: "
|
|
14609
|
+
{ command: "zoomToFit", key: "Shift+1" },
|
|
14610
|
+
{ command: "zoomToSelection", key: "Shift+2" },
|
|
14611
|
+
{ command: "zoomToNextFrame", key: "N" },
|
|
14463
14612
|
{ command: "zoomToPreviousFrame", key: "Shift+N" }
|
|
14464
14613
|
],
|
|
14465
14614
|
events: {
|
|
14466
|
-
setDoc: () => exec("zoomToFit")
|
|
14467
|
-
setCurrentFrame: () => {
|
|
14468
|
-
if (elementSelection.value.length) {
|
|
14469
|
-
exec("zoomToSelection");
|
|
14470
|
-
} else {
|
|
14471
|
-
exec("zoomToFit");
|
|
14472
|
-
}
|
|
14473
|
-
}
|
|
14615
|
+
setDoc: () => exec("zoomToFit")
|
|
14474
14616
|
},
|
|
14475
14617
|
setup: () => {
|
|
14476
14618
|
const {
|
|
@@ -15536,6 +15678,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15536
15678
|
setup(__props, { expose: __expose }) {
|
|
15537
15679
|
const props = __props;
|
|
15538
15680
|
const {
|
|
15681
|
+
emit,
|
|
15539
15682
|
isElement,
|
|
15540
15683
|
state,
|
|
15541
15684
|
resizeElement,
|
|
@@ -15552,18 +15695,15 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15552
15695
|
isLock,
|
|
15553
15696
|
config,
|
|
15554
15697
|
snapThreshold,
|
|
15555
|
-
getSnapPoints
|
|
15556
|
-
handleDragOutReparent,
|
|
15557
|
-
getGlobalPointer
|
|
15698
|
+
getSnapPoints
|
|
15558
15699
|
} = useEditor();
|
|
15559
15700
|
const transformable = useTemplateRef("transformableTpl");
|
|
15560
|
-
const
|
|
15561
|
-
const currentEvent = ref();
|
|
15701
|
+
const startEvent = ref();
|
|
15562
15702
|
onBeforeMount(() => {
|
|
15563
15703
|
registerCommand({
|
|
15564
15704
|
command: "startTransform",
|
|
15565
15705
|
handle: (event) => {
|
|
15566
|
-
|
|
15706
|
+
startEvent.value = event;
|
|
15567
15707
|
Boolean(transformable.value?.start(event));
|
|
15568
15708
|
}
|
|
15569
15709
|
});
|
|
@@ -15637,6 +15777,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15637
15777
|
}
|
|
15638
15778
|
return currentPos;
|
|
15639
15779
|
}
|
|
15780
|
+
function createSelectionTransformContext() {
|
|
15781
|
+
return {
|
|
15782
|
+
startEvent: startEvent.value,
|
|
15783
|
+
handle: transformable.value?.activeHandle ?? "move",
|
|
15784
|
+
elements: elementSelection.value
|
|
15785
|
+
};
|
|
15786
|
+
}
|
|
15640
15787
|
const transform = computed({
|
|
15641
15788
|
get: () => _transform2.value,
|
|
15642
15789
|
set: (val) => {
|
|
@@ -15663,7 +15810,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15663
15810
|
rotate: transform2.rotate - (oldTransform.rotate ?? 0),
|
|
15664
15811
|
borderRadius: transform2.borderRadius - (oldTransform.borderRadius ?? 0) / zoom.y
|
|
15665
15812
|
};
|
|
15666
|
-
elementSelection.value
|
|
15813
|
+
const elements = elementSelection.value;
|
|
15814
|
+
elements.forEach((element) => {
|
|
15667
15815
|
const style = element.style;
|
|
15668
15816
|
const newStyle = {
|
|
15669
15817
|
left: style.left + offsetStyle.left,
|
|
@@ -15697,16 +15845,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15697
15845
|
}
|
|
15698
15846
|
return false;
|
|
15699
15847
|
});
|
|
15700
|
-
if (handle === "move" && !currentEvent.value?.__FORM__) {
|
|
15701
|
-
handleDragOutReparent(
|
|
15702
|
-
element,
|
|
15703
|
-
{
|
|
15704
|
-
...startContext.value[element.instanceId],
|
|
15705
|
-
pointer: getGlobalPointer()
|
|
15706
|
-
}
|
|
15707
|
-
);
|
|
15708
|
-
}
|
|
15709
15848
|
});
|
|
15849
|
+
emit("selectionTransforming", createSelectionTransformContext());
|
|
15710
15850
|
}
|
|
15711
15851
|
});
|
|
15712
15852
|
const movable = computed(() => {
|
|
@@ -15729,14 +15869,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15729
15869
|
return elementSelection.value.length === 1 && !isLock(element) && element.foreground.isValid();
|
|
15730
15870
|
});
|
|
15731
15871
|
function onStart() {
|
|
15732
|
-
|
|
15733
|
-
elementSelection.value.forEach((el) => {
|
|
15734
|
-
ctx[el.instanceId] = {
|
|
15735
|
-
parent: el.getParent(),
|
|
15736
|
-
index: el.getIndex()
|
|
15737
|
-
};
|
|
15738
|
-
});
|
|
15739
|
-
startContext.value = ctx;
|
|
15872
|
+
emit("selectionTransformStart", createSelectionTransformContext());
|
|
15740
15873
|
}
|
|
15741
15874
|
function onMove() {
|
|
15742
15875
|
if (!state.value) {
|
|
@@ -15747,7 +15880,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15747
15880
|
if (state.value === "transforming") {
|
|
15748
15881
|
state.value = void 0;
|
|
15749
15882
|
}
|
|
15750
|
-
|
|
15883
|
+
emit("selectionTransformEnd", createSelectionTransformContext());
|
|
15751
15884
|
}
|
|
15752
15885
|
function tipFormat() {
|
|
15753
15886
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
|
|
@@ -16211,7 +16344,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16211
16344
|
hovered = result;
|
|
16212
16345
|
}
|
|
16213
16346
|
}
|
|
16214
|
-
if (!(isElement(hovered) && !isLock(hovered) && !hovered.findAncestor((ancestor) => isLock(ancestor)) && !isTopFrame(hovered))) {
|
|
16347
|
+
if (!(isElement(hovered) && !isLock(hovered) && !hovered.findAncestor((ancestor) => isLock(ancestor)) && (!hovered.children.some((node) => isElement(node)) || !isTopFrame(hovered)))) {
|
|
16215
16348
|
hovered = void 0;
|
|
16216
16349
|
cursor = void 0;
|
|
16217
16350
|
}
|
|
@@ -16226,7 +16359,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16226
16359
|
allowTopFrame = false
|
|
16227
16360
|
} = options;
|
|
16228
16361
|
function isIncluded(node) {
|
|
16229
|
-
return isElement(node) && !isLock(node) && (allowTopFrame || !isTopFrame(node)) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
16362
|
+
return isElement(node) && !isLock(node) && (allowTopFrame || (!node.children.some((node2) => isElement(node2)) || !isTopFrame(node))) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
16230
16363
|
}
|
|
16231
16364
|
const drawing = state.value === "drawing";
|
|
16232
16365
|
const hand = state.value === "hand";
|
|
@@ -16239,7 +16372,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16239
16372
|
let isUp = false;
|
|
16240
16373
|
let selected = [];
|
|
16241
16374
|
let ctxState;
|
|
16242
|
-
const inSelection = selectionAabbInDrawboard.value.contains({
|
|
16375
|
+
const inSelection = allowTopFrame && elementSelection.value.some((node) => node.equal(element)) || selectionAabbInDrawboard.value.contains({
|
|
16243
16376
|
x: start.x - drawboardAabb.value.left,
|
|
16244
16377
|
y: start.y - drawboardAabb.value.top
|
|
16245
16378
|
});
|
|
@@ -16411,7 +16544,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16411
16544
|
document.addEventListener("pointermove", onMove);
|
|
16412
16545
|
document.addEventListener("pointerup", onUp);
|
|
16413
16546
|
}
|
|
16414
|
-
editor.registerCommand({ command: "
|
|
16547
|
+
editor.registerCommand({ command: "pointerDown", handle: onPointerdown });
|
|
16415
16548
|
function onPointermove(event) {
|
|
16416
16549
|
if (event.srcElement !== drawboardDom.value) {
|
|
16417
16550
|
return;
|
|
@@ -16667,6 +16800,7 @@ export {
|
|
|
16667
16800
|
imageExts,
|
|
16668
16801
|
imageMimeTypeExtMap,
|
|
16669
16802
|
isClickInsideElement,
|
|
16803
|
+
isInputElement,
|
|
16670
16804
|
isInputEvent,
|
|
16671
16805
|
isMac,
|
|
16672
16806
|
isWindows,
|
package/dist/mixins/zoom.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Element2D } from 'modern-canvas';
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Mce {
|
|
4
4
|
type ZoomTarget = 'root' | 'selection' | Element2D | Element2D[] | number;
|
|
5
|
-
type ZoomToMode = 'contain' | 'cover';
|
|
5
|
+
type ZoomToMode = 'contain' | 'cover' | 'width' | 'height';
|
|
6
6
|
interface ZoomToOptions {
|
|
7
7
|
intoView?: boolean;
|
|
8
8
|
mode?: ZoomToMode;
|
package/dist/plugins/ui.d.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import type { PointerInputEvent } from 'modern-canvas';
|
|
2
|
-
import type { AxisAlignedBoundingBox } from '../types';
|
|
1
|
+
import type { Element2D, PointerInputEvent } from 'modern-canvas';
|
|
3
2
|
declare global {
|
|
4
3
|
namespace Mce {
|
|
5
|
-
interface
|
|
4
|
+
interface PointerDownOptions {
|
|
6
5
|
allowTopFrame?: boolean;
|
|
7
6
|
}
|
|
8
7
|
interface Commands {
|
|
9
|
-
|
|
8
|
+
pointerDown: (e: PointerInputEvent, options?: PointerDownOptions) => void;
|
|
10
9
|
startTyping: (e?: MouseEvent | PointerEvent) => Promise<boolean>;
|
|
11
10
|
startTransform: (e?: MouseEvent | PointerEvent) => boolean;
|
|
12
11
|
openContextMenu: (e?: MouseEvent | PointerEvent) => boolean;
|
|
13
12
|
layerScrollIntoView: () => boolean;
|
|
14
13
|
}
|
|
14
|
+
type TransformableHandle = 'move' | 'resize-top' | 'resize-right' | 'resize-bottom' | 'resize-left' | 'resize-top-left' | 'resize-top-right' | 'resize-bottom-left' | 'resize-bottom-right' | 'rotate-top-left' | 'rotate-top-right' | 'rotate-bottom-left' | 'rotate-bottom-right' | 'border-radius-top-left' | 'border-radius-top-right' | 'border-radius-bottom-left' | 'border-radius-bottom-right';
|
|
15
|
+
interface SelectionTransformContext {
|
|
16
|
+
startEvent: MouseEvent | PointerEvent;
|
|
17
|
+
handle: TransformableHandle;
|
|
18
|
+
elements: Element2D[];
|
|
19
|
+
}
|
|
15
20
|
interface Events {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
selectionTransformStart: [context: SelectionTransformContext];
|
|
22
|
+
selectionTransforming: [context: SelectionTransformContext];
|
|
23
|
+
selectionTransformEnd: [context: SelectionTransformContext];
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
package/dist/plugins/zoom.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ declare global {
|
|
|
8
8
|
zoomOut: () => void;
|
|
9
9
|
zoomTo100: () => void;
|
|
10
10
|
zoomToFit: () => void;
|
|
11
|
-
zoomToCover: () => void;
|
|
12
11
|
zoomToSelection: (options?: ZoomToOptions) => void;
|
|
13
12
|
}
|
|
14
13
|
interface Hotkeys {
|
|
@@ -16,7 +15,6 @@ declare global {
|
|
|
16
15
|
zoomOut: [event: KeyboardEvent];
|
|
17
16
|
zoomTo100: [event: KeyboardEvent];
|
|
18
17
|
zoomToFit: [event: KeyboardEvent];
|
|
19
|
-
zoomToCover: [event: KeyboardEvent];
|
|
20
18
|
zoomToSelection: [event: KeyboardEvent];
|
|
21
19
|
}
|
|
22
20
|
interface Editor {
|
package/dist/utils/helper.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function convertToUnit(str: number, unit?: string): string;
|
|
|
11
11
|
export declare function convertToUnit(str: string | number | null | undefined, unit?: string): string | undefined;
|
|
12
12
|
export declare function templateRef(): TemplateRef;
|
|
13
13
|
export declare function findChildrenWithProvide(key: InjectionKey<any> | symbol, vnode?: VNodeChild): ComponentInternalInstance[];
|
|
14
|
+
export declare function isInputElement(target: HTMLElement): boolean;
|
|
14
15
|
export declare function isInputEvent(event?: Event): boolean;
|
|
15
16
|
export declare function toKebabCase(str?: string): string;
|
|
16
17
|
export declare namespace toKebabCase {
|