@mekari/pixel3-rich-text-editor 0.1.3 → 0.2.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.
- package/dist/{chunk-6O4HSL2C.mjs → chunk-B5BN5T5O.mjs} +6 -2
- package/dist/{chunk-4ZCPCZD2.mjs → chunk-E4R6ETA7.mjs} +16 -9
- package/dist/{chunk-4TUA5VF4.mjs → chunk-ELFAGDKG.mjs} +17 -3
- package/dist/{chunk-4KJOYLJI.mjs → chunk-RTEK53TL.mjs} +47 -15
- package/dist/{chunk-BA5A7DIS.mjs → chunk-RVXAG7LK.mjs} +3 -3
- package/dist/editor-toolbar.mjs +4 -4
- package/dist/extensions/index.mjs +9 -9
- 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 +16 -2
- package/dist/extensions/mention-list-extension.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -22
- package/dist/index.mjs +13 -13
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/rich-text-editor.props.d.mts +7 -3
- package/dist/modules/rich-text-editor.props.d.ts +7 -3
- package/dist/modules/rich-text-editor.props.js +6 -2
- package/dist/modules/rich-text-editor.props.mjs +1 -1
- package/dist/modules/rich-text-editor.types.d.mts +12 -3
- package/dist/modules/rich-text-editor.types.d.ts +12 -3
- package/dist/rich-text-editor.d.mts +15 -5
- package/dist/rich-text-editor.d.ts +15 -5
- package/dist/rich-text-editor.js +79 -22
- package/dist/rich-text-editor.mjs +12 -12
- package/dist/rte-style-provider.js +1 -1
- package/dist/rte-style-provider.mjs +2 -2
- package/dist/rte-suggestion.d.mts +7 -3
- package/dist/rte-suggestion.d.ts +7 -3
- package/dist/rte-suggestion.js +62 -16
- package/dist/rte-suggestion.mjs +2 -2
- package/package.json +13 -12
- package/dist/{chunk-G4CGNV6P.mjs → chunk-RX7ZEE2M.mjs} +6 -6
package/dist/rte-suggestion.js
CHANGED
|
@@ -34,6 +34,7 @@ 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 import_pixel3_spinner = require("@mekari/pixel3-spinner");
|
|
37
38
|
var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
|
|
38
39
|
var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
|
|
39
40
|
return avatarVariantColors[index % avatarVariantColors.length];
|
|
@@ -48,6 +49,10 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
48
49
|
command: {
|
|
49
50
|
type: Function,
|
|
50
51
|
required: true
|
|
52
|
+
},
|
|
53
|
+
isLoading: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
58
|
setup(props, {
|
|
@@ -132,7 +137,16 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
132
137
|
},
|
|
133
138
|
"data-pixel-rte": true
|
|
134
139
|
}, {
|
|
135
|
-
default: () => [
|
|
140
|
+
default: () => [props.isLoading && (0, import_vue.createVNode)("div", {
|
|
141
|
+
"class": (0, import_css.css)({
|
|
142
|
+
display: "flex",
|
|
143
|
+
justifyContent: "center",
|
|
144
|
+
px: "3",
|
|
145
|
+
py: "3"
|
|
146
|
+
})
|
|
147
|
+
}, [(0, import_vue.createVNode)(import_pixel3_spinner.MpSpinner, {
|
|
148
|
+
"size": "sm"
|
|
149
|
+
}, null)]), !props.isLoading && !props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
136
150
|
"color": "text.secondary",
|
|
137
151
|
"class": (0, import_css.css)({
|
|
138
152
|
px: "3",
|
|
@@ -140,7 +154,7 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
140
154
|
})
|
|
141
155
|
}, {
|
|
142
156
|
default: () => [(0, import_vue.createTextVNode)("No result")]
|
|
143
|
-
}), props.items.map((item, index) => {
|
|
157
|
+
}), !props.isLoading && props.items.map((item, index) => {
|
|
144
158
|
return (0, import_vue.createVNode)(import_pixel3_popover.MpPopoverListItem, {
|
|
145
159
|
"key": `${item.id}-${index}`,
|
|
146
160
|
"is-active": selectedIndex.value === index,
|
|
@@ -194,8 +208,7 @@ var MentionList = (0, import_vue2.defineComponent)({
|
|
|
194
208
|
});
|
|
195
209
|
|
|
196
210
|
// src/rte-suggestion.ts
|
|
197
|
-
var
|
|
198
|
-
var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query) => {
|
|
211
|
+
var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query, maxItems) => {
|
|
199
212
|
const normalizedQuery = query.trim().toLowerCase();
|
|
200
213
|
return items.filter((item) => {
|
|
201
214
|
var _a, _b;
|
|
@@ -206,14 +219,25 @@ var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query) => {
|
|
|
206
219
|
const label = ((_a = item.name) != null ? _a : "").toLowerCase();
|
|
207
220
|
const description = ((_b = item.description) != null ? _b : "").toLowerCase();
|
|
208
221
|
return id.includes(normalizedQuery) || label.includes(normalizedQuery) || description.includes(normalizedQuery);
|
|
209
|
-
}).slice(0,
|
|
222
|
+
}).slice(0, maxItems);
|
|
210
223
|
}, "getFilteredSuggestionItems");
|
|
211
|
-
var createMentionSuggestion = /* @__PURE__ */ __name((
|
|
224
|
+
var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionSource = () => [], options = {}) => {
|
|
225
|
+
var _a;
|
|
226
|
+
const maxItems = (_a = options.maxItems) != null ? _a : 50;
|
|
212
227
|
return {
|
|
213
|
-
items: ({
|
|
228
|
+
items: async ({
|
|
214
229
|
query
|
|
215
230
|
}) => {
|
|
216
|
-
|
|
231
|
+
var _a2, _b, _c;
|
|
232
|
+
const source = getSuggestionSource();
|
|
233
|
+
if (typeof source === "function") {
|
|
234
|
+
const items2 = ((_a2 = await source(query)) != null ? _a2 : []).slice(0, maxItems);
|
|
235
|
+
(_b = options.onSuggestionsChange) == null ? void 0 : _b.call(options, items2);
|
|
236
|
+
return items2;
|
|
237
|
+
}
|
|
238
|
+
const items = getFilteredSuggestionItems(source != null ? source : [], query, maxItems);
|
|
239
|
+
(_c = options.onSuggestionsChange) == null ? void 0 : _c.call(options, items);
|
|
240
|
+
return items;
|
|
217
241
|
},
|
|
218
242
|
render: () => {
|
|
219
243
|
let component = null;
|
|
@@ -274,8 +298,8 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () =>
|
|
|
274
298
|
}
|
|
275
299
|
return {
|
|
276
300
|
getBoundingClientRect: () => {
|
|
277
|
-
var
|
|
278
|
-
return (
|
|
301
|
+
var _a2;
|
|
302
|
+
return (_a2 = clientRectProvider == null ? void 0 : clientRectProvider()) != null ? _a2 : new DOMRect();
|
|
279
303
|
}
|
|
280
304
|
};
|
|
281
305
|
}, "getVirtualElement");
|
|
@@ -304,14 +328,18 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () =>
|
|
|
304
328
|
popperInstance.update();
|
|
305
329
|
}, "updatePopoverPosition");
|
|
306
330
|
return {
|
|
307
|
-
|
|
331
|
+
// Fires synchronously before `items()` resolves, so the popover can
|
|
332
|
+
// mount showing a loading state instead of a blank/"No result" flash
|
|
333
|
+
// while the (possibly async) suggestion source is fetched.
|
|
334
|
+
onBeforeStart: (props) => {
|
|
308
335
|
clientRectProvider = props.clientRect;
|
|
309
336
|
editorElement = props.editor.view.dom;
|
|
310
337
|
component = new import_vue_3.VueRenderer(MentionList, {
|
|
311
338
|
editor: props.editor,
|
|
312
339
|
props: {
|
|
313
|
-
items:
|
|
314
|
-
command: props.command
|
|
340
|
+
items: [],
|
|
341
|
+
command: props.command,
|
|
342
|
+
isLoading: true
|
|
315
343
|
}
|
|
316
344
|
});
|
|
317
345
|
popoverWrapper = document.createElement("div");
|
|
@@ -324,21 +352,39 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () =>
|
|
|
324
352
|
setupOutsideListeners();
|
|
325
353
|
updatePopoverPosition();
|
|
326
354
|
},
|
|
355
|
+
onStart: (props) => {
|
|
356
|
+
clientRectProvider = props.clientRect;
|
|
357
|
+
component == null ? void 0 : component.updateProps({
|
|
358
|
+
items: props.items,
|
|
359
|
+
command: props.command,
|
|
360
|
+
isLoading: false
|
|
361
|
+
});
|
|
362
|
+
updatePopoverPosition();
|
|
363
|
+
},
|
|
364
|
+
// Fires before every re-fetch triggered by a query change — flips
|
|
365
|
+
// back to the loading state until the new `items()` call resolves.
|
|
366
|
+
onBeforeUpdate: (props) => {
|
|
367
|
+
clientRectProvider = props.clientRect;
|
|
368
|
+
component == null ? void 0 : component.updateProps({
|
|
369
|
+
isLoading: true
|
|
370
|
+
});
|
|
371
|
+
},
|
|
327
372
|
onUpdate: (props) => {
|
|
328
373
|
clientRectProvider = props.clientRect;
|
|
329
374
|
component == null ? void 0 : component.updateProps({
|
|
330
375
|
items: props.items,
|
|
331
|
-
command: props.command
|
|
376
|
+
command: props.command,
|
|
377
|
+
isLoading: false
|
|
332
378
|
});
|
|
333
379
|
updatePopoverPosition();
|
|
334
380
|
},
|
|
335
381
|
onKeyDown: (props) => {
|
|
336
|
-
var
|
|
382
|
+
var _a2, _b;
|
|
337
383
|
if (props.event.key === "Escape") {
|
|
338
384
|
destroyMentionPopover();
|
|
339
385
|
return true;
|
|
340
386
|
}
|
|
341
|
-
return (_b = (
|
|
387
|
+
return (_b = (_a2 = component == null ? void 0 : component.ref) == null ? void 0 : _a2.onKeyDown(props)) != null ? _b : false;
|
|
342
388
|
},
|
|
343
389
|
onExit: () => {
|
|
344
390
|
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.1
|
|
4
|
+
"version": "0.2.0-dev.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -41,17 +41,18 @@
|
|
|
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-
|
|
45
|
-
"@mekari/pixel3-
|
|
46
|
-
"@mekari/pixel3-
|
|
47
|
-
"@mekari/pixel3-
|
|
48
|
-
"@mekari/pixel3-form-control": "0.0.
|
|
49
|
-
"@mekari/pixel3-input": "0.0.
|
|
50
|
-
"@mekari/pixel3-popover": "0.0.
|
|
51
|
-
"@mekari/pixel3-scrollbar": "0.1.
|
|
52
|
-
"@mekari/pixel3-
|
|
53
|
-
"@mekari/pixel3-
|
|
54
|
-
"@mekari/pixel3-
|
|
44
|
+
"@mekari/pixel3-avatar": "0.0.29-dev.0",
|
|
45
|
+
"@mekari/pixel3-button": "0.2.4-dev.0",
|
|
46
|
+
"@mekari/pixel3-divider": "0.0.24-dev.0",
|
|
47
|
+
"@mekari/pixel3-color-picker": "0.2.3-dev.0",
|
|
48
|
+
"@mekari/pixel3-form-control": "0.0.24-dev.0",
|
|
49
|
+
"@mekari/pixel3-input": "0.0.29-dev.0",
|
|
50
|
+
"@mekari/pixel3-popover": "0.0.29-dev.0",
|
|
51
|
+
"@mekari/pixel3-scrollbar": "0.1.8-dev.0",
|
|
52
|
+
"@mekari/pixel3-styled-system": "0.3.0-dev.0",
|
|
53
|
+
"@mekari/pixel3-spinner": "0.0.29-dev.0",
|
|
54
|
+
"@mekari/pixel3-text": "0.0.24-dev.0",
|
|
55
|
+
"@mekari/pixel3-utils": "0.1.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"vue": "^3.4.9"
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HeadingExtention
|
|
3
|
+
} from "./chunk-X2CB42A3.mjs";
|
|
4
|
+
import {
|
|
5
|
+
LinkExtension
|
|
6
|
+
} from "./chunk-COZ45QUD.mjs";
|
|
1
7
|
import {
|
|
2
8
|
SingleExtention
|
|
3
9
|
} from "./chunk-FCLBNBXD.mjs";
|
|
@@ -7,12 +13,6 @@ import {
|
|
|
7
13
|
import {
|
|
8
14
|
ColorExtension
|
|
9
15
|
} from "./chunk-Y6UPQ6EU.mjs";
|
|
10
|
-
import {
|
|
11
|
-
HeadingExtention
|
|
12
|
-
} from "./chunk-X2CB42A3.mjs";
|
|
13
|
-
import {
|
|
14
|
-
LinkExtension
|
|
15
|
-
} from "./chunk-COZ45QUD.mjs";
|
|
16
16
|
import {
|
|
17
17
|
__name
|
|
18
18
|
} from "./chunk-QZ7VFGWC.mjs";
|