@mekari/pixel3-rich-text-editor 0.1.3-dev.0 → 0.1.3-dev.1

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.
@@ -872,14 +872,13 @@ var SingleExtention = (0, import_vue9.defineComponent)({
872
872
  },
873
873
  editor: {
874
874
  type: Object
875
+ },
876
+ isDisabled: {
877
+ type: Boolean,
878
+ default: false
875
879
  }
876
880
  },
877
- setup({
878
- name,
879
- tooltipLabel,
880
- onClick,
881
- editor
882
- }) {
881
+ setup(props) {
883
882
  const iconMap = {
884
883
  bold: (0, import_vue8.createVNode)(BoldIcon, null, null),
885
884
  italic: (0, import_vue8.createVNode)(ItalicIcon, null, null),
@@ -898,14 +897,22 @@ var SingleExtention = (0, import_vue9.defineComponent)({
898
897
  variable: (0, import_vue8.createVNode)(VariableIcon, null, null),
899
898
  location: (0, import_vue8.createVNode)(LocationIcon, null, null)
900
899
  };
901
- return () => (0, import_vue8.withDirectives)((0, import_vue8.createVNode)("button", {
902
- "class": {
903
- "is-active": name && (editor == null ? void 0 : editor.isActive(name))
904
- },
905
- "onClick": onClick
906
- }, [name && iconMap[name]]), [[(0, import_vue8.resolveDirective)("tooltip"), {
907
- label: tooltipLabel
908
- }]]);
900
+ return () => {
901
+ var _a;
902
+ return (0, import_vue8.withDirectives)((0, import_vue8.createVNode)("button", {
903
+ "class": {
904
+ "is-active": props.name && ((_a = props.editor) == null ? void 0 : _a.isActive(props.name))
905
+ },
906
+ "style": props.isDisabled ? {
907
+ opacity: "0.4",
908
+ cursor: "not-allowed"
909
+ } : void 0,
910
+ "disabled": props.isDisabled,
911
+ "onClick": props.isDisabled ? void 0 : props.onClick
912
+ }, [props.name && iconMap[props.name]]), [[(0, import_vue8.resolveDirective)("tooltip"), {
913
+ label: props.tooltipLabel
914
+ }]]);
915
+ };
909
916
  }
910
917
  });
911
918
 
@@ -1543,77 +1550,102 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1543
1550
  type: Function
1544
1551
  }
1545
1552
  },
