@mekari/pixel3-rich-text-editor 0.2.1-dev.0 → 0.3.0-dev.2

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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-ZRAXSVO5.mjs";
4
4
  import {
5
5
  RTEStyleProviderProps
6
- } from "./chunk-B5BN5T5O.mjs";
6
+ } from "./chunk-QJYUKM5Q.mjs";
7
7
 
8
8
  // src/rte-style-provider.tsx
9
9
  import { createVNode as _createVNode } from "vue";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MentionList
3
- } from "./chunk-ELFAGDKG.mjs";
3
+ } from "./chunk-NC3P3FRE.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-QZ7VFGWC.mjs";
@@ -22,21 +22,24 @@ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query, maxItems)
22
22
  }).slice(0, maxItems);
23
23
  }, "getFilteredSuggestionItems");
24
24
  var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () => [], options = {}) => {
25
- var _a;
25
+ var _a, _b;
26
26
  const maxItems = (_a = options.maxItems) != null ? _a : 50;
27
+ const emptyTextOption = (_b = options.emptyText) != null ? _b : "No result";
28
+ const resolveEmptyText = /* @__PURE__ */ __name((query) => typeof emptyTextOption === "function" ? emptyTextOption(query) : emptyTextOption, "resolveEmptyText");
29
+ let latestRequestId = 0;
27
30
  return {
28
31
  items: async ({
29
32
  query
30
33
  }) => {
31
- var _a2, _b, _c;
34
+ var _a2, _b2;
35
+ const requestId = ++latestRequestId;
32
36
  const source = getSuggestionSource();
33
- if (typeof source === "function") {
34
- const items2 = ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems);
35
- (_b = options.onSuggestionsChange) == null ? void 0 : _b.call(options, items2);
36
- return items2;
37
+ const items = typeof source === "function" ? ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems) : getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
38
+ if (requestId !== latestRequestId) {
39
+ return new Promise(() => {
40
+ });
37
41
  }
38
- const items = getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
39
- (_c = options.onSuggestionsChange) == null ? void 0 : _c.call(options, items);
42
+ (_b2 = options.onSuggestionsChange) == null ? void 0 : _b2.call(options, items);
40
43
  return items;
41
44
  },
42
45
  render: () => {
@@ -139,7 +142,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
139
142
  props: {
140
143
  items: [],
141
144
  command: props.command,
142
- isLoading: true
145
+ isLoading: true,
146
+ emptyText: resolveEmptyText(props.query)
143
147
  }
144
148
  });
145
149
  popoverWrapper = document.createElement("div");
@@ -157,7 +161,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
157
161
  component == null ? void 0 : component.updateProps({
158
162
  items: props.items,
159
163
  command: props.command,
160
- isLoading: false
164
+ isLoading: false,
165
+ emptyText: resolveEmptyText(props.query)
161
166
  });
162
167
  updatePopoverPosition();
163
168
  },
@@ -174,17 +179,18 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
174
179
  component == null ? void 0 : component.updateProps({
175
180
  items: props.items,
176
181
  command: props.command,
177
- isLoading: false
182
+ isLoading: false,
183
+ emptyText: resolveEmptyText(props.query)
178
184
  });
179
185
  updatePopoverPosition();
180
186
  },
181
187
  onKeyDown: (props) => {
182
- var _a2, _b;
188
+ var _a2, _b2;
183
189
  if (props.event.key === "Escape") {
184
190
  destroyMentionPopover();
185
191
  return true;
186
192
  }
187
- return (_b = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b : false;
193
+ return (_b2 = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b2 : false;
188
194
  },
189
195
  onExit: () => {
190
196
  destroyMentionPopover();
@@ -6,17 +6,17 @@ import {
6
6
  } from "./chunk-ENKUUZPM.mjs";
7
7
  import {
8
8
  MpRTEStyleProvider
9
- } from "./chunk-RVXAG7LK.mjs";
9
+ } from "./chunk-6SZJ4DXO.mjs";
10
10
  import {
11
11
  useRichTextEditor
12
12
  } from "./chunk-ZRAXSVO5.mjs";
13
13
  import {
14
14
  richTextEditorEmits,
15
15
  richTextEditorProps
16
- } from "./chunk-B5BN5T5O.mjs";
16
+ } from "./chunk-QJYUKM5Q.mjs";
17
17
  import {
18
18
  createMentionSuggestion
19
- } from "./chunk-RTEK53TL.mjs";
19
+ } from "./chunk-7T3KAUCV.mjs";
20
20
  import {
21
21
  createVariableSuggestion
22
22
  } from "./chunk-BWRU2WZN.mjs";
