@mantine-vue/tiptap 3.0.0 → 3.2.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.
Files changed (40) hide show
  1. package/cjs/index.cjs +725 -588
  2. package/cjs/index.cjs.map +1 -1
  3. package/esm/index.mjs +725 -614
  4. package/esm/index.mjs.map +1 -1
  5. package/lib/RichTextEditor.d.ts +63 -2674
  6. package/lib/RichTextEditor.types.d.ts +83 -0
  7. package/lib/RichTextEditor.vue.d.ts +25 -0
  8. package/lib/RichTextEditorContent/RichTextEditorContent.d.ts +8 -42
  9. package/lib/RichTextEditorContent/RichTextEditorContent.types.d.ts +18 -0
  10. package/lib/RichTextEditorContent/RichTextEditorContent.vue.d.ts +4 -0
  11. package/lib/RichTextEditorControl/RichTextEditorColorControl.d.ts +8 -17
  12. package/lib/RichTextEditorControl/RichTextEditorColorControl.types.d.ts +15 -0
  13. package/lib/RichTextEditorControl/RichTextEditorColorControl.vue.d.ts +4 -0
  14. package/lib/RichTextEditorControl/RichTextEditorColorPickerControl.d.ts +8 -39
  15. package/lib/RichTextEditorControl/RichTextEditorColorPickerControl.types.d.ts +19 -0
  16. package/lib/RichTextEditorControl/RichTextEditorColorPickerControl.vue.d.ts +4 -0
  17. package/lib/RichTextEditorControl/RichTextEditorControl.d.ts +18 -240
  18. package/lib/RichTextEditorControl/RichTextEditorControl.types.d.ts +91 -0
  19. package/lib/RichTextEditorControl/RichTextEditorControl.vue.d.ts +11 -0
  20. package/lib/RichTextEditorControl/RichTextEditorControlBase.vue.d.ts +11 -0
  21. package/lib/RichTextEditorControl/RichTextEditorGeneratedControl.vue.d.ts +11 -0
  22. package/lib/RichTextEditorControl/RichTextEditorLinkControl.d.ts +9 -81
  23. package/lib/RichTextEditorControl/RichTextEditorLinkControl.types.d.ts +34 -0
  24. package/lib/RichTextEditorControl/RichTextEditorLinkControl.vue.d.ts +11 -0
  25. package/lib/RichTextEditorControl/RichTextEditorSourceCodeControl.d.ts +8 -6
  26. package/lib/RichTextEditorControl/RichTextEditorSourceCodeControl.types.d.ts +10 -0
  27. package/lib/RichTextEditorControl/RichTextEditorSourceCodeControl.vue.d.ts +3 -0
  28. package/lib/RichTextEditorControl/controls.d.ts +248 -2139
  29. package/lib/RichTextEditorControl/use-editor-selector.d.ts +3 -0
  30. package/lib/RichTextEditorControlsGroup/RichTextEditorControlsGroup.d.ts +9 -50
  31. package/lib/RichTextEditorControlsGroup/RichTextEditorControlsGroup.types.d.ts +24 -0
  32. package/lib/RichTextEditorControlsGroup/RichTextEditorControlsGroup.vue.d.ts +11 -0
  33. package/lib/RichTextEditorToolbar/RichTextEditorToolbar.d.ts +9 -81
  34. package/lib/RichTextEditorToolbar/RichTextEditorToolbar.types.d.ts +32 -0
  35. package/lib/RichTextEditorToolbar/RichTextEditorToolbar.vue.d.ts +11 -0
  36. package/lib/icons/Icons.d.ts +40 -113
  37. package/lib/icons/RichTextEditorIcon.d.ts +5 -0
  38. package/lib/icons/RichTextEditorIcon.types.d.ts +10 -0
  39. package/lib/icons/RichTextEditorIcon.vue.d.ts +4 -0
  40. package/package.json +3 -3
package/esm/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { computed, defineComponent, h, onBeforeUnmount, ref, watch } from "vue";
2
- import { ActionIcon, Box, Button, ColorPicker, ColorSwatch, Group, Popover, SimpleGrid, TextInput, Tooltip, Typography, UnstyledButton, createSafeContext, rem, useProps, useStyles } from "@mantine-vue/core";
1
+ import { ActionIcon, Box, Button, ColorPicker, ColorSwatch, Group, Popover, SimpleGrid, TextInput, Tooltip, Typography, UnstyledButton, createSafeContext, factory, rem, useProps, useStyles } from "@mantine-vue/core";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, watch, withCtx } from "vue";
3
3
  import { EditorContent } from "@tiptap/vue-3";
4
- import { useDisclosure, useWindowEvent } from "@mantine-vue/hooks";
4
+ import { useDisclosure } from "@mantine-vue/hooks";
5
5
  import TipTapLink from "@tiptap/extension-link";
6
6
  //#region src/labels.ts
