@mekari/pixel3-rich-text-editor 0.0.18 → 0.1.0-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.
Files changed (67) hide show
  1. package/dist/chunk-4KJOYLJI.mjs +168 -0
  2. package/dist/{chunk-JAKI6TU2.mjs → chunk-4SN6MBXS.mjs} +8 -22
  3. package/dist/chunk-4TUA5VF4.mjs +173 -0
  4. package/dist/{chunk-2OCRJNTJ.mjs → chunk-7RMCTPMN.mjs} +2 -2
  5. package/dist/{chunk-RNQQ7LGC.mjs → chunk-C7IUW3FX.mjs} +73 -1
  6. package/dist/{chunk-ES3FCTTF.mjs → chunk-JE7IG7UU.mjs} +27 -6
  7. package/dist/{chunk-73N5SLQ5.mjs → chunk-MGNW6NK2.mjs} +82 -25
  8. package/dist/{chunk-FZPMIQTC.mjs → chunk-OZGNQAK5.mjs} +2 -1
  9. package/dist/{chunk-VK7QDWXR.mjs → chunk-PTKS3BYW.mjs} +18 -5
  10. package/dist/{chunk-V52XUOVW.mjs → chunk-SBD2AUDA.mjs} +10 -2
  11. package/dist/{chunk-GVMGRBDI.mjs → chunk-TNDDXUVW.mjs} +5 -1
  12. package/dist/{chunk-WBMECFO3.mjs → chunk-X25J3BAC.mjs} +18 -46
  13. package/dist/{chunk-HF36L4GZ.mjs → chunk-ZAXJ3BEP.mjs} +2 -0
  14. package/dist/{chunk-5IPS4HT7.mjs → chunk-ZRAXSVO5.mjs} +1 -1
  15. package/dist/editor-toolbar.d.mts +9 -5
  16. package/dist/editor-toolbar.d.ts +9 -5
  17. package/dist/editor-toolbar.js +193 -92
  18. package/dist/editor-toolbar.mjs +7 -7
  19. package/dist/extensions/align-extension.js +75 -21
  20. package/dist/extensions/align-extension.mjs +2 -2
  21. package/dist/extensions/color-extension.js +69 -0
  22. package/dist/extensions/color-extension.mjs +2 -2
  23. package/dist/extensions/heading-extension.js +85 -45
  24. package/dist/extensions/heading-extension.mjs +2 -2
  25. package/dist/extensions/icons.d.mts +5 -1
  26. package/dist/extensions/icons.d.ts +5 -1
  27. package/dist/extensions/icons.js +76 -0
  28. package/dist/extensions/icons.mjs +9 -1
  29. package/dist/extensions/index.js +115 -71
  30. package/dist/extensions/index.mjs +6 -6
  31. package/dist/extensions/link-extension.js +85 -4
  32. package/dist/extensions/link-extension.mjs +2 -2
  33. package/dist/extensions/mention-list-extension.d.mts +33 -0
  34. package/dist/extensions/mention-list-extension.d.ts +33 -0
  35. package/dist/extensions/mention-list-extension.js +194 -0
  36. package/dist/extensions/mention-list-extension.mjs +7 -0
  37. package/dist/extensions/single-extension.d.mts +1 -1
  38. package/dist/extensions/single-extension.d.ts +1 -1
  39. package/dist/extensions/single-extension.js +73 -1
  40. package/dist/extensions/single-extension.mjs +2 -2
  41. package/dist/index.d.mts +1 -1
  42. package/dist/index.d.ts +1 -1
  43. package/dist/index.js +552 -104
  44. package/dist/index.mjs +14 -12
  45. package/dist/metafile-cjs.json +1 -1
  46. package/dist/metafile-esm.json +1 -1
  47. package/dist/modules/rich-text-editor.connects.js +2 -0
  48. package/dist/modules/rich-text-editor.connects.mjs +1 -1
  49. package/dist/modules/rich-text-editor.hooks.js +2 -0
  50. package/dist/modules/rich-text-editor.hooks.mjs +2 -2
  51. package/dist/modules/rich-text-editor.props.d.mts +7 -3
  52. package/dist/modules/rich-text-editor.props.d.ts +7 -3
  53. package/dist/modules/rich-text-editor.props.js +5 -1
  54. package/dist/modules/rich-text-editor.props.mjs +1 -1
  55. package/dist/modules/rich-text-editor.types.d.mts +18 -4
  56. package/dist/modules/rich-text-editor.types.d.ts +18 -4
  57. package/dist/rich-text-editor.d.mts +15 -4
  58. package/dist/rich-text-editor.d.ts +15 -4
  59. package/dist/rich-text-editor.js +552 -104
  60. package/dist/rich-text-editor.mjs +14 -12
  61. package/dist/rte-style-provider.js +1 -1
  62. package/dist/rte-style-provider.mjs +4 -4
  63. package/dist/rte-suggestion.d.mts +7 -0
  64. package/dist/rte-suggestion.d.ts +7 -0
  65. package/dist/rte-suggestion.js +354 -0
  66. package/dist/rte-suggestion.mjs +8 -0
  67. package/package.json +15 -11