1546
- setup({
1547
- editor,
1548
- options,
1549
- validateLink,
1550
- transformLink
1551
- }, {
1553
+ setup(props, {
1552
1554
  emit
1553
1555
  }) {
1554
1556
  const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
1555
- const itemOptions = {
1557
+ const getItemOptions = /* @__PURE__ */ __name(() => ({
1556
1558
  heading: {
1557
1559
  tooltipLabel: "Text style",
1558
- editor
1560
+ editor: props.editor
1559
1561
  },
1560
1562
  bold: {
1561
1563
  tooltipLabel: "Bold",
1562
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleBold().run()
1564
+ onClick: () => {
1565
+ var _a;
1566
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBold().run();
1567
+ }
1563
1568
  },
1564
1569
  italic: {
1565
1570
  tooltipLabel: "Italic",
1566
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleItalic().run()
1571
+ onClick: () => {
1572
+ var _a;
1573
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleItalic().run();
1574
+ }
1567
1575
  },
1568
1576
  underline: {
1569
1577
  tooltipLabel: "Underline",
1570
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleUnderline().run()
1578
+ onClick: () => {
1579
+ var _a;
1580
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleUnderline().run();
1581
+ }
1571
1582
  },
1572
1583
  strike: {
1573
1584
  tooltipLabel: "Strike",
1574
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleStrike().run()
1585
+ onClick: () => {
1586
+ var _a;
1587
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleStrike().run();
1588
+ }
1575
1589
  },
1576
1590
  blockquote: {
1577
1591
  tooltipLabel: "Blockquote",
1578
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleBlockquote().run()
1592
+ onClick: () => {
1593
+ var _a;
1594
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBlockquote().run();
1595
+ }
1579
1596
  },
1580
1597
  bulletList: {
1581
1598
  tooltipLabel: "Bullet list",
1582
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleBulletList().run()
1599
+ onClick: () => {
1600
+ var _a;
1601
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBulletList().run();
1602
+ }
1583
1603
  },
1584
1604
  orderedList: {
1585
1605
  tooltipLabel: "Number list",
1586
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().toggleOrderedList().run()
1606
+ onClick: () => {
1607
+ var _a;
1608
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleOrderedList().run();
1609
+ }
1587
1610
  },
1588
1611
  textColor: {
1589
1612
  tooltipLabel: "Text color",
1590
- editor,
1613
+ editor: props.editor,
1591
1614
  type: "text"
1592
1615
  },
1593
1616
  fillColor: {
1594
1617
  tooltipLabel: "Fill color",
1595
- editor,
1618
+ editor: props.editor,
1596
1619
  type: "fill"
1597
1620
  },
1598
1621
  textLink: {
1599
1622
  tooltipLabel: "Insert link",
1600
- editor
1623
+ editor: props.editor
1601
1624
  },
1602
1625
  align: {
1603
1626
  tooltipLabel: "Text alignment",
1604
- editor
1627
+ editor: props.editor
1605
1628
  },
1606
1629
  undo: {
1607
1630
  tooltipLabel: "Undo",
1608
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().undo().run()
1631
+ onClick: () => {
1632
+ var _a;
1633
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().undo().run();
1634
+ }
1609
1635
  },
1610
1636
  redo: {
1611
1637
  tooltipLabel: "Redo",
1612
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().redo().run()
1638
+ onClick: () => {
1639
+ var _a;
1640
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().redo().run();
1641
+ }
1613
1642
  },
1614
1643
  clear: {
1615
1644
  tooltipLabel: "Reset format",
1616
- onClick: () => (editor == null ? void 0 : editor.chain()).focus().unsetAllMarks().run()
1645
+ onClick: () => {
1646
+ var _a;
1647
+ return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().unsetAllMarks().run();
1648
+ }
1617
1649
  },
1618
1650
  image: {
1619
1651
  tooltipLabel: "Add image",
@@ -1629,19 +1661,21 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1629
1661
  },
1630
1662
  mention: {
1631
1663
  tooltipLabel: "Mention",
1632
- editor,
1664
+ editor: props.editor,
1633
1665
  onClick: () => {
1666
+ var _a;
1634
1667
  ;
1635
- (editor == null ? void 0 : editor.chain()).focus().insertContent("@").run();
1668
+ ((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("@").run();
1636
1669
  emit("clickMention");
1637
1670
  }
1638
1671
  },
1639
1672
  variable: {
1640
1673
  tooltipLabel: "Insert variable",
1641
- editor,
1674
+ editor: props.editor,
1642
1675
  onClick: () => {
1676
+ var _a;
1643
1677
  ;
1644
- (editor == null ? void 0 : editor.chain()).focus().insertContent("{").run();
1678
+ ((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("{").run();
1645
1679
  emit("clickVariable");
1646
1680
  }
1647
1681
  },
@@ -1649,7 +1683,7 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1649
1683
  tooltipLabel: "Add location",
1650
1684
  onClick: () => emit("clickLocation")
1651
1685
  }
1652
- };
1686
+ }), "getItemOptions");
1653
1687
  const getResolvedItem = /* @__PURE__ */ __name((option) => {
1654
1688
  if (typeof option === "string") {
1655
1689
  return {
@@ -1658,17 +1692,20 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1658
1692
  }
1659
1693
  return {
1660
1694
  item: option.value,
1661
- tooltip: option.tooltip
1695
+ tooltip: option.tooltip,
1696
+ disabled: option.disabled
1662
1697
  };
1663
1698
  }, "getResolvedItem");
1664
1699
  const renderExtension = /* @__PURE__ */ __name((option) => {
1665
1700
  const {
1666
1701
  item,
1667
- tooltip
1702
+ tooltip,
1703
+ disabled
1668
1704
  } = getResolvedItem(option);
1669
1705
  if (!items.includes(item))
1670
1706
  return null;
1671
1707
  const resolvedItem = item;
1708
+ const itemOptions = getItemOptions();
1672
1709
  const resolvedOptions = itemOptions[resolvedItem];
1673
1710
  if (!resolvedOptions)
1674
1711
  return null;
@@ -1677,33 +1714,34 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1677
1714
  case "heading":
1678
1715
  return (0, import_vue16.createVNode)(HeadingExtention, {
1679
1716
  "tooltipLabel": tooltipLabel,
1680
- "editor": editor
1717
+ "editor": props.editor
1681
1718
  }, null);
1682
1719
  case "align":
1683
1720
  return (0, import_vue16.createVNode)(AlignExtention, {
1684
1721
  "tooltipLabel": tooltipLabel,
1685
- "editor": editor
1722
+ "editor": props.editor
1686
1723
  }, null);
1687
1724
  case "textColor":
1688
1725
  case "fillColor":
1689
1726
  return (0, import_vue16.createVNode)(ColorExtension, {
1690
1727
  "tooltipLabel": tooltipLabel,
1691
- "editor": editor,
1728
+ "editor": props.editor,
1692
1729
  "type": resolvedOptions.type
1693
1730
  }, null);
1694
1731
  case "textLink":
1695
1732
  return (0, import_vue16.createVNode)(LinkExtension, {
1696
1733
  "tooltipLabel": tooltipLabel,
1697
- "editor": editor,
1698
- "validateLink": validateLink,
1699
- "transformLink": transformLink
1734
+ "editor": props.editor,
1735
+ "validateLink": props.validateLink,
1736
+ "transformLink": props.transformLink
1700
1737
  }, null);
1701
1738
  default:
1702
1739
  return (0, import_vue16.createVNode)(SingleExtention, {
1703
1740
  "name": resolvedItem,
1704
1741
  "tooltipLabel": tooltipLabel,
1705
1742
  "onClick": resolvedOptions.onClick,
1706
- "editor": editor
1743
+ "editor": props.editor,
1744
+ "isDisabled": disabled
1707
1745
  }, null);
1708
1746
  }
1709
1747
  }, "renderExtension");
@@ -1715,21 +1753,27 @@ var EditorToolbar = (0, import_vue17.defineComponent)({
1715
1753
  }
1716
1754
  }
1717
1755
  }, {
1718
- default: () => [(0, import_vue16.createVNode)("div", {
1719
- "class": (0, import_css6.css)({
1720
- display: "flex",
1721
- alignItems: "stretch",
1722
- gap: "1"
1723
- })
1724
- }, [options == null ? void 0 : options.map((option, index) => (0, import_vue16.createVNode)(import_vue16.Fragment, null, [option.map((item) => {
1725
- const resolvedItem = typeof item === "string" ? item : item.value;
1726
- if (items.includes(resolvedItem)) {
1727
- return renderExtension(item);
1728
- }
1729
- }), index !== (options == null ? void 0 : options.length) - 1 && (0, import_vue16.createVNode)(import_pixel3_divider.MpDivider, {
1730
- "id": "divider-toolbar",
1731
- "orientation": "vertical"
1732
- }, null)]))])]
1756
+ default: () => {
1757
+ var _a;
1758
+ return [(0, import_vue16.createVNode)("div", {
1759
+ "class": (0, import_css6.css)({
1760
+ display: "flex",
1761
+ alignItems: "stretch",
1762
+ gap: "1"
1763
+ })
1764
+ }, [(_a = props.options) == null ? void 0 : _a.map((option, index) => {
1765
+ var _a2, _b;
1766
+ return (0, import_vue16.createVNode)(import_vue16.Fragment, null, [option.map((item) => {
1767
+ const resolvedItem = typeof item === "string" ? item : item.value;
1768
+ if (items.includes(resolvedItem)) {
1769
+ return renderExtension(item);
1770
+ }
1771
+ }), index !== ((_b = (_a2 = props.options) == null ? void 0 : _a2.length) != null ? _b : 0) - 1 && (0, import_vue16.createVNode)(import_pixel3_divider.MpDivider, {
1772
+ "id": "divider-toolbar",
1773
+ "orientation": "vertical"
1774
+ }, null)]);
1775
+ })])];
1776
+ }
1733
1777
  });
1734
1778
  }
1735
1779
  });
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  MpRichTextEditor
3
- } from "./chunk-ZYSEHV5N.mjs";
4
- import "./chunk-UD5PDCGC.mjs";
3
+ } from "./chunk-T7RFFPSJ.mjs";
4
+ import "./chunk-RX7ZEE2M.mjs";
5
5
  import "./chunk-HIHIKPNN.mjs";
