@mekari/pixel3-rich-text-editor 0.1.3-dev.0 → 0.1.3
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-ZYSEHV5N.mjs → chunk-4ZCPCZD2.mjs} +5 -5
- package/dist/{chunk-47IOAHWN.mjs → chunk-FCLBNBXD.mjs} +21 -14
- package/dist/{chunk-UD5PDCGC.mjs → chunk-G4CGNV6P.mjs} +95 -58
- package/dist/editor-toolbar.js +109 -65
- package/dist/editor-toolbar.mjs +5 -5
- package/dist/extensions/index.js +21 -14
- package/dist/extensions/index.mjs +10 -10
- package/dist/extensions/single-extension.d.mts +11 -1
- package/dist/extensions/single-extension.d.ts +11 -1
- package/dist/extensions/single-extension.js +21 -14
- package/dist/extensions/single-extension.mjs +1 -1
- package/dist/index.js +109 -65
- package/dist/index.mjs +10 -10
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +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.js +109 -65
- package/dist/rich-text-editor.mjs +10 -10
- package/dist/rte-style-provider.mjs +2 -2
- package/package.json +12 -12
- package/dist/{chunk-AIWY3FHJ.mjs → chunk-BA5A7DIS.mjs} +3 -3
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EditorToolbar
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G4CGNV6P.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Variable
|
|
6
6
|
} from "./chunk-ENKUUZPM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
MpRTEStyleProvider
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
useRichTextEditor
|
|
12
|
-
} from "./chunk-ZRAXSVO5.mjs";
|
|
9
|
+
} from "./chunk-BA5A7DIS.mjs";
|
|
13
10
|
import {
|
|
14
11
|
richTextEditorEmits,
|
|
15
12
|
richTextEditorProps
|
|
@@ -20,6 +17,9 @@ import {
|
|
|
20
17
|
import {
|
|
21
18
|
createVariableSuggestion
|
|
22
19
|
} from "./chunk-BWRU2WZN.mjs";
|
|
20
|
+
import {
|
|
21
|
+
useRichTextEditor
|
|
22
|
+
} from "./chunk-ZRAXSVO5.mjs";
|
|
23
23
|
import {
|
|
24
24
|
__name
|
|
25
25
|
} from "./chunk-QZ7VFGWC.mjs";
|
|
@@ -34,14 +34,13 @@ var SingleExtention = defineComponent({
|
|
|
34
34
|
},
|
|
35
35
|
editor: {
|
|
36
36
|
type: Object
|
|
37
|
+
},
|
|
38
|
+
isDisabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
37
41
|
}
|
|
38
42
|
},
|
|
39
|
-
setup({
|
|
40
|
-
name,
|
|
41
|
-
tooltipLabel,
|
|
42
|
-
onClick,
|
|
43
|
-
editor
|
|
44
|
-
}) {
|
|
43
|
+
setup(props) {
|
|
45
44
|
const iconMap = {
|
|
46
45
|
bold: _createVNode(BoldIcon, null, null),
|
|
47
46
|
italic: _createVNode(ItalicIcon, null, null),
|
|
@@ -60,14 +59,22 @@ var SingleExtention = defineComponent({
|
|
|
60
59
|
variable: _createVNode(VariableIcon, null, null),
|
|
61
60
|
location: _createVNode(LocationIcon, null, null)
|
|
62
61
|
};
|
|
63
|
-
return () =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
return () => {
|
|
63
|
+
var _a;
|
|
64
|
+
return _withDirectives(_createVNode("button", {
|
|
65
|
+
"class": {
|
|
66
|
+
"is-active": props.name && ((_a = props.editor) == null ? void 0 : _a.isActive(props.name))
|
|
67
|
+
},
|
|
68
|
+
"style": props.isDisabled ? {
|
|
69
|
+
opacity: "0.4",
|
|
70
|
+
cursor: "not-allowed"
|
|
71
|
+
} : void 0,
|
|
72
|
+
"disabled": props.isDisabled,
|
|
73
|
+
"onClick": props.isDisabled ? void 0 : props.onClick
|
|
74
|
+
}, [props.name && iconMap[props.name]]), [[_resolveDirective("tooltip"), {
|
|
75
|
+
label: props.tooltipLabel
|
|
76
|
+
}]]);
|
|
77
|
+
};
|
|
71
78
|
}
|
|
72
79
|
});
|
|
73
80
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HeadingExtention
|
|
3
|
-
} from "./chunk-X2CB42A3.mjs";
|
|
4
|
-
import {
|
|
5
|
-
LinkExtension
|
|
6
|
-
} from "./chunk-COZ45QUD.mjs";
|
|
7
1
|
import {
|
|
8
2
|
SingleExtention
|
|
9
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FCLBNBXD.mjs";
|
|
10
4
|
import {
|
|
11
5
|
AlignExtention
|
|
12
6
|
} from "./chunk-YWVVMJGP.mjs";
|
|
13
7
|
import {
|
|
14
8
|
ColorExtension
|
|
15
9
|
} 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";
|
|
@@ -40,77 +40,102 @@ var EditorToolbar = defineComponent({
|
|
|
40
40
|
type: Function
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
setup({
|
|
44
|
-
editor,
|
|
45
|
-
options,
|
|
46
|
-
validateLink,
|
|
47
|
-
transformLink
|
|
48
|
-
}, {
|
|
43
|
+
setup(props, {
|
|
49
44
|
emit
|
|
50
45
|
}) {
|
|
51
46
|
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
|
|
52
|
-
const
|
|
47
|
+
const getItemOptions = /* @__PURE__ */ __name(() => ({
|
|
53
48
|
heading: {
|
|
54
49
|
tooltipLabel: "Text style",
|
|
55
|
-
editor
|
|
50
|
+
editor: props.editor
|
|
56
51
|
},
|
|
57
52
|
bold: {
|
|
58
53
|
tooltipLabel: "Bold",
|
|
59
|
-
onClick: () =>
|
|
54
|
+
onClick: () => {
|
|
55
|
+
var _a;
|
|
56
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBold().run();
|
|
57
|
+
}
|
|
60
58
|
},
|
|
61
59
|
italic: {
|
|
62
60
|
tooltipLabel: "Italic",
|
|
63
|
-
onClick: () =>
|
|
61
|
+
onClick: () => {
|
|
62
|
+
var _a;
|
|
63
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleItalic().run();
|
|
64
|
+
}
|
|
64
65
|
},
|
|
65
66
|
underline: {
|
|
66
67
|
tooltipLabel: "Underline",
|
|
67
|
-
onClick: () =>
|
|
68
|
+
onClick: () => {
|
|
69
|
+
var _a;
|
|
70
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleUnderline().run();
|
|
71
|
+
}
|
|
68
72
|
},
|
|
69
73
|
strike: {
|
|
70
74
|
tooltipLabel: "Strike",
|
|
71
|
-
onClick: () =>
|
|
75
|
+
onClick: () => {
|
|
76
|
+
var _a;
|
|
77
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleStrike().run();
|
|
78
|
+
}
|
|
72
79
|
},
|
|
73
80
|
blockquote: {
|
|
74
81
|
tooltipLabel: "Blockquote",
|
|
75
|
-
onClick: () =>
|
|
82
|
+
onClick: () => {
|
|
83
|
+
var _a;
|
|
84
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBlockquote().run();
|
|
85
|
+
}
|
|
76
86
|
},
|
|
77
87
|
bulletList: {
|
|
78
88
|
tooltipLabel: "Bullet list",
|
|
79
|
-
onClick: () =>
|
|
89
|
+
onClick: () => {
|
|
90
|
+
var _a;
|
|
91
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBulletList().run();
|
|
92
|
+
}
|
|
80
93
|
},
|
|
81
94
|
orderedList: {
|
|
82
95
|
tooltipLabel: "Number list",
|
|
83
|
-
onClick: () =>
|
|
96
|
+
onClick: () => {
|
|
97
|
+
var _a;
|
|
98
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleOrderedList().run();
|
|
99
|
+
}
|
|
84
100
|
},
|
|
85
101
|
textColor: {
|
|
86
102
|
tooltipLabel: "Text color",
|
|
87
|
-
editor,
|
|
103
|
+
editor: props.editor,
|
|
88
104
|
type: "text"
|
|
89
105
|
},
|
|
90
106
|
fillColor: {
|
|
91
107
|
tooltipLabel: "Fill color",
|
|
92
|
-
editor,
|
|
108
|
+
editor: props.editor,
|
|
93
109
|
type: "fill"
|
|
94
110
|
},
|
|
95
111
|
textLink: {
|
|
96
112
|
tooltipLabel: "Insert link",
|
|
97
|
-
editor
|
|
113
|
+
editor: props.editor
|
|
98
114
|
},
|
|
99
115
|
align: {
|
|
100
116
|
tooltipLabel: "Text alignment",
|
|
101
|
-
editor
|
|
117
|
+
editor: props.editor
|
|
102
118
|
},
|
|
103
119
|
undo: {
|
|
104
120
|
tooltipLabel: "Undo",
|
|
105
|
-
onClick: () =>
|
|
121
|
+
onClick: () => {
|
|
122
|
+
var _a;
|
|
123
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().undo().run();
|
|
124
|
+
}
|
|
106
125
|
},
|
|
107
126
|
redo: {
|
|
108
127
|
tooltipLabel: "Redo",
|
|
109
|
-
onClick: () =>
|
|
128
|
+
onClick: () => {
|
|
129
|
+
var _a;
|
|
130
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().redo().run();
|
|
131
|
+
}
|
|
110
132
|
},
|
|
111
133
|
clear: {
|
|
112
134
|
tooltipLabel: "Reset format",
|
|
113
|
-
onClick: () =>
|
|
135
|
+
onClick: () => {
|
|
136
|
+
var _a;
|
|
137
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().unsetAllMarks().run();
|
|
138
|
+
}
|
|
114
139
|
},
|
|
115
140
|
image: {
|
|
116
141
|
tooltipLabel: "Add image",
|
|
@@ -126,19 +151,21 @@ var EditorToolbar = defineComponent({
|
|
|
126
151
|
},
|
|
127
152
|
mention: {
|
|
128
153
|
tooltipLabel: "Mention",
|
|
129
|
-
editor,
|
|
154
|
+
editor: props.editor,
|
|
130
155
|
onClick: () => {
|
|
156
|
+
var _a;
|
|
131
157
|
;
|
|
132
|
-
(editor == null ? void 0 :
|
|
158
|
+
((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("@").run();
|
|
133
159
|
emit("clickMention");
|
|
134
160
|
}
|
|
135
161
|
},
|
|
136
162
|
variable: {
|
|
137
163
|
tooltipLabel: "Insert variable",
|
|
138
|
-
editor,
|
|
164
|
+
editor: props.editor,
|
|
139
165
|
onClick: () => {
|
|
166
|
+
var _a;
|
|
140
167
|
;
|
|
141
|
-
(editor == null ? void 0 :
|
|
168
|
+
((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("{").run();
|
|
142
169
|
emit("clickVariable");
|
|
143
170
|
}
|
|
144
171
|
},
|
|
@@ -146,7 +173,7 @@ var EditorToolbar = defineComponent({
|
|
|
146
173
|
tooltipLabel: "Add location",
|
|
147
174
|
onClick: () => emit("clickLocation")
|
|
148
175
|
}
|
|
149
|
-
};
|
|
176
|
+
}), "getItemOptions");
|
|
150
177
|
const getResolvedItem = /* @__PURE__ */ __name((option) => {
|
|
151
178
|
if (typeof option === "string") {
|
|
152
179
|
return {
|
|
@@ -155,17 +182,20 @@ var EditorToolbar = defineComponent({
|
|
|
155
182
|
}
|
|
156
183
|
return {
|
|
157
184
|
item: option.value,
|
|
158
|
-
tooltip: option.tooltip
|
|
185
|
+
tooltip: option.tooltip,
|
|
186
|
+
disabled: option.disabled
|
|
159
187
|
};
|
|
160
188
|
}, "getResolvedItem");
|
|
161
189
|
const renderExtension = /* @__PURE__ */ __name((option) => {
|
|
162
190
|
const {
|
|
163
191
|
item,
|
|
164
|
-
tooltip
|
|
192
|
+
tooltip,
|
|
193
|
+
disabled
|
|
165
194
|
} = getResolvedItem(option);
|
|
166
195
|
if (!items.includes(item))
|
|
167
196
|
return null;
|
|
168
197
|
const resolvedItem = item;
|
|
198
|
+
const itemOptions = getItemOptions();
|
|
169
199
|
const resolvedOptions = itemOptions[resolvedItem];
|
|
170
200
|
if (!resolvedOptions)
|
|
171
201
|
return null;
|
|
@@ -174,33 +204,34 @@ var EditorToolbar = defineComponent({
|
|
|
174
204
|
case "heading":
|
|
175
205
|
return _createVNode(HeadingExtention, {
|
|
176
206
|
"tooltipLabel": tooltipLabel,
|
|
177
|
-
"editor": editor
|
|
207
|
+
"editor": props.editor
|
|
178
208
|
}, null);
|
|
179
209
|
case "align":
|
|
180
210
|
return _createVNode(AlignExtention, {
|
|
181
211
|
"tooltipLabel": tooltipLabel,
|
|
182
|
-
"editor": editor
|
|
212
|
+
"editor": props.editor
|
|
183
213
|
}, null);
|
|
184
214
|
case "textColor":
|
|
185
215
|
case "fillColor":
|
|
186
216
|
return _createVNode(ColorExtension, {
|
|
187
217
|
"tooltipLabel": tooltipLabel,
|
|
188
|
-
"editor": editor,
|
|
218
|
+
"editor": props.editor,
|
|
189
219
|
"type": resolvedOptions.type
|
|
190
220
|
}, null);
|
|
191
221
|
case "textLink":
|
|
192
222
|
return _createVNode(LinkExtension, {
|
|
193
223
|
"tooltipLabel": tooltipLabel,
|
|
194
|
-
"editor": editor,
|
|
195
|
-
"validateLink": validateLink,
|
|
196
|
-
"transformLink": transformLink
|
|
224
|
+
"editor": props.editor,
|
|
225
|
+
"validateLink": props.validateLink,
|
|
226
|
+
"transformLink": props.transformLink
|
|
197
227
|
}, null);
|
|
198
228
|
default:
|
|
199
229
|
return _createVNode(SingleExtention, {
|
|
200
230
|
"name": resolvedItem,
|
|
201
231
|
"tooltipLabel": tooltipLabel,
|
|
202
232
|
"onClick": resolvedOptions.onClick,
|
|
203
|
-
"editor": editor
|
|
233
|
+
"editor": props.editor,
|
|
234
|
+
"isDisabled": disabled
|
|
204
235
|
}, null);
|
|
205
236
|
}
|
|
206
237
|
}, "renderExtension");
|
|
@@ -212,21 +243,27 @@ var EditorToolbar = defineComponent({
|
|
|
212
243
|
}
|
|
213
244
|
}
|
|
214
245
|
}, {
|
|
215
|
-
default: () =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
246
|
+
default: () => {
|
|
247
|
+
var _a;
|
|
248
|
+
return [_createVNode("div", {
|
|
249
|
+
"class": css({
|
|
250
|
+
display: "flex",
|
|
251
|
+
alignItems: "stretch",
|
|
252
|
+
gap: "1"
|
|
253
|
+
})
|
|
254
|
+
}, [(_a = props.options) == null ? void 0 : _a.map((option, index) => {
|
|
255
|
+
var _a2, _b;
|
|
256
|
+
return _createVNode(_Fragment, null, [option.map((item) => {
|
|
257
|
+
const resolvedItem = typeof item === "string" ? item : item.value;
|
|
258
|
+
if (items.includes(resolvedItem)) {
|
|
259
|
+
return renderExtension(item);
|
|
260
|
+
}
|
|
261
|
+
}), index !== ((_b = (_a2 = props.options) == null ? void 0 : _a2.length) != null ? _b : 0) - 1 && _createVNode(MpDivider, {
|
|
262
|
+
"id": "divider-toolbar",
|
|
263
|
+
"orientation": "vertical"
|
|
264
|
+
}, null)]);
|
|
265
|
+
})])];
|
|
266
|
+
}
|
|
230
267
|
});
|
|
231
268
|
}
|
|
232
269
|
});
|