@@ -0,0 +1,168 @@
1
+ import {
2
+ MentionList
3
+ } from "./chunk-4TUA5VF4.mjs";
4
+ import {
5
+ __name
6
+ } from "./chunk-QZ7VFGWC.mjs";
7
+
8
+ // src/rte-suggestion.ts
9
+ import { VueRenderer } from "@tiptap/vue-3";
10
+ import { createPopper } from "@popperjs/core";
11
+ var MAX_SUGGESTION_ITEMS = 10;
12
+ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query) => {
13
+ const normalizedQuery = query.trim().toLowerCase();
14
+ return items.filter((item) => {
15
+ var _a, _b;
16
+ if (!normalizedQuery) {
17
+ return true;
18
+ }
19
+ const id = item.id.toLowerCase();
20
+ const label = ((_a = item.name) != null ? _a : "").toLowerCase();
21
+ const description = ((_b = item.description) != null ? _b : "").toLowerCase();
22
+ return id.includes(normalizedQuery) || label.includes(normalizedQuery) || description.includes(normalizedQuery);
23
+ }).slice(0, MAX_SUGGESTION_ITEMS);
24
+ }, "getFilteredSuggestionItems");
25
+ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () => []) => {
26
+ return {
27
+ items: ({
28
+ query
29
+ }) => {
30
+ return getFilteredSuggestionItems(getSuggestionItems(), query);
31
+ },
32
+ render: () => {
33
+ let component = null;
34
+ let popperInstance = null;
35
+ let popoverWrapper = null;
36
+ let clientRectProvider;
37
+ let editorElement = null;
38
+ let removeOutsideListeners = null;
39
+ const destroyMentionPopover = /* @__PURE__ */ __name(() => {
40
+ removeOutsideListeners == null ? void 0 : removeOutsideListeners();
41
+ removeOutsideListeners = null;
42
+ popperInstance == null ? void 0 : popperInstance.destroy();
43
+ popperInstance = null;
44
+ popoverWrapper == null ? void 0 : popoverWrapper.remove();
45
+ popoverWrapper = null;
46
+ component == null ? void 0 : component.destroy();
47
+ component = null;
48
+ }, "destroyMentionPopover");
49
+ const isWithinMentionContext = /* @__PURE__ */ __name((target) => {
50
+ if (!(target instanceof Node)) {
51
+ return false;
52
+ }
53
+ return Boolean((editorElement == null ? void 0 : editorElement.contains(target)) || (popoverWrapper == null ? void 0 : popoverWrapper.contains(target)));
54
+ }, "isWithinMentionContext");
55
+ const setupOutsideListeners = /* @__PURE__ */ __name(() => {
56
+ if (!editorElement || removeOutsideListeners) {
57
+ return;
58
+ }
59
+ const handleDocumentFocusIn = /* @__PURE__ */ __name((event) => {
60
+ if (!isWithinMentionContext(event.target)) {
61
+ destroyMentionPopover();
62
+ }
63
+ }, "handleDocumentFocusIn");
64
+ const handleDocumentPointerDown = /* @__PURE__ */ __name((event) => {
65
+ if (!isWithinMentionContext(event.target)) {
66
+ destroyMentionPopover();
67
+ }
68
+ }, "handleDocumentPointerDown");
69
+ const handleEditorFocusOut = /* @__PURE__ */ __name((event) => {
70
+ if (!isWithinMentionContext(event.relatedTarget)) {
71
+ destroyMentionPopover();
72
+ }
73
+ }, "handleEditorFocusOut");
74
+ document.addEventListener("focusin", handleDocumentFocusIn);
75
+ document.addEventListener("mousedown", handleDocumentPointerDown, true);
76
+ document.addEventListener("touchstart", handleDocumentPointerDown, true);
77
+ editorElement.addEventListener("focusout", handleEditorFocusOut);
78
+ removeOutsideListeners = /* @__PURE__ */ __name(() => {
79
+ document.removeEventListener("focusin", handleDocumentFocusIn);
80
+ document.removeEventListener("mousedown", handleDocumentPointerDown, true);
81
+ document.removeEventListener("touchstart", handleDocumentPointerDown, true);
82
+ editorElement == null ? void 0 : editorElement.removeEventListener("focusout", handleEditorFocusOut);
83
+ }, "removeOutsideListeners");
84
+ }, "setupOutsideListeners");
85
+ const getVirtualElement = /* @__PURE__ */ __name(() => {
86
+ if (!clientRectProvider) {
87
+ return null;
88
+ }
89
+ return {
90
+ getBoundingClientRect: () => {
91
+ var _a;
92
+ return (_a = clientRectProvider == null ? void 0 : clientRectProvider()) != null ? _a : new DOMRect();
93
+ }
94
+ };
95
+ }, "getVirtualElement");
96
+ const updatePopoverPosition = /* @__PURE__ */ __name(() => {
97
+ const virtualElement = getVirtualElement();
98
+ if (!virtualElement || !popoverWrapper) {
99
+ return;
100
+ }
101
+ if (!popperInstance) {
102
+ popperInstance = createPopper(virtualElement, popoverWrapper, {
103
+ placement: "bottom-start",
104
+ modifiers: [{
105
+ name: "offset",
106
+ options: {
107
+ offset: [0, 8]
108
+ }
109
+ }, {
110
+ name: "flip",
111
+ options: {
112
+ fallbackPlacements: ["top-start"]
113
+ }
114
+ }]
115
+ });
116
+ return;
117
+ }
118
+ popperInstance.update();
119
+ }, "updatePopoverPosition");
120
+ return {
121
+ onStart: (props) => {
122
+ clientRectProvider = props.clientRect;
123
+ editorElement = props.editor.view.dom;
124
+ component = new VueRenderer(MentionList, {
125
+ editor: props.editor,
126
+ props: {
127
+ items: props.items,
128
+ command: props.command
129
+ }
130
+ });
131
+ popoverWrapper = document.createElement("div");
132
+ popoverWrapper.style.position = "absolute";
133
+ popoverWrapper.style.zIndex = "var(--mp-z-index-popover)";
134
+ if (component.element) {
135
+ popoverWrapper.append(component.element);
136
+ }
137
+ document.body.append(popoverWrapper);
138
+ setupOutsideListeners();
139
+ updatePopoverPosition();
140
+ },
141
+ onUpdate: (props) => {
142
+ clientRectProvider = props.clientRect;
143
+ component == null ? void 0 : component.updateProps({
144
+ items: props.items,
145
+ command: props.command
146
+ });
147
+ updatePopoverPosition();
148
+ },
149
+ onKeyDown: (props) => {
150
+ var _a, _b;
151
+ if (props.event.key === "Escape") {
152
+ destroyMentionPopover();
153
+ return true;
154
+ }
155
+ return (_b = (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props)) != null ? _b : false;
156
+ },
157
+ onExit: () => {
158
+ destroyMentionPopover();
159
+ editorElement = null;
160
+ }
161
+ };
162
+ }
163
+ };
164
+ }, "createMentionSuggestion");
165
+
166
+ export {
167
+ createMentionSuggestion
168
+ };
@@ -3,7 +3,7 @@ import {
3
3
  AlignJustifyIcon,
4
4
  AlignLeftIcon,
5
5
  AlignRightIcon
6
- } from "./chunk-RNQQ7LGC.mjs";
6
+ } from "./chunk-C7IUW3FX.mjs";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-QZ7VFGWC.mjs";
@@ -33,7 +33,8 @@ var AlignExtention = defineComponent({
33
33
  });