6
6
  import "./chunk-X2CB42A3.mjs";
7
7
  import "./chunk-COZ45QUD.mjs";
8
- import "./chunk-47IOAHWN.mjs";
8
+ import "./chunk-FCLBNBXD.mjs";
9
9
  import "./chunk-ENKUUZPM.mjs";
10
10
  import "./chunk-AIWY3FHJ.mjs";
11
11
  import "./chunk-ZRAXSVO5.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mekari/pixel3-rich-text-editor",
3
3
  "description": "Mekari Pixel 3 | Rich text editor component is used to content editor based Tiptap.js",
4
- "version": "0.1.3-dev.0",
4
+ "version": "0.1.3-dev.1",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
7
7
  "files": [
@@ -41,17 +41,17 @@
41
41
  "@tiptap/starter-kit": "2.7.4",
42
42
  "@tiptap/suggestion": "2.7.4",
43
43
  "@tiptap/vue-3": "2.7.4",
44
- "@mekari/pixel3-avatar": "0.0.28-dev.0",
45
- "@mekari/pixel3-divider": "0.0.22",
46
- "@mekari/pixel3-button": "0.2.3-dev.0",
47
- "@mekari/pixel3-form-control": "0.0.22",
48
- "@mekari/pixel3-color-picker": "0.2.2-dev.0",
49
- "@mekari/pixel3-popover": "0.0.28-dev.0",
50
- "@mekari/pixel3-scrollbar": "0.1.6",
51
- "@mekari/pixel3-input": "0.0.28-dev.0",
52
- "@mekari/pixel3-styled-system": "0.2.0",
53
- "@mekari/pixel3-text": "0.0.22",
54
- "@mekari/pixel3-utils": "0.1.0"
44
+ "@mekari/pixel3-avatar": "0.0.28-dev.1",
45
+ "@mekari/pixel3-button": "0.2.3-dev.1",
46
+ "@mekari/pixel3-color-picker": "0.2.2-dev.1",
47
+ "@mekari/pixel3-divider": "0.0.23-dev.0",
48
+ "@mekari/pixel3-form-control": "0.0.23-dev.0",
49
+ "@mekari/pixel3-popover": "0.0.28-dev.1",
50
+ "@mekari/pixel3-scrollbar": "0.1.7-dev.0",
51
+ "@mekari/pixel3-input": "0.0.28-dev.1",
52
+ "@mekari/pixel3-styled-system": "0.2.1-dev.0",
53
+ "@mekari/pixel3-utils": "0.1.0",
54
+ "@mekari/pixel3-text": "0.0.23-dev.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vue": "^3.4.9"