@mekari/pixel3-rich-text-editor 0.1.2 → 0.1.3-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.
Files changed (68) hide show
  1. package/dist/{chunk-7BEXEMOE.mjs → chunk-6O4HSL2C.mjs} +4 -0
  2. package/dist/chunk-76GEEOAG.mjs +189 -0
  3. package/dist/{chunk-MKTM47RO.mjs → chunk-AIWY3FHJ.mjs} +1 -1
  4. package/dist/chunk-BWRU2WZN.mjs +202 -0
  5. package/dist/{chunk-ZO6THAT6.mjs → chunk-COZ45QUD.mjs} +1 -1
  6. package/dist/chunk-ENKUUZPM.mjs +124 -0
  7. package/dist/{chunk-25RKPG44.mjs → chunk-FCLBNBXD.mjs} +25 -16
  8. package/dist/{chunk-Q7QLZISF.mjs → chunk-IFRJVX2K.mjs} +29 -1
  9. package/dist/{chunk-YE6FEVD4.mjs → chunk-RX7ZEE2M.mjs} +104 -58
  10. package/dist/{chunk-XNM3YX37.mjs → chunk-T7RFFPSJ.mjs} +13 -3
  11. package/dist/{chunk-YIEQVTEO.mjs → chunk-X2CB42A3.mjs} +1 -1
  12. package/dist/{chunk-5S2LSGJV.mjs → chunk-Y6UPQ6EU.mjs} +1 -1
  13. package/dist/{chunk-UBJOZ2IA.mjs → chunk-YWVVMJGP.mjs} +1 -1
  14. package/dist/editor-toolbar.d.mts +2 -1
  15. package/dist/editor-toolbar.d.ts +2 -1
  16. package/dist/editor-toolbar.js +469 -75
  17. package/dist/editor-toolbar.mjs +10 -8
  18. package/dist/extensions/align-extension.js +27 -0
  19. package/dist/extensions/align-extension.mjs +2 -2
  20. package/dist/extensions/color-extension.js +27 -0
  21. package/dist/extensions/color-extension.mjs +2 -2
  22. package/dist/extensions/heading-extension.js +27 -0
  23. package/dist/extensions/heading-extension.mjs +2 -2
  24. package/dist/extensions/icons.d.mts +2 -1
  25. package/dist/extensions/icons.d.ts +2 -1
  26. package/dist/extensions/icons.js +31 -2
  27. package/dist/extensions/icons.mjs +5 -3
  28. package/dist/extensions/index.d.mts +6 -0
  29. package/dist/extensions/index.d.ts +6 -0
  30. package/dist/extensions/index.js +368 -16
  31. package/dist/extensions/index.mjs +18 -10
  32. package/dist/extensions/link-extension.js +27 -0
  33. package/dist/extensions/link-extension.mjs +2 -2
  34. package/dist/extensions/single-extension.d.mts +12 -2
  35. package/dist/extensions/single-extension.d.ts +12 -2
  36. package/dist/extensions/single-extension.js +49 -14
  37. package/dist/extensions/single-extension.mjs +2 -2
  38. package/dist/extensions/variable-extension.d.mts +19 -0
  39. package/dist/extensions/variable-extension.d.ts +19 -0
  40. package/dist/extensions/variable-extension.js +158 -0
  41. package/dist/extensions/variable-extension.mjs +7 -0
  42. package/dist/extensions/variable-list-extension.d.mts +33 -0
  43. package/dist/extensions/variable-list-extension.d.ts +33 -0
  44. package/dist/extensions/variable-list-extension.js +210 -0
  45. package/dist/extensions/variable-list-extension.mjs +7 -0
  46. package/dist/index.d.mts +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +699 -116
  49. package/dist/index.mjs +14 -11
  50. package/dist/metafile-cjs.json +1 -1
  51. package/dist/metafile-esm.json +1 -1
  52. package/dist/modules/rich-text-editor.props.d.mts +5 -1
  53. package/dist/modules/rich-text-editor.props.d.ts +5 -1
  54. package/dist/modules/rich-text-editor.props.js +4 -0
  55. package/dist/modules/rich-text-editor.props.mjs +1 -1
  56. package/dist/modules/rich-text-editor.types.d.mts +11 -3
  57. package/dist/modules/rich-text-editor.types.d.ts +11 -3
  58. package/dist/rich-text-editor.d.mts +10 -1
  59. package/dist/rich-text-editor.d.ts +10 -1
  60. package/dist/rich-text-editor.js +699 -116
  61. package/dist/rich-text-editor.mjs +14 -11
  62. package/dist/rte-style-provider.mjs +2 -2
  63. package/dist/rte-variable-suggestion.d.mts +11 -0
  64. package/dist/rte-variable-suggestion.d.ts +11 -0
  65. package/dist/rte-variable-suggestion.js +405 -0
  66. package/dist/rte-variable-suggestion.mjs +10 -0
  67. package/package.json +12 -12
  68. /package/dist/{chunk-VYCDVS5I.mjs → chunk-HIHIKPNN.mjs} +0 -0
