@mekari/pixel3-rich-text-editor 0.2.1-dev.1 → 0.3.0
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/{chunk-RVXAG7LK.mjs → chunk-6SZJ4DXO.mjs} +1 -1
- package/dist/{chunk-RTEK53TL.mjs → chunk-7T3KAUCV.mjs} +20 -14
- package/dist/{chunk-E4R6ETA7.mjs → chunk-LUWDIXAC.mjs} +4 -3
- package/dist/{chunk-ELFAGDKG.mjs → chunk-NC3P3FRE.mjs} +59 -10
- package/dist/{chunk-B5BN5T5O.mjs → chunk-QJYUKM5Q.mjs} +4 -0
- package/dist/extensions/mention-list-extension.d.mts +9 -0
- package/dist/extensions/mention-list-extension.d.ts +9 -0
- package/dist/extensions/mention-list-extension.js +57 -8
- package/dist/extensions/mention-list-extension.mjs +1 -1
- package/dist/index.js +81 -21
- package/dist/index.mjs +5 -5
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/rich-text-editor.props.d.mts +4 -0
- package/dist/modules/rich-text-editor.props.d.ts +4 -0
- package/dist/modules/rich-text-editor.props.js +4 -0
- package/dist/modules/rich-text-editor.props.mjs +1 -1
- package/dist/modules/rich-text-editor.types.d.mts +1 -0
- package/dist/modules/rich-text-editor.types.d.ts +1 -0
- package/dist/rich-text-editor.d.mts +9 -0
- package/dist/rich-text-editor.d.ts +9 -0
- package/dist/rich-text-editor.js +81 -21
- package/dist/rich-text-editor.mjs +5 -5
- package/dist/rte-style-provider.mjs +2 -2
- package/dist/rte-suggestion.d.mts +1 -0
- package/dist/rte-suggestion.d.ts +1 -0
- package/dist/rte-suggestion.js +76 -21
- package/dist/rte-suggestion.mjs +2 -2
- package/package.json +12 -12
|
@@ -30,6 +30,7 @@ interface RichTextEditorProps {
|
|
|
30
30
|
options?: ToolbarOption[][];
|
|
31
31
|
suggestions?: MentionSuggestionSource;
|
|
32
32
|
maxSuggestions?: number;
|
|
33
|
+
mentionEmptyText?: string | ((query: string) => string);
|
|
33
34
|
variables?: VariableSuggestionItem[];
|
|
34
35
|
isInvalid: boolean;
|
|
35
36
|
isDisabled: boolean;
|
|
@@ -30,6 +30,7 @@ interface RichTextEditorProps {
|
|
|
30
30
|
options?: ToolbarOption[][];
|
|
31
31
|
suggestions?: MentionSuggestionSource;
|
|
32
32
|
maxSuggestions?: number;
|
|
33
|
+
mentionEmptyText?: string | ((query: string) => string);
|
|
33
34
|
variables?: VariableSuggestionItem[];
|
|
34
35
|
isInvalid: boolean;
|
|
35
36
|
isDisabled: boolean;
|
|
@@ -39,6 +39,10 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
39
39
|
type: vue.PropType<number | undefined>;
|
|
40
40
|
default: number;
|
|
41
41
|
};
|
|
42
|
+
mentionEmptyText: {
|
|
43
|
+
type: vue.PropType<string | ((query: string) => string) | undefined>;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
42
46
|
variables: {
|
|
43
47
|
type: vue.PropType<VariableSuggestionItem[] | undefined>;
|
|
44
48
|
default: () => never[];
|
|
@@ -88,6 +92,10 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
88
92
|
type: vue.PropType<number | undefined>;
|
|
89
93
|
default: number;
|
|
90
94
|
};
|
|
95
|
+
mentionEmptyText: {
|
|
96
|
+
type: vue.PropType<string | ((query: string) => string) | undefined>;
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
91
99
|
variables: {
|
|
92
100
|
type: vue.PropType<VariableSuggestionItem[] | undefined>;
|
|
93
101
|
default: () => never[];
|
|
@@ -111,6 +119,7 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
111
119
|
}, {
|
|
112
120
|
suggestions: MentionSuggestionSource | undefined;
|
|
113
121
|
maxSuggestions: number | undefined;
|
|
122
|
+
mentionEmptyText: string | ((query: string) => string) | undefined;
|
|
114
123
|
variables: VariableSuggestionItem[] | undefined;
|
|
115
124
|
isInvalid: boolean;
|
|
116
125
|
isDisabled: boolean;
|
|
@@ -39,6 +39,10 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
39
39
|
type: vue.PropType<number | undefined>;
|
|
40
40
|
default: number;
|
|
41
41
|
};
|
|
42
|
+
mentionEmptyText: {
|
|
43
|
+
type: vue.PropType<string | ((query: string) => string) | undefined>;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
42
46
|
variables: {
|
|
43
47
|
type: vue.PropType<VariableSuggestionItem[] | undefined>;
|
|
44
48
|
default: () => never[];
|
|
@@ -88,6 +92,10 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
88
92
|
type: vue.PropType<number | undefined>;
|
|
89
93
|
default: number;
|
|
90
94
|
};
|
|
95
|
+
mentionEmptyText: {
|
|
96
|
+
type: vue.PropType<string | ((query: string) => string) | undefined>;
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
91
99
|
variables: {
|
|
92
100
|
type: vue.PropType<VariableSuggestionItem[] | undefined>;
|
|
93
101
|
default: () => never[];
|
|
@@ -111,6 +119,7 @@ declare const MpRichTextEditor: vue.DefineComponent<{
|
|
|
111
119
|
}, {
|
|
112
120
|
suggestions: MentionSuggestionSource | undefined;
|
|
113
121
|
maxSuggestions: number | undefined;
|
|
122
|
+
mentionEmptyText: string | ((query: string) => string) | undefined;
|
|
114
123
|
variables: VariableSuggestionItem[] | undefined;
|
|
115
124
|
isInvalid: boolean;
|
|
116
125
|
isDisabled: boolean;
|
package/dist/rich-text-editor.js
CHANGED
|
@@ -76,6 +76,10 @@ var richTextEditorProps = {
|
|
|
76
76
|
type: Number,
|
|
77
77
|
default: 50
|
|
78
78
|
},
|
|
79
|
+
mentionEmptyText: {
|
|
80
|
+
type: [String, Function],
|
|
81
|
+
default: "No result"
|
|
82
|
+
},
|
|
79
83
|
variables: {
|
|
80
84
|
type: Array,
|
|
81
85
|
default: () => []
|
|
@@ -1810,7 +1814,8 @@ var import_css7 = require("@mekari/pixel3-styled-system/css");
|
|
|
1810
1814
|
var import_pixel3_avatar = require("@mekari/pixel3-avatar");
|
|
1811
1815
|
var import_pixel3_popover4 = require("@mekari/pixel3-popover");
|
|
1812
1816
|
var import_pixel3_text3 = require("@mekari/pixel3-text");
|
|
1813
|
-
var
|
|
1817
|
+
var import_pixel3_skeleton = require("@mekari/pixel3-skeleton");
|
|
1818
|
+
var SKELETON_ROW_COUNT = 3;
|
|
1814
1819
|
var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
|
|
1815
1820
|
var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
|
|
1816
1821
|
return avatarVariantColors[index % avatarVariantColors.length];
|
|
@@ -1829,6 +1834,10 @@ var MentionList = (0, import_vue21.defineComponent)({
|
|
|
1829
1834
|
isLoading: {
|
|
1830
1835
|
type: Boolean,
|
|
1831
1836
|
default: false
|
|
1837
|
+
},
|
|
1838
|
+
emptyText: {
|
|
1839
|
+
type: String,
|
|
1840
|
+
default: "No result"
|
|
1832
1841
|
}
|
|
1833
1842
|
},
|
|
1834
1843
|
setup(props, {
|
|
@@ -1836,6 +1845,16 @@ var MentionList = (0, import_vue21.defineComponent)({
|
|
|
1836
1845
|
}) {
|
|
1837
1846
|
const selectedIndex = (0, import_vue21.ref)(0);
|
|
1838
1847
|
const listRef = (0, import_vue21.ref)(null);
|
|
1848
|
+
const hasResolvedNonEmptyBatch = (0, import_vue21.ref)(false);
|
|
1849
|
+
(0, import_vue21.watch)(() => props.items, (items) => {
|
|
1850
|
+
if (items.length > 0) {
|
|
1851
|
+
hasResolvedNonEmptyBatch.value = true;
|
|
1852
|
+
}
|
|
1853
|
+
}, {
|
|
1854
|
+
immediate: true
|
|
1855
|
+
});
|
|
1856
|
+
const hasAvatarData = (0, import_vue21.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.avatar));
|
|
1857
|
+
const hasDescriptionData = (0, import_vue21.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.description));
|
|
1839
1858
|
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
1840
1859
|
(0, import_vue21.nextTick)(() => {
|
|
1841
1860
|
if (!listRef.value)
|
|
@@ -1916,20 +1935,54 @@ var MentionList = (0, import_vue21.defineComponent)({
|
|
|
1916
1935
|
default: () => [props.isLoading && (0, import_vue20.createVNode)("div", {
|
|
1917
1936
|
"class": (0, import_css7.css)({
|
|
1918
1937
|
display: "flex",
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1938
|
+
flexDirection: "column",
|
|
1939
|
+
gap: "3",
|
|
1940
|
+
p: "3",
|
|
1941
|
+
width: "full"
|
|
1942
|
+
})
|
|
1943
|
+
}, [Array.from({
|
|
1944
|
+
length: SKELETON_ROW_COUNT
|
|
1945
|
+
}, (_, index) => (0, import_vue20.createVNode)("div", {
|
|
1946
|
+
"key": index,
|
|
1947
|
+
"class": (0, import_css7.css)({
|
|
1948
|
+
display: "flex",
|
|
1949
|
+
alignItems: "center",
|
|
1950
|
+
gap: "2",
|
|
1951
|
+
width: "full"
|
|
1952
|
+
})
|
|
1953
|
+
}, [hasAvatarData.value && (0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
1954
|
+
"class": (0, import_css7.css)({
|
|
1955
|
+
width: "9",
|
|
1956
|
+
height: "9",
|
|
1957
|
+
rounded: "full"
|
|
1958
|
+
})
|
|
1959
|
+
}, null), (0, import_vue20.createVNode)("div", {
|
|
1960
|
+
"class": (0, import_css7.css)({
|
|
1961
|
+
display: "flex",
|
|
1962
|
+
flexDirection: "column",
|
|
1963
|
+
gap: "1",
|
|
1964
|
+
width: "full"
|
|
1965
|
+
})
|
|
1966
|
+
}, [(0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
1967
|
+
"class": (0, import_css7.css)({
|
|
1968
|
+
width: "40%",
|
|
1969
|
+
height: "14px",
|
|
1970
|
+
rounded: "sm"
|
|
1971
|
+
})
|
|
1972
|
+
}, null), hasDescriptionData.value && (0, import_vue20.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
1973
|
+
"class": (0, import_css7.css)({
|
|
1974
|
+
width: "70%",
|
|
1975
|
+
height: "12px",
|
|
1976
|
+
rounded: "sm"
|
|
1922
1977
|
})
|
|
1923
|
-
},
|
|
1924
|
-
"size": "sm"
|
|
1925
|
-
}, null)]), !props.isLoading && !props.items.length && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
|
|
1978
|
+
}, null)])]))]), !props.isLoading && !props.items.length && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
|
|
1926
1979
|
"color": "text.secondary",
|
|
1927
1980
|
"class": (0, import_css7.css)({
|
|
1928
1981
|
px: "3",
|
|
1929
1982
|
py: "2"
|
|
1930
1983
|
})
|
|
1931
1984
|
}, {
|
|
1932
|
-
default: () => [
|
|
1985
|
+
default: () => [props.emptyText]
|
|
1933
1986
|
}), !props.isLoading && props.items.map((item, index) => {
|
|
1934
1987
|
return (0, import_vue20.createVNode)(import_pixel3_popover4.MpPopoverListItem, {
|
|
1935
1988
|
"key": `${item.id}-${index}`,
|
|
@@ -1998,21 +2051,24 @@ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query, maxItems)
|
|
|
1998
2051
|
}).slice(0, maxItems);
|
|
1999
2052
|
}, "getFilteredSuggestionItems");
|
|
2000
2053
|
var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () => [], options = {}) => {
|
|
2001
|
-
var _a;
|
|
2054
|
+
var _a, _b;
|
|
2002
2055
|
const maxItems = (_a = options.maxItems) != null ? _a : 50;
|
|
2056
|
+
const emptyTextOption = (_b = options.emptyText) != null ? _b : "No result";
|
|
2057
|
+
const resolveEmptyText = /* @__PURE__ */ __name((query) => typeof emptyTextOption === "function" ? emptyTextOption(query) : emptyTextOption, "resolveEmptyText");
|
|
2058
|
+
let latestRequestId = 0;
|
|
2003
2059
|
return {
|
|
2004
2060
|
items: async ({
|
|
2005
2061
|
query
|
|
2006
2062
|
}) => {
|
|
2007
|
-
var _a2,
|
|
2063
|
+
var _a2, _b2;
|
|
2064
|
+
const requestId = ++latestRequestId;
|
|
2008
2065
|
const source = getSuggestionSource();
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2066
|
+
const items = typeof source === "function" ? ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems) : getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
|
|
2067
|
+
if (requestId !== latestRequestId) {
|
|
2068
|
+
return new Promise(() => {
|
|
2069
|
+
});
|
|
2013
2070
|
}
|
|
2014
|
-
|
|
2015
|
-
(_c = options.onSuggestionsChange) == null ? void 0 : _c.call(options, items);
|
|
2071
|
+
(_b2 = options.onSuggestionsChange) == null ? void 0 : _b2.call(options, items);
|
|
2016
2072
|
return items;
|
|
2017
2073
|
},
|
|
2018
2074
|
render: () => {
|
|
@@ -2115,7 +2171,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
2115
2171
|
props: {
|
|
2116
2172
|
items: [],
|
|
2117
2173
|
command: props.command,
|
|
2118
|
-
isLoading: true
|
|
2174
|
+
isLoading: true,
|
|
2175
|
+
emptyText: resolveEmptyText(props.query)
|
|
2119
2176
|
}
|
|
2120
2177
|
});
|
|
2121
2178
|
popoverWrapper = document.createElement("div");
|
|
@@ -2133,7 +2190,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
2133
2190
|
component == null ? void 0 : component.updateProps({
|
|
2134
2191
|
items: props.items,
|
|
2135
2192
|
command: props.command,
|
|
2136
|
-
isLoading: false
|
|
2193
|
+
isLoading: false,
|
|
2194
|
+
emptyText: resolveEmptyText(props.query)
|
|
2137
2195
|
});
|
|
2138
2196
|
updatePopoverPosition();
|
|
2139
2197
|
},
|
|
@@ -2150,17 +2208,18 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
2150
2208
|
component == null ? void 0 : component.updateProps({
|
|
2151
2209
|
items: props.items,
|
|
2152
2210
|
command: props.command,
|
|
2153
|
-
isLoading: false
|
|
2211
|
+
isLoading: false,
|
|
2212
|
+
emptyText: resolveEmptyText(props.query)
|
|
2154
2213
|
});
|
|
2155
2214
|
updatePopoverPosition();
|
|
2156
2215
|
},
|
|
2157
2216
|
onKeyDown: (props) => {
|
|
2158
|
-
var _a2,
|
|
2217
|
+
var _a2, _b2;
|
|
2159
2218
|
if (props.event.key === "Escape") {
|
|
2160
2219
|
destroyMentionPopover();
|
|
2161
2220
|
return true;
|
|
2162
2221
|
}
|
|
2163
|
-
return (
|
|
2222
|
+
return (_b2 = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b2 : false;
|
|
2164
2223
|
},
|
|
2165
2224
|
onExit: () => {
|
|
2166
2225
|
destroyMentionPopover();
|
|
@@ -2422,6 +2481,7 @@ var MpRichTextEditor = (0, import_vue23.defineComponent)({
|
|
|
2422
2481
|
...typeof props.suggestions === "function" || props.suggestions && props.suggestions.length > 0 ? [import_extension_mention.default.configure({
|
|
2423
2482
|
suggestion: createMentionSuggestion(() => props.suggestions, {
|
|
2424
2483
|
maxItems: props.maxSuggestions,
|
|
2484
|
+
emptyText: props.mentionEmptyText,
|
|
2425
2485
|
onSuggestionsChange: (items) => emit("suggestionsChange", items)
|
|
2426
2486
|
})
|
|
2427
2487
|
})] : [],
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRichTextEditor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LUWDIXAC.mjs";
|
|
4
4
|
import "./chunk-RX7ZEE2M.mjs";
|
|
5
5
|
import "./chunk-HIHIKPNN.mjs";
|
|
6
6
|
import "./chunk-X2CB42A3.mjs";
|
|
7
7
|
import "./chunk-COZ45QUD.mjs";
|
|
8
8
|
import "./chunk-FCLBNBXD.mjs";
|
|
9
9
|
import "./chunk-ENKUUZPM.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-6SZJ4DXO.mjs";
|
|
11
11
|
import "./chunk-ZRAXSVO5.mjs";
|
|
12
12
|
import "./chunk-ZAXJ3BEP.mjs";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-QJYUKM5Q.mjs";
|
|
14
|
+
import "./chunk-7T3KAUCV.mjs";
|
|
15
|
+
import "./chunk-NC3P3FRE.mjs";
|
|
16
16
|
import "./chunk-BWRU2WZN.mjs";
|
|
17
17
|
import "./chunk-76GEEOAG.mjs";
|
|
18
18
|
import "./chunk-YWVVMJGP.mjs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRTEStyleProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6SZJ4DXO.mjs";
|
|
4
4
|
import "./chunk-ZRAXSVO5.mjs";
|
|
5
5
|
import "./chunk-ZAXJ3BEP.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-QJYUKM5Q.mjs";
|
|
7
7
|
import "./chunk-QZ7VFGWC.mjs";
|
|
8
8
|
export {
|
|
9
9
|
MpRTEStyleProvider
|
|
@@ -4,6 +4,7 @@ import '@mekari/pixel3-utils';
|
|
|
4
4
|
|
|
5
5
|
interface CreateMentionSuggestionOptions {
|
|
6
6
|
maxItems?: number;
|
|
7
|
+
emptyText?: string | ((query: string) => string);
|
|
7
8
|
onSuggestionsChange?: (items: MentionSuggestionItem[]) => void;
|
|
8
9
|
}
|
|
9
10
|
declare const createMentionSuggestion: (getSuggestionSource?: () => MentionSuggestionSource | undefined, options?: CreateMentionSuggestionOptions) => MentionOptions['suggestion'];
|
package/dist/rte-suggestion.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import '@mekari/pixel3-utils';
|
|
|
4
4
|
|
|
5
5
|
interface CreateMentionSuggestionOptions {
|
|
6
6
|
maxItems?: number;
|
|
7
|
+
emptyText?: string | ((query: string) => string);
|
|
7
8
|
onSuggestionsChange?: (items: MentionSuggestionItem[]) => void;
|
|
8
9
|
}
|
|
9
10
|
declare const createMentionSuggestion: (getSuggestionSource?: () => MentionSuggestionSource | undefined, options?: CreateMentionSuggestionOptions) => MentionOptions['suggestion'];
|
package/dist/rte-suggestion.js
CHANGED
|
@@ -34,7 +34,8 @@ var import_css = require("@mekari/pixel3-styled-system/css");
|
|
|
34
34
|
var import_pixel3_avatar = require("@mekari/pixel3-avatar");
|
|
35
35
|
var import_pixel3_popover = require("@mekari/pixel3-popover");
|
|
36
36
|
var import_pixel3_text = require("@mekari/pixel3-text");
|
|
37
|
-
var
|
|
37
|
+
var import_pixel3_skeleton = require("@mekari/pixel3-skeleton");
|
|
38
|
+
var SKELETON_ROW_COUNT = 3;
|
|
38
39
|
var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
|
|
39
40
|
var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
|
|
40
41
|
return avatarVariantColors[index % avatarVariantColors.length];
|
|
@@ -53,6 +54,10 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
53
54
|
isLoading: {
|
|
54
55
|
type: Boolean,
|
|
55
56
|
default: false
|
|
57
|
+
},
|
|
58
|
+
emptyText: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "No result"
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
setup(props, {
|
|
@@ -60,6 +65,16 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
60
65
|
}) {
|
|
61
66
|
const selectedIndex = (0, import_vue2.ref)(0);
|
|
62
67
|
const listRef = (0, import_vue2.ref)(null);
|
|
68
|
+
const hasResolvedNonEmptyBatch = (0, import_vue2.ref)(false);
|
|
69
|
+
(0, import_vue2.watch)(() => props.items, (items) => {
|
|
70
|
+
if (items.length > 0) {
|
|
71
|
+
hasResolvedNonEmptyBatch.value = true;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
immediate: true
|
|
75
|
+
});
|
|
76
|
+
const hasAvatarData = (0, import_vue2.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.avatar));
|
|
77
|
+
const hasDescriptionData = (0, import_vue2.computed)(() => !hasResolvedNonEmptyBatch.value || props.items.some((item) => item.description));
|
|
63
78
|
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
64
79
|
(0, import_vue2.nextTick)(() => {
|
|
65
80
|
if (!listRef.value)
|
|
@@ -140,20 +155,54 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
140
155
|
default: () => [props.isLoading && (0, import_vue.createVNode)("div", {
|
|
141
156
|
"class": (0, import_css.css)({
|
|
142
157
|
display: "flex",
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
158
|
+
flexDirection: "column",
|
|
159
|
+
gap: "3",
|
|
160
|
+
p: "3",
|
|
161
|
+
width: "full"
|
|
162
|
+
})
|
|
163
|
+
}, [Array.from({
|
|
164
|
+
length: SKELETON_ROW_COUNT
|
|
165
|
+
}, (_, index) => (0, import_vue.createVNode)("div", {
|
|
166
|
+
"key": index,
|
|
167
|
+
"class": (0, import_css.css)({
|
|
168
|
+
display: "flex",
|
|
169
|
+
alignItems: "center",
|
|
170
|
+
gap: "2",
|
|
171
|
+
width: "full"
|
|
172
|
+
})
|
|
173
|
+
}, [hasAvatarData.value && (0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
174
|
+
"class": (0, import_css.css)({
|
|
175
|
+
width: "9",
|
|
176
|
+
height: "9",
|
|
177
|
+
rounded: "full"
|
|
146
178
|
})
|
|
147
|
-
},
|
|
148
|
-
"
|
|
149
|
-
|
|
179
|
+
}, null), (0, import_vue.createVNode)("div", {
|
|
180
|
+
"class": (0, import_css.css)({
|
|
181
|
+
display: "flex",
|
|
182
|
+
flexDirection: "column",
|
|
183
|
+
gap: "1",
|
|
184
|
+
width: "full"
|
|
185
|
+
})
|
|
186
|
+
}, [(0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
187
|
+
"class": (0, import_css.css)({
|
|
188
|
+
width: "40%",
|
|
189
|
+
height: "14px",
|
|
190
|
+
rounded: "sm"
|
|
191
|
+
})
|
|
192
|
+
}, null), hasDescriptionData.value && (0, import_vue.createVNode)(import_pixel3_skeleton.MpSkeleton, {
|
|
193
|
+
"class": (0, import_css.css)({
|
|
194
|
+
width: "70%",
|
|
195
|
+
height: "12px",
|
|
196
|
+
rounded: "sm"
|
|
197
|
+
})
|
|
198
|
+
}, null)])]))]), !props.isLoading && !props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
150
199
|
"color": "text.secondary",
|
|
151
200
|
"class": (0, import_css.css)({
|
|
152
201
|
px: "3",
|
|
153
202
|
py: "2"
|
|
154
203
|
})
|
|
155
204
|
}, {
|
|
156
|
-
default: () => [
|
|
205
|
+
default: () => [props.emptyText]
|
|
157
206
|
}), !props.isLoading && props.items.map((item, index) => {
|
|
158
207
|
return (0, import_vue.createVNode)(import_pixel3_popover.MpPopoverListItem, {
|
|
159
208
|
"key": `${item.id}-${index}`,
|
|
@@ -222,21 +271,24 @@ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query, maxItems)
|
|
|
222
271
|
}).slice(0, maxItems);
|
|
223
272
|
}, "getFilteredSuggestionItems");
|
|
224
273
|
var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () => [], options = {}) => {
|
|
225
|
-
var _a;
|
|
274
|
+
var _a, _b;
|
|
226
275
|
const maxItems = (_a = options.maxItems) != null ? _a : 50;
|
|
276
|
+
const emptyTextOption = (_b = options.emptyText) != null ? _b : "No result";
|
|
277
|
+
const resolveEmptyText = /* @__PURE__ */ __name((query) => typeof emptyTextOption === "function" ? emptyTextOption(query) : emptyTextOption, "resolveEmptyText");
|
|
278
|
+
let latestRequestId = 0;
|
|
227
279
|
return {
|
|
228
280
|
items: async ({
|
|
229
281
|
query
|
|
230
282
|
}) => {
|
|
231
|
-
var _a2,
|
|
283
|
+
var _a2, _b2;
|
|
284
|
+
const requestId = ++latestRequestId;
|
|
232
285
|
const source = getSuggestionSource();
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
286
|
+
const items = typeof source === "function" ? ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems) : getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
|
|
287
|
+
if (requestId !== latestRequestId) {
|
|
288
|
+
return new Promise(() => {
|
|
289
|
+
});
|
|
237
290
|
}
|
|
238
|
-
|
|
239
|
-
(_c = options.onSuggestionsChange) == null ? void 0 : _c.call(options, items);
|
|
291
|
+
(_b2 = options.onSuggestionsChange) == null ? void 0 : _b2.call(options, items);
|
|
240
292
|
return items;
|
|
241
293
|
},
|
|
242
294
|
render: () => {
|
|
@@ -339,7 +391,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
339
391
|
props: {
|
|
340
392
|
items: [],
|
|
341
393
|
command: props.command,
|
|
342
|
-
isLoading: true
|
|
394
|
+
isLoading: true,
|
|
395
|
+
emptyText: resolveEmptyText(props.query)
|
|
343
396
|
}
|
|
344
397
|
});
|
|
345
398
|
popoverWrapper = document.createElement("div");
|
|
@@ -357,7 +410,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
357
410
|
component == null ? void 0 : component.updateProps({
|
|
358
411
|
items: props.items,
|
|
359
412
|
command: props.command,
|
|
360
|
-
isLoading: false
|
|
413
|
+
isLoading: false,
|
|
414
|
+
emptyText: resolveEmptyText(props.query)
|
|
361
415
|
});
|
|
362
416
|
updatePopoverPosition();
|
|
363
417
|
},
|
|
@@ -374,17 +428,18 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () =
|
|
|
374
428
|
component == null ? void 0 : component.updateProps({
|
|
375
429
|
items: props.items,
|
|
376
430
|
command: props.command,
|
|
377
|
-
isLoading: false
|
|
431
|
+
isLoading: false,
|
|
432
|
+
emptyText: resolveEmptyText(props.query)
|
|
378
433
|
});
|
|
379
434
|
updatePopoverPosition();
|
|
380
435
|
},
|
|
381
436
|
onKeyDown: (props) => {
|
|
382
|
-
var _a2,
|
|
437
|
+
var _a2, _b2;
|
|
383
438
|
if (props.event.key === "Escape") {
|
|
384
439
|
destroyMentionPopover();
|
|
385
440
|
return true;
|
|
386
441
|
}
|
|
387
|
-
return (
|
|
442
|
+
return (_b2 = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b2 : false;
|
|
388
443
|
},
|
|
389
444
|
onExit: () => {
|
|
390
445
|
destroyMentionPopover();
|
package/dist/rte-suggestion.mjs
CHANGED
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.
|
|
4
|
+
"version": "0.3.0",
|
|
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.30
|
|
45
|
-
"@mekari/pixel3-
|
|
46
|
-
"@mekari/pixel3-divider": "0.0.25
|
|
47
|
-
"@mekari/pixel3-
|
|
48
|
-
"@mekari/pixel3-
|
|
49
|
-
"@mekari/pixel3-
|
|
50
|
-
"@mekari/pixel3-
|
|
51
|
-
"@mekari/pixel3-scrollbar": "0.1.9
|
|
52
|
-
"@mekari/pixel3-
|
|
53
|
-
"@mekari/pixel3-
|
|
54
|
-
"@mekari/pixel3-text": "0.0.25
|
|
44
|
+
"@mekari/pixel3-avatar": "0.0.30",
|
|
45
|
+
"@mekari/pixel3-button": "0.2.5",
|
|
46
|
+
"@mekari/pixel3-divider": "0.0.25",
|
|
47
|
+
"@mekari/pixel3-input": "0.0.30",
|
|
48
|
+
"@mekari/pixel3-color-picker": "0.2.4",
|
|
49
|
+
"@mekari/pixel3-popover": "0.0.30",
|
|
50
|
+
"@mekari/pixel3-form-control": "0.0.25",
|
|
51
|
+
"@mekari/pixel3-scrollbar": "0.1.9",
|
|
52
|
+
"@mekari/pixel3-styled-system": "0.3.1",
|
|
53
|
+
"@mekari/pixel3-skeleton": "0.1.8",
|
|
54
|
+
"@mekari/pixel3-text": "0.0.25",
|
|
55
55
|
"@mekari/pixel3-utils": "0.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|