7
7
  var DEFAULT_LABELS = {
@@ -71,158 +71,268 @@ var RichTextEditor_module_default = {
71
71
  taskList: "_taskList_1ljoi_345"
72
72
  };
73
73
  //#endregion
74
- //#region src/RichTextEditorContent/RichTextEditorContent.ts
75
- var RichTextEditorContent = defineComponent({
76
- name: "RichTextEditorContent",
74
+ //#region src/RichTextEditor.vue
75
+ var RichTextEditor_default = /* @__PURE__ */ defineComponent({
76
+ name: "RichTextEditor",
77
77
  inheritAttrs: false,
78
+ __name: "RichTextEditor",
78
79
  props: {
79
- classNames: {
80
- type: [Object, Function],
81
- default: void 0
80
+ editor: { default: null },
81
+ withCodeHighlightStyles: {
82
+ type: Boolean,
83
+ default: true
82
84
  },
83
- styles: {
84
- type: [Object, Function],
85
+ withTypographyStyles: {
86
+ type: Boolean,
87
+ default: true
88
+ },
89
+ onSourceCodeTextSwitch: {
90
+ type: Function,
85
91
  default: void 0
86
92
  },
87
- vars: {
88
- type: [Object, Function],
93
+ labels: { default: void 0 },
94
+ variant: { default: "default" },
95
+ classNames: { default: void 0 },
96
+ styles: { default: void 0 },
97
+ vars: { default: void 0 },
98
+ unstyled: {
99
+ type: Boolean,
89
100
  default: void 0
90
101
  }
91
102
  },
92
- setup(rawProps, { attrs }) {
103
+ setup(__props) {
104
+ const rawProps = __props;
105
+ const attrs = useAttrs();
106
+ const props = useProps("RichTextEditor", null, rawProps);
107
+ const getStyles = useStyles({
108
+ name: "RichTextEditor",
109
+ classes: RichTextEditor_module_default,
110
+ props,
111
+ className: attrs.class,
112
+ style: attrs.style,
113
+ classNames: props.classNames,
114
+ styles: props.styles,
115
+ vars: props.vars,
116
+ unstyled: props.unstyled
117
+ });
118
+ const mergedLabels = computed(() => ({
119
+ ...DEFAULT_LABELS,
120
+ ...props.labels
121
+ }));
122
+ const rootProps = computed(() => {
123
+ const forwarded = { ...attrs };
124
+ delete forwarded.class;
125
+ delete forwarded.style;
126
+ return {
127
+ ...getStyles("root"),
128
+ ...forwarded
129
+ };
130
+ });
131
+ provideRichTextEditorContext({
132
+ get editor() {
133
+ return props.editor;
134
+ },
135
+ getStyles,
136
+ get labels() {
137
+ return mergedLabels.value;
138
+ },
139
+ get withCodeHighlightStyles() {
140
+ return props.withCodeHighlightStyles;
141
+ },
142
+ get withTypographyStyles() {
143
+ return props.withTypographyStyles;
144
+ },
145
+ get onSourceCodeTextSwitch() {
146
+ return props.onSourceCodeTextSwitch;
147
+ },
148
+ get unstyled() {
149
+ return props.unstyled;
150
+ },
151
+ get variant() {
152
+ return props.variant;
153
+ }
154
+ });
155
+ return (_ctx, _cache) => {
156
+ return openBlock(), createBlock(unref(Box), normalizeProps(guardReactiveProps(rootProps.value)), {
157
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
158
+ _: 3
159
+ }, 16);
160
+ };
161
+ }
162
+ });
163
+ //#endregion
164
+ //#region src/RichTextEditorContent/RichTextEditorContent.ts
165
+ var RichTextEditorContent = factory(/* @__PURE__ */ defineComponent({
166
+ name: "RichTextEditorContent",
167
+ inheritAttrs: false,
168
+ __name: "RichTextEditorContent",
169
+ props: {
170
+ classNames: { default: void 0 },
171
+ styles: { default: void 0 },
172
+ vars: { default: void 0 },
173
+ unstyled: {
174
+ type: Boolean,
175
+ default: void 0
176
+ }
177
+ },
178
+ setup(__props) {
179
+ const rawProps = __props;
180
+ const attrs = useAttrs();
93
181
  const props = useProps("RichTextEditorContent", null, rawProps);
94
182
  const ctx = useRichTextEditorContext();
95
- return () => {
96
- const editorContent = h(Box, {
97
- component: EditorContent,
98
- editor: ctx.editor,
183
+ const contentProps = computed(() => {
184
+ const forwarded = { ...attrs };
185
+ delete forwarded.class;
186
+ delete forwarded.style;
187
+ return {
99
188
  ...ctx.getStyles("content", {
100
189
  classNames: props.classNames,
101
190
  styles: props.styles,
102
191
  className: ctx.withTypographyStyles ? void 0 : attrs.class,
103
192
  style: ctx.withTypographyStyles ? void 0 : attrs.style
104
193
  }),
105
- ...attrs
106
- });
107
- return ctx.withTypographyStyles ? h(Typography, {
108
- ...ctx.getStyles("Typography", {
109
- className: attrs.class,
110
- style: attrs.style,
111
- styles: props.styles,
112
- classNames: props.classNames
113
- }),
114
- unstyled: ctx.unstyled
115
- }, () => editorContent) : editorContent;
194
+ ...forwarded
195
+ };
196
+ });
197
+ const typographyProps = computed(() => ctx.getStyles("Typography", {
198
+ className: attrs.class,
199
+ style: attrs.style,
200
+ styles: props.styles,
201
+ classNames: props.classNames
202
+ }));
203
+ return (_ctx, _cache) => {
204
+ return unref(ctx).withTypographyStyles ? (openBlock(), createBlock(unref(Typography), mergeProps({ key: 0 }, typographyProps.value, { unstyled: unref(ctx).unstyled }), {
205
+ default: withCtx(() => [createVNode(unref(Box), mergeProps({
206
+ component: unref(EditorContent),
207
+ editor: unref(ctx).editor
208
+ }, contentProps.value), null, 16, ["component", "editor"])]),
209
+ _: 1
210
+ }, 16, ["unstyled"])) : (openBlock(), createBlock(unref(Box), mergeProps({
211
+ key: 1,
212
+ component: unref(EditorContent),
213
+ editor: unref(ctx).editor
214
+ }, contentProps.value), null, 16, ["component", "editor"]));
116
215
  };
117
216
  }
118
- });
119
- Object.assign(RichTextEditorContent, { classes: RichTextEditor_module_default });
217
+ }), { classes: RichTextEditor_module_default });
120
218
  //#endregion
121
- //#region src/RichTextEditorControl/RichTextEditorControl.ts
122
- var defaultProps$1 = { interactive: true };
123
- var RichTextEditorControl = defineComponent({
219
+ //#region src/RichTextEditorControl/RichTextEditorControl.vue
220
+ var RichTextEditorControl_default = /* @__PURE__ */ defineComponent({
124
221
  name: "RichTextEditorControl",
125
222
  inheritAttrs: false,
223
+ __name: "RichTextEditorControl",
126
224
  props: {
225
+ classNames: { default: void 0 },
226
+ styles: { default: void 0 },
227
+ vars: { default: void 0 },
228
+ unstyled: {
229
+ type: Boolean,
230
+ default: void 0
231
+ },
127
232
  active: {
128
233
  type: Boolean,
129
234
  default: void 0
130
235
  },
131
236
  interactive: {
132
237
  type: Boolean,
133
- default: void 0
238
+ default: true
134
239
  },
135
240
  disabled: {
136
241
  type: Boolean,
137
242
  default: void 0
138
243
  },
139
- variant: {
140
- type: String,
141
- default: void 0
142
- },
143
- classNames: {
144
- type: [Object, Function],
145
- default: void 0
146
- },
147
- styles: {
148
- type: [Object, Function],
149
- default: void 0
150
- },
151
- vars: {
152
- type: [Object, Function],
153
- default: void 0
154
- }
244
+ variant: { default: void 0 }
155
245
  },
156
- setup(rawProps, { attrs, slots }) {
157
- const props = useProps("RichTextEditorControl", defaultProps$1, rawProps);
246
+ setup(__props) {
247
+ const rawProps = __props;
248
+ const attrs = useAttrs();
249
+ const props = useProps("RichTextEditorControl", null, rawProps);
158
250
  const ctx = useRichTextEditorContext();
159
- return () => h(UnstyledButton, {
160
- ...attrs,
251
+ const forwardedAttrs = computed(() => {
252
+ const result = { ...attrs };
253
+ delete result.onMousedown;
254
+ return result;
255
+ });
256
+ const controlProps = computed(() => ({
257
+ ...forwardedAttrs.value,
161
258
  ...ctx.getStyles("control", {
162
259
  className: attrs.class,
163
260
  style: attrs.style,
164
261
  classNames: props.classNames,
165
262
  styles: props.styles
166
- }),
167
- disabled: props.disabled,
168
- "data-rich-text-editor-control": "",
169
- tabindex: props.interactive ? 0 : -1,
170
- "data-interactive": props.interactive || void 0,
171
- "data-disabled": props.disabled || void 0,
172
- "data-active": props.active || void 0,
173
- "aria-pressed": props.active && props.interactive ? true : void 0,
174
- "aria-hidden": !props.interactive || void 0,
175
- unstyled: ctx.unstyled,
176
- variant: props.variant || ctx.variant || "default",
177
- onMousedown: (event) => {
178
- event.preventDefault();
179
- attrs.onMousedown?.(event);
180
- }
181
- }, slots);
263
+ })
264
+ }));
265
+ function onMousedown(event) {
266
+ event.preventDefault();
267
+ const handler = attrs.onMousedown;
268
+ if (typeof handler === "function") handler(event);
269
+ }
270
+ return (_ctx, _cache) => {
271
+ return openBlock(), createBlock(unref(UnstyledButton), mergeProps(controlProps.value, {
272
+ disabled: unref(props).disabled,
273
+ "data-rich-text-editor-control": "",
274
+ tabindex: unref(props).interactive ? 0 : -1,
275
+ "data-interactive": unref(props).interactive || void 0,
276
+ "data-disabled": unref(props).disabled || void 0,
277
+ "data-active": unref(props).active || void 0,
278
+ "aria-pressed": unref(props).active && unref(props).interactive ? true : void 0,
279
+ "aria-hidden": !unref(props).interactive || void 0,
280
+ unstyled: unref(ctx).unstyled,
281
+ variant: unref(props).variant || unref(ctx).variant || "default",
282
+ onMousedown
283
+ }), {
284
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
285
+ _: 3
286
+ }, 16, [
287
+ "disabled",
288
+ "tabindex",
289
+ "data-interactive",
290
+ "data-disabled",
291
+ "data-active",
292
+ "aria-pressed",
293
+ "aria-hidden",
294
+ "unstyled",
295
+ "variant"
296
+ ]);
297
+ };
182
298
  }
183
299
  });
184
- Object.assign(RichTextEditorControl, { classes: RichTextEditor_module_default });
185
- var RichTextEditorControlBase = defineComponent({
300
+ //#endregion
301
+ //#region src/RichTextEditorControl/RichTextEditorControlBase.vue
302
+ var RichTextEditorControlBase_default = /* @__PURE__ */ defineComponent({
186
303
  name: "RichTextEditorControlBase",
187
304
  inheritAttrs: false,
305
+ __name: "RichTextEditorControlBase",
188
306
  props: {
189
- icon: {
190
- type: [Object, Function],
191
- required: true
192
- },
193
- active: {
194
- type: Boolean,
195
- default: void 0
196
- },
197
- interactive: {
198
- type: Boolean,
199
- default: void 0
200
- },
201
- disabled: {
202
- type: Boolean,
203
- default: void 0
204
- },
205
- variant: {
206
- type: String,
207
- default: void 0
208
- },
209
- classNames: {
210
- type: [Object, Function],
211
- default: void 0
212
- },
213
- styles: {
214
- type: [Object, Function],
215
- default: void 0
216
- }
307
+ icon: {},
308
+ classNames: {},
309
+ styles: {},
310
+ vars: {},
311
+ unstyled: { type: Boolean },
312
+ active: { type: Boolean },
313
+ interactive: { type: Boolean },
314
+ disabled: { type: Boolean },
315
+ variant: {}
217
316
  },
218
- setup(props, { attrs }) {
317
+ setup(__props) {
318
+ const props = __props;
319
+ const attrs = useAttrs();
219
320
  const ctx = useRichTextEditorContext();
220
- return () => h(RichTextEditorControl, {
221
- ...attrs,
222
- ...props
223
- }, () => h(props.icon, ctx.getStyles("controlIcon")));
321
+ const controlProps = computed(() => ({
322
+ ...props,
323
+ ...attrs
324
+ }));
325
+ const iconProps = computed(() => ctx.getStyles("controlIcon"));
326
+ return (_ctx, _cache) => {
327
+ return openBlock(), createBlock(RichTextEditorControl_default, normalizeProps(guardReactiveProps(controlProps.value)), {
328
+ default: withCtx(() => [renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(iconProps.value)), () => [(openBlock(), createBlock(resolveDynamicComponent(props.icon), normalizeProps(guardReactiveProps(iconProps.value)), null, 16))])]),
329
+ _: 3
330
+ }, 16);
331
+ };
224
332
  }
225
333
  });
334
+ //#endregion
335
+ //#region src/RichTextEditorControl/use-editor-selector.ts
226
336
  function isSafeEditor(editor) {
227
337
  return !!editor && !editor.isDestroyed;
228
338
  }
@@ -255,128 +365,171 @@ function useEditorSelector(editor, selector) {
255
365
  return selector(editor());
256
366
  });
257
367
  }
258
- function createControl({ label, isActive, operation, icon, isDisabled }) {
259
- return defineComponent({
260
- name: `RichTextEditor${String(label)}`,
261
- inheritAttrs: false,
262
- props: {
263
- icon: {
264
- type: [Object, Function],
265
- default: void 0
266
- },
267
- active: {
268
- type: Boolean,
269
- default: void 0
270
- },
271
- interactive: {
272
- type: Boolean,
273
- default: void 0
274
- },
275
- disabled: {
276
- type: Boolean,
277
- default: void 0
278
- },
279
- variant: {
280
- type: String,
281
- default: void 0
282
- },
283
- classNames: {
284
- type: [Object, Function],
285
- default: void 0
286
- },
287
- styles: {
288
- type: [Object, Function],
289
- default: void 0
290
- }
368
+ //#endregion
369
+ //#region src/RichTextEditorControl/RichTextEditorGeneratedControl.vue
370
+ var RichTextEditorGeneratedControl_default = /* @__PURE__ */ defineComponent({
371
+ name: "RichTextEditorGeneratedControl",
372
+ inheritAttrs: false,
373
+ __name: "RichTextEditorGeneratedControl",
374
+ props: {
375
+ classNames: { default: void 0 },
376
+ styles: { default: void 0 },
377
+ vars: { default: void 0 },
378
+ unstyled: {
379
+ type: Boolean,
380
+ default: void 0
291
381
  },
292
- setup(props, { attrs }) {
293
- const ctx = useRichTextEditorContext();
294
- const editorState = useEditorSelector(() => ctx.editor, (editor) => {
295
- const safeEditor = isSafeEditor(editor) ? editor : null;
296
- return {
297
- active: safeEditor && isActive?.name ? safeEditor.isActive(isActive.name, isActive.attributes) : false,
298
- disabled: safeEditor ? isDisabled?.(safeEditor) ?? false : true
299
- };
300
- });
301
- return () => {
302
- const controlLabel = ctx.labels[label];
303
- return h(RichTextEditorControlBase, {
304
- ...attrs,
305
- ...props,
306
- "aria-label": controlLabel,
307
- title: controlLabel,
308
- active: props.active ?? editorState.value.active,
309
- icon: props.icon || icon,
310
- disabled: props.disabled ?? editorState.value.disabled,
311
- onClick: () => {
312
- if (!isSafeEditor(ctx.editor)) return;
313
- ctx.editor.chain().focus()[operation.name](operation.attributes).run();
314
- }
315
- });
382
+ active: {
383
+ type: Boolean,
384
+ default: void 0
385
+ },
386
+ interactive: {
387
+ type: Boolean,
388
+ default: true
389
+ },
390
+ disabled: {
391
+ type: Boolean,
392
+ default: void 0
393
+ },
394
+ variant: { default: void 0 },
395
+ label: {},
396
+ icon: {},
397
+ isActive: { default: void 0 },
398
+ isDisabled: {
399
+ type: Function,
400
+ default: void 0
401
+ },
402
+ operation: {}
403
+ },
404
+ setup(__props) {
405
+ const props = __props;
406
+ const attrs = useAttrs();
407
+ const ctx = useRichTextEditorContext();
408
+ const label = computed(() => ctx.labels[props.label]);
409
+ const editorState = useEditorSelector(() => ctx.editor, (editor) => {
410
+ const safeEditor = isSafeEditor(editor) ? editor : null;
411
+ return {
412
+ active: safeEditor && props.isActive?.name ? safeEditor.isActive(props.isActive.name, props.isActive.attributes) : false,
413
+ disabled: safeEditor ? props.isDisabled?.(safeEditor) ?? false : true
316
414
  };
415
+ });
416
+ function runOperation() {
417
+ if (!isSafeEditor(ctx.editor)) return;
418
+ ctx.editor.chain().focus()[props.operation.name](props.operation.attributes).run();
317
419
  }
318
- });
319
- }
320
- function renderControlIcon(Icon) {
321
- return h(Box, {
322
- component: Icon,
323
- class: RichTextEditor_module_default.controlIcon
324
- });
420
+ return (_ctx, _cache) => {
421
+ return openBlock(), createBlock(RichTextEditorControlBase_default, mergeProps(unref(attrs), {
422
+ active: props.active ?? unref(editorState).active,
423
+ interactive: props.interactive,
424
+ disabled: props.disabled ?? unref(editorState).disabled,
425
+ variant: props.variant,
426
+ "class-names": props.classNames,
427
+ styles: props.styles,
428
+ "aria-label": label.value,
429
+ title: label.value,
430
+ onClick: runOperation
431
+ }), {
432
+ icon: withCtx((iconProps) => [renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(iconProps)), () => [(openBlock(), createBlock(resolveDynamicComponent(props.icon), normalizeProps(guardReactiveProps(iconProps)), null, 16))])]),
433
+ _: 3
434
+ }, 16, [
435
+ "active",
436
+ "interactive",
437
+ "disabled",
438
+ "variant",
439
+ "class-names",
440
+ "styles",
441
+ "aria-label",
442
+ "title"
443
+ ]);
444
+ };
445
+ }
446
+ });
447
+ //#endregion
448
+ //#region src/RichTextEditorControl/RichTextEditorControl.ts
449
+ var RichTextEditorControl = factory(RichTextEditorControl_default, { classes: RichTextEditor_module_default });
450
+ var RichTextEditorControlBase = factory(RichTextEditorControlBase_default, { classes: RichTextEditor_module_default });
451
+ var RichTextEditorGeneratedControl = factory(RichTextEditorGeneratedControl_default, { classes: RichTextEditor_module_default });
452
+ function createControl(config) {
453
+ return RichTextEditorGeneratedControl.withProps(config);
325
454
  }
326
455
  //#endregion
327
456
  //#region src/RichTextEditorControl/RichTextEditorColorControl.ts
328
- var RichTextEditorColorControl = defineComponent({
457
+ var RichTextEditorColorControl = factory(/* @__PURE__ */ defineComponent({
329
458
  name: "RichTextEditorColorControl",
330
459
  inheritAttrs: false,
331
- props: { color: {
332
- type: String,
333
- required: true
334
- } },
335
- setup(rawProps, { attrs }) {
336
- const props = useProps("RichTextEditorColorControl", null, rawProps);
460
+ __name: "RichTextEditorColorControl",
461
+ props: { color: {} },
462
+ setup(__props) {
463
+ const props = __props;
464
+ const attrs = useAttrs();
337
465
  const ctx = useRichTextEditorContext();
338
- return () => {
339
- const currentColor = ctx.editor?.getAttributes("textStyle").color || null;
340
- const label = ctx.labels.colorControlLabel(props.color);
341
- return h(RichTextEditorControl, {
342
- ...attrs,
343
- variant: ctx.variant,
344
- active: currentColor === props.color,
345
- "aria-label": label,
346
- title: label,
347
- onClick: () => (ctx.editor?.chain())?.focus().setColor(props.color).run()
348
- }, () => h(ColorSwatch, {
349
- color: props.color,
350
- size: 14
351
- }));
466
+ const currentColor = useEditorSelector(() => ctx.editor, (editor) => String(editor?.getAttributes("textStyle").color || ""));
467
+ const label = computed(() => ctx.labels.colorControlLabel(props.color));
468
+ function setColor() {
469
+ (ctx.editor?.chain())?.focus().setColor(props.color).run();
470
+ }
471
+ return (_ctx, _cache) => {
472
+ return openBlock(), createBlock(RichTextEditorControl_default, mergeProps(unref(attrs), {
473
+ variant: unref(ctx).variant,
474
+ active: unref(currentColor) === props.color,
475
+ "aria-label": label.value,
476
+ title: label.value,
477
+ onClick: setColor
478
+ }), {
479
+ default: withCtx(() => [createVNode(unref(ColorSwatch), {
480
+ color: props.color,
481
+ size: 14
482
+ }, null, 8, ["color"])]),
483
+ _: 1
484
+ }, 16, [
485
+ "variant",
486
+ "active",
487
+ "aria-label",
488
+ "title"
489
+ ]);
352
490
  };
353
491
  }
354
- });
492
+ }), { classes: RichTextEditor_module_default });
355
493
  //#endregion
356
- //#region src/icons/Icons.ts
357
- function createIcon(name, children) {
358
- return defineComponent({
359
- name,
360
- inheritAttrs: false,
361
- setup(_, { attrs }) {
362
- return () => h("svg", {
363
- ...attrs,
494
+ //#region src/icons/RichTextEditorIcon.vue?vue&type=script&setup=true&lang.ts
495
+ var _hoisted_1 = ["d"];
496
+ //#endregion
497
+ //#region src/icons/RichTextEditorIcon.ts
498
+ var RichTextEditorIcon = factory(/* @__PURE__ */ defineComponent({
499
+ name: "RichTextEditorIcon",
500
+ inheritAttrs: false,
501
+ __name: "RichTextEditorIcon",
502
+ props: { paths: {} },
503
+ setup(__props) {
504
+ const attrs = useAttrs();
505
+ return (_ctx, _cache) => {
506
+ return openBlock(), createElementBlock("svg", mergeProps(unref(attrs), {
364
507
  xmlns: "http://www.w3.org/2000/svg",
365
508
  viewBox: "0 0 24 24",
366
- strokeWidth: "1.5",
509
+ "stroke-width": "1.5",
367
510
  stroke: "currentColor",
368
511
  fill: "none",
369
- strokeLinecap: "round",
370
- strokeLinejoin: "round"
371
- }, [h("path", {
512
+ "stroke-linecap": "round",
513
+ "stroke-linejoin": "round"
514
+ }), [_cache[0] || (_cache[0] = createElementVNode("path", {
372
515
  stroke: "none",
373
516
  d: "M0 0h24v24H0z",
374
517
  fill: "none"
375
- }), ...children]);
376
- }
377
- });
518
+ }, null, -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.paths, (path) => {
519
+ return openBlock(), createElementBlock("path", {
520
+ key: path,
521
+ d: path
522
+ }, null, 8, _hoisted_1);
523
+ }), 128))], 16);
524
+ };
525
+ }
526
+ }));
527
+ //#endregion
528
+ //#region src/icons/Icons.ts
529
+ function createIcon(_name, paths) {
530
+ return RichTextEditorIcon.withProps({ paths });
378
531
  }
379
- var path = (d) => h("path", { d });
532
+ var path = (d) => d;
380
533
  var IconBold = createIcon("IconBold", [path("M7 5h6a3.5 3.5 0 0 1 0 7h-6z"), path("M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7")]);
381
534
  var IconItalic = createIcon("IconItalic", [
382
535
  path("M11 5l6 0"),
@@ -572,141 +725,184 @@ var IconBraces = createIcon("IconBraces", [
572
725
  ]);
573
726
  //#endregion
574
727
  //#region src/RichTextEditorControl/RichTextEditorColorPickerControl.ts
575
- var RichTextEditorColorPickerControl = defineComponent({
728
+ var RichTextEditorColorPickerControl = factory(/* @__PURE__ */ defineComponent({
576
729
  name: "RichTextEditorColorPickerControl",
577
730
  inheritAttrs: false,
731
+ __name: "RichTextEditorColorPickerControl",
578
732
  props: {
579
- popoverProps: {
580
- type: Object,
581
- default: void 0
582
- },
583
- colorPickerProps: {
584
- type: Object,
585
- default: void 0
586
- },
587
- colors: {
588
- type: Array,
589
- required: true
590
- }
733
+ popoverProps: {},
734
+ colorPickerProps: {},
735
+ colors: {}
591
736
  },
592
- setup(rawProps, { attrs }) {
593
- const props = useProps("RichTextEditorColorPickerControl", null, rawProps);
737
+ setup(__props) {
738
+ const props = __props;
739
+ const attrs = useAttrs();
594
740
  const ctx = useRichTextEditorContext();
595
741
  const [opened, handlers] = useDisclosure(false);
596
742
  const state = ref("palette");
597
- const handleChange = (value, shouldClose = true) => {
743
+ const currentColor = useEditorSelector(() => ctx.editor, (editor) => String(editor?.getAttributes("textStyle").color || "var(--mantine-color-text)"));
744
+ function handleChange(value, shouldClose = true) {
598
745
  (ctx.editor?.chain())?.focus().setColor(value).run();
599
746
  if (shouldClose) handlers.close();
600
- };
601
- const handleClear = () => {
747
+ }
748
+ function handleClear() {
602
749
  (ctx.editor?.chain())?.focus().unsetColor().run();
603
750
  handlers.close();
604
- };
605
- return () => {
606
- const currentColor = ctx.editor?.getAttributes("textStyle").color || "var(--mantine-color-text)";
607
- return h(Popover, {
608
- opened: opened.value,
609
- withinPortal: true,
610
- trapFocus: true,
611
- onChange: (nextOpened) => !nextOpened && handlers.close(),
612
- ...props.popoverProps
613
- }, { default: () => [h(Popover.Target, null, () => h(RichTextEditorControl, {
614
- ...attrs,
615
- variant: ctx.variant,
616
- "aria-label": ctx.labels.colorPickerControlLabel,
617
- title: ctx.labels.colorPickerControlLabel,
618
- onClick: handlers.toggle
619
- }, () => h(ColorSwatch, {
620
- color: currentColor,
621
- size: 14
622
- }))), h(Popover.Dropdown, ctx.getStyles("linkEditorDropdown"), () => [
623
- state.value === "palette" ? h(SimpleGrid, {
624
- cols: 7,
625
- spacing: 2
626
- }, () => props.colors.map((color, index) => h(ColorSwatch, {
627
- key: index,
628
- component: "button",
629
- color,
630
- onClick: () => handleChange(color),
631
- size: 26,
632
- radius: "xs",
633
- style: { cursor: "pointer" },
634
- title: ctx.labels.colorPickerColorLabel(color),
635
- "aria-label": ctx.labels.colorPickerColorLabel(color)
636
- }))) : null,
637
- state.value === "colorPicker" ? h(ColorPicker, {
638
- defaultValue: currentColor,
639
- onChange: (value) => handleChange(value, false),
640
- ...props.colorPickerProps
641
- }) : null,
642
- h(Group, {
643
- justify: "flex-end",
644
- gap: "xs",
645
- mt: "sm"
646
- }, () => [
647
- state.value === "palette" ? h(ActionIcon, {
648
- variant: "default",
649
- onClick: handlers.close,
650
- title: ctx.labels.colorPickerCancel,
651
- "aria-label": ctx.labels.colorPickerCancel
652
- }, () => h(IconX, { style: {
653
- width: rem(16),
654
- height: rem(16)
655
- } })) : null,
656
- h(ActionIcon, {
657
- variant: "default",
658
- onClick: handleClear,
659
- title: ctx.labels.colorPickerClear,
660
- "aria-label": ctx.labels.colorPickerClear
661
- }, () => h(IconCircleOff, { style: {
662
- width: rem(16),
663
- height: rem(16)
664
- } })),
665
- state.value === "palette" ? h(ActionIcon, {
666
- variant: "default",
667
- onClick: () => {
668
- state.value = "colorPicker";
669
- },
670
- title: ctx.labels.colorPickerColorPicker,
671
- "aria-label": ctx.labels.colorPickerColorPicker
672
- }, () => h(IconColorPicker, { style: {
673
- width: rem(16),
674
- height: rem(16)
675
- } })) : h(ActionIcon, {
676
- variant: "default",
677
- onClick: () => {
678
- state.value = "palette";
679
- },
680
- title: ctx.labels.colorPickerPalette,
681
- "aria-label": ctx.labels.colorPickerPalette
682
- }, () => h(IconPalette, { style: {
683
- width: rem(16),
684
- height: rem(16)
685
- } })),
686
- state.value === "colorPicker" ? h(ActionIcon, {
687
- variant: "default",
688
- onClick: handlers.close,
689
- title: ctx.labels.colorPickerSave,
690
- "aria-label": ctx.labels.colorPickerSave
691
- }, () => h(IconCheck, { style: {
692
- width: rem(16),
693
- height: rem(16)
694
- } })) : null
695
- ])
696
- ])] });
751
+ }
752
+ return (_ctx, _cache) => {
753
+ return openBlock(), createBlock(unref(Popover), mergeProps({
754
+ opened: unref(opened),
755
+ "within-portal": true,
756
+ "trap-focus": true
757
+ }, props.popoverProps, { onChange: _cache[2] || (_cache[2] = (value) => !value && unref(handlers).close()) }), {
758
+ default: withCtx(() => [createVNode(unref(Popover).Target, null, {
759
+ default: withCtx(() => [createVNode(RichTextEditorControl_default, mergeProps(unref(attrs), {
760
+ variant: unref(ctx).variant,
761
+ "aria-label": unref(ctx).labels.colorPickerControlLabel,
762
+ title: unref(ctx).labels.colorPickerControlLabel,
763
+ onClick: unref(handlers).toggle
764
+ }), {
765
+ default: withCtx(() => [createVNode(unref(ColorSwatch), {
766
+ color: unref(currentColor),
767
+ size: 14
768
+ }, null, 8, ["color"])]),
769
+ _: 1
770
+ }, 16, [
771
+ "variant",
772
+ "aria-label",
773
+ "title",
774
+ "onClick"
775
+ ])]),
776
+ _: 1
777
+ }), createVNode(unref(Popover).Dropdown, normalizeProps(guardReactiveProps(unref(ctx).getStyles("linkEditorDropdown"))), {
778
+ default: withCtx(() => [state.value === "palette" ? (openBlock(), createBlock(unref(SimpleGrid), {
779
+ key: 0,
780
+ cols: 7,
781
+ spacing: 2
782
+ }, {
783
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(props.colors, (color) => {
784
+ return openBlock(), createBlock(unref(ColorSwatch), {
785
+ key: color,
786
+ component: "button",
787
+ color,
788
+ size: 26,
789
+ radius: "xs",
790
+ style: { cursor: "pointer" },
791
+ title: unref(ctx).labels.colorPickerColorLabel(color),
792
+ "aria-label": unref(ctx).labels.colorPickerColorLabel(color),
793
+ onClick: ($event) => handleChange(color)
794
+ }, null, 8, [
795
+ "color",
796
+ "title",
797
+ "aria-label",
798
+ "onClick"
799
+ ]);
800
+ }), 128))]),
801
+ _: 1
802
+ })) : (openBlock(), createBlock(unref(ColorPicker), mergeProps({
803
+ key: 1,
804
+ "model-value": unref(currentColor)
805
+ }, props.colorPickerProps, { "onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => handleChange(value, false)) }), null, 16, ["model-value"])), createVNode(unref(Tooltip).Group, { "close-delay": 200 }, {
806
+ default: withCtx(() => [createVNode(unref(Group), {
807
+ justify: "flex-end",
808
+ gap: "xs",
809
+ mt: "sm"
810
+ }, {
811
+ default: withCtx(() => [
812
+ state.value === "palette" ? (openBlock(), createBlock(unref(ActionIcon), {
813
+ key: 0,
814
+ variant: "default",
815
+ title: unref(ctx).labels.colorPickerCancel,
816
+ "aria-label": unref(ctx).labels.colorPickerCancel,
817
+ onClick: unref(handlers).close
818
+ }, {
819
+ default: withCtx(() => [createVNode(unref(IconX), { style: normalizeStyle({
820
+ width: unref(rem)(16),
821
+ height: unref(rem)(16)
822
+ }) }, null, 8, ["style"])]),
823
+ _: 1
824
+ }, 8, [
825
+ "title",
826
+ "aria-label",
827
+ "onClick"
828
+ ])) : createCommentVNode("", true),
829
+ createVNode(unref(ActionIcon), {
830
+ variant: "default",
831
+ title: unref(ctx).labels.colorPickerClear,
832
+ "aria-label": unref(ctx).labels.colorPickerClear,
833
+ onClick: handleClear
834
+ }, {
835
+ default: withCtx(() => [createVNode(unref(IconCircleOff), { style: normalizeStyle({
836
+ width: unref(rem)(16),
837
+ height: unref(rem)(16)
838
+ }) }, null, 8, ["style"])]),
839
+ _: 1
840
+ }, 8, ["title", "aria-label"]),
841
+ createVNode(unref(ActionIcon), {
842
+ variant: "default",
843
+ title: state.value === "palette" ? unref(ctx).labels.colorPickerColorPicker : unref(ctx).labels.colorPickerPalette,
844
+ "aria-label": state.value === "palette" ? unref(ctx).labels.colorPickerColorPicker : unref(ctx).labels.colorPickerPalette,
845
+ onClick: _cache[1] || (_cache[1] = ($event) => state.value = state.value === "palette" ? "colorPicker" : "palette")
846
+ }, {
847
+ default: withCtx(() => [state.value === "palette" ? (openBlock(), createBlock(unref(IconColorPicker), {
848
+ key: 0,
849
+ style: normalizeStyle({
850
+ width: unref(rem)(16),
851
+ height: unref(rem)(16)
852
+ })
853
+ }, null, 8, ["style"])) : (openBlock(), createBlock(unref(IconPalette), {
854
+ key: 1,
855
+ style: normalizeStyle({
856
+ width: unref(rem)(16),
857
+ height: unref(rem)(16)
858
+ })
859
+ }, null, 8, ["style"]))]),
860
+ _: 1
861
+ }, 8, ["title", "aria-label"]),
862
+ state.value === "colorPicker" ? (openBlock(), createBlock(unref(ActionIcon), {
863
+ key: 1,
864
+ variant: "default",
865
+ title: unref(ctx).labels.colorPickerSave,
866
+ "aria-label": unref(ctx).labels.colorPickerSave,
867
+ onClick: unref(handlers).close
868
+ }, {
869
+ default: withCtx(() => [createVNode(unref(IconCheck), { style: normalizeStyle({
870
+ width: unref(rem)(16),
871
+ height: unref(rem)(16)
872
+ }) }, null, 8, ["style"])]),
873
+ _: 1
874
+ }, 8, [
875
+ "title",
876
+ "aria-label",
877
+ "onClick"
878
+ ])) : createCommentVNode("", true)
879
+ ]),
880
+ _: 1
881
+ })]),
882
+ _: 1
883
+ })]),
884
+ _: 1
885
+ }, 16)]),
886
+ _: 1
887
+ }, 16, ["opened"]);
697
888
  };
698
889
  }
699
- });
890
+ }), { classes: RichTextEditor_module_default });
700
891
  //#endregion
701
892
  //#region src/RichTextEditorControl/RichTextEditorLinkControl.ts
702
- var RichTextEditorLinkControl = defineComponent({
893
+ var RichTextEditorLinkControl = factory(/* @__PURE__ */ defineComponent({
703
894
  name: "RichTextEditorLinkControl",
704
895
  inheritAttrs: false,
896
+ __name: "RichTextEditorLinkControl",
705
897
  props: {
706
- popoverProps: {
707
- type: Object,
898
+ classNames: { default: void 0 },
899
+ styles: { default: void 0 },
900
+ vars: { default: void 0 },
901
+ unstyled: {
902
+ type: Boolean,
708
903
  default: void 0
709
904
  },
905
+ popoverProps: { default: void 0 },
710
906
  disableTooltips: {
711
907
  type: Boolean,
712
908
  default: false
@@ -715,147 +911,168 @@ var RichTextEditorLinkControl = defineComponent({
715
911
  type: Boolean,
716
912
  default: false
717
913
  },
718
- icon: {
719
- type: [Object, Function],
720
- default: void 0
721
- },
722
- classNames: {
723
- type: [Object, Function],
724
- default: void 0
725
- },
726
- styles: {
727
- type: [Object, Function],
728
- default: void 0
729
- },
730
- vars: {
731
- type: [Object, Function],
732
- default: void 0
733
- }
914
+ icon: { default: void 0 }
734
915
  },
735
- setup(rawProps, { attrs }) {
736
- const props = useProps("RichTextEditorLinkControl", null, rawProps);
916
+ setup(__props) {
917
+ const props = __props;
918
+ const attrs = useAttrs();
737
919
  const ctx = useRichTextEditorContext();
738
920
  const url = ref("");
739
921
  const external = ref(props.initialExternal);
740
922
  const [opened, handlers] = useDisclosure(false);
741
- const handleOpen = () => {
923
+ const stylesApiProps = computed(() => ({
924
+ classNames: props.classNames,
925
+ styles: props.styles
926
+ }));
927
+ const active = useEditorSelector(() => ctx.editor, (editor) => isSafeEditor(editor) ? editor.isActive("link") : false);
928
+ function open() {
742
929
  handlers.open();
743
- const linkData = ctx.editor?.getAttributes("link");
744
- url.value = linkData?.href || "";
745
- external.value = linkData?.href ? linkData?.target === "_blank" : !!props.initialExternal;
746
- };
747
- const handleClose = () => {
930
+ const link = isSafeEditor(ctx.editor) ? ctx.editor.getAttributes("link") : void 0;
931
+ url.value = link?.href || "";
932
+ external.value = link?.href ? link.target === "_blank" : props.initialExternal;
933
+ }
934
+ function close() {
748
935
  handlers.close();
749
936
  url.value = "";
750
- external.value = !!props.initialExternal;
751
- };
752
- const setLink = () => {
753
- handleClose();
754
- if (url.value === "") ctx.editor?.chain().focus().extendMarkRange("link").unsetLink().run();
755
- else ctx.editor?.chain().focus().extendMarkRange("link").setLink({
937
+ external.value = props.initialExternal;
938
+ }
939
+ function setLink() {
940
+ close();
941
+ if (!isSafeEditor(ctx.editor)) return;
942
+ if (url.value === "") ctx.editor.chain().focus().extendMarkRange("link").unsetLink().run();
943
+ else ctx.editor.chain().focus().extendMarkRange("link").setLink({
756
944
  href: url.value,
757
945
  target: external.value ? "_blank" : null
758
946
  }).run();
759
- };
760
- useWindowEvent("edit-link", handleOpen);
761
- return () => {
762
- const stylesApiProps = {
763
- classNames: props.classNames,
764
- styles: props.styles
765
- };
766
- const active = ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false;
767
- return h(Popover, {
768
- trapFocus: true,
947
+ }
948
+ function onKeydown(event) {
949
+ if (event.key === "Enter") {
950
+ event.preventDefault();
951
+ setLink();
952
+ }
953
+ }
954
+ function onPopoverChange(nextOpened) {
955
+ if (!nextOpened) close();
956
+ }
957
+ onMounted(() => window.addEventListener("edit-link", open));
958
+ onBeforeUnmount(() => window.removeEventListener("edit-link", open));
959
+ return (_ctx, _cache) => {
960
+ return openBlock(), createBlock(unref(Popover), mergeProps({
961
+ "trap-focus": true,
769
962
  shadow: "md",
770
- withinPortal: true,
771
- opened: opened.value,
772
- onChange: (nextOpened) => !nextOpened && handleClose(),
963
+ "within-portal": true,
964
+ opened: unref(opened),
773
965
  offset: -44,
774
- zIndex: 1e4,
775
- ...props.popoverProps
776
- }, { default: () => [h(Popover.Target, null, () => h(RichTextEditorControlBase, {
777
- ...attrs,
778
- icon: props.icon || IconLink,
779
- "aria-label": ctx.labels.linkControlLabel,
780
- title: ctx.labels.linkControlLabel,
781
- onClick: handleOpen,
782
- active,
783
- classNames: props.classNames,
784
- styles: props.styles,
785
- variant: ctx.variant
786
- })), h(Popover.Dropdown, ctx.getStyles("linkEditorDropdown", stylesApiProps), () => h("div", ctx.getStyles("linkEditor", stylesApiProps), [h(TextInput, {
787
- placeholder: ctx.labels.linkEditorInputPlaceholder,
788
- "aria-label": ctx.labels.linkEditorInputLabel,
789
- type: "url",
790
- value: url.value,
791
- onInput: (event) => {
792
- url.value = event.currentTarget.value;
793
- },
794
- classNames: { input: ctx.getStyles("linkEditorInput", stylesApiProps).class },
795
- onKeydown: (event) => {
796
- if (event.key === "Enter") {
797
- event.preventDefault();
798
- setLink();
799
- }
800
- },
801
- rightSection: () => h(Tooltip, {
802
- label: external.value ? ctx.labels.linkEditorExternalLink : ctx.labels.linkEditorInternalLink,
803
- events: {
804
- hover: true,
805
- focus: true,
806
- touch: true
807
- },
808
- withinPortal: true,
809
- withArrow: true,
810
- disabled: props.disableTooltips,
811
- zIndex: 1e4
812
- }, () => h(UnstyledButton, {
813
- onClick: () => {
814
- external.value = !external.value;
815
- },
816
- "data-active": external.value || void 0,
817
- ...ctx.getStyles("linkEditorExternalControl", stylesApiProps)
818
- }, () => h(IconExternalLink, { style: {
819
- width: rem(14),
820
- height: rem(14)
821
- } })))
822
- }), h(Button, {
823
- variant: "default",
824
- onClick: setLink,
825
- ...ctx.getStyles("linkEditorSave", stylesApiProps)
826
- }, () => ctx.labels.linkEditorSave)]))] });
966
+ "z-index": 1e4
967
+ }, props.popoverProps, { onChange: onPopoverChange }), {
968
+ default: withCtx(() => [createVNode(unref(Popover).Target, null, {
969
+ default: withCtx(() => [createVNode(RichTextEditorControlBase_default, mergeProps(unref(attrs), {
970
+ "aria-label": unref(ctx).labels.linkControlLabel,
971
+ title: unref(ctx).labels.linkControlLabel,
972
+ active: unref(active),
973
+ "class-names": props.classNames,
974
+ styles: props.styles,
975
+ variant: unref(ctx).variant,
976
+ onClick: open
977
+ }), {
978
+ icon: withCtx((iconProps) => [renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(iconProps)), () => [(openBlock(), createBlock(resolveDynamicComponent(props.icon || unref(IconLink)), normalizeProps(guardReactiveProps(iconProps)), null, 16))])]),
979
+ _: 3
980
+ }, 16, [
981
+ "aria-label",
982
+ "title",
983
+ "active",
984
+ "class-names",
985
+ "styles",
986
+ "variant"
987
+ ])]),
988
+ _: 3
989
+ }), createVNode(unref(Popover).Dropdown, normalizeProps(guardReactiveProps(unref(ctx).getStyles("linkEditorDropdown", stylesApiProps.value))), {
990
+ default: withCtx(() => [createElementVNode("div", normalizeProps(guardReactiveProps(unref(ctx).getStyles("linkEditor", stylesApiProps.value))), [createVNode(unref(TextInput), {
991
+ modelValue: url.value,
992
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => url.value = $event),
993
+ placeholder: unref(ctx).labels.linkEditorInputPlaceholder,
994
+ "aria-label": unref(ctx).labels.linkEditorInputLabel,
995
+ type: "url",
996
+ "class-names": { input: unref(ctx).getStyles("linkEditorInput", stylesApiProps.value).class },
997
+ onKeydown
998
+ }, {
999
+ rightSection: withCtx(() => [createVNode(unref(Tooltip), {
1000
+ label: external.value ? unref(ctx).labels.linkEditorExternalLink : unref(ctx).labels.linkEditorInternalLink,
1001
+ events: {
1002
+ hover: true,
1003
+ focus: true,
1004
+ touch: true
1005
+ },
1006
+ "within-portal": true,
1007
+ "with-arrow": true,
1008
+ disabled: props.disableTooltips,
1009
+ "z-index": 1e4
1010
+ }, {
1011
+ default: withCtx(() => [createVNode(unref(UnstyledButton), mergeProps({ "data-active": external.value || void 0 }, unref(ctx).getStyles("linkEditorExternalControl", stylesApiProps.value), { onClick: _cache[0] || (_cache[0] = ($event) => external.value = !external.value) }), {
1012
+ default: withCtx(() => [createVNode(unref(IconExternalLink), { style: normalizeStyle({
1013
+ width: unref(rem)(14),
1014
+ height: unref(rem)(14)
1015
+ }) }, null, 8, ["style"])]),
1016
+ _: 1
1017
+ }, 16, ["data-active"])]),
1018
+ _: 1
1019
+ }, 8, ["label", "disabled"])]),
1020
+ _: 1
1021
+ }, 8, [
1022
+ "modelValue",
1023
+ "placeholder",
1024
+ "aria-label",
1025
+ "class-names"
1026
+ ]), createVNode(unref(Button), mergeProps({ variant: "default" }, unref(ctx).getStyles("linkEditorSave", stylesApiProps.value), { onClick: setLink }), {
1027
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(ctx).labels.linkEditorSave), 1)]),
1028
+ _: 1
1029
+ }, 16)], 16)]),
1030
+ _: 1
1031
+ }, 16)]),
1032
+ _: 3
1033
+ }, 16, ["opened"]);
827
1034
  };
828
1035
  }
829
- });
830
- Object.assign(RichTextEditorLinkControl, { classes: RichTextEditor_module_default });
1036
+ }), { classes: RichTextEditor_module_default });
831
1037
  //#endregion
832
1038
  //#region src/RichTextEditorControl/RichTextEditorSourceCodeControl.ts
833
- var RichTextEditorSourceCodeControl = defineComponent({
1039
+ var RichTextEditorSourceCodeControl = factory(/* @__PURE__ */ defineComponent({
834
1040
  name: "RichTextEditorSourceCodeControl",
835
1041
  inheritAttrs: false,
836
- setup(rawProps, { attrs }) {
837
- useProps("RichTextEditorSourceCodeControl", {}, rawProps);
1042
+ __name: "RichTextEditorSourceCodeControl",
1043
+ setup(__props) {
1044
+ const attrs = useAttrs();
838
1045
  const ctx = useRichTextEditorContext();
839
- const isSourceCodeModeActive = ref(false);
840
- const handleStateChange = () => {
841
- if (isSourceCodeModeActive.value) ctx.editor?.commands.setContent(ctx.editor.getText(), { emitUpdate: true });
842
- else ctx.editor?.commands.setContent(`<textarea>${ctx.editor.getHTML()}</textarea>`);
843
- isSourceCodeModeActive.value = !isSourceCodeModeActive.value;
844
- ctx.onSourceCodeTextSwitch?.(isSourceCodeModeActive.value);
1046
+ const active = ref(false);
1047
+ function toggleSourceCode() {
1048
+ if (!isSafeEditor(ctx.editor)) return;
1049
+ if (active.value) ctx.editor.commands.setContent(ctx.editor.getText(), { emitUpdate: true });
1050
+ else ctx.editor.commands.setContent(`<textarea>${ctx.editor.getHTML()}</textarea>`);
1051
+ active.value = !active.value;
1052
+ ctx.onSourceCodeTextSwitch?.(active.value);
1053
+ }
1054
+ return (_ctx, _cache) => {
1055
+ return openBlock(), createBlock(RichTextEditorControl_default, mergeProps(unref(attrs), {
1056
+ variant: unref(ctx).variant,
1057
+ active: active.value,
1058
+ "aria-label": unref(ctx).labels.sourceCodeControlLabel,
1059
+ title: unref(ctx).labels.sourceCodeControlLabel,
1060
+ onClick: toggleSourceCode
1061
+ }), {
1062
+ default: withCtx(() => [createVNode(unref(IconBraces), { style: normalizeStyle({
1063
+ width: unref(rem)(16),
1064
+ height: unref(rem)(16)
1065
+ }) }, null, 8, ["style"])]),
1066
+ _: 1
1067
+ }, 16, [
1068
+ "variant",
1069
+ "active",
1070
+ "aria-label",
1071
+ "title"
1072
+ ]);
845
1073
  };
846
- return () => h(RichTextEditorControl, {
847
- ...attrs,
848
- variant: ctx.variant,
849
- active: isSourceCodeModeActive.value,
850
- "aria-label": ctx.labels.sourceCodeControlLabel,
851
- title: ctx.labels.sourceCodeControlLabel,
852
- onClick: handleStateChange
853
- }, () => h(IconBraces, { style: {
854
- width: rem(16),
855
- height: rem(16)
856
- } }));
857
1074
  }
858
- });
1075
+ }), { classes: RichTextEditor_module_default });
859
1076
  //#endregion
860
1077
  //#region src/RichTextEditorControl/controls.ts
861
1078
  var BoldControl = createControl({
@@ -1092,31 +1309,26 @@ var TaskListLiftControl = createControl({
1092
1309
  });
1093
1310
  //#endregion
1094
1311
  //#region src/RichTextEditorControlsGroup/RichTextEditorControlsGroup.ts
1095
- var RichTextEditorControlsGroup = defineComponent({
1312
+ var RichTextEditorControlsGroup = factory(/* @__PURE__ */ defineComponent({
1096
1313
  name: "RichTextEditorControlsGroup",
1097
1314
  inheritAttrs: false,
1315
+ __name: "RichTextEditorControlsGroup",
1098
1316
  props: {
1099
- variant: {
1100
- type: String,
1101
- default: void 0
1102
- },
1103
- classNames: {
1104
- type: [Object, Function],
1105
- default: void 0
1106
- },
1107
- styles: {
1108
- type: [Object, Function],
1317
+ classNames: { default: void 0 },
1318
+ styles: { default: void 0 },
1319
+ vars: { default: void 0 },
1320
+ unstyled: {
1321
+ type: Boolean,
1109
1322
  default: void 0
1110
1323
  },
1111
- vars: {
1112
- type: [Object, Function],
1113
- default: void 0
1114
- }
1324
+ variant: { default: void 0 }
1115
1325
  },
1116
- setup(rawProps, { attrs, slots }) {
1326
+ setup(__props) {
1327
+ const rawProps = __props;
1328
+ const attrs = useAttrs();
1117
1329
  const props = useProps("RichTextEditorControlsGroup", null, rawProps);
1118
1330
  const ctx = useRichTextEditorContext();
1119
- return () => h(Box, {
1331
+ const rootProps = computed(() => ({
1120
1332
  ...attrs,
1121
1333
  variant: props.variant || ctx.variant,
1122
1334
  ...ctx.getStyles("controlsGroup", {
@@ -1125,166 +1337,65 @@ var RichTextEditorControlsGroup = defineComponent({
1125
1337
  styles: props.styles,
1126
1338
  classNames: props.classNames
1127
1339
  })
1128
- }, slots);
1129
- }
1130
- });
1131
- Object.assign(RichTextEditorControlsGroup, { classes: RichTextEditor_module_default });
1132
- //#endregion
1133
- //#region src/RichTextEditorToolbar/RichTextEditorToolbar.ts
1134
- var RichTextEditorToolbar = defineComponent({
1135
- name: "RichTextEditorToolbar",
1136
- inheritAttrs: false,
1137
- props: {
1138
- sticky: {
1139
- type: Boolean,
1140
- default: false
1141
- },
1142
- stickyOffset: {
1143
- type: [String, Number],
1144
- default: void 0
1145
- },
1146
- variant: {
1147
- type: String,
1148
- default: void 0
1149
- },
1150
- classNames: {
1151
- type: [Object, Function],
1152
- default: void 0
1153
- },
1154
- styles: {
1155
- type: [Object, Function],
1156
- default: void 0
1157
- },
1158
- vars: {
1159
- type: [Object, Function],
1160
- default: void 0
1161
- },
1162
- mod: {
1163
- type: [Object, Array],
1164
- default: void 0
1165
- }
1166
- },
1167
- setup(rawProps, { attrs, slots }) {
1168
- const props = useProps("RichTextEditorToolbar", null, rawProps);
1169
- const ctx = useRichTextEditorContext();
1170
- return () => h(Box, {
1171
- ...attrs,
1172
- mod: [{ sticky: props.sticky }, props.mod],
1173
- variant: props.variant || ctx.variant,
1174
- ...ctx.getStyles("toolbar", {
1175
- className: attrs.class,
1176
- style: [attrs.style, { "--rte-sticky-offset": rem(props.stickyOffset) }],
1177
- styles: props.styles,
1178
- classNames: props.classNames
1179
- })
1180
- }, slots);
1340
+ }));
1341
+ return (_ctx, _cache) => {
1342
+ return openBlock(), createBlock(unref(Box), normalizeProps(guardReactiveProps(rootProps.value)), {
1343
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
1344
+ _: 3
1345
+ }, 16);
1346
+ };
1181
1347
  }
1182
- });
1183
- Object.assign(RichTextEditorToolbar, { classes: RichTextEditor_module_default });
1348
+ }), { classes: RichTextEditor_module_default });
1184
1349
  //#endregion
1185
1350
  //#region src/RichTextEditor.ts
1186
- var defaultProps = {
1187
- withCodeHighlightStyles: true,
1188
- withTypographyStyles: true,
1189
- variant: "default"
1190
- };
1191
- var RichTextEditorBase = defineComponent({
1192
- name: "RichTextEditor",
1193
- inheritAttrs: false,
1194
- props: {
1195
- editor: {
1196
- type: Object,
1197
- default: null
1198
- },
1199
- withCodeHighlightStyles: {
1200
- type: Boolean,
1201
- default: void 0
1202
- },
1203
- withTypographyStyles: {
1204
- type: Boolean,
1205
- default: void 0
1206
- },
1207
- onSourceCodeTextSwitch: {
1208
- type: Function,
1209
- default: void 0
1210
- },
1211
- labels: {
1212
- type: Object,
1213
- default: void 0
1214
- },
1215
- variant: {
1216
- type: String,
1217
- default: void 0
1218
- },
1219
- classNames: {
1220
- type: [Object, Function],
1221
- default: void 0
1222
- },
1223
- styles: {
1224
- type: [Object, Function],
1225
- default: void 0
1226
- },
1227
- vars: {
1228
- type: [Object, Function],
1229
- default: void 0
1230
- },
1231
- unstyled: {
1232
- type: Boolean,
1233
- default: false
1234
- }
1235
- },
1236
- setup(rawProps, { attrs, slots }) {
1237
- const props = useProps("RichTextEditor", defaultProps, rawProps);
1238
- const getStyles = useStyles({
1239
- name: "RichTextEditor",
1240
- classes: RichTextEditor_module_default,
1241
- props,
1242
- className: attrs.class,
1243
- style: attrs.style,
1244
- classNames: props.classNames,
1245
- styles: props.styles,
1246
- vars: props.vars,
1247
- unstyled: props.unstyled
1248
- });
1249
- const mergedLabels = computed(() => ({
1250
- ...DEFAULT_LABELS,
1251
- ...props.labels
1252
- }));
1253
- provideRichTextEditorContext({
1254
- get editor() {
1255
- return props.editor;
1256
- },
1257
- getStyles,
1258
- get labels() {
1259
- return mergedLabels.value;
1260
- },
1261
- get withCodeHighlightStyles() {
1262
- return props.withCodeHighlightStyles;
1263
- },
1264
- get withTypographyStyles() {
1265
- return props.withTypographyStyles;
1266
- },
1267
- get onSourceCodeTextSwitch() {
1268
- return props.onSourceCodeTextSwitch;
1269
- },
1270
- get unstyled() {
1271
- return props.unstyled;
1272
- },
1273
- get variant() {
1274
- return props.variant;
1275
- }
1276
- });
1277
- return () => h(Box, {
1278
- ...attrs,
1279
- ...getStyles("root")
1280
- }, slots);
1281
- }
1282
- });
1283
- var RichTextEditor = Object.assign(RichTextEditorBase, {
1351
+ var RichTextEditor = factory(RichTextEditor_default, {
1284
1352
  classes: RichTextEditor_module_default,
1285
1353
  Content: RichTextEditorContent,
1286
1354
  Control: RichTextEditorControl,
1287
- Toolbar: RichTextEditorToolbar,
1355
+ Toolbar: factory(/* @__PURE__ */ defineComponent({
1356
+ name: "RichTextEditorToolbar",
1357
+ inheritAttrs: false,
1358
+ __name: "RichTextEditorToolbar",
1359
+ props: {
1360
+ classNames: { default: void 0 },
1361
+ styles: { default: void 0 },
1362
+ vars: { default: void 0 },
1363
+ unstyled: {
1364
+ type: Boolean,
1365
+ default: void 0
1366
+ },
1367
+ sticky: {
1368
+ type: Boolean,
1369
+ default: false
1370
+ },
1371
+ stickyOffset: { default: void 0 },
1372
+ mod: { default: void 0 },
1373
+ variant: { default: void 0 }
1374
+ },
1375
+ setup(__props) {
1376
+ const rawProps = __props;
1377
+ const attrs = useAttrs();
1378
+ const props = useProps("RichTextEditorToolbar", null, rawProps);
1379
+ const ctx = useRichTextEditorContext();
1380
+ const rootProps = computed(() => ({
1381
+ ...attrs,
1382
+ mod: [{ sticky: props.sticky }, props.mod],
1383
+ variant: props.variant || ctx.variant,
1384
+ ...ctx.getStyles("toolbar", {
1385
+ className: attrs.class,
1386
+ style: [attrs.style, { "--rte-sticky-offset": rem(props.stickyOffset) }],
1387
+ styles: props.styles,
1388
+ classNames: props.classNames
1389
+ })
1390
+ }));
1391
+ return (_ctx, _cache) => {
1392
+ return openBlock(), createBlock(unref(Box), normalizeProps(guardReactiveProps(rootProps.value)), {
1393
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
1394
+ _: 3
1395
+ }, 16);
1396
+ };
1397
+ }
1398
+ }), { classes: RichTextEditor_module_default }),
1288
1399
  ControlsGroup: RichTextEditorControlsGroup,
1289
1400
  Bold: BoldControl,
1290
1401
  Italic: ItalicControl,
@@ -1341,6 +1452,6 @@ var getTaskListExtension = (TipTapTaskList) => TipTapTaskList.extend({ addKeyboa
1341
1452
  }
1342
1453
  }) }).configure({ HTMLAttributes: { class: `${RichTextEditor_module_default.taskList} mantine-RichTextEditor-taskList` } });
1343
1454
  //#endregion
1344
- export { AlignCenterControl, AlignJustifyControl, AlignLeftControl, AlignRightControl, BlockquoteControl, BoldControl, BulletListControl, ClearFormattingControl, CodeBlockControl, CodeControl, DEFAULT_LABELS, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, HighlightControl, HrControl, ItalicControl, Link, OrderedListControl, RedoControl, RichTextEditor, RichTextEditorColorControl, RichTextEditorColorPickerControl, RichTextEditorControl, RichTextEditorControlBase, RichTextEditorLinkControl, RichTextEditorSourceCodeControl, StrikeThroughControl, SubscriptControl, SuperscriptControl, TaskListControl, TaskListLiftControl, TaskListSinkControl, UnderlineControl, UndoControl, UnlinkControl, UnsetColorControl, createControl, getTaskListExtension, renderControlIcon, useRichTextEditorContext };
1455
+ export { AlignCenterControl, AlignJustifyControl, AlignLeftControl, AlignRightControl, BlockquoteControl, BoldControl, BulletListControl, ClearFormattingControl, CodeBlockControl, CodeControl, DEFAULT_LABELS, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, HighlightControl, HrControl, ItalicControl, Link, OrderedListControl, RedoControl, RichTextEditor, RichTextEditorColorControl, RichTextEditorColorPickerControl, RichTextEditorControl, RichTextEditorControlBase, RichTextEditorLinkControl, RichTextEditorSourceCodeControl, StrikeThroughControl, SubscriptControl, SuperscriptControl, TaskListControl, TaskListLiftControl, TaskListSinkControl, UnderlineControl, UndoControl, UnlinkControl, UnsetColorControl, createControl, getTaskListExtension, useRichTextEditorContext };
1345
1456
 
1346
1457
  //# sourceMappingURL=index.mjs.map