@@ -1,18 +1,18 @@
1
+ import {
2
+ HeadingExtention
3
+ } from "./chunk-X2CB42A3.mjs";
1
4
  import {
2
5
  LinkExtension
3
- } from "./chunk-ZO6THAT6.mjs";
6
+ } from "./chunk-COZ45QUD.mjs";
4
7
  import {
5
8
  SingleExtention
6
- } from "./chunk-25RKPG44.mjs";
9
+ } from "./chunk-FCLBNBXD.mjs";
7
10
  import {
8
11
  AlignExtention
9
- } from "./chunk-UBJOZ2IA.mjs";
12
+ } from "./chunk-YWVVMJGP.mjs";
10
13
  import {
11
14
  ColorExtension
12
- } from "./chunk-5S2LSGJV.mjs";
13
- import {
14
- HeadingExtention
15
- } from "./chunk-YIEQVTEO.mjs";
15
+ } from "./chunk-Y6UPQ6EU.mjs";
16
16
  import {
17
17
  __name
18
18
  } from "./chunk-QZ7VFGWC.mjs";
@@ -25,7 +25,7 @@ import { MpDivider } from "@mekari/pixel3-divider";
25
25
  import { MpScrollbar } from "@mekari/pixel3-scrollbar";
26
26
  var EditorToolbar = defineComponent({
27
27
  name: "EditorToolbar",
28
- emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickLocation"],
28
+ emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickVariable", "clickLocation"],
29
29
  props: {
30
30
  editor: {
31
31
  type: Object
@@ -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
- const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "location"];
52
- const itemOptions = {
46
+ const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleBold().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleItalic().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleUnderline().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleStrike().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleBlockquote().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleBulletList().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().toggleOrderedList().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().undo().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().redo().run()
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: () => (editor == null ? void 0 : editor.chain()).focus().unsetAllMarks().run()
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,18 +151,29 @@ 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 : editor.chain()).focus().insertContent("@").run();
158
+ ((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("@").run();
133
159
  emit("clickMention");
134
160
  }
135
161
  },
162
+ variable: {
163
+ tooltipLabel: "Insert variable",
164
+ editor: props.editor,
165
+ onClick: () => {
166
+ var _a;
167
+ ;
168
+ ((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("{").run();
169
+ emit("clickVariable");
170
+ }
171
+ },
136
172
  location: {
137
173
  tooltipLabel: "Add location",
138
174
  onClick: () => emit("clickLocation")
139
175
  }
140
- };
176
+ }), "getItemOptions");
141
177
  const getResolvedItem = /* @__PURE__ */ __name((option) => {
142
178
  if (typeof option === "string") {
143
179
  return {
@@ -146,17 +182,20 @@ var EditorToolbar = defineComponent({
146
182
  }
147
183
  return {
148
184
  item: option.value,
149
- tooltip: option.tooltip
185
+ tooltip: option.tooltip,
186
+ disabled: option.disabled
150
187
  };
151
188
  }, "getResolvedItem");
152
189
  const renderExtension = /* @__PURE__ */ __name((option) => {
153
190
  const {
154
191
  item,
155
- tooltip
192
+ tooltip,
193
+ disabled
156
194
  } = getResolvedItem(option);
157
195
  if (!items.includes(item))
158
196
  return null;
159
197
  const resolvedItem = item;
198
+ const itemOptions = getItemOptions();
160
199
  const resolvedOptions = itemOptions[resolvedItem];
161
200
  if (!resolvedOptions)
162
201
  return null;
@@ -165,33 +204,34 @@ var EditorToolbar = defineComponent({
165
204
  case "heading":
166
205
  return _createVNode(HeadingExtention, {
167
206
  "tooltipLabel": tooltipLabel,
168
- "editor": editor
207
+ "editor": props.editor
169
208
  }, null);
170
209
  case "align":
171
210
  return _createVNode(AlignExtention, {
172
211
  "tooltipLabel": tooltipLabel,
173
- "editor": editor
212
+ "editor": props.editor
174
213
  }, null);
175
214
  case "textColor":
176
215
  case "fillColor":
177
216
  return _createVNode(ColorExtension, {
178
217
  "tooltipLabel": tooltipLabel,
179
- "editor": editor,
218
+ "editor": props.editor,
180
219
  "type": resolvedOptions.type
181
220
  }, null);
182
221
  case "textLink":
183
222
  return _createVNode(LinkExtension, {
184
223
  "tooltipLabel": tooltipLabel,
185
- "editor": editor,
186
- "validateLink": validateLink,
187
- "transformLink": transformLink
224
+ "editor": props.editor,
225
+ "validateLink": props.validateLink,
226
+ "transformLink": props.transformLink
188
227
  }, null);
189
228
  default:
190
229
  return _createVNode(SingleExtention, {
191
230
  "name": resolvedItem,
192
231
  "tooltipLabel": tooltipLabel,
193
232
  "onClick": resolvedOptions.onClick,
194
- "editor": editor
233
+ "editor": props.editor,
234
+ "isDisabled": disabled
195
235
  }, null);
196
236
  }
197
237
  }, "renderExtension");
@@ -203,21 +243,27 @@ var EditorToolbar = defineComponent({
203
243
  }
204
244
  }
205
245
  }, {
206
- default: () => [_createVNode("div", {
207
- "class": css({
208
- display: "flex",
209
- alignItems: "stretch",
210
- gap: "1"
211
- })
212
- }, [options == null ? void 0 : options.map((option, index) => _createVNode(_Fragment, null, [option.map((item) => {
213
- const resolvedItem = typeof item === "string" ? item : item.value;
214
- if (items.includes(resolvedItem)) {
215
- return renderExtension(item);
216
- }
217
- }), index !== (options == null ? void 0 : options.length) - 1 && _createVNode(MpDivider, {
218
- "id": "divider-toolbar",
219
- "orientation": "vertical"
220
- }, null)]))])]
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
+ }
221
267
  });
222
268
  }
223
269
  });