@@ -100,6 +100,7 @@ var MpRichTextEditor = defineComponent({
100
100
  ...typeof props.suggestions === "function" || props.suggestions && props.suggestions.length > 0 ? [Mention.configure({
101
101
  suggestion: createMentionSuggestion(() => props.suggestions, {
102
102
  maxItems: props.maxSuggestions,
103
+ emptyText: props.mentionEmptyText,
103
104
  onSuggestionsChange: (items) => emit("suggestionsChange", items)
104
105
  })
105
106
  })] : [],
@@ -3,13 +3,14 @@ import {
3
3
  } from "./chunk-QZ7VFGWC.mjs";
4
4
 
5
5
  // src/extensions/mention-list-extension.tsx
6
- import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
7
- import { defineComponent, nextTick, ref, watch } from "vue";
6
+ import { createVNode as _createVNode } from "vue";
7
+ import { computed, defineComponent, nextTick, ref, watch } from "vue";
8
8
  import { css } from "@mekari/pixel3-styled-system/css";
9
9
  import { MpAvatar } from "@mekari/pixel3-avatar";
10
10
  import { MpPopover, MpPopoverContent, MpPopoverList, MpPopoverListItem } from "@mekari/pixel3-popover";
11
11
  import { MpText } from "@mekari/pixel3-text";
12
- import { MpSpinner } from "@mekari/pixel3-spinner";
12
+ import { MpSkeleton } from "@mekari/pixel3-skeleton";
13
+ var SKELETON_ROW_COUNT = 3;
13
14
  var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
14
15
  var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
15
16
  return avatarVariantColors[index % avatarVariantColors.length];
@@ -28,6 +29,10 @@ var MentionList = defineComponent({
28
29
  isLoading: {
29
30
  type: Boolean,
30
31
  default: false
32
+ },
33
+ emptyText: {
34
+ type: String,
35
+ default: "No result"
31
36
  }
32
37
  },
33
38
  setup(props, {
@@ -35,6 +40,16 @@ var MentionList = defineComponent({
35
40
  }) {
36
41
  const selectedIndex = ref(0);
37
42
  const listRef = ref(null);
43
+ const hasResolvedNonEmptyBatch = ref(false);
44
+ watch(() => props.items, (items) => {
45
+ if (items.length > 0) {
46
+ hasResolvedNonEmptyBatch.value = true;
47
+ }
48
+ }, {
49
+ immediate: true
50
+ });
51
+ const hasAvatarData = computed(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.avatar));
52
+ const hasDescriptionData = computed(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.description));
38
53
  const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
39
54
  nextTick(() => {
40
55
  if (!listRef.value)
@@ -115,20 +130,54 @@ var MentionList = defineComponent({
115
130
  default: () => [props.isLoading && _createVNode("div", {
116
131
  "class": css({
117
132
  display: "flex",
118
- justifyContent: "center",
119
- px: "3",
120
- py: "3"
133
+ flexDirection: "column",
134
+ gap: "3",
135
+ p: "3",
136
+ width: "full"
137
+ })
138
+ }, [Array.from({
139
+ length: SKELETON_ROW_COUNT
140
+ }, (_, index) => _createVNode("div", {
141
+ "key": index,
142
+ "class": css({
143
+ display: "flex",
144
+ alignItems: "center",
145
+ gap: "2",
146
+ width: "full"
147
+ })
148
+ }, [hasAvatarData.value && _createVNode(MpSkeleton, {
149
+ "class": css({
150
+ width: "9",
151
+ height: "9",
152
+ rounded: "full"
153
+ })
154
+ }, null), _createVNode("div", {
155
+ "class": css({
156
+ display: "flex",
157
+ flexDirection: "column",
158
+ gap: "1",
159
+ width: "full"
160
+ })
161
+ }, [_createVNode(MpSkeleton, {
162
+ "class": css({
163
+ width: "40%",
164
+ height: "14px",
165
+ rounded: "sm"
166
+ })
167
+ }, null), hasDescriptionData.value && _createVNode(MpSkeleton, {
168
+ "class": css({
169
+ width: "70%",
170
+ height: "12px",
171
+ rounded: "sm"
121
172
  })
122
- }, [_createVNode(MpSpinner, {
123
- "size": "sm"
124
- }, null)]), !props.isLoading && !props.items.length && _createVNode(MpText, {
173
+ }, null)])]))]), !props.isLoading && !props.items.length && _createVNode(MpText, {
125
174
  "color": "text.secondary",
126
175
  "class": css({
127
176
  px: "3",
128
177
  py: "2"
129
178
  })
130
179
  }, {
131
- default: () => [_createTextVNode("No result")]
180
+ default: () => [props.emptyText]
132
181
  }), !props.isLoading && props.items.map((item, index) => {
133
182
  return _createVNode(MpPopoverListItem, {
134
183
  "key": `${item.id}-${index}`,
@@ -36,6 +36,10 @@ var richTextEditorProps = {
36
36
  type: Number,
37
37
  default: 50
38
38
  },
39
+ mentionEmptyText: {
40
+ type: [String, Function],
41
+ default: "No result"
42
+ },
39
43
  variables: {
40
44
  type: Array,
41
45
  default: () => []
@@ -19,6 +19,10 @@ declare const MentionList: vue.DefineComponent<{
19
19
  type: BooleanConstructor;
20
20
  default: boolean;
21
21
  };
22
+ emptyText: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
22
26
  }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
23
27
  items: {
24
28
  type: PropType<MentionSuggestionItem[]>;
@@ -34,9 +38,14 @@ declare const MentionList: vue.DefineComponent<{
34
38
  type: BooleanConstructor;
35
39
  default: boolean;
36
40
  };
41
+ emptyText: {
42
+ type: StringConstructor;
43
+ default: string;
44
+ };
37
45
  }>>, {
38
- isLoading: boolean;
39
46
  items: MentionSuggestionItem[];
47
+ emptyText: string;
48
+ isLoading: boolean;
40
49
  }, {}>;
41
50
 
42
51
  export { MentionList };
@@ -19,6 +19,10 @@ declare const MentionList: vue.DefineComponent<{
19
19
  type: BooleanConstructor;
20
20
  default: boolean;
21
21
  };
22
+ emptyText: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
22
26
  }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
23
27
  items: {
24
28
  type: PropType<MentionSuggestionItem[]>;
@@ -34,9 +38,14 @@ declare const MentionList: vue.DefineComponent<{
34
38
  type: BooleanConstructor;
35
39
  default: boolean;
36
40
  };
41
+ emptyText: {
42
+ type: StringConstructor;
43
+ default: string;
44
+ };
37
45
  }>>, {
38
- isLoading: boolean;
39
46
  items: MentionSuggestionItem[];
47
+ emptyText: string;
48
+ isLoading: boolean;
40
49
  }, {}>;
41
50
 
42
51
  export { MentionList };
@@ -30,7 +30,8 @@ var import_css = require("@mekari/pixel3-styled-system/css");
30
30
  var import_pixel3_avatar = require("@mekari/pixel3-avatar");
31
31
  var import_pixel3_popover = require("@mekari/pixel3-popover");
32
32
  var import_pixel3_text = require("@mekari/pixel3-text");
33
- var import_pixel3_spinner = require("@mekari/pixel3-spinner");
33
+ var import_pixel3_skeleton = require("@mekari/pixel3-skeleton");
34
+ var SKELETON_ROW_COUNT = 3;
34
35
  var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
35
36
  var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
36
37
  return avatarVariantColors[index % avatarVariantColors.length];
@@ -49,6 +50,10 @@ var MentionList = (0, import_vue2.defineComponent)({
49
50
  isLoading: {
50
51
  type: Boolean,
51
52
  default: false
53
+ },
54
+ emptyText: {
55
+ type: String,
56
+ default: "No result"
52
57
  }
53
58
  },
54
59
  setup(props, {
@@ -56,6 +61,16 @@ var MentionList = (0, import_vue2.defineComponent)({
56
61
  }) {
57
62
  const selectedIndex = (0, import_vue2.ref)(0);
58
63
  const listRef = (0, import_vue2.ref)(null);
64
+ const hasResolvedNonEmptyBatch = (0, import_vue2.ref)(false);
65
+ (0, import_vue2.watch)(() => props.items, (items) => {
66
+ if (items.length > 0) {
67
+ hasResolvedNonEmptyBatch.value = true;
68
+ }
69
+ }, {
70
+ immediate: true
71
+ });
72
+ const hasAvatarData = (0, import_vue2.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.avatar));
73
+ const hasDescriptionData = (0, import_vue2.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.description));
59
74
  const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
60
75
  (0, import_vue2.nextTick)(() => {
61
76
  if (!listRef.value)
@@ -136,20 +151,54 @@ var MentionList = (0, import_vue2.defineComponent)({
136
151
  default: () => [props.isLoading && (0, import_vue.createVNode)("div", {
137
152
  "class": (0, import_css.css)({
138
153
  display: "flex",
139
- justifyContent: "center",
140
- px: "3",
141
- py: "3"
154
+ flexDirection: "column",
155
+ gap: "3",
156
+ p: "3",
157
+ width: "full"
158
+ })
159
+ }, [Array.from({
160
+ length: SKELETON_ROW_COUNT
161
+ }, (_, index) => (0, import_vue.createVNode)("div", {
162
+ "key": index,
163
+ "class": (0, import_css.css)({
164
+ display: "flex",
165
+ alignItems: "center",
166
+ gap: "2",
167
+ width: "full"
168
+ })
169
+ }, [hasAvatarData.value && (0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
170
+ "class": (0, import_css.css)({
171
+ width: "9",
172
+ height: "9",
173
+ rounded: "full"
174
+ })
175
+ }, null), (0, import_vue.createVNode)("div", {
176
+ "class": (0, import_css.css)({
177
+ display: "flex",
178
+ flexDirection: "column",
179
+ gap: "1",
180
+ width: "full"
181
+ })
182
+ }, [(0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
183
+ "class": (0, import_css.css)({
184
+ width: "40%",
185
+ height: "14px",
186
+ rounded: "sm"
187
+ })
188
+ }, null), hasDescriptionData.value && (0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
189
+ "class": (0, import_css.css)({
190
+ width: "70%",
191
+ height: "12px",
192
+ rounded: "sm"
142
193
  })
143
- }, [(0, import_vue.createVNode)(import_pixel3_spinner.MpSpinner, {
144
- "size": "sm"
145
- }, null)]), !props.isLoading && !props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
194
+ }, null)])]))]), !props.isLoading && !props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
146
195
  "color": "text.secondary",
147
196
  "class": (0, import_css.css)({
148
197
  px: "3",
149
198
  py: "2"
150
199
  })
151
200
  }, {
152
- default: () => [(0, import_vue.createTextVNode)("No result")]
201
+ default: () => [props.emptyText]
153
202
  }), !props.isLoading && props.items.map((item, index) => {
154
203
  return (0, import_vue.createVNode)(import_pixel3_popover.MpPopoverListItem, {
155
204
  "key": `${item.id}-${index}`,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MentionList
3
- } from "../chunk-ELFAGDKG.mjs";
3
+ } from "../chunk-NC3P3FRE.mjs";
4
4
  import "../chunk-QZ7VFGWC.mjs";
5
5
  export {
6
6
  MentionList
package/dist/index.js CHANGED
@@ -79,6 +79,10 @@ var richTextEditorProps = {
79
79
  type: Number,
80
80
  default: 50
81
81
  },
82
+ mentionEmptyText: {
83
+ type: [String, Function],
84
+ default: "No result"
85
+ },
82
86
  variables: {
83
87
  type: Array,
84
88
  default: () => []
@@ -1813,7 +1817,8 @@ var import_css7 = require("@mekari/pixel3-styled-system/css");
1813
1817
  var import_pixel3_avatar = require("@mekari/pixel3-avatar");
1814
1818
  var import_pixel3_popover4 = require("@mekari/pixel3-popover");
1815
1819
  var import_pixel3_text3 = require("@mekari/pixel3-text");
1816
- var import_pixel3_spinner = require("@mekari/pixel3-spinner");
1820
+ var import_pixel3_skeleton = require("@mekari/pixel3-skeleton");
1821
+ var SKELETON_ROW_COUNT = 3;
1817
1822
  var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
1818
1823
  var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
1819
1824
  return avatarVariantColors[index % avatarVariantColors.length];
@@ -1832,6 +1837,10 @@ var MentionList = (0, import_vue21.defineComponent)({
1832
1837
  isLoading: {
1833
1838
  type: Boolean,
1834
1839
  default: false
1840
+ },
1841
+ emptyText: {
1842
+ type: String,
1843
+ default: "No result"
1835
1844
  }
1836
1845
  },
1837
1846
  setup(props, {
@@ -1839,6 +1848,16 @@ var MentionList = (0, import_vue21.defineComponent)({
1839
1848
  }) {
1840
1849
  const selectedIndex = (0, import_vue21.ref)(0);
1841
1850
  const listRef = (0, import_vue21.ref)(null);
1851
+ const hasResolvedNonEmptyBatch = (0, import_vue21.ref)(false);
1852
+ (0, import_vue21.watch)(() => props.items, (items) => {
1853
+ if (items.length > 0) {
1854
+ hasResolvedNonEmptyBatch.value = true;
1855
+ }
1856
+ }, {
1857
+ immediate: true
1858
+ });
1859
+ const hasAvatarData = (0, import_vue21.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.avatar));
1860
+ const hasDescriptionData = (0, import_vue21.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.description));
1842
1861
  const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
1843
1862
  (0, import_vue21.nextTick)(() => {
1844
1863
  if (!listRef.value)
@@ -1919,20 +1938,54 @@ var MentionList = (0, import_vue21.defineComponent)({
1919
1938
  default: () => [props.isLoading && (0, import_vue20.createVNode)("div", {
1920
1939
  "class": (0, import_css7.css)({
1921
1940
  display: "flex",
1922
- justifyContent: "center",
1923
- px: "3",
1924
- py: "3"
1941
+ flexDirection: "column",
1942
+ gap: "3",
1943
+ p: "3",
1944
+ width: "full"
1945
+ })
1946
+ }, [Array.from({
1947
+ length: SKELETON_ROW_COUNT
1948
+ }, (_, index) => (0, import_vue20.createVNode)("div", {
1949
+ "key": index,
1950
+ "class": (0, import_css7.css)({
1951
+ display: "flex",
1952
+ alignItems: "center",
1953
+ gap: "2",
1954
+ width: "full"
1955
+ })
1956
+ }, [hasAvatarData.value && (0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
1957
+ "class": (0, import_css7.css)({
1958
+ width: "9",
1959
+ height: "9",
1960
+ rounded: "full"
1961
+ })
1962
+ }, null), (0, import_vue20.createVNode)("div", {
1963
+ "class": (0, import_css7.css)({
1964
+ display: "flex",
1965
+ flexDirection: "column",
1966
+ gap: "1",
1967
+ width: "full"
1968
+ })
1969
+ }, [(0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
1970
+ "class": (0, import_css7.css)({
1971
+ width: "40%",
1972
+ height: "14px",
1973
+ rounded: "sm"
1974
+ })
1975
+ }, null), hasDescriptionData.value && (0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
1976
+ "class": (0, import_css7.css)({
1977
+ width: "70%",
1978
+ height: "12px",
1979
+ rounded: "sm"
1925
1980
  })
1926
- }, [(0, import_vue20.createVNode)(import_pixel3_spinner.MpSpinner, {
1927
- "size": "sm"
1928
- }, null)]), !props.isLoading && !props.items.length && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
1981
+ }, null)])]))]), !props.isLoading && !props.items.length && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
1929
1982
  "color": "text.secondary",
1930
1983
  "class": (0, import_css7.css)({
1931
1984
  px: "3",
1932
1985
  py: "2"
1933
1986
  })
1934
1987
  }, {
1935
- default: () => [(0, import_vue20.createTextVNode)("No result")]
1988
+ default: () => [props.emptyText]
1936
1989
  }), !props.isLoading && props.items.map((item, index) => {
1937
1990
  return (0, import_vue20.createVNode)(import_pixel3_popover4.MpPopoverListItem, {
1938
1991
  "key": `${item.id}-${index}`,
@@ -2001,21 +2054,24 @@ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query, maxItems)
2001
2054
  }).slice(0, maxItems);
2002
2055
  }, "getFilteredSuggestionItems");
2003
2056
  var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () => [], options = {}) => {
2004
- var _a;
2057
+ var _a, _b;
2005
2058
  const maxItems = (_a = options.maxItems) != null ? _a : 50;
2059
+ const emptyTextOption = (_b = options.emptyText) != null ? _b : "No result";
2060
+ const resolveEmptyText = /* @__PURE__ */ __name((query) => typeof emptyTextOption === "function" ? emptyTextOption(query) : emptyTextOption, "resolveEmptyText");
2061
+ let latestRequestId = 0;
2006
2062
  return {
2007
2063
  items: async ({
2008
2064
  query
2009
2065
  }) => {
2010
- var _a2, _b, _c;
2066
+ var _a2, _b2;
2067
+ const requestId = ++latestRequestId;
2011
2068
  const source = getSuggestionSource();
2012
- if (typeof source === "function") {
2013
- const items2 = ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems);
2014
- (_b = options.onSuggestionsChange) == null ? void 0 : _b.call(options, items2);
2015
- return items2;
2069
+ const items = typeof source === "function" ? ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems) : getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
2070
+ if (requestId !== latestRequestId) {
2071
+ return new Promise(() => {
2072
+ });
2016
2073
  }
2017
- const items = getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
2018
- (_c = options.onSuggestionsChange) == null ? void 0 : _c.call(options, items);
2074
+ (_b2 = options.onSuggestionsChange) == null ? void 0 : _b2.call(options, items);
2019
2075
  return items;
2020
2076
  },
2021
2077
  render: () => {
@@ -2118,7 +2174,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
2118
2174
  props: {
2119
2175
  items: [],
2120
2176
  command: props.command,
2121
- isLoading: true
2177
+ isLoading: true,
2178
+ emptyText: resolveEmptyText(props.query)
2122
2179
  }
2123
2180
  });
2124
2181
  popoverWrapper = document.createElement("div");
@@ -2136,7 +2193,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
2136
2193
  component == null ? void 0 : component.updateProps({
2137
2194
  items: props.items,
2138
2195
  command: props.command,
2139
- isLoading: false
2196
+ isLoading: false,
2197
+ emptyText: resolveEmptyText(props.query)
2140
2198
  });
2141
2199
  updatePopoverPosition();
2142
2200
  },
@@ -2153,17 +2211,18 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
2153
2211
  component == null ? void 0 : component.updateProps({
2154
2212
  items: props.items,
2155
2213
  command: props.command,
2156
- isLoading: false
2214
+ isLoading: false,
2215
+ emptyText: resolveEmptyText(props.query)
2157
2216
  });
2158
2217
  updatePopoverPosition();
2159
2218
  },
2160
2219
  onKeyDown: (props) => {
2161
- var _a2, _b;
2220
+ var _a2, _b2;
2162
2221
  if (props.event.key === "Escape") {
2163
2222
  destroyMentionPopover();
2164
2223
  return true;
2165
2224
  }
2166
- return (_b = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b : false;
2225
+ return (_b2 = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b2 : false;
2167
2226
  },
2168
2227
  onExit: () => {
2169
2228
  destroyMentionPopover();
@@ -2425,6 +2484,7 @@ var MpRichTextEditor = (0, import_vue23.defineComponent)({
2425
2484
  ...typeof props.suggestions === "function" || props.suggestions && props.suggestions.length > 0 ? [import_extension_mention.default.configure({
2426
2485
  suggestion: createMentionSuggestion(() => props.suggestions, {
2427
2486
  maxItems: props.maxSuggestions,
2487
+ emptyText: props.mentionEmptyText,
2428
2488
  onSuggestionsChange: (items) => emit("suggestionsChange", items)
2429
2489
  })
2430
2490
  })] : [],
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-7ZWZAIUI.mjs";
2
2
  import {
3
3
  MpRichTextEditor
4
- } from "./chunk-E4R6ETA7.mjs";
4
+ } from "./chunk-LUWDIXAC.mjs";
5
5
  import "./chunk-RX7ZEE2M.mjs";
6
6
  import "./chunk-HIHIKPNN.mjs";
7
7
  import "./chunk-X2CB42A3.mjs";
@@ -10,12 +10,12 @@ import "./chunk-FCLBNBXD.mjs";
10
10
  import "./chunk-ENKUUZPM.mjs";
11
11
  import {
12
12
  MpRTEStyleProvider
13
- } from "./chunk-RVXAG7LK.mjs";
13
+ } from "./chunk-6SZJ4DXO.mjs";
14
14
  import "./chunk-ZRAXSVO5.mjs";
15
15
  import "./chunk-ZAXJ3BEP.mjs";
16
- import "./chunk-B5BN5T5O.mjs";
17
- import "./chunk-RTEK53TL.mjs";
18
- import "./chunk-ELFAGDKG.mjs";
16
+ import "./chunk-QJYUKM5Q.mjs";
17
+ import "./chunk-7T3KAUCV.mjs";
18
+ import "./chunk-NC3P3FRE.mjs";
19
19
  import "./chunk-BWRU2WZN.mjs";
20
20
  import "./chunk-76GEEOAG.mjs";
21
21
  import "./chunk-YWVVMJGP.mjs";