vue-devui 1.6.27 → 1.6.29

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.
@@ -1509,13 +1509,26 @@ ToolBarHandler.fullscreen = (editor) => {
1509
1509
  };
1510
1510
  ToolBarHandler.color = () => {
1511
1511
  };
1512
+ const GET_CTRL_KEY = () => {
1513
+ var _a;
1514
+ if (typeof window !== "undefined") {
1515
+ return ((_a = navigator == null ? void 0 : navigator.platform) == null ? void 0 : _a.indexOf("Mac")) !== -1 ? "\u2318" : "Ctrl";
1516
+ }
1517
+ };
1518
+ const GET_ALT_KEY = () => {
1519
+ var _a;
1520
+ if (typeof window !== "undefined") {
1521
+ return ((_a = navigator == null ? void 0 : navigator.platform) == null ? void 0 : _a.indexOf("Mac")) !== -1 ? "\u2325" : "Alt";
1522
+ }
1523
+ };
1512
1524
  const DEFAULT_TOOLBARS = {
1513
1525
  undo: {
1514
1526
  id: "undo",
1515
1527
  name: "undo",
1516
1528
  type: "button",
1517
1529
  icon: UNDO_ICON,
1518
- shortKey: "Ctrl+Z",
1530
+ shortKey: `${GET_CTRL_KEY()}+Z`,
1531
+ shortKeyWithCode: `${GET_CTRL_KEY()}+90`,
1519
1532
  handler: ToolBarHandler.undo
1520
1533
  },
1521
1534
  redo: {
@@ -1523,7 +1536,8 @@ const DEFAULT_TOOLBARS = {
1523
1536
  name: "redo",
1524
1537
  type: "button",
1525
1538
  icon: REDO_ICON,
1526
- shortKey: "Ctrl+Y",
1539
+ shortKey: `${GET_CTRL_KEY()}+Y`,
1540
+ shortKeyWithCode: `${GET_CTRL_KEY()}+89`,
1527
1541
  handler: ToolBarHandler.redo
1528
1542
  },
1529
1543
  bold: {
@@ -1531,7 +1545,8 @@ const DEFAULT_TOOLBARS = {
1531
1545
  name: "bold",
1532
1546
  type: "button",
1533
1547
  icon: BOLD_ICON,
1534
- shortKey: "Ctrl+B",
1548
+ shortKey: `${GET_CTRL_KEY()}+B`,
1549
+ shortKeyWithCode: `${GET_CTRL_KEY()}+66`,
1535
1550
  handler: ToolBarHandler.bold
1536
1551
  },
1537
1552
  italic: {
@@ -1539,7 +1554,8 @@ const DEFAULT_TOOLBARS = {
1539
1554
  name: "italic",
1540
1555
  type: "button",
1541
1556
  icon: ITALIC_ICON,
1542
- shortKey: "Ctrl+I",
1557
+ shortKey: `${GET_CTRL_KEY()}+I`,
1558
+ shortKeyWithCode: `${GET_CTRL_KEY()}+73`,
1543
1559
  handler: ToolBarHandler.italic
1544
1560
  },
1545
1561
  strike: {
@@ -1547,7 +1563,8 @@ const DEFAULT_TOOLBARS = {
1547
1563
  name: "strike",
1548
1564
  type: "button",
1549
1565
  icon: STRIKE_ICON,
1550
- shortKey: "Ctrl+D",
1566
+ shortKey: `${GET_CTRL_KEY()}+D`,
1567
+ shortKeyWithCode: `${GET_CTRL_KEY()}+68`,
1551
1568
  handler: ToolBarHandler.strike
1552
1569
  },
1553
1570
  h1: {
@@ -1555,7 +1572,8 @@ const DEFAULT_TOOLBARS = {
1555
1572
  name: "h1",
1556
1573
  type: "button",
1557
1574
  icon: H1_ICON,
1558
- shortKey: "Ctrl+1",
1575
+ shortKey: `${GET_CTRL_KEY()}+1`,
1576
+ shortKeyWithCode: `${GET_CTRL_KEY()}+49`,
1559
1577
  handler: ToolBarHandler.h1
1560
1578
  },
1561
1579
  h2: {
@@ -1563,7 +1581,8 @@ const DEFAULT_TOOLBARS = {
1563
1581
  name: "h2",
1564
1582
  type: "button",
1565
1583
  icon: H2_ICON,
1566
- shortKey: "Ctrl+2",
1584
+ shortKey: `${GET_CTRL_KEY()}+2`,
1585
+ shortKeyWithCode: `${GET_CTRL_KEY()}+50`,
1567
1586
  handler: ToolBarHandler.h2
1568
1587
  },
1569
1588
  ul: {
@@ -1571,7 +1590,8 @@ const DEFAULT_TOOLBARS = {
1571
1590
  name: "unorderedlist",
1572
1591
  type: "button",
1573
1592
  icon: LIST_UNORDERED_ICON,
1574
- shortKey: "Ctrl+U",
1593
+ shortKey: `${GET_CTRL_KEY()}+U`,
1594
+ shortKeyWithCode: `${GET_CTRL_KEY()}+85`,
1575
1595
  handler: ToolBarHandler.ul
1576
1596
  },
1577
1597
  ol: {
@@ -1579,7 +1599,8 @@ const DEFAULT_TOOLBARS = {
1579
1599
  name: "orderedlist",
1580
1600
  type: "button",
1581
1601
  icon: LIST_ORDERED_ICON,
1582
- shortKey: "Ctrl+O",
1602
+ shortKey: `${GET_CTRL_KEY()}+O`,
1603
+ shortKeyWithCode: `${GET_CTRL_KEY()}+79`,
1583
1604
  handler: ToolBarHandler.ol
1584
1605
  },
1585
1606
  checklist: {
@@ -1587,7 +1608,8 @@ const DEFAULT_TOOLBARS = {
1587
1608
  name: "checklist",
1588
1609
  type: "button",
1589
1610
  icon: LIST_CHECK_ICON,
1590
- shortKey: "Ctrl+Alt+C",
1611
+ shortKey: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+C`,
1612
+ shortKeyWithCode: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+67`,
1591
1613
  handler: ToolBarHandler.checkList
1592
1614
  },
1593
1615
  underline: {
@@ -1595,7 +1617,8 @@ const DEFAULT_TOOLBARS = {
1595
1617
  name: "underline",
1596
1618
  type: "button",
1597
1619
  icon: UNDERLINE_ICON,
1598
- shortKey: "Ctrl+R",
1620
+ shortKey: `${GET_CTRL_KEY()}+R`,
1621
+ shortKeyWithCode: `${GET_CTRL_KEY()}+82`,
1599
1622
  handler: ToolBarHandler.underline
1600
1623
  },
1601
1624
  font: {
@@ -1611,7 +1634,8 @@ const DEFAULT_TOOLBARS = {
1611
1634
  name: "link",
1612
1635
  type: "button",
1613
1636
  icon: LINK_ICON,
1614
- shortKey: "Ctrl+L",
1637
+ shortKey: `${GET_CTRL_KEY()}+L`,
1638
+ shortKeyWithCode: `${GET_CTRL_KEY()}+76`,
1615
1639
  handler: ToolBarHandler.link
1616
1640
  },
1617
1641
  image: {
@@ -1619,7 +1643,8 @@ const DEFAULT_TOOLBARS = {
1619
1643
  name: "image",
1620
1644
  type: "button",
1621
1645
  icon: IMAGE_ICON,
1622
- shortKey: "Ctrl+G",
1646
+ shortKey: `${GET_CTRL_KEY()}+G`,
1647
+ shortKeyWithCode: `${GET_CTRL_KEY()}+71`,
1623
1648
  params: { imageUploadToServer: false },
1624
1649
  handler: ToolBarHandler.image
1625
1650
  },
@@ -1629,7 +1654,8 @@ const DEFAULT_TOOLBARS = {
1629
1654
  type: "button",
1630
1655
  icon: FILE_ICON,
1631
1656
  params: {},
1632
- shortKey: "Ctrl+F",
1657
+ shortKey: `${GET_CTRL_KEY()}+F`,
1658
+ shortKeyWithCode: `${GET_CTRL_KEY()}+70`,
1633
1659
  handler: ToolBarHandler.file
1634
1660
  },
1635
1661
  code: {
@@ -1637,7 +1663,8 @@ const DEFAULT_TOOLBARS = {
1637
1663
  name: "code",
1638
1664
  type: "button",
1639
1665
  icon: CODE_ICON,
1640
- shortKey: "Ctrl+K",
1666
+ shortKey: `${GET_CTRL_KEY()}+K`,
1667
+ shortKeyWithCode: `${GET_CTRL_KEY()}+75`,
1641
1668
  handler: ToolBarHandler.code
1642
1669
  },
1643
1670
  table: {
@@ -1645,7 +1672,8 @@ const DEFAULT_TOOLBARS = {
1645
1672
  name: "table",
1646
1673
  type: "button",
1647
1674
  icon: TABLE_ICON,
1648
- shortKey: "Ctrl+Alt+T",
1675
+ shortKey: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+T`,
1676
+ shortKeyWithCode: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+84`,
1649
1677
  handler: ToolBarHandler.table
1650
1678
  },
1651
1679
  fullscreen: {
@@ -7477,8 +7505,8 @@ function useEditorMd(props, ctx) {
7477
7505
  const tempToolbars = { ...toolbars, ...customToolbars == null ? void 0 : customToolbars.value };
7478
7506
  for (const key of Object.keys(tempToolbars)) {
7479
7507
  const toolbarItem = tempToolbars[key];
7480
- if (toolbarItem.shortKey && flatToolbarConfig.includes(toolbarItem.id)) {
7481
- shortKeys[toolbarItem.shortKey.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
7508
+ if (toolbarItem.shortKeyWithCode && flatToolbarConfig.includes(toolbarItem.id)) {
7509
+ shortKeys[toolbarItem.shortKeyWithCode.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
7482
7510
  }
7483
7511
  }
7484
7512
  editorIns.setOption(
@@ -7500,6 +7528,26 @@ function useEditorMd(props, ctx) {
7500
7528
  setTimeout(() => {
7501
7529
  ctx.emit("contentChange", editorIns.getValue());
7502
7530
  }, 100);
7531
+ containerRef.value.addEventListener("keydown", (e) => {
7532
+ let keyCombination = "";
7533
+ if (e.ctrlKey) {
7534
+ keyCombination += "Ctrl-";
7535
+ }
7536
+ if (e.metaKey) {
7537
+ keyCombination += "\u2318-";
7538
+ }
7539
+ if (e.altKey) {
7540
+ keyCombination += `${GET_ALT_KEY()}-`;
7541
+ }
7542
+ if (e.shiftKey) {
7543
+ keyCombination += "Shift-";
7544
+ }
7545
+ keyCombination += e.keyCode;
7546
+ if (shortKeys[keyCombination] && typeof shortKeys[keyCombination] === "function") {
7547
+ e.preventDefault();
7548
+ shortKeys[keyCombination]();
7549
+ }
7550
+ });
7503
7551
  };
7504
7552
  const onPaste = (e) => {
7505
7553
  const clipboardData = e.clipboardData;