@@ -1,19 +1,25 @@
1
1
  import {
2
2
  EditorToolbar
3
- } from "./chunk-YE6FEVD4.mjs";
3
+ } from "./chunk-RX7ZEE2M.mjs";
4
+ import {
5
+ Variable
6
+ } from "./chunk-ENKUUZPM.mjs";
4
7
  import {
5
8
  MpRTEStyleProvider
6
- } from "./chunk-MKTM47RO.mjs";
9
+ } from "./chunk-AIWY3FHJ.mjs";
7
10
  import {
8
11
  useRichTextEditor
9
12
  } from "./chunk-ZRAXSVO5.mjs";
10
13
  import {
11
14
  richTextEditorEmits,
12
15
  richTextEditorProps
13
- } from "./chunk-7BEXEMOE.mjs";
16
+ } from "./chunk-6O4HSL2C.mjs";
14
17
  import {
15
18
  createMentionSuggestion
16
19
  } from "./chunk-4KJOYLJI.mjs";
20
+ import {
21
+ createVariableSuggestion
22
+ } from "./chunk-BWRU2WZN.mjs";
17
23
  import {
18
24
  __name
19
25
  } from "./chunk-QZ7VFGWC.mjs";
@@ -89,6 +95,9 @@ var MpRichTextEditor = defineComponent({
89
95
  }),
