mce 0.15.23 → 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 +285 -141
- package/dist/mixins/zoom.d.ts +1 -1
- package/dist/plugins/ui.d.ts +13 -8
- 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,9 @@ 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
|
-
|
|
5291
|
-
|
|
5452
|
+
cloend.__FROM__ = event.target;
|
|
5453
|
+
exec("pointerDown", cloend, {
|
|
5454
|
+
allowTopFrame: true
|
|
5292
5455
|
});
|
|
5293
5456
|
}
|
|
5294
5457
|
}
|
|
@@ -5391,7 +5554,7 @@ const _frame = definePlugin((editor) => {
|
|
|
5391
5554
|
}
|
|
5392
5555
|
],
|
|
5393
5556
|
hotkeys: [
|
|
5394
|
-
{ command: "setActiveDrawingTool:frame", key: "
|
|
5557
|
+
{ command: "setActiveDrawingTool:frame", key: "F" }
|
|
5395
5558
|
]
|
|
5396
5559
|
};
|
|
5397
5560
|
});
|
|
@@ -5509,8 +5672,8 @@ const _group = definePlugin((editor) => {
|
|
|
5509
5672
|
{ command: "ungroup", handle: ungroup }
|
|
5510
5673
|
],
|
|
5511
5674
|
hotkeys: [
|
|
5512
|
-
{ command: "groupSelection", key: "CmdOrCtrl+
|
|
5513
|
-
{ command: "frameSelection", key: "Alt+CmdOrCtrl+
|
|
5675
|
+
{ command: "groupSelection", key: "CmdOrCtrl+G" },
|
|
5676
|
+
{ command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
|
|
5514
5677
|
{ command: "ungroup", key: "CmdOrCtrl+Backspace" }
|
|
5515
5678
|
]
|
|
5516
5679
|
};
|
|
@@ -5547,8 +5710,8 @@ const _history = definePlugin((editor) => {
|
|
|
5547
5710
|
{ command: "redo", handle: redo }
|
|
5548
5711
|
],
|
|
5549
5712
|
hotkeys: [
|
|
5550
|
-
{ command: "undo", key: "CmdOrCtrl+
|
|
5551
|
-
{ command: "redo", key: "Shift+CmdOrCtrl+
|
|
5713
|
+
{ command: "undo", key: "CmdOrCtrl+Z" },
|
|
5714
|
+
{ command: "redo", key: "Shift+CmdOrCtrl+Z" }
|
|
5552
5715
|
]
|
|
5553
5716
|
};
|
|
5554
5717
|
});
|
|
@@ -5702,8 +5865,8 @@ const _image = definePlugin((editor) => {
|
|
|
5702
5865
|
{ name: "image", handle: (position) => exec("import", { position }) }
|
|
5703
5866
|
],
|
|
5704
5867
|
hotkeys: [
|
|
5705
|
-
{ command: "copyAs:png", key: "Shift+CmdOrCtrl+
|
|
5706
|
-
{ command: "setActiveDrawingTool:image", key: "Shift+CmdOrCtrl+
|
|
5868
|
+
{ command: "copyAs:png", key: "Shift+CmdOrCtrl+C" },
|
|
5869
|
+
{ command: "setActiveDrawingTool:image", key: "Shift+CmdOrCtrl+K" }
|
|
5707
5870
|
]
|
|
5708
5871
|
};
|
|
5709
5872
|
});
|
|
@@ -5734,7 +5897,7 @@ const _import = definePlugin((editor) => {
|
|
|
5734
5897
|
{ command: "import", handle: _import2 }
|
|
5735
5898
|
],
|
|
5736
5899
|
hotkeys: [
|
|
5737
|
-
{ command: "import", key: "CmdOrCtrl+
|
|
5900
|
+
{ command: "import", key: "CmdOrCtrl+I" }
|
|
5738
5901
|
],
|
|
5739
5902
|
setup: () => {
|
|
5740
5903
|
const {
|
|
@@ -6274,7 +6437,7 @@ const _lock = definePlugin((editor) => {
|
|
|
6274
6437
|
{ command: "lock/unlock", handle: () => selection.value.forEach((el) => setLock(el, !isLock(el))) }
|
|
6275
6438
|
],
|
|
6276
6439
|
hotkeys: [
|
|
6277
|
-
{ command: "lock/unlock", key: "Shift+CmdOrCtrl+
|
|
6440
|
+
{ command: "lock/unlock", key: "Shift+CmdOrCtrl+L" }
|
|
6278
6441
|
]
|
|
6279
6442
|
};
|
|
6280
6443
|
});
|
|
@@ -7216,7 +7379,7 @@ const _open = definePlugin((editor) => {
|
|
|
7216
7379
|
{ command: "open", handle: open }
|
|
7217
7380
|
],
|
|
7218
7381
|
hotkeys: [
|
|
7219
|
-
{ command: "open", key: "CmdOrCtrl+
|
|
7382
|
+
{ command: "open", key: "CmdOrCtrl+O" }
|
|
7220
7383
|
]
|
|
7221
7384
|
};
|
|
7222
7385
|
});
|
|
@@ -7230,7 +7393,7 @@ const _panels = definePlugin((editor) => {
|
|
|
7230
7393
|
{ command: "panels", handle: (panel) => config.value[panel] = !config.value[panel] }
|
|
7231
7394
|
],
|
|
7232
7395
|
hotkeys: [
|
|
7233
|
-
{ command: "panels:layers", key: "Alt
|
|
7396
|
+
{ command: "panels:layers", key: "Alt+1" }
|
|
7234
7397
|
]
|
|
7235
7398
|
};
|
|
7236
7399
|
});
|
|
@@ -11303,8 +11466,8 @@ const _pen = definePlugin((editor) => {
|
|
|
11303
11466
|
}
|
|
11304
11467
|
],
|
|
11305
11468
|
hotkeys: [
|
|
11306
|
-
{ command: "setActiveDrawingTool:pen", key: "
|
|
11307
|
-
{ command: "setActiveDrawingTool:pencil", key: "Shift+
|
|
11469
|
+
{ command: "setActiveDrawingTool:pen", key: "P" },
|
|
11470
|
+
{ command: "setActiveDrawingTool:pencil", key: "Shift+P" }
|
|
11308
11471
|
]
|
|
11309
11472
|
};
|
|
11310
11473
|
});
|
|
@@ -12021,8 +12184,8 @@ const _selection = definePlugin((editor) => {
|
|
|
12021
12184
|
{ command: "selectNextSibling", handle: () => selectSibling("next") }
|
|
12022
12185
|
],
|
|
12023
12186
|
hotkeys: [
|
|
12024
|
-
{ command: "selectAll", key: "CmdOrCtrl+
|
|
12025
|
-
{ command: "deselectAll", key: "Shift+CmdOrCtrl+
|
|
12187
|
+
{ command: "selectAll", key: "CmdOrCtrl+A" },
|
|
12188
|
+
{ command: "deselectAll", key: "Shift+CmdOrCtrl+A" },
|
|
12026
12189
|
{ command: "selectChildren", key: "Enter" },
|
|
12027
12190
|
{ command: "selectParent", key: "\\" },
|
|
12028
12191
|
{ command: "selectPreviousSibling", key: "Shift+Tab" },
|
|
@@ -12197,10 +12360,10 @@ const _shape = definePlugin((editor) => {
|
|
|
12197
12360
|
}
|
|
12198
12361
|
],
|
|
12199
12362
|
hotkeys: [
|
|
12200
|
-
{ command: "setActiveDrawingTool:rectangle", key: "
|
|
12201
|
-
{ command: "setActiveDrawingTool:line", key: "
|
|
12202
|
-
{ command: "setActiveDrawingTool:arrow", key: "Shift+
|
|
12203
|
-
{ 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" }
|
|
12204
12367
|
]
|
|
12205
12368
|
};
|
|
12206
12369
|
});
|
|
@@ -13547,8 +13710,8 @@ const _state = definePlugin((editor) => {
|
|
|
13547
13710
|
{ command: "setState", handle: (val) => state.value = val }
|
|
13548
13711
|
],
|
|
13549
13712
|
hotkeys: [
|
|
13550
|
-
{ command: "setState:move", key: "
|
|
13551
|
-
{ command: "setState:hand", key: "
|
|
13713
|
+
{ command: "setState:move", key: "V" },
|
|
13714
|
+
{ command: "setState:hand", key: "H" }
|
|
13552
13715
|
]
|
|
13553
13716
|
};
|
|
13554
13717
|
});
|
|
@@ -13779,7 +13942,7 @@ const _text = definePlugin((editor) => {
|
|
|
13779
13942
|
}
|
|
13780
13943
|
],
|
|
13781
13944
|
hotkeys: [
|
|
13782
|
-
{ command: "setActiveDrawingTool:text", key: "
|
|
13945
|
+
{ command: "setActiveDrawingTool:text", key: "T" }
|
|
13783
13946
|
]
|
|
13784
13947
|
};
|
|
13785
13948
|
});
|
|
@@ -14110,7 +14273,7 @@ const _timeline = definePlugin((editor) => {
|
|
|
14110
14273
|
}
|
|
14111
14274
|
],
|
|
14112
14275
|
hotkeys: [
|
|
14113
|
-
{ command: "panels:timeline", key: "Alt
|
|
14276
|
+
{ command: "panels:timeline", key: "Alt+2" }
|
|
14114
14277
|
]
|
|
14115
14278
|
};
|
|
14116
14279
|
});
|
|
@@ -14326,25 +14489,14 @@ const _transform = definePlugin((editor) => {
|
|
|
14326
14489
|
{ command: "flipVertical", handle: flipVertical }
|
|
14327
14490
|
],
|
|
14328
14491
|
hotkeys: [
|
|
14329
|
-
{ command: "flipHorizontal", key: "Shift+
|
|
14330
|
-
{ command: "flipVertical", key: "Shift+
|
|
14492
|
+
{ command: "flipHorizontal", key: "Shift+H" },
|
|
14493
|
+
{ command: "flipVertical", key: "Shift+V" }
|
|
14331
14494
|
]
|
|
14332
14495
|
};
|
|
14333
14496
|
});
|
|
14334
|
-
const _ui = definePlugin((
|
|
14335
|
-
const {
|
|
14336
|
-
selectionAabbInDrawboard,
|
|
14337
|
-
emit
|
|
14338
|
-
} = editor;
|
|
14497
|
+
const _ui = definePlugin(() => {
|
|
14339
14498
|
return {
|
|
14340
|
-
name: "mce:ui"
|
|
14341
|
-
setup: () => {
|
|
14342
|
-
watch(
|
|
14343
|
-
selectionAabbInDrawboard,
|
|
14344
|
-
(aabb) => emit("setTransform", { aabb }),
|
|
14345
|
-
{ deep: true }
|
|
14346
|
-
);
|
|
14347
|
-
}
|
|
14499
|
+
name: "mce:ui"
|
|
14348
14500
|
};
|
|
14349
14501
|
});
|
|
14350
14502
|
const _url = definePlugin((editor) => {
|
|
@@ -14416,7 +14568,7 @@ const _visibility = definePlugin((editor) => {
|
|
|
14416
14568
|
{ command: "hide/show", handle: hideOrShow }
|
|
14417
14569
|
],
|
|
14418
14570
|
hotkeys: [
|
|
14419
|
-
{ command: "hide/show", key: "Shift+CmdOrCtrl+
|
|
14571
|
+
{ command: "hide/show", key: "Shift+CmdOrCtrl+H" }
|
|
14420
14572
|
]
|
|
14421
14573
|
};
|
|
14422
14574
|
});
|
|
@@ -14426,7 +14578,6 @@ const _zoom = definePlugin((editor) => {
|
|
|
14426
14578
|
camera,
|
|
14427
14579
|
drawboardAabb,
|
|
14428
14580
|
zoomTo,
|
|
14429
|
-
elementSelection,
|
|
14430
14581
|
exec,
|
|
14431
14582
|
config,
|
|
14432
14583
|
findFrame,
|
|
@@ -14446,7 +14597,6 @@ const _zoom = definePlugin((editor) => {
|
|
|
14446
14597
|
{ command: "zoomIn", handle: () => camera.value.addZoom(0.25) },
|
|
14447
14598
|
{ command: "zoomOut", handle: () => camera.value.addZoom(-0.25) },
|
|
14448
14599
|
{ command: "zoomTo100", handle: () => camera.value.setZoom(1) },
|
|
14449
|
-
{ command: "zoomToCover", handle: () => zoomTo("root", { mode: "cover" }) },
|
|
14450
14600
|
{ command: "zoomToFit", handle: () => zoomTo("root", { mode: config.value.zoomToFit }) },
|
|
14451
14601
|
{ command: "zoomToSelection", handle: (options) => zoomTo("selection", options) },
|
|
14452
14602
|
{ command: "zoomToNextFrame", handle: (options) => zoomToFrame("next", options) },
|
|
@@ -14456,20 +14606,13 @@ const _zoom = definePlugin((editor) => {
|
|
|
14456
14606
|
{ command: "zoomIn", key: "CmdOrCtrl+=" },
|
|
14457
14607
|
{ command: "zoomOut", key: "CmdOrCtrl+-" },
|
|
14458
14608
|
{ command: "zoomTo100", key: "CmdOrCtrl+0" },
|
|
14459
|
-
{ command: "zoomToFit", key: "Shift
|
|
14460
|
-
{ command: "zoomToSelection", key: "Shift
|
|
14461
|
-
{ command: "zoomToNextFrame", key: "
|
|
14609
|
+
{ command: "zoomToFit", key: "Shift+1" },
|
|
14610
|
+
{ command: "zoomToSelection", key: "Shift+2" },
|
|
14611
|
+
{ command: "zoomToNextFrame", key: "N" },
|
|
14462
14612
|
{ command: "zoomToPreviousFrame", key: "Shift+N" }
|
|
14463
14613
|
],
|
|
14464
14614
|
events: {
|
|
14465
|
-
setDoc: () => exec("zoomToFit")
|
|
14466
|
-
setCurrentFrame: () => {
|
|
14467
|
-
if (elementSelection.value.length) {
|
|
14468
|
-
exec("zoomToSelection");
|
|
14469
|
-
} else {
|
|
14470
|
-
exec("zoomToFit");
|
|
14471
|
-
}
|
|
14472
|
-
}
|
|
14615
|
+
setDoc: () => exec("zoomToFit")
|
|
14473
14616
|
},
|
|
14474
14617
|
setup: () => {
|
|
14475
14618
|
const {
|
|
@@ -15535,6 +15678,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15535
15678
|
setup(__props, { expose: __expose }) {
|
|
15536
15679
|
const props = __props;
|
|
15537
15680
|
const {
|
|
15681
|
+
emit,
|
|
15538
15682
|
isElement,
|
|
15539
15683
|
state,
|
|
15540
15684
|
resizeElement,
|
|
@@ -15551,14 +15695,18 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15551
15695
|
isLock,
|
|
15552
15696
|
config,
|
|
15553
15697
|
snapThreshold,
|
|
15554
|
-
getSnapPoints
|
|
15555
|
-
handleDragOutReparent,
|
|
15556
|
-
getGlobalPointer
|
|
15698
|
+
getSnapPoints
|
|
15557
15699
|
} = useEditor();
|
|
15558
15700
|
const transformable = useTemplateRef("transformableTpl");
|
|
15559
|
-
const
|
|
15701
|
+
const startEvent = ref();
|
|
15560
15702
|
onBeforeMount(() => {
|
|
15561
|
-
registerCommand({
|
|
15703
|
+
registerCommand({
|
|
15704
|
+
command: "startTransform",
|
|
15705
|
+
handle: (event) => {
|
|
15706
|
+
startEvent.value = event;
|
|
15707
|
+
Boolean(transformable.value?.start(event));
|
|
15708
|
+
}
|
|
15709
|
+
});
|
|
15562
15710
|
});
|
|
15563
15711
|
onBeforeUnmount(() => {
|
|
15564
15712
|
unregisterCommand("startTransform");
|
|
@@ -15629,6 +15777,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15629
15777
|
}
|
|
15630
15778
|
return currentPos;
|
|
15631
15779
|
}
|
|
15780
|
+
function createSelectionTransformContext() {
|
|
15781
|
+
return {
|
|
15782
|
+
startEvent: startEvent.value,
|
|
15783
|
+
handle: transformable.value?.activeHandle ?? "move",
|
|
15784
|
+
elements: elementSelection.value
|
|
15785
|
+
};
|
|
15786
|
+
}
|
|
15632
15787
|
const transform = computed({
|
|
15633
15788
|
get: () => _transform2.value,
|
|
15634
15789
|
set: (val) => {
|
|
@@ -15655,7 +15810,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15655
15810
|
rotate: transform2.rotate - (oldTransform.rotate ?? 0),
|
|
15656
15811
|
borderRadius: transform2.borderRadius - (oldTransform.borderRadius ?? 0) / zoom.y
|
|
15657
15812
|
};
|
|
15658
|
-
elementSelection.value
|
|
15813
|
+
const elements = elementSelection.value;
|
|
15814
|
+
elements.forEach((element) => {
|
|
15659
15815
|
const style = element.style;
|
|
15660
15816
|
const newStyle = {
|
|
15661
15817
|
left: style.left + offsetStyle.left,
|
|
@@ -15689,14 +15845,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15689
15845
|
}
|
|
15690
15846
|
return false;
|
|
15691
15847
|
});
|
|
15692
|
-
handleDragOutReparent(
|
|
15693
|
-
element,
|
|
15694
|
-
{
|
|
15695
|
-
...startContext.value[element.instanceId],
|
|
15696
|
-
pointer: getGlobalPointer()
|
|
15697
|
-
}
|
|
15698
|
-
);
|
|
15699
15848
|
});
|
|
15849
|
+
emit("selectionTransforming", createSelectionTransformContext());
|
|
15700
15850
|
}
|
|
15701
15851
|
});
|
|
15702
15852
|
const movable = computed(() => {
|
|
@@ -15719,14 +15869,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15719
15869
|
return elementSelection.value.length === 1 && !isLock(element) && element.foreground.isValid();
|
|
15720
15870
|
});
|
|
15721
15871
|
function onStart() {
|
|
15722
|
-
|
|
15723
|
-
elementSelection.value.forEach((el) => {
|
|
15724
|
-
ctx[el.instanceId] = {
|
|
15725
|
-
parent: el.getParent(),
|
|
15726
|
-
index: el.getIndex()
|
|
15727
|
-
};
|
|
15728
|
-
});
|
|
15729
|
-
startContext.value = ctx;
|
|
15872
|
+
emit("selectionTransformStart", createSelectionTransformContext());
|
|
15730
15873
|
}
|
|
15731
15874
|
function onMove() {
|
|
15732
15875
|
if (!state.value) {
|
|
@@ -15737,7 +15880,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
15737
15880
|
if (state.value === "transforming") {
|
|
15738
15881
|
state.value = void 0;
|
|
15739
15882
|
}
|
|
15740
|
-
|
|
15883
|
+
emit("selectionTransformEnd", createSelectionTransformContext());
|
|
15741
15884
|
}
|
|
15742
15885
|
function tipFormat() {
|
|
15743
15886
|
const obb = elementSelection.value.length === 1 ? elementSelection.value[0].style : selectionObb.value;
|
|
@@ -16201,7 +16344,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16201
16344
|
hovered = result;
|
|
16202
16345
|
}
|
|
16203
16346
|
}
|
|
16204
|
-
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)))) {
|
|
16205
16348
|
hovered = void 0;
|
|
16206
16349
|
cursor = void 0;
|
|
16207
16350
|
}
|
|
@@ -16213,10 +16356,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16213
16356
|
return;
|
|
16214
16357
|
}
|
|
16215
16358
|
const {
|
|
16216
|
-
|
|
16359
|
+
allowTopFrame = false
|
|
16217
16360
|
} = options;
|
|
16218
16361
|
function isIncluded(node) {
|
|
16219
|
-
return isElement(node) && !isLock(node) && (
|
|
16362
|
+
return isElement(node) && !isLock(node) && (allowTopFrame || (!node.children.some((node2) => isElement(node2)) || !isTopFrame(node))) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
16220
16363
|
}
|
|
16221
16364
|
const drawing = state.value === "drawing";
|
|
16222
16365
|
const hand = state.value === "hand";
|
|
@@ -16229,7 +16372,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16229
16372
|
let isUp = false;
|
|
16230
16373
|
let selected = [];
|
|
16231
16374
|
let ctxState;
|
|
16232
|
-
const inSelection = selectionAabbInDrawboard.value.contains({
|
|
16375
|
+
const inSelection = allowTopFrame && elementSelection.value.some((node) => node.equal(element)) || selectionAabbInDrawboard.value.contains({
|
|
16233
16376
|
x: start.x - drawboardAabb.value.left,
|
|
16234
16377
|
y: start.y - drawboardAabb.value.top
|
|
16235
16378
|
});
|
|
@@ -16401,7 +16544,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
16401
16544
|
document.addEventListener("pointermove", onMove);
|
|
16402
16545
|
document.addEventListener("pointerup", onUp);
|
|
16403
16546
|
}
|
|
16404
|
-
editor.registerCommand({ command: "
|
|
16547
|
+
editor.registerCommand({ command: "pointerDown", handle: onPointerdown });
|
|
16405
16548
|
function onPointermove(event) {
|
|
16406
16549
|
if (event.srcElement !== drawboardDom.value) {
|
|
16407
16550
|
return;
|
|
@@ -16657,6 +16800,7 @@ export {
|
|
|
16657
16800
|
imageExts,
|
|
16658
16801
|
imageMimeTypeExtMap,
|
|
16659
16802
|
isClickInsideElement,
|
|
16803
|
+
isInputElement,
|
|
16660
16804
|
isInputEvent,
|
|
16661
16805
|
isMac,
|
|
16662
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
|
|
6
|
-
|
|
4
|
+
interface PointerDownOptions {
|
|
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 {
|