@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.
- package/dist/chunk-4KJOYLJI.mjs +168 -0
- package/dist/{chunk-JAKI6TU2.mjs → chunk-4SN6MBXS.mjs} +8 -22
- package/dist/chunk-4TUA5VF4.mjs +173 -0
- package/dist/{chunk-2OCRJNTJ.mjs → chunk-7RMCTPMN.mjs} +2 -2
- package/dist/{chunk-RNQQ7LGC.mjs → chunk-C7IUW3FX.mjs} +73 -1
- package/dist/{chunk-ES3FCTTF.mjs → chunk-JE7IG7UU.mjs} +27 -6
- package/dist/{chunk-73N5SLQ5.mjs → chunk-MGNW6NK2.mjs} +82 -25
- package/dist/{chunk-FZPMIQTC.mjs → chunk-OZGNQAK5.mjs} +2 -1
- package/dist/{chunk-VK7QDWXR.mjs → chunk-PTKS3BYW.mjs} +18 -5
- package/dist/{chunk-V52XUOVW.mjs → chunk-SBD2AUDA.mjs} +10 -2
- package/dist/{chunk-GVMGRBDI.mjs → chunk-TNDDXUVW.mjs} +5 -1
- package/dist/{chunk-WBMECFO3.mjs → chunk-X25J3BAC.mjs} +18 -46
- package/dist/{chunk-HF36L4GZ.mjs → chunk-ZAXJ3BEP.mjs} +2 -0
- package/dist/{chunk-5IPS4HT7.mjs → chunk-ZRAXSVO5.mjs} +1 -1
- package/dist/editor-toolbar.d.mts +9 -5
- package/dist/editor-toolbar.d.ts +9 -5
- package/dist/editor-toolbar.js +193 -92
- package/dist/editor-toolbar.mjs +7 -7
- package/dist/extensions/align-extension.js +75 -21
- package/dist/extensions/align-extension.mjs +2 -2
- package/dist/extensions/color-extension.js +69 -0
- package/dist/extensions/color-extension.mjs +2 -2
- package/dist/extensions/heading-extension.js +85 -45
- package/dist/extensions/heading-extension.mjs +2 -2
- package/dist/extensions/icons.d.mts +5 -1
- package/dist/extensions/icons.d.ts +5 -1
- package/dist/extensions/icons.js +76 -0
- package/dist/extensions/icons.mjs +9 -1
- package/dist/extensions/index.js +115 -71
- package/dist/extensions/index.mjs +6 -6
- package/dist/extensions/link-extension.js +85 -4
- package/dist/extensions/link-extension.mjs +2 -2
- package/dist/extensions/mention-list-extension.d.mts +33 -0
- package/dist/extensions/mention-list-extension.d.ts +33 -0
- package/dist/extensions/mention-list-extension.js +194 -0
- package/dist/extensions/mention-list-extension.mjs +7 -0
- package/dist/extensions/single-extension.d.mts +1 -1
- package/dist/extensions/single-extension.d.ts +1 -1
- package/dist/extensions/single-extension.js +73 -1
- package/dist/extensions/single-extension.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +552 -104
- package/dist/index.mjs +14 -12
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/rich-text-editor.connects.js +2 -0
- package/dist/modules/rich-text-editor.connects.mjs +1 -1
- package/dist/modules/rich-text-editor.hooks.js +2 -0
- package/dist/modules/rich-text-editor.hooks.mjs +2 -2
- 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 +5 -1
- package/dist/modules/rich-text-editor.props.mjs +1 -1
- package/dist/modules/rich-text-editor.types.d.mts +18 -4
- package/dist/modules/rich-text-editor.types.d.ts +18 -4
- package/dist/rich-text-editor.d.mts +15 -4
- package/dist/rich-text-editor.d.ts +15 -4
- package/dist/rich-text-editor.js +552 -104
- package/dist/rich-text-editor.mjs +14 -12
- package/dist/rte-style-provider.js +1 -1
- package/dist/rte-style-provider.mjs +4 -4
- package/dist/rte-suggestion.d.mts +7 -0
- package/dist/rte-suggestion.d.ts +7 -0
- package/dist/rte-suggestion.js +354 -0
- package/dist/rte-suggestion.mjs +8 -0
- package/package.json +15 -11
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRichTextEditor
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-JE7IG7UU.mjs";
|
|
4
|
+
import "./chunk-MGNW6NK2.mjs";
|
|
5
5
|
import "./chunk-VYCDVS5I.mjs";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-PTKS3BYW.mjs";
|
|
7
|
+
import "./chunk-SBD2AUDA.mjs";
|
|
8
|
+
import "./chunk-7RMCTPMN.mjs";
|
|
9
|
+
import "./chunk-ZRAXSVO5.mjs";
|
|
10
|
+
import "./chunk-ZAXJ3BEP.mjs";
|
|
11
|
+
import "./chunk-TNDDXUVW.mjs";
|
|
12
|
+
import "./chunk-4KJOYLJI.mjs";
|
|
13
|
+
import "./chunk-4TUA5VF4.mjs";
|
|
14
|
+
import "./chunk-4SN6MBXS.mjs";
|
|
15
|
+
import "./chunk-OZGNQAK5.mjs";
|
|
16
|
+
import "./chunk-X25J3BAC.mjs";
|
|
17
|
+
import "./chunk-C7IUW3FX.mjs";
|
|
16
18
|
import "./chunk-QZ7VFGWC.mjs";
|
|
17
19
|
export {
|
|
18
20
|
MpRichTextEditor
|
|
@@ -34,7 +34,7 @@ var RTEStyleProviderProps = {
|
|
|
34
34
|
type: String
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var richTextEditorEmits = (0, import_pixel3_utils.declareEmit)(["change", "blur", "focus"]);
|
|
37
|
+
var richTextEditorEmits = (0, import_pixel3_utils.declareEmit)(["change", "blur", "focus", "action", "paste"]);
|
|
38
38
|
|
|
39
39
|
// src/modules/rich-text-editor.hooks.ts
|
|
40
40
|
var import_vue = require("vue");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRTEStyleProvider
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-7RMCTPMN.mjs";
|
|
4
|
+
import "./chunk-ZRAXSVO5.mjs";
|
|
5
|
+
import "./chunk-ZAXJ3BEP.mjs";
|
|
6
|
+
import "./chunk-TNDDXUVW.mjs";
|
|
7
7
|
import "./chunk-QZ7VFGWC.mjs";
|
|
8
8
|
export {
|
|
9
9
|
MpRTEStyleProvider
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MentionOptions } from '@tiptap/extension-mention';
|
|
2
|
+
import { MentionSuggestionItem } from './modules/rich-text-editor.types.mjs';
|
|
3
|
+
import '@mekari/pixel3-utils';
|
|
4
|
+
|
|
5
|
+
declare const createMentionSuggestion: (getSuggestionItems?: () => MentionSuggestionItem[]) => MentionOptions['suggestion'];
|
|
6
|
+
|
|
7
|
+
export { createMentionSuggestion };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MentionOptions } from '@tiptap/extension-mention';
|
|
2
|
+
import { MentionSuggestionItem } from './modules/rich-text-editor.types.js';
|
|
3
|
+
import '@mekari/pixel3-utils';
|
|
4
|
+
|
|
5
|
+
declare const createMentionSuggestion: (getSuggestionItems?: () => MentionSuggestionItem[]) => MentionOptions['suggestion'];
|
|
6
|
+
|
|
7
|
+
export { createMentionSuggestion };
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/rte-suggestion.ts
|
|
22
|
+
var rte_suggestion_exports = {};
|
|
23
|
+
__export(rte_suggestion_exports, {
|
|
24
|
+
createMentionSuggestion: () => createMentionSuggestion
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(rte_suggestion_exports);
|
|
27
|
+
var import_vue_3 = require("@tiptap/vue-3");
|
|
28
|
+
var import_core = require("@popperjs/core");
|
|
29
|
+
|
|
30
|
+
// src/extensions/mention-list-extension.tsx
|
|
31
|
+
var import_vue = require("vue");
|
|
32
|
+
var import_vue2 = require("vue");
|
|
33
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
34
|
+
var import_pixel3_avatar = require("@mekari/pixel3-avatar");
|
|
35
|
+
var import_pixel3_popover = require("@mekari/pixel3-popover");
|
|
36
|
+
var import_pixel3_text = require("@mekari/pixel3-text");
|
|
37
|
+
var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
|
|
38
|
+
var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
|
|
39
|
+
return avatarVariantColors[index % avatarVariantColors.length];
|
|
40
|
+
}, "getAvatarVariantColor");
|
|
41
|
+
var MentionList = (0, import_vue2.defineComponent)({
|
|
42
|
+
name: "MentionList",
|
|
43
|
+
props: {
|
|
44
|
+
items: {
|
|
45
|
+
type: Array,
|
|
46
|
+
default: () => []
|
|
47
|
+
},
|
|
48
|
+
command: {
|
|
49
|
+
type: Function,
|
|
50
|
+
required: true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
setup(props, {
|
|
54
|
+
expose
|
|
55
|
+
}) {
|
|
56
|
+
const selectedIndex = (0, import_vue2.ref)(0);
|
|
57
|
+
const listRef = (0, import_vue2.ref)(null);
|
|
58
|
+
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
59
|
+
(0, import_vue2.nextTick)(() => {
|
|
60
|
+
if (!listRef.value)
|
|
61
|
+
return;
|
|
62
|
+
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
63
|
+
if (targetItem) {
|
|
64
|
+
targetItem.scrollIntoView({
|
|
65
|
+
block: "nearest"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}, "scrollToFocusedItem");
|
|
70
|
+
(0, import_vue2.watch)(() => props.items, () => {
|
|
71
|
+
selectedIndex.value = 0;
|
|
72
|
+
});
|
|
73
|
+
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
74
|
+
const item = props.items[index];
|
|
75
|
+
if (item) {
|
|
76
|
+
props.command({
|
|
77
|
+
...item,
|
|
78
|
+
label: item.name
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, "onSelect");
|
|
82
|
+
const onKeyDown = /* @__PURE__ */ __name(({
|
|
83
|
+
event
|
|
84
|
+
}) => {
|
|
85
|
+
if (!props.items.length) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (event.key === "ArrowUp") {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
const total = props.items.length;
|
|
91
|
+
selectedIndex.value = (selectedIndex.value + total - 1) % total;
|
|
92
|
+
scrollToFocusedItem();
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
if (event.key === "ArrowDown") {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
|
|
98
|
+
scrollToFocusedItem();
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (event.key === "Enter") {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
onSelect(selectedIndex.value);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}, "onKeyDown");
|
|
108
|
+
expose({
|
|
109
|
+
onKeyDown
|
|
110
|
+
});
|
|
111
|
+
return () => (0, import_vue.createVNode)(import_pixel3_popover.MpPopover, {
|
|
112
|
+
"id": "popover-rte-mention-list",
|
|
113
|
+
"is-manual": true,
|
|
114
|
+
"is-default-open": true,
|
|
115
|
+
"is-open": true
|
|
116
|
+
}, {
|
|
117
|
+
default: () => [(0, import_vue.createVNode)(import_pixel3_popover.MpPopoverContent, {
|
|
118
|
+
"class": (0, import_css.css)({
|
|
119
|
+
width: "280px",
|
|
120
|
+
maxHeight: "284px",
|
|
121
|
+
overflowY: "auto"
|
|
122
|
+
})
|
|
123
|
+
}, {
|
|
124
|
+
default: () => [(0, import_vue.createVNode)(import_pixel3_popover.MpPopoverList, {
|
|
125
|
+
"ref": (element) => {
|
|
126
|
+
var _a;
|
|
127
|
+
if (!element) {
|
|
128
|
+
listRef.value = null;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
listRef.value = (_a = element.$el) != null ? _a : element;
|
|
132
|
+
},
|
|
133
|
+
"data-pixel-rte": true
|
|
134
|
+
}, {
|
|
135
|
+
default: () => [!props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
136
|
+
"color": "text.secondary",
|
|
137
|
+
"class": (0, import_css.css)({
|
|
138
|
+
px: "3",
|
|
139
|
+
py: "2"
|
|
140
|
+
})
|
|
141
|
+
}, {
|
|
142
|
+
default: () => [(0, import_vue.createTextVNode)("No result")]
|
|
143
|
+
}), props.items.map((item, index) => {
|
|
144
|
+
return (0, import_vue.createVNode)(import_pixel3_popover.MpPopoverListItem, {
|
|
145
|
+
"key": `${item.id}-${index}`,
|
|
146
|
+
"is-active": selectedIndex.value === index,
|
|
147
|
+
"onMousedown": (event) => event.preventDefault(),
|
|
148
|
+
"onMouseenter": () => {
|
|
149
|
+
selectedIndex.value = index;
|
|
150
|
+
},
|
|
151
|
+
"onClick": () => {
|
|
152
|
+
onSelect(index);
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
default: () => [(0, import_vue.createVNode)("div", {
|
|
156
|
+
"class": (0, import_css.css)({
|
|
157
|
+
display: "flex",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
gap: "2",
|
|
160
|
+
width: "full",
|
|
161
|
+
minWidth: "0"
|
|
162
|
+
})
|
|
163
|
+
}, [item.avatar && (0, import_vue.createVNode)(import_pixel3_avatar.MpAvatar, {
|
|
164
|
+
"id": `avatar-rte-mention-${index}`,
|
|
165
|
+
"name": item.avatar,
|
|
166
|
+
"size": "lg",
|
|
167
|
+
"variant-color": getAvatarVariantColor(index)
|
|
168
|
+
}, null), (0, import_vue.createVNode)("div", {
|
|
169
|
+
"class": (0, import_css.css)({
|
|
170
|
+
display: "flex",
|
|
171
|
+
flexDirection: "column",
|
|
172
|
+
alignItems: "flex-start",
|
|
173
|
+
minWidth: "0",
|
|
174
|
+
flex: "1 1 0%"
|
|
175
|
+
})
|
|
176
|
+
}, [(0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
177
|
+
"size": "label",
|
|
178
|
+
"is-truncated": true
|
|
179
|
+
}, {
|
|
180
|
+
default: () => [item.name || "Unknown"]
|
|
181
|
+
}), item.description && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
182
|
+
"size": "label-small",
|
|
183
|
+
"color": "text.secondary",
|
|
184
|
+
"is-truncated": true
|
|
185
|
+
}, {
|
|
186
|
+
default: () => [item.description]
|
|
187
|
+
})])])]
|
|
188
|
+
});
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// src/rte-suggestion.ts
|
|
197
|
+
var MAX_SUGGESTION_ITEMS = 10;
|
|
198
|
+
var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query) => {
|
|
199
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
200
|
+
return items.filter((item) => {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
if (!normalizedQuery) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
const id = item.id.toLowerCase();
|
|
206
|
+
const label = ((_a = item.name) != null ? _a : "").toLowerCase();
|
|
207
|
+
const description = ((_b = item.description) != null ? _b : "").toLowerCase();
|
|
208
|
+
return id.includes(normalizedQuery) || label.includes(normalizedQuery) || description.includes(normalizedQuery);
|
|
209
|
+
}).slice(0, MAX_SUGGESTION_ITEMS);
|
|
210
|
+
}, "getFilteredSuggestionItems");
|
|
211
|
+
var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () => []) => {
|
|
212
|
+
return {
|
|
213
|
+
items: ({
|
|
214
|
+
query
|
|
215
|
+
}) => {
|
|
216
|
+
return getFilteredSuggestionItems(getSuggestionItems(), query);
|
|
217
|
+
},
|
|
218
|
+
render: () => {
|
|
219
|
+
let component = null;
|
|
220
|
+
let popperInstance = null;
|
|
221
|
+
let popoverWrapper = null;
|
|
222
|
+
let clientRectProvider;
|
|
223
|
+
let editorElement = null;
|
|
224
|
+
let removeOutsideListeners = null;
|
|
225
|
+
const destroyMentionPopover = /* @__PURE__ */ __name(() => {
|
|
226
|
+
removeOutsideListeners == null ? void 0 : removeOutsideListeners();
|
|
227
|
+
removeOutsideListeners = null;
|
|
228
|
+
popperInstance == null ? void 0 : popperInstance.destroy();
|
|
229
|
+
popperInstance = null;
|
|
230
|
+
popoverWrapper == null ? void 0 : popoverWrapper.remove();
|
|
231
|
+
popoverWrapper = null;
|
|
232
|
+
component == null ? void 0 : component.destroy();
|
|
233
|
+
component = null;
|
|
234
|
+
}, "destroyMentionPopover");
|
|
235
|
+
const isWithinMentionContext = /* @__PURE__ */ __name((target) => {
|
|
236
|
+
if (!(target instanceof Node)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return Boolean((editorElement == null ? void 0 : editorElement.contains(target)) || (popoverWrapper == null ? void 0 : popoverWrapper.contains(target)));
|
|
240
|
+
}, "isWithinMentionContext");
|
|
241
|
+
const setupOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
242
|
+
if (!editorElement || removeOutsideListeners) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const handleDocumentFocusIn = /* @__PURE__ */ __name((event) => {
|
|
246
|
+
if (!isWithinMentionContext(event.target)) {
|
|
247
|
+
destroyMentionPopover();
|
|
248
|
+
}
|
|
249
|
+
}, "handleDocumentFocusIn");
|
|
250
|
+
const handleDocumentPointerDown = /* @__PURE__ */ __name((event) => {
|
|
251
|
+
if (!isWithinMentionContext(event.target)) {
|
|
252
|
+
destroyMentionPopover();
|
|
253
|
+
}
|
|
254
|
+
}, "handleDocumentPointerDown");
|
|
255
|
+
const handleEditorFocusOut = /* @__PURE__ */ __name((event) => {
|
|
256
|
+
if (!isWithinMentionContext(event.relatedTarget)) {
|
|
257
|
+
destroyMentionPopover();
|
|
258
|
+
}
|
|
259
|
+
}, "handleEditorFocusOut");
|
|
260
|
+
document.addEventListener("focusin", handleDocumentFocusIn);
|
|
261
|
+
document.addEventListener("mousedown", handleDocumentPointerDown, true);
|
|
262
|
+
document.addEventListener("touchstart", handleDocumentPointerDown, true);
|
|
263
|
+
editorElement.addEventListener("focusout", handleEditorFocusOut);
|
|
264
|
+
removeOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
265
|
+
document.removeEventListener("focusin", handleDocumentFocusIn);
|
|
266
|
+
document.removeEventListener("mousedown", handleDocumentPointerDown, true);
|
|
267
|
+
document.removeEventListener("touchstart", handleDocumentPointerDown, true);
|
|
268
|
+
editorElement == null ? void 0 : editorElement.removeEventListener("focusout", handleEditorFocusOut);
|
|
269
|
+
}, "removeOutsideListeners");
|
|
270
|
+
}, "setupOutsideListeners");
|
|
271
|
+
const getVirtualElement = /* @__PURE__ */ __name(() => {
|
|
272
|
+
if (!clientRectProvider) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
getBoundingClientRect: () => {
|
|
277
|
+
var _a;
|
|
278
|
+
return (_a = clientRectProvider == null ? void 0 : clientRectProvider()) != null ? _a : new DOMRect();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}, "getVirtualElement");
|
|
282
|
+
const updatePopoverPosition = /* @__PURE__ */ __name(() => {
|
|
283
|
+
const virtualElement = getVirtualElement();
|
|
284
|
+
if (!virtualElement || !popoverWrapper) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (!popperInstance) {
|
|
288
|
+
popperInstance = (0, import_core.createPopper)(virtualElement, popoverWrapper, {
|
|
289
|
+
placement: "bottom-start",
|
|
290
|
+
modifiers: [{
|
|
291
|
+
name: "offset",
|
|
292
|
+
options: {
|
|
293
|
+
offset: [0, 8]
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
name: "flip",
|
|
297
|
+
options: {
|
|
298
|
+
fallbackPlacements: ["top-start"]
|
|
299
|
+
}
|
|
300
|
+
}]
|
|
301
|
+
});
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
popperInstance.update();
|
|
305
|
+
}, "updatePopoverPosition");
|
|
306
|
+
return {
|
|
307
|
+
onStart: (props) => {
|
|
308
|
+
clientRectProvider = props.clientRect;
|
|
309
|
+
editorElement = props.editor.view.dom;
|
|
310
|
+
component = new import_vue_3.VueRenderer(MentionList, {
|
|
311
|
+
editor: props.editor,
|
|
312
|
+
props: {
|
|
313
|
+
items: props.items,
|
|
314
|
+
command: props.command
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
popoverWrapper = document.createElement("div");
|
|
318
|
+
popoverWrapper.style.position = "absolute";
|
|
319
|
+
popoverWrapper.style.zIndex = "var(--mp-z-index-popover)";
|
|
320
|
+
if (component.element) {
|
|
321
|
+
popoverWrapper.append(component.element);
|
|
322
|
+
}
|
|
323
|
+
document.body.append(popoverWrapper);
|
|
324
|
+
setupOutsideListeners();
|
|
325
|
+
updatePopoverPosition();
|
|
326
|
+
},
|
|
327
|
+
onUpdate: (props) => {
|
|
328
|
+
clientRectProvider = props.clientRect;
|
|
329
|
+
component == null ? void 0 : component.updateProps({
|
|
330
|
+
items: props.items,
|
|
331
|
+
command: props.command
|
|
332
|
+
});
|
|
333
|
+
updatePopoverPosition();
|
|
334
|
+
},
|
|
335
|
+
onKeyDown: (props) => {
|
|
336
|
+
var _a, _b;
|
|
337
|
+
if (props.event.key === "Escape") {
|
|
338
|
+
destroyMentionPopover();
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
return (_b = (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props)) != null ? _b : false;
|
|
342
|
+
},
|
|
343
|
+
onExit: () => {
|
|
344
|
+
destroyMentionPopover();
|
|
345
|
+
editorElement = null;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}, "createMentionSuggestion");
|
|
351
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
352
|
+
0 && (module.exports = {
|
|
353
|
+
createMentionSuggestion
|
|
354
|
+
});
|
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.0.
|
|
4
|
+
"version": "0.1.0-dev.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -9,43 +9,47 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@popperjs/core": "^2.11.4",
|
|
12
|
+
"@tiptap/core": "2.7.4",
|
|
12
13
|
"@tiptap/extension-blockquote": "2.7.4",
|
|
13
14
|
"@tiptap/extension-bold": "2.7.4",
|
|
14
15
|
"@tiptap/extension-bullet-list": "2.7.4",
|
|
15
16
|
"@tiptap/extension-character-count": "2.7.4",
|
|
16
17
|
"@tiptap/extension-code": "2.7.4",
|
|
17
18
|
"@tiptap/extension-code-block": "2.7.4",
|
|
19
|
+
"@tiptap/extension-color": "2.7.4",
|
|
18
20
|
"@tiptap/extension-document": "2.7.4",
|
|
19
21
|
"@tiptap/extension-dropcursor": "2.7.4",
|
|
20
22
|
"@tiptap/extension-gapcursor": "2.7.4",
|
|
21
23
|
"@tiptap/extension-hard-break": "2.7.4",
|
|
22
24
|
"@tiptap/extension-heading": "2.7.4",
|
|
25
|
+
"@tiptap/extension-highlight": "2.7.4",
|
|
23
26
|
"@tiptap/extension-horizontal-rule": "2.7.4",
|
|
24
27
|
"@tiptap/extension-italic": "2.7.4",
|
|
25
28
|
"@tiptap/extension-link": "2.7.4",
|
|
26
29
|
"@tiptap/extension-list-item": "2.7.4",
|
|
27
30
|
"@tiptap/extension-list-keymap": "2.7.4",
|
|
31
|
+
"@tiptap/extension-mention": "2.7.4",
|
|
28
32
|
"@tiptap/extension-ordered-list": "2.7.4",
|
|
29
33
|
"@tiptap/extension-paragraph": "2.7.4",
|
|
34
|
+
"@tiptap/extension-placeholder": "2.7.4",
|
|
30
35
|
"@tiptap/extension-strike": "2.7.4",
|
|
31
36
|
"@tiptap/extension-text": "2.7.4",
|
|
32
|
-
"@tiptap/extension-underline": "2.7.4",
|
|
33
|
-
"@tiptap/extension-color": "2.7.4",
|
|
34
|
-
"@tiptap/extension-highlight": "2.7.4",
|
|
35
|
-
"@tiptap/extension-placeholder": "2.7.4",
|
|
36
37
|
"@tiptap/extension-text-align": "2.7.4",
|
|
37
38
|
"@tiptap/extension-text-style": "2.7.4",
|
|
39
|
+
"@tiptap/extension-underline": "2.7.4",
|
|
38
40
|
"@tiptap/pm": "2.7.4",
|
|
39
41
|
"@tiptap/starter-kit": "2.7.4",
|
|
40
|
-
"@tiptap/
|
|
42
|
+
"@tiptap/suggestion": "2.7.4",
|
|
41
43
|
"@tiptap/vue-3": "2.7.4",
|
|
42
|
-
"@mekari/pixel3-
|
|
43
|
-
"@mekari/pixel3-
|
|
44
|
-
"@mekari/pixel3-divider": "0.0.22",
|
|
44
|
+
"@mekari/pixel3-avatar": "0.0.26-dev.0",
|
|
45
|
+
"@mekari/pixel3-button": "0.2.1-dev.0",
|
|
45
46
|
"@mekari/pixel3-form-control": "0.0.22",
|
|
46
|
-
"@mekari/pixel3-
|
|
47
|
-
"@mekari/pixel3-
|
|
47
|
+
"@mekari/pixel3-divider": "0.0.22",
|
|
48
|
+
"@mekari/pixel3-input": "0.0.26-dev.0",
|
|
49
|
+
"@mekari/pixel3-color-picker": "0.2.0-dev.1",
|
|
50
|
+
"@mekari/pixel3-popover": "0.0.26-dev.0",
|
|
48
51
|
"@mekari/pixel3-styled-system": "0.2.0",
|
|
52
|
+
"@mekari/pixel3-scrollbar": "0.1.6",
|
|
49
53
|
"@mekari/pixel3-text": "0.0.22",
|
|
50
54
|
"@mekari/pixel3-utils": "0.1.0"
|
|
51
55
|
},
|