90
96
  ...props.suggestions && props.suggestions.length > 0 ? [Mention.configure({
91
97
  suggestion: createMentionSuggestion(() => props.suggestions || [])
98
+ })] : [],
99
+ ...props.variables && props.variables.length > 0 ? [Variable.configure({
100
+ suggestion: createVariableSuggestion(() => props.variables || [])
92
101
  })] : []
93
102
  ],
94
103
  onFocus({
@@ -119,6 +128,7 @@ var MpRichTextEditor = defineComponent({
119
128
  onClickFile: () => onClickToolbar("file"),
120
129
  onClickAudio: () => onClickToolbar("audio"),
121
130
  onClickMention: () => onClickToolbar("mention"),
131
+ onClickVariable: () => onClickToolbar("variable"),
122
132
  onClickLocation: () => onClickToolbar("location")
123
133
  };
124
134
  return () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CaretIcon
3
- } from "./chunk-Q7QLZISF.mjs";
3
+ } from "./chunk-IFRJVX2K.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";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ColorTextIcon,
3
3
  FillTextIcon
4
- } from "./chunk-Q7QLZISF.mjs";
4
+ } from "./chunk-IFRJVX2K.mjs";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-QZ7VFGWC.mjs";
@@ -3,7 +3,7 @@ import {
3
3
  AlignJustifyIcon,
4
4
  AlignLeftIcon,
5
5
  AlignRightIcon
6
- } from "./chunk-Q7QLZISF.mjs";
6
+ } from "./chunk-IFRJVX2K.mjs";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-QZ7VFGWC.mjs";
@@ -21,7 +21,7 @@ declare const EditorToolbar: vue.DefineComponent<{
21
21
  transformLink: {
22
22
  type: PropType<(url: string) => string>;
23
23
  };
24
- }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
24
+ }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
25
25
  editor: {
26
26
  type: PropType<Editor>;
27
27
  };
@@ -42,6 +42,7 @@ declare const EditorToolbar: vue.DefineComponent<{
42
42
  onClickFile?: ((...args: any[]) => any) | undefined;
43
43
  onClickAudio?: ((...args: any[]) => any) | undefined;
44
44
  onClickMention?: ((...args: any[]) => any) | undefined;
45
+ onClickVariable?: ((...args: any[]) => any) | undefined;
45
46
  onClickLocation?: ((...args: any[]) => any) | undefined;
46
47
  }, {}, {}>;
47
48
 
@@ -21,7 +21,7 @@ declare const EditorToolbar: vue.DefineComponent<{
21
21
  transformLink: {
22
22
  type: PropType<(url: string) => string>;
23
23
  };
24
- }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
24
+ }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
25
25
  editor: {
26
26
  type: PropType<Editor>;
27
27
  };
@@ -42,6 +42,7 @@ declare const EditorToolbar: vue.DefineComponent<{
42
42
  onClickFile?: ((...args: any[]) => any) | undefined;
43
43
  onClickAudio?: ((...args: any[]) => any) | undefined;
44
44
  onClickMention?: ((...args: any[]) => any) | undefined;
45
+ onClickVariable?: ((...args: any[]) => any) | undefined;
45
46
  onClickLocation?: ((...args: any[]) => any) | undefined;
46
47
  }, {}, {}>;
47
48