@mekari/pixel3-rich-text-editor 0.0.18 → 0.1.0-dev.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-FZPMIQTC.mjs → chunk-2LGSTJSZ.mjs} +2 -1
- package/dist/chunk-4KJOYLJI.mjs +168 -0
- package/dist/chunk-4TUA5VF4.mjs +173 -0
- package/dist/{chunk-2OCRJNTJ.mjs → chunk-7RMCTPMN.mjs} +2 -2
- package/dist/{chunk-ES3FCTTF.mjs → chunk-E3MEVHFO.mjs} +27 -6
- package/dist/{chunk-WBMECFO3.mjs → chunk-MCGJK3E4.mjs} +18 -46
- package/dist/{chunk-73N5SLQ5.mjs → chunk-MUYPED2X.mjs} +82 -25
- package/dist/{chunk-V52XUOVW.mjs → chunk-O33DDWRB.mjs} +10 -2
- package/dist/{chunk-RNQQ7LGC.mjs → chunk-PQRMWB4A.mjs} +73 -1
- package/dist/{chunk-JAKI6TU2.mjs → chunk-QG3GEBVL.mjs} +8 -22
- package/dist/{chunk-GVMGRBDI.mjs → chunk-TNDDXUVW.mjs} +5 -1
- package/dist/{chunk-VK7QDWXR.mjs → chunk-YCSNVWMP.mjs} +18 -5
- 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 +12 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ColorTextIcon,
|
|
3
3
|
FillTextIcon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PQRMWB4A.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-QZ7VFGWC.mjs";
|
|
@@ -57,6 +57,7 @@ var ColorExtension = defineComponent({
|
|
|
57
57
|
"preset": colorPreset,
|
|
58
58
|
"variant": "basic",
|
|
59
59
|
"placement": "bottom-start",
|
|
60
|
+
"usePortal": true,
|
|
60
61
|
"isShowPreset": true,
|
|
61
62
|
"isShowInput": false,
|
|
62
63
|
"class": css({
|
|
@@ -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
|
+
};
|
|
@@ -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-
|
|
3
|
+
} from "./chunk-ZRAXSVO5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
RTEStyleProviderProps
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TNDDXUVW.mjs";
|
|
7
7
|
|
|
8
8
|
// src/rte-style-provider.tsx
|
|
9
9
|
import { createVNode as _createVNode } from "vue";
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EditorToolbar
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MUYPED2X.mjs";
|
|
4
4
|
import {
|
|
5
5
|
MpRTEStyleProvider
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7RMCTPMN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useRichTextEditor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZRAXSVO5.mjs";
|
|
10
10
|
import {
|
|
11
11
|
richTextEditorEmits,
|
|
12
12
|
richTextEditorProps
|
|
13
|
-
} from "./chunk-
|
|
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
|
|
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({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CaretIcon
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PQRMWB4A.mjs";
|
|
4
4
|
|
|
5
5
|
// src/extensions/heading-extension.tsx
|
|
6
6
|
import { withDirectives as _withDirectives, resolveDirective as _resolveDirective, createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
|
@@ -23,7 +23,8 @@ var HeadingExtention = defineComponent({
|
|
|
23
23
|
editor
|
|
24
24
|
}) {
|
|
25
25
|
return () => _createVNode(MpPopover, {
|
|
26
|
-
"id": "popover-heading-extention"
|
|
26
|
+
"id": "popover-heading-extention",
|
|
27
|
+
"usePortal": true
|
|
27
28
|
}, {
|
|
28
29
|
default: () => [_createVNode(MpPopoverTrigger, null, {
|
|
29
30
|
default: () => [_withDirectives(_createVNode("button", {
|
|
@@ -94,84 +95,55 @@ var HeadingExtention = defineComponent({
|
|
|
94
95
|
})
|
|
95
96
|
}, {
|
|
96
97
|
default: () => [_createVNode(MpPopoverList, {
|
|
97
|
-
"
|
|
98
|
-
gap: "2",
|
|
99
|
-
alignItems: "flex-start",
|
|
100
|
-
paddingLeft: "3"
|
|
101
|
-
})
|
|
98
|
+
"data-pixel-rte": true
|
|
102
99
|
}, {
|
|
103
100
|
default: () => [_createVNode(MpPopoverListItem, {
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
-
"text-sizing": true
|
|
109
|
-
},
|
|
101
|
+
"is-active": editor == null ? void 0 : editor.isActive("heading", {
|
|
102
|
+
level: 1
|
|
103
|
+
}),
|
|
110
104
|
"onClick": () => (editor == null ? void 0 : editor.chain()).focus().toggleHeading({
|
|
111
105
|
level: 1
|
|
112
106
|
}).run()
|
|
113
107
|
}, {
|
|
114
108
|
default: () => [_createVNode(MpText, {
|
|
115
109
|
"as": "h1",
|
|
116
|
-
"size": "h1"
|
|
117
|
-
"class": css({
|
|
118
|
-
color: "currentColor"
|
|
119
|
-
})
|
|
110
|
+
"size": "h1"
|
|
120
111
|
}, {
|
|
121
112
|
default: () => [_createTextVNode("Heading 1")]
|
|
122
113
|
})]
|
|
123
114
|
}), _createVNode(MpPopoverListItem, {
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}),
|
|
128
|
-
"text-sizing": true
|
|
129
|
-
},
|
|
115
|
+
"is-active": editor == null ? void 0 : editor.isActive("heading", {
|
|
116
|
+
level: 2
|
|
117
|
+
}),
|
|
130
118
|
"onClick": () => (editor == null ? void 0 : editor.chain()).focus().toggleHeading({
|
|
131
119
|
level: 2
|
|
132
120
|
}).run()
|
|
133
121
|
}, {
|
|
134
122
|
default: () => [_createVNode(MpText, {
|
|
135
123
|
"as": "h2",
|
|
136
|
-
"size": "h2"
|
|
137
|
-
"class": css({
|
|
138
|
-
color: "currentColor"
|
|
139
|
-
})
|
|
124
|
+
"size": "h2"
|
|
140
125
|
}, {
|
|
141
126
|
default: () => [_createTextVNode("Heading 2")]
|
|
142
127
|
})]
|
|
143
128
|
}), _createVNode(MpPopoverListItem, {
|
|
144
|
-
"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}),
|
|
148
|
-
"text-sizing": true
|
|
149
|
-
},
|
|
129
|
+
"is-active": editor == null ? void 0 : editor.isActive("heading", {
|
|
130
|
+
level: 3
|
|
131
|
+
}),
|
|
150
132
|
"onClick": () => (editor == null ? void 0 : editor.chain()).focus().toggleHeading({
|
|
151
133
|
level: 3
|
|
152
134
|
}).run()
|
|
153
135
|
}, {
|
|
154
136
|
default: () => [_createVNode(MpText, {
|
|
155
137
|
"as": "h3",
|
|
156
|
-
"size": "h3"
|
|
157
|
-
"class": css({
|
|
158
|
-
color: "currentColor"
|
|
159
|
-
})
|
|
138
|
+
"size": "h3"
|
|
160
139
|
}, {
|
|
161
140
|
default: () => [_createTextVNode("Heading 3")]
|
|
162
141
|
})]
|
|
163
142
|
}), _createVNode(MpPopoverListItem, {
|
|
164
|
-
"
|
|
165
|
-
"is-active": editor == null ? void 0 : editor.isActive("paragraph"),
|
|
166
|
-
"text-sizing": true
|
|
167
|
-
},
|
|
143
|
+
"is-active": editor == null ? void 0 : editor.isActive("paragraph"),
|
|
168
144
|
"onClick": () => (editor == null ? void 0 : editor.chain()).focus().setParagraph().run()
|
|
169
145
|
}, {
|
|
170
|
-
default: () => [_createVNode(MpText, {
|
|
171
|
-
"class": css({
|
|
172
|
-
color: "currentColor"
|
|
173
|
-
})
|
|
174
|
-
}, {
|
|
146
|
+
default: () => [_createVNode(MpText, null, {
|
|
175
147
|
default: () => [_createTextVNode("Normal text")]
|
|
176
148
|
})]
|
|
177
149
|
})]
|