34
34
  }, "isActiveAlignment");
35
35
  return () => _createVNode(MpPopover, {
36
- "id": "popover-align-extention"
36
+ "id": "popover-align-extention",
37
+ "usePortal": true
37
38
  }, {
38
39
  default: () => [_createVNode(MpPopoverTrigger, null, {
39
40
  default: () => [_withDirectives(_createVNode("button", {
@@ -55,40 +56,25 @@ var AlignExtention = defineComponent({
55
56
  })
56
57
  }, {
57
58
  default: () => [_createVNode(MpPopoverList, {
58
- "class": css({
59
- gap: "2",
60
- alignItems: "center"
61
- })
59
+ "data-pixel-rte": true
62
60
  }, {
63
61
  default: () => [_createVNode(MpPopoverListItem, {
64
- "class": {
65
- "is-active": isActiveAlignment("left"),
66
- "text-sizing": true
67
- },
62
+ "is-active": isActiveAlignment("left"),
68
63
  "onClick": () => (editor == null ? void 0 : editor.chain()).focus().setTextAlign("left").run()
69
64
  }, {
70
65
  default: () => [_createVNode(AlignLeftIcon, null, null)]
71
66
  }), _createVNode(MpPopoverListItem, {
72
- "class": {
73
- "is-active": isActiveAlignment("center"),
74
- "text-sizing": true
75
- },
67
+ "is-active": isActiveAlignment("center"),
76
68
  "onClick": () => (editor == null ? void 0 : editor.chain()).focus().setTextAlign("center").run()
77
69
  }, {
78
70
  default: () => [_createVNode(AlignCenterIcon, null, null)]
79
71
  }), _createVNode(MpPopoverListItem, {
80
- "class": {
81
- "is-active": isActiveAlignment("right"),
82
- "text-sizing": true
83
- },
72
+ "is-active": isActiveAlignment("right"),
84
73
  "onClick": () => (editor == null ? void 0 : editor.chain()).focus().setTextAlign("right").run()
85
74
  }, {
86
75
  default: () => [_createVNode(AlignRightIcon, null, null)]
87
76
  }), _createVNode(MpPopoverListItem, {
88
- "class": {
89
- "is-active": isActiveAlignment("justify"),
90
- "text-sizing": true
91
- },
77
+ "is-active": isActiveAlignment("justify"),
92
78
  "onClick": () => (editor == null ? void 0 : editor.chain()).focus().setTextAlign("justify").run()
93
79
  }, {
94
80
  default: () => [_createVNode(AlignJustifyIcon, null, null)]
@@ -0,0 +1,173 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-QZ7VFGWC.mjs";
4
+
5
+ // src/extensions/mention-list-extension.tsx
6
+ import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
7
+ import { defineComponent, nextTick, ref, watch } from "vue";
8
+ import { css } from "@mekari/pixel3-styled-system/css";
9
+ import { MpAvatar } from "@mekari/pixel3-avatar";
10
+ import { MpPopover, MpPopoverContent, MpPopoverList, MpPopoverListItem } from "@mekari/pixel3-popover";
11
+ import { MpText } from "@mekari/pixel3-text";
12
+ var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
13
+ var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
14
+ return avatarVariantColors[index % avatarVariantColors.length];
15
+ }, "getAvatarVariantColor");
16
+ var MentionList = defineComponent({
17
+ name: "MentionList",
18
+ props: {
19
+ items: {
20
+ type: Array,
21
+ default: () => []
22
+ },
23
+ command: {
24
+ type: Function,
25
+ required: true
26
+ }
27
+ },
28
+ setup(props, {
29
+ expose
30
+ }) {
31
+ const selectedIndex = ref(0);
32
+ const listRef = ref(null);
33
+ const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
34
+ nextTick(() => {
35
+ if (!listRef.value)
36
+ return;
37
+ const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
38
+ if (targetItem) {
39
+ targetItem.scrollIntoView({
40
+ block: "nearest"
41
+ });
42
+ }
43
+ });
44
+ }, "scrollToFocusedItem");
45
+ watch(() => props.items, () => {
46
+ selectedIndex.value = 0;
47
+ });
48
+ const onSelect = /* @__PURE__ */ __name((index) => {
49
+ const item = props.items[index];
50
+ if (item) {
51
+ props.command({
52
+ ...item,
53
+ label: item.name
54
+ });
55
+ }
56
+ }, "onSelect");
57
+ const onKeyDown = /* @__PURE__ */ __name(({
58
+ event
59
+ }) => {
60
+ if (!props.items.length) {
61
+ return false;
62
+ }
63
+ if (event.key === "ArrowUp") {
64
+ event.preventDefault();
65
+ const total = props.items.length;
66
+ selectedIndex.value = (selectedIndex.value + total - 1) % total;
67
+ scrollToFocusedItem();
68
+ return true;
69
+ }
70
+ if (event.key === "ArrowDown") {
71
+ event.preventDefault();
72
+ selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
73
+ scrollToFocusedItem();
74
+ return true;
75
+ }
76
+ if (event.key === "Enter") {
77
+ event.preventDefault();
78
+ onSelect(selectedIndex.value);
79
+ return true;
80
+ }
81
+ return false;
82
+ }, "onKeyDown");
83
+ expose({
84
+ onKeyDown
85
+ });
86
+ return () => _createVNode(MpPopover, {
87
+ "id": "popover-rte-mention-list",
88
+ "is-manual": true,
89
+ "is-default-open": true,
90
+ "is-open": true
91
+ }, {
92
+ default: () => [_createVNode(MpPopoverContent, {
93
+ "class": css({
94
+ width: "280px",
95
+ maxHeight: "284px",
96
+ overflowY: "auto"
97
+ })
98
+ }, {
99
+ default: () => [_createVNode(MpPopoverList, {
100
+ "ref": (element) => {
101
+ var _a;
102
+ if (!element) {
103
+ listRef.value = null;
104
+ return;
105
+ }
106
+ listRef.value = (_a = element.$el) != null ? _a : element;
107
+ },
108
+ "data-pixel-rte": true
109
+ }, {
110
+ default: () => [!props.items.length && _createVNode(MpText, {
111
+ "color": "text.secondary",
112
+ "class": css({
113
+ px: "3",
114
+ py: "2"
115
+ })
116
+ }, {
117
+ default: () => [_createTextVNode("No result")]
118
+ }), props.items.map((item, index) => {
119
+ return _createVNode(MpPopoverListItem, {
120
+ "key": `${item.id}-${index}`,
121
+ "is-active": selectedIndex.value === index,
122
+ "onMousedown": (event) => event.preventDefault(),
123
+ "onMouseenter": () => {
124
+ selectedIndex.value = index;
125
+ },
126
+ "onClick": () => {
127
+ onSelect(index);
128
+ }
129
+ }, {
130
+ default: () => [_createVNode("div", {
131
+ "class": css({
132
+ display: "flex",
133
+ alignItems: "center",
134
+ gap: "2",
135
+ width: "full",
136
+ minWidth: "0"
137
+ })
138
+ }, [item.avatar && _createVNode(MpAvatar, {
139
+ "id": `avatar-rte-mention-${index}`,
140
+ "name": item.avatar,
141
+ "size": "lg",
142
+ "variant-color": getAvatarVariantColor(index)
143
+ }, null), _createVNode("div", {
144
+ "class": css({
145
+ display: "flex",
146
+ flexDirection: "column",
147
+ alignItems: "flex-start",
148
+ minWidth: "0",
149
+ flex: "1 1 0%"
150
+ })
151
+ }, [_createVNode(MpText, {
152
+ "size": "label",
153
+ "is-truncated": true
154
+ }, {
155
+ default: () => [item.name || "Unknown"]
156
+ }), item.description && _createVNode(MpText, {
157
+ "size": "label-small",
158
+ "color": "text.secondary",
159
+ "is-truncated": true
160
+ }, {
161
+ default: () => [item.description]
162
+ })])])]
163
+ });
164
+ })]
165
+ })]
166
+ })]
167
+ });
168
+ }
169
+ });
170
+
171
+ export {
172
+ MentionList
173
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  useRTEStyleProvider
3
- } from "./chunk-5IPS4HT7.mjs";
3
+ } from "./chunk-ZRAXSVO5.mjs";
4
4
  import {
5
5
  RTEStyleProviderProps
6
- } from "./chunk-GVMGRBDI.mjs";
6
+ } from "./chunk-TNDDXUVW.mjs";
7
7
 
8
8
  // src/rte-style-provider.tsx
9
9
  import { createVNode as _createVNode } from "vue";
@@ -319,6 +319,74 @@ var CaretIcon = defineComponent({
319
319
  }, null)]);
320
320
  }
321
321
  });
322
+ var ImageIcon = defineComponent({
323
+ name: "ImageIcon",
324
+ setup() {
325
+ return () => _createVNode("svg", {
326
+ "xmlns": "http://www.w3.org/2000/svg",
327
+ "width": "20",
328
+ "height": "20",
329
+ "viewBox": "0 0 20 20",
330
+ "fill": "none"
331
+ }, [_createVNode("path", {
332
+ "fill-rule": "evenodd",
333
+ "clip-rule": "evenodd",
334
+ "d": "M9.13948 1.25H10.8605C12.3328 1.24998 13.5133 1.24997 14.4405 1.37376C15.4002 1.50189 16.2001 1.77481 16.8347 2.4051C17.4701 3.03609 17.7459 3.83259 17.8753 4.78811C18 5.70986 18 6.88312 18 8.34439V11.6556C18 13.1169 18 14.2901 17.8753 15.2119C17.7459 16.1674 17.4701 16.9639 16.8347 17.5949C16.2001 18.2252 15.4002 18.4981 14.4405 18.6262C13.5133 18.75 12.3328 18.75 10.8605 18.75H9.13947C7.66718 18.75 6.48666 18.75 5.55953 18.6262C4.59985 18.4981 3.79994 18.2252 3.16528 17.5949C2.58896 17.0226 2.30764 16.313 2.16398 15.4695C1.99993 14.5064 1.99996 13.2565 2 11.6731L2 8.34442C1.99998 6.88313 1.99997 5.70987 2.12475 4.78811C2.25411 3.83259 2.5299 3.03609 3.16528 2.4051C3.79994 1.77481 4.59985 1.50189 5.55953 1.37376C6.48666 1.24997 7.66719 1.24998 9.13948 1.25ZM5.75805 2.86056C4.96282 2.96674 4.53137 3.16245 4.22226 3.46942C3.91387 3.77568 3.71778 4.20206 3.61119 4.98935C3.50162 5.79875 3.5 6.87016 3.5 8.4V11.6C3.5 12.5721 3.50087 13.3576 3.52902 14.0064L6.03954 12.2878C6.94782 11.6827 8.2354 11.7423 9.0689 12.4535L9.07527 12.4589L9.33734 12.6877C9.68567 12.9822 10.2858 12.9815 10.6328 12.6855L13.984 9.82945C14.6747 9.24036 15.6655 9.09888 16.5 9.40545V8.4C16.5 6.87016 16.4984 5.79875 16.3888 4.98935C16.2822 4.20206 16.0861 3.77568 15.7777 3.46942C15.4686 3.16245 15.0372 2.96674 14.242 2.86056C13.4257 2.75157 12.3456 2.75 10.8056 2.75H9.19445C7.65442 2.75 6.57433 2.75157 5.75805 2.86056ZM16.2474 10.9638L16.5 11.1945V11.6C16.5 13.1298 16.4984 14.2013 16.3888 15.0107C16.2822 15.7979 16.0861 16.2243 15.7777 16.5306C15.4686 16.8376 15.0372 17.0333 14.242 17.1394C13.4257 17.2484 12.3456 17.25 10.8056 17.25H9.19445C7.65442 17.25 6.57433 17.2484 5.75805 17.1394C4.96282 17.0333 4.53137 16.8376 4.22226 16.5306C4.01416 16.3239 3.85786 16.0633 3.74539 15.6761L6.87456 13.534C7.23802 13.2943 7.78269 13.3303 8.09262 13.5923L8.35477 13.8211L8.36118 13.8266C9.26993 14.6019 10.6976 14.6019 11.6063 13.8266L14.9572 10.9709C15.3024 10.6764 15.8983 10.6739 16.2474 10.9638ZM5.22222 6.8C5.22222 5.49725 6.28423 4.45 7.58334 4.45C8.88244 4.45 9.94445 5.49725 9.94445 6.8C9.94445 8.10276 8.88244 9.15 7.58334 9.15C6.28423 9.15 5.22222 8.10276 5.22222 6.8Z",
335
+ "fill": "currentColor"
336
+ }, null)]);
337
+ }
338
+ });
339
+ var FileIcon = defineComponent({
340
+ name: "FileIcon",
341
+ setup() {
342
+ return () => _createVNode("svg", {
343
+ "xmlns": "http://www.w3.org/2000/svg",
344
+ "width": "18",
345
+ "height": "17",
346
+ "viewBox": "0 0 18 17",
347
+ "fill": "none"
348
+ }, [_createVNode("path", {
349
+ "fill-rule": "evenodd",
350
+ "clip-rule": "evenodd",
351
+ "d": "M11.6901 2.47169C10.3906 1.1761 8.28282 1.1761 6.98332 2.47169L3.07076 6.37248C0.976415 8.46053 0.976415 11.845 3.07076 13.933C5.16636 16.0223 8.56492 16.0223 10.6605 13.933L16.2205 8.3898C16.5138 8.09734 16.9887 8.09806 17.2811 8.39139C17.5736 8.68473 17.5729 9.1596 17.2795 9.45205L11.7196 14.9953C9.03856 17.6682 4.69271 17.6682 2.0117 14.9953C-0.670564 12.3211 -0.670564 7.98442 2.0117 5.31022L5.92426 1.40943C7.80917 -0.469814 10.8643 -0.469812 12.7492 1.40943C14.6354 3.28992 14.6354 6.33973 12.7492 8.22022L8.83664 12.121C7.74783 13.2066 5.98345 13.2066 4.89464 12.121C3.80458 11.0342 3.80458 9.27127 4.89464 8.18449L8.8072 4.2837C9.10053 3.99125 9.5754 3.99196 9.86786 4.2853C10.1603 4.57863 10.1596 5.0535 9.86626 5.34596L5.9537 9.24675C5.45156 9.74738 5.45156 10.5581 5.9537 11.0588C6.45709 11.5606 7.27419 11.5606 7.77758 11.0588L11.6901 7.15797C12.9884 5.86363 12.9884 3.76603 11.6901 2.47169Z",
352
+ "fill": "currentColor"
353
+ }, null)]);
354
+ }
355
+ });
356
+ var AudioIcon = defineComponent({
357
+ name: "AudioIcon",
358
+ setup() {
359
+ return () => _createVNode("svg", {
360
+ "xmlns": "http://www.w3.org/2000/svg",
361
+ "width": "20",
362
+ "height": "20",
363
+ "viewBox": "0 0 20 20",
364
+ "fill": "none"
365
+ }, [_createVNode("path", {
366
+ "fill-rule": "evenodd",
367
+ "clip-rule": "evenodd",
368
+ "d": "M6.32334 4.94737C6.32334 2.91036 7.96446 1.25 10 1.25C12.0355 1.25 13.6767 2.91036 13.6767 4.94737V10C13.6767 12.037 12.0355 13.6974 10 13.6974C7.96446 13.6974 6.32334 12.037 6.32334 10V4.94737ZM10 2.75C8.80284 2.75 7.82334 3.7288 7.82334 4.94737V10C7.82334 11.2186 8.80284 12.1974 10 12.1974C11.1972 12.1974 12.1767 11.2186 12.1767 10V4.94737C12.1767 3.7288 11.1972 2.75 10 2.75ZM14.9948 9.67107C15.409 9.66825 15.7471 10.0017 15.7499 10.4159C15.7686 13.1719 13.4277 15.3958 10.75 15.7526L10.75 17.25H11.6724C12.0866 17.25 12.4224 17.5858 12.4224 18C12.4224 18.4142 12.0866 18.75 11.6724 18.75H8.3276C7.91339 18.75 7.5776 18.4142 7.5776 18C7.5776 17.5858 7.91339 17.25 8.3276 17.25H9.24997L9.24996 15.7526C6.57163 15.3957 4.25 13.1696 4.25 10.4211C4.25 10.0068 4.58579 9.67105 5 9.67105C5.41421 9.67105 5.75 10.0068 5.75 10.4211C5.75 12.4712 7.71926 14.3026 9.99995 14.3026C12.2856 14.3026 14.2638 12.4679 14.2499 10.4262C14.2471 10.012 14.5806 9.67389 14.9948 9.67107Z",
369
+ "fill": "currentColor"
370
+ }, null)]);
371
+ }
372
+ });
373
+ var MentionIcon = defineComponent({
374
+ name: "MentionIcon",
375
+ setup() {
376
+ return () => _createVNode("svg", {
377
+ "xmlns": "http://www.w3.org/2000/svg",
378
+ "width": "18",
379
+ "height": "18",
380
+ "viewBox": "0 0 18 18",
381
+ "fill": "none"
382
+ }, [_createVNode("path", {
383
+ "fill-rule": "evenodd",
384
+ "clip-rule": "evenodd",
385
+ "d": "M5.04155 0.82474C6.82687 -0.0106618 8.84196 -0.218789 10.7603 0.234079C12.6787 0.686946 14.388 1.77428 15.6112 3.3199C16.8345 4.86553 17.5 6.7789 17.5 8.75V9.55C17.5 10.3854 17.1681 11.1866 16.5774 11.7774C15.9866 12.3681 15.1854 12.7 14.35 12.7C13.5146 12.7 12.7134 12.3681 12.1226 11.7774C11.9824 11.6371 11.8567 11.485 11.7466 11.3234C11.0222 12.1662 9.94841 12.7 8.74991 12.7C6.56839 12.7 4.79991 10.9315 4.79991 8.74999C4.79991 6.56847 6.56839 4.79999 8.74991 4.79999C9.67546 4.79999 10.5267 5.11833 11.2 5.65148V5.55C11.2 5.13579 11.5358 4.8 11.95 4.8C12.3642 4.8 12.7 5.13579 12.7 5.55V9.55C12.7 9.98761 12.8738 10.4073 13.1833 10.7167C13.4927 11.0262 13.9124 11.2 14.35 11.2C14.7876 11.2 15.2073 11.0262 15.5167 10.7167C15.8262 10.4073 16 9.98761 16 9.55V8.75C16 7.1168 15.4486 5.53144 14.435 4.25078C13.4215 2.97012 12.0052 2.06919 10.4157 1.69395C8.8262 1.31872 7.15655 1.49117 5.67729 2.18336C4.19802 2.87555 2.9958 4.04692 2.26541 5.50771C1.53502 6.96849 1.31925 8.63309 1.65306 10.2318C1.98687 11.8305 2.85069 13.2697 4.10459 14.3162C5.35848 15.3627 6.92898 15.9551 8.56164 15.9976C10.1943 16.04 11.7934 15.5299 13.1 14.55C13.4314 14.3015 13.9015 14.3686 14.15 14.7C14.3985 15.0314 14.3314 15.5015 14 15.75C12.4231 16.9327 10.4931 17.5483 8.52266 17.497C6.55222 17.4458 4.65679 16.7308 3.14347 15.4678C1.63015 14.2048 0.587595 12.4679 0.184723 10.5384C-0.218148 8.6089 0.0422661 6.5999 0.923772 4.83689C1.80528 3.07387 3.25623 1.66014 5.04155 0.82474ZM8.74991 6.29999C7.39682 6.29999 6.29991 7.3969 6.29991 8.74999C6.29991 10.1031 7.39682 11.2 8.74991 11.2C10.103 11.2 11.1999 10.1031 11.1999 8.74999C11.1999 7.3969 10.103 6.29999 8.74991 6.29999Z",
386
+ "fill": "currentColor"
387
+ }, null)]);
388
+ }
389
+ });
322
390
 
323
391
  export {
324
392
  BoldIcon,
@@ -338,5 +406,9 @@ export {
338
406
  UndoIcon,
339
407
  RedoIcon,
340
408
  ClearIcon,
341
- CaretIcon
409
+ CaretIcon,
410
+ ImageIcon,
411
+ FileIcon,
412
+ AudioIcon,
413
+ MentionIcon
342
414
  };
@@ -1,16 +1,22 @@
1
1
  import {
2
2
  EditorToolbar
3
- } from "./chunk-73N5SLQ5.mjs";
3
+ } from "./chunk-MGNW6NK2.mjs";
4
4
  import {
5
5
  MpRTEStyleProvider
6
- } from "./chunk-2OCRJNTJ.mjs";
6
+ } from "./chunk-7RMCTPMN.mjs";
7
7
  import {
8
8
  useRichTextEditor
9
- } from "./chunk-5IPS4HT7.mjs";
9
+ } from "./chunk-ZRAXSVO5.mjs";
10
10
  import {
11
11
  richTextEditorEmits,
12
12
  richTextEditorProps
13
- } from "./chunk-GVMGRBDI.mjs";
13
+ } from "./chunk-TNDDXUVW.mjs";
14
+ import {
15
+ createMentionSuggestion
16
+ } from "./chunk-4KJOYLJI.mjs";
17
+ import {
18
+ __name
19
+ } from "./chunk-QZ7VFGWC.mjs";
14
20
 
15
21
  // src/rich-text-editor.tsx
16
22
  import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
@@ -23,6 +29,7 @@ import TextAlign from "@tiptap/extension-text-align";
23
29
  import TextStyle from "@tiptap/extension-text-style";
24
30
  import Placeholder from "@tiptap/extension-placeholder";
25
31
  import CharacterCount from "@tiptap/extension-character-count";
32
+ import Mention from "@tiptap/extension-mention";
26
33
  import { Color } from "@tiptap/extension-color";
27
34
  import Link from "@tiptap/extension-link";
28
35
  import Highlight from "@tiptap/extension-highlight";
@@ -37,7 +44,6 @@ var MpRichTextEditor = defineComponent({
37
44
  }) {
38
45
  const formControlProp = useFormControlContext();
39
46
  const api = useRichTextEditor(props);
40
- console.log(api.value);
41
47
  const isFocused = ref(false);
42
48
  const {
43
49
  isNextTheme
@@ -45,6 +51,12 @@ var MpRichTextEditor = defineComponent({
45
51
  const editor = new Editor({
46
52
  content: api.value.value,
47
53
  editable: (formControlProp == null ? void 0 : formControlProp.value.isDisabled) === void 0 ? !api.value.isDisabled : !(formControlProp == null ? void 0 : formControlProp.value.isDisabled),
54
+ editorProps: {
55
+ handlePaste(_view, event) {
56
+ emit("paste", event);
57
+ return false;
58
+ }
59
+ },
48
60
  extensions: [StarterKit.configure({
49
61
  heading: {
50
62
  levels: [1, 2, 3]
@@ -61,6 +73,8 @@ var MpRichTextEditor = defineComponent({
61
73
  placeholder: api.value.placeholder || ""
62
74
  }), CharacterCount.configure({
63
75
  limit: api.value.maxlength
76
+ }), Mention.configure({
77
+ suggestion: createMentionSuggestion(() => props.suggestions || [])
64
78
  })],
65
79
  onFocus({
66
80
  editor: editor2,
@@ -82,6 +96,9 @@ var MpRichTextEditor = defineComponent({
82
96
  emit("change", editor2.getHTML(), editor2);
83
97
  }
84
98
  });
99
+ const onClickToolbar = /* @__PURE__ */ __name((name) => {
100
+ emit("action", name);
101
+ }, "onClickToolbar");
85
102
  return () => {
86
103
  return _createVNode("div", _mergeProps(api.value.rootProps, {
87
104
  "style": {
@@ -93,7 +110,11 @@ var MpRichTextEditor = defineComponent({
93
110
  }), [_createVNode(EditorToolbar, _mergeProps({
94
111
  "editor": editor,
95
112
  "options": api.value.options
96
- }, api.value.toolbarProps), null), _createVNode(MpRTEStyleProvider, {
113
+ }, api.value.toolbarProps, {
114
+ "onClickImage": () => onClickToolbar("image"),
115
+ "onClickFile": () => onClickToolbar("file"),
116
+ "onClickAudio": () => onClickToolbar("audio")
117
+ }), null), _createVNode(MpRTEStyleProvider, {
97
118
  "id": `${api.value.id}-style-provider`
98
119
  }, {
99
120
  default: () => [_createVNode(EditorContent, _mergeProps({