@questpie/admin 3.2.4 → 3.2.5
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/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +94 -296
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +39 -74
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +285 -605
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +176 -476
- package/dist/client/components/preview/live-preview-mode.mjs +233 -458
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +200 -559
- package/dist/client/components/primitives/select-single.mjs +165 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.mjs +63 -146
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +167 -348
- package/dist/client/preview/use-collection-preview.mjs +121 -215
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +109 -363
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +58 -182
- package/dist/client/views/collection/form-view.mjs +284 -518
- package/dist/client/views/collection/table-view.mjs +231 -463
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -560
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +477 -1301
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +458 -1274
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +39 -39
- package/dist/server/modules/admin/collections/session.d.mts +41 -41
- package/dist/server/modules/admin/collections/user.d.mts +63 -63
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/index.d.mts +20 -19
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/package.json +3 -5
|
@@ -13,7 +13,6 @@ import { ImagePopover } from "./image-popover.mjs";
|
|
|
13
13
|
import { mergePresetFeatures } from "./presets.mjs";
|
|
14
14
|
import { defaultFeatures } from "./types.mjs";
|
|
15
15
|
import { getCharacterCount, getHeadingLevel, getOutput, isSameValue } from "./utils.mjs";
|
|
16
|
-
import { c } from "react/compiler-runtime";
|
|
17
16
|
import * as React from "react";
|
|
18
17
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
18
|
import { toast } from "sonner";
|
|
@@ -21,143 +20,71 @@ import { EditorContent, useEditor } from "@tiptap/react";
|
|
|
21
20
|
|
|
22
21
|
//#region src/client/components/fields/rich-text-editor/index.tsx
|
|
23
22
|
function RichTextToolbarSkeleton() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
t1,
|
|
48
|
-
/* @__PURE__ */ jsxs("div", {
|
|
49
|
-
className: "flex items-center gap-1",
|
|
50
|
-
role: "presentation",
|
|
51
|
-
children: [
|
|
52
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
53
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
54
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" })
|
|
55
|
-
]
|
|
56
|
-
}),
|
|
57
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
58
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" })
|
|
59
|
-
]
|
|
60
|
-
});
|
|
61
|
-
$[2] = t2;
|
|
62
|
-
} else t2 = $[2];
|
|
63
|
-
return t2;
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: "qp-rich-text-editor__toolbar border-border-subtle bg-surface-low flex flex-nowrap items-center gap-1.5 overflow-hidden border-b p-1.5",
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "flex items-center gap-1",
|
|
29
|
+
role: "presentation",
|
|
30
|
+
children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }), /* @__PURE__ */ jsx(Skeleton, { className: "size-8" })]
|
|
31
|
+
}),
|
|
32
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 min-w-[136px]" }),
|
|
33
|
+
/* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: "flex items-center gap-1",
|
|
35
|
+
role: "presentation",
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
38
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
39
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" })
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
|
|
43
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-8" })
|
|
44
|
+
]
|
|
45
|
+
});
|
|
64
46
|
}
|
|
65
47
|
function RichTextEditorContentSkeleton() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
t0 = $[0];
|
|
88
|
-
t1 = $[1];
|
|
89
|
-
t2 = $[2];
|
|
90
|
-
}
|
|
91
|
-
let t3;
|
|
92
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
93
|
-
t3 = /* @__PURE__ */ jsxs("div", {
|
|
94
|
-
className: "qp-rich-text-editor__content space-y-3",
|
|
95
|
-
"aria-hidden": "true",
|
|
96
|
-
children: [
|
|
97
|
-
t0,
|
|
98
|
-
t1,
|
|
99
|
-
t2,
|
|
100
|
-
/* @__PURE__ */ jsx("div", {
|
|
101
|
-
className: "pt-3",
|
|
102
|
-
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
103
|
-
variant: "text",
|
|
104
|
-
className: "h-4 w-full max-w-[58%]"
|
|
105
|
-
})
|
|
48
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
49
|
+
className: "qp-rich-text-editor__content space-y-3",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Skeleton, {
|
|
53
|
+
variant: "text",
|
|
54
|
+
className: "h-4 w-full max-w-[92%]"
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ jsx(Skeleton, {
|
|
57
|
+
variant: "text",
|
|
58
|
+
className: "h-4 w-full max-w-[78%]"
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ jsx(Skeleton, {
|
|
61
|
+
variant: "text",
|
|
62
|
+
className: "h-4 w-full max-w-[86%]"
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsx("div", {
|
|
65
|
+
className: "pt-3",
|
|
66
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
67
|
+
variant: "text",
|
|
68
|
+
className: "h-4 w-full max-w-[58%]"
|
|
106
69
|
})
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} else t3 = $[3];
|
|
111
|
-
return t3;
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
112
73
|
}
|
|
113
|
-
function RichTextEditorLoadingSkeleton(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
t4 = /* @__PURE__ */ jsx("span", {
|
|
128
|
-
className: "sr-only",
|
|
129
|
-
children: "Loading editor"
|
|
130
|
-
});
|
|
131
|
-
$[3] = t4;
|
|
132
|
-
} else t4 = $[3];
|
|
133
|
-
let t5;
|
|
134
|
-
if ($[4] !== showToolbar) {
|
|
135
|
-
t5 = showToolbar && /* @__PURE__ */ jsx(RichTextToolbarSkeleton, {});
|
|
136
|
-
$[4] = showToolbar;
|
|
137
|
-
$[5] = t5;
|
|
138
|
-
} else t5 = $[5];
|
|
139
|
-
let t6;
|
|
140
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
141
|
-
t6 = /* @__PURE__ */ jsx(RichTextEditorContentSkeleton, {});
|
|
142
|
-
$[6] = t6;
|
|
143
|
-
} else t6 = $[6];
|
|
144
|
-
let t7;
|
|
145
|
-
if ($[7] !== t3 || $[8] !== t5) {
|
|
146
|
-
t7 = /* @__PURE__ */ jsxs("div", {
|
|
147
|
-
className: t3,
|
|
148
|
-
"data-admin-rich-text-editor": "root",
|
|
149
|
-
"aria-busy": "true",
|
|
150
|
-
children: [
|
|
151
|
-
t4,
|
|
152
|
-
t5,
|
|
153
|
-
t6
|
|
154
|
-
]
|
|
155
|
-
});
|
|
156
|
-
$[7] = t3;
|
|
157
|
-
$[8] = t5;
|
|
158
|
-
$[9] = t7;
|
|
159
|
-
} else t7 = $[9];
|
|
160
|
-
return t7;
|
|
74
|
+
function RichTextEditorLoadingSkeleton({ disabled, readOnly, error, showToolbar }) {
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
76
|
+
className: cn("qp-rich-text-editor control-surface h-auto min-h-[160px] overflow-hidden", disabled || readOnly ? "opacity-60" : "", error ? "border-destructive" : "border-border"),
|
|
77
|
+
"data-admin-rich-text-editor": "root",
|
|
78
|
+
"aria-busy": "true",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx("span", {
|
|
81
|
+
className: "sr-only",
|
|
82
|
+
children: "Loading editor"
|
|
83
|
+
}),
|
|
84
|
+
showToolbar && /* @__PURE__ */ jsx(RichTextToolbarSkeleton, {}),
|
|
85
|
+
/* @__PURE__ */ jsx(RichTextEditorContentSkeleton, {})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
161
88
|
}
|
|
162
89
|
/**
|
|
163
90
|
* Main RichText Editor Component.
|
|
@@ -167,366 +94,121 @@ function RichTextEditorLoadingSkeleton(t0) {
|
|
|
167
94
|
* `useEditor` with an empty extension list which causes the ProseMirror
|
|
168
95
|
* "Schema is missing its top node type" error.
|
|
169
96
|
*/
|
|
170
|
-
function RichTextEditor(
|
|
171
|
-
const $ = c(114);
|
|
172
|
-
const { name, value, onChange, disabled, readOnly, label, description, placeholder, required, error, localized, locale, extensions, preset, features, showCharacterCount, maxCharacters, enableImages, onImageUpload, imageCollection, enableMediaLibrary } = t0;
|
|
97
|
+
function RichTextEditor({ name, value, onChange, disabled, readOnly, label, description, placeholder, required, error, localized, locale, extensions, preset, features, showCharacterCount, maxCharacters, enableImages, onImageUpload, imageCollection, enableMediaLibrary }) {
|
|
173
98
|
const { t } = useTranslation();
|
|
174
99
|
const resolveText = useResolveText();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
t1 = label ? resolveText(label) : void 0;
|
|
178
|
-
$[0] = label;
|
|
179
|
-
$[1] = resolveText;
|
|
180
|
-
$[2] = t1;
|
|
181
|
-
} else t1 = $[2];
|
|
182
|
-
const resolvedLabel = t1;
|
|
183
|
-
let t2;
|
|
184
|
-
if ($[3] !== description || $[4] !== resolveText) {
|
|
185
|
-
t2 = description ? resolveText(description) : void 0;
|
|
186
|
-
$[3] = description;
|
|
187
|
-
$[4] = resolveText;
|
|
188
|
-
$[5] = t2;
|
|
189
|
-
} else t2 = $[5];
|
|
190
|
-
const resolvedDescription = t2;
|
|
100
|
+
const resolvedLabel = label ? resolveText(label) : void 0;
|
|
101
|
+
const resolvedDescription = description ? resolveText(description) : void 0;
|
|
191
102
|
const descriptionId = resolvedDescription ? `${name}-description` : void 0;
|
|
192
103
|
const errorId = error ? `${name}-error` : void 0;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
} else t3 = $[8];
|
|
200
|
-
const describedBy = t3.join(" ");
|
|
201
|
-
let t4;
|
|
202
|
-
bb0: {
|
|
203
|
-
if (preset) {
|
|
204
|
-
let t5$2;
|
|
205
|
-
if ($[9] !== features || $[10] !== preset) {
|
|
206
|
-
t5$2 = mergePresetFeatures(preset, features);
|
|
207
|
-
$[9] = features;
|
|
208
|
-
$[10] = preset;
|
|
209
|
-
$[11] = t5$2;
|
|
210
|
-
} else t5$2 = $[11];
|
|
211
|
-
t4 = t5$2;
|
|
212
|
-
break bb0;
|
|
213
|
-
}
|
|
214
|
-
let t5$1;
|
|
215
|
-
if ($[12] !== features) {
|
|
216
|
-
t5$1 = {
|
|
217
|
-
...defaultFeatures,
|
|
218
|
-
...features
|
|
219
|
-
};
|
|
220
|
-
$[12] = features;
|
|
221
|
-
$[13] = t5$1;
|
|
222
|
-
} else t5$1 = $[13];
|
|
223
|
-
t4 = t5$1;
|
|
224
|
-
}
|
|
225
|
-
const resolvedFeatures = t4;
|
|
226
|
-
let t5;
|
|
227
|
-
if ($[14] !== t) {
|
|
228
|
-
t5 = t("editor.unorderedList");
|
|
229
|
-
$[14] = t;
|
|
230
|
-
$[15] = t5;
|
|
231
|
-
} else t5 = $[15];
|
|
232
|
-
let t6;
|
|
233
|
-
if ($[16] !== t) {
|
|
234
|
-
t6 = t("editor.bulletListDescription");
|
|
235
|
-
$[16] = t;
|
|
236
|
-
$[17] = t6;
|
|
237
|
-
} else t6 = $[17];
|
|
238
|
-
let t7;
|
|
239
|
-
if ($[18] !== t) {
|
|
240
|
-
t7 = t("editor.codeBlock");
|
|
241
|
-
$[18] = t;
|
|
242
|
-
$[19] = t7;
|
|
243
|
-
} else t7 = $[19];
|
|
244
|
-
let t8;
|
|
245
|
-
if ($[20] !== t) {
|
|
246
|
-
t8 = t("editor.codeBlockDescription");
|
|
247
|
-
$[20] = t;
|
|
248
|
-
$[21] = t8;
|
|
249
|
-
} else t8 = $[21];
|
|
250
|
-
let t9;
|
|
251
|
-
if ($[22] !== t) {
|
|
252
|
-
t9 = t("editor.horizontalRule");
|
|
253
|
-
$[22] = t;
|
|
254
|
-
$[23] = t9;
|
|
255
|
-
} else t9 = $[23];
|
|
256
|
-
let t10;
|
|
257
|
-
if ($[24] !== t) {
|
|
258
|
-
t10 = t("editor.dividerDescription");
|
|
259
|
-
$[24] = t;
|
|
260
|
-
$[25] = t10;
|
|
261
|
-
} else t10 = $[25];
|
|
262
|
-
let t11;
|
|
263
|
-
let t12;
|
|
264
|
-
if ($[26] !== t) {
|
|
265
|
-
t11 = (level) => t("editor.heading", { level });
|
|
266
|
-
t12 = t("editor.heading1Description");
|
|
267
|
-
$[26] = t;
|
|
268
|
-
$[27] = t11;
|
|
269
|
-
$[28] = t12;
|
|
270
|
-
} else {
|
|
271
|
-
t11 = $[27];
|
|
272
|
-
t12 = $[28];
|
|
273
|
-
}
|
|
274
|
-
let t13;
|
|
275
|
-
if ($[29] !== t) {
|
|
276
|
-
t13 = t("editor.heading2Description");
|
|
277
|
-
$[29] = t;
|
|
278
|
-
$[30] = t13;
|
|
279
|
-
} else t13 = $[30];
|
|
280
|
-
let t14;
|
|
281
|
-
if ($[31] !== t) {
|
|
282
|
-
t14 = t("editor.heading3Description");
|
|
283
|
-
$[31] = t;
|
|
284
|
-
$[32] = t14;
|
|
285
|
-
} else t14 = $[32];
|
|
286
|
-
let t15;
|
|
287
|
-
if ($[33] !== t) {
|
|
288
|
-
t15 = t("editor.orderedList");
|
|
289
|
-
$[33] = t;
|
|
290
|
-
$[34] = t15;
|
|
291
|
-
} else t15 = $[34];
|
|
292
|
-
let t16;
|
|
293
|
-
if ($[35] !== t) {
|
|
294
|
-
t16 = t("editor.orderedListDescription");
|
|
295
|
-
$[35] = t;
|
|
296
|
-
$[36] = t16;
|
|
297
|
-
} else t16 = $[36];
|
|
298
|
-
let t17;
|
|
299
|
-
if ($[37] !== t) {
|
|
300
|
-
t17 = t("editor.paragraph");
|
|
301
|
-
$[37] = t;
|
|
302
|
-
$[38] = t17;
|
|
303
|
-
} else t17 = $[38];
|
|
304
|
-
let t18;
|
|
305
|
-
if ($[39] !== t) {
|
|
306
|
-
t18 = t("editor.paragraphDescription");
|
|
307
|
-
$[39] = t;
|
|
308
|
-
$[40] = t18;
|
|
309
|
-
} else t18 = $[40];
|
|
310
|
-
let t19;
|
|
311
|
-
if ($[41] !== t) {
|
|
312
|
-
t19 = t("editor.quote");
|
|
313
|
-
$[41] = t;
|
|
314
|
-
$[42] = t19;
|
|
315
|
-
} else t19 = $[42];
|
|
316
|
-
let t20;
|
|
317
|
-
if ($[43] !== t) {
|
|
318
|
-
t20 = t("editor.quoteDescription");
|
|
319
|
-
$[43] = t;
|
|
320
|
-
$[44] = t20;
|
|
321
|
-
} else t20 = $[44];
|
|
322
|
-
let t21;
|
|
323
|
-
if ($[45] !== t) {
|
|
324
|
-
t21 = t("editor.table");
|
|
325
|
-
$[45] = t;
|
|
326
|
-
$[46] = t21;
|
|
327
|
-
} else t21 = $[46];
|
|
328
|
-
let t22;
|
|
329
|
-
if ($[47] !== t) {
|
|
330
|
-
t22 = t("editor.tableDescription");
|
|
331
|
-
$[47] = t;
|
|
332
|
-
$[48] = t22;
|
|
333
|
-
} else t22 = $[48];
|
|
334
|
-
let t23;
|
|
335
|
-
if ($[49] !== t10 || $[50] !== t11 || $[51] !== t12 || $[52] !== t13 || $[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t18 || $[58] !== t19 || $[59] !== t20 || $[60] !== t21 || $[61] !== t22 || $[62] !== t5 || $[63] !== t6 || $[64] !== t7 || $[65] !== t8 || $[66] !== t9) {
|
|
336
|
-
t23 = {
|
|
337
|
-
bulletList: t5,
|
|
338
|
-
bulletListDescription: t6,
|
|
339
|
-
codeBlock: t7,
|
|
340
|
-
codeBlockDescription: t8,
|
|
341
|
-
divider: t9,
|
|
342
|
-
dividerDescription: t10,
|
|
343
|
-
heading: t11,
|
|
344
|
-
heading1Description: t12,
|
|
345
|
-
heading2Description: t13,
|
|
346
|
-
heading3Description: t14,
|
|
347
|
-
orderedList: t15,
|
|
348
|
-
orderedListDescription: t16,
|
|
349
|
-
paragraph: t17,
|
|
350
|
-
paragraphDescription: t18,
|
|
351
|
-
quote: t19,
|
|
352
|
-
quoteDescription: t20,
|
|
353
|
-
table: t21,
|
|
354
|
-
tableDescription: t22
|
|
104
|
+
const describedBy = [descriptionId, errorId].filter(Boolean).join(" ");
|
|
105
|
+
const resolvedFeatures = React.useMemo(() => {
|
|
106
|
+
if (preset) return mergePresetFeatures(preset, features);
|
|
107
|
+
return {
|
|
108
|
+
...defaultFeatures,
|
|
109
|
+
...features
|
|
355
110
|
};
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
$[73] = t;
|
|
392
|
-
$[74] = t24;
|
|
393
|
-
} else t24 = $[74];
|
|
394
|
-
const extensionBuild = t24;
|
|
111
|
+
}, [preset, features]);
|
|
112
|
+
const extensionLabels = React.useMemo(() => ({
|
|
113
|
+
bulletList: t("editor.unorderedList"),
|
|
114
|
+
bulletListDescription: t("editor.bulletListDescription"),
|
|
115
|
+
codeBlock: t("editor.codeBlock"),
|
|
116
|
+
codeBlockDescription: t("editor.codeBlockDescription"),
|
|
117
|
+
divider: t("editor.horizontalRule"),
|
|
118
|
+
dividerDescription: t("editor.dividerDescription"),
|
|
119
|
+
heading: (level) => t("editor.heading", { level }),
|
|
120
|
+
heading1Description: t("editor.heading1Description"),
|
|
121
|
+
heading2Description: t("editor.heading2Description"),
|
|
122
|
+
heading3Description: t("editor.heading3Description"),
|
|
123
|
+
orderedList: t("editor.orderedList"),
|
|
124
|
+
orderedListDescription: t("editor.orderedListDescription"),
|
|
125
|
+
paragraph: t("editor.paragraph"),
|
|
126
|
+
paragraphDescription: t("editor.paragraphDescription"),
|
|
127
|
+
quote: t("editor.quote"),
|
|
128
|
+
quoteDescription: t("editor.quoteDescription"),
|
|
129
|
+
table: t("editor.table"),
|
|
130
|
+
tableDescription: t("editor.tableDescription")
|
|
131
|
+
}), [t]);
|
|
132
|
+
const extensionBuild = React.useMemo(() => buildExtensions({
|
|
133
|
+
features: resolvedFeatures,
|
|
134
|
+
labels: extensionLabels,
|
|
135
|
+
placeholder: placeholder || t("editor.startWriting"),
|
|
136
|
+
maxCharacters,
|
|
137
|
+
customExtensions: extensions
|
|
138
|
+
}), [
|
|
139
|
+
resolvedFeatures,
|
|
140
|
+
extensionLabels,
|
|
141
|
+
placeholder,
|
|
142
|
+
maxCharacters,
|
|
143
|
+
extensions,
|
|
144
|
+
t
|
|
145
|
+
]);
|
|
395
146
|
const syncExtensions = extensionBuild instanceof Promise ? void 0 : extensionBuild;
|
|
396
147
|
const [asyncExtensionState, setAsyncExtensionState] = React.useState(null);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
if (mounted) setAsyncExtensionState({
|
|
405
|
-
source: extensionBuild,
|
|
406
|
-
extensions: exts
|
|
407
|
-
});
|
|
148
|
+
React.useEffect(() => {
|
|
149
|
+
if (!(extensionBuild instanceof Promise)) return;
|
|
150
|
+
let mounted = true;
|
|
151
|
+
extensionBuild.then((exts) => {
|
|
152
|
+
if (mounted) setAsyncExtensionState({
|
|
153
|
+
source: extensionBuild,
|
|
154
|
+
extensions: exts
|
|
408
155
|
});
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
156
|
+
});
|
|
157
|
+
return () => {
|
|
158
|
+
mounted = false;
|
|
412
159
|
};
|
|
413
|
-
|
|
414
|
-
$[75] = extensionBuild;
|
|
415
|
-
$[76] = t25;
|
|
416
|
-
$[77] = t26;
|
|
417
|
-
} else {
|
|
418
|
-
t25 = $[76];
|
|
419
|
-
t26 = $[77];
|
|
420
|
-
}
|
|
421
|
-
React.useEffect(t25, t26);
|
|
160
|
+
}, [extensionBuild]);
|
|
422
161
|
const resolvedExtensions = syncExtensions ?? (asyncExtensionState?.source === extensionBuild ? asyncExtensionState.extensions : void 0);
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
error,
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
$[88] = error;
|
|
474
|
-
$[89] = imageCollection;
|
|
475
|
-
$[90] = locale;
|
|
476
|
-
$[91] = maxCharacters;
|
|
477
|
-
$[92] = name;
|
|
478
|
-
$[93] = onChange;
|
|
479
|
-
$[94] = onImageUpload;
|
|
480
|
-
$[95] = readOnly;
|
|
481
|
-
$[96] = resolvedExtensions;
|
|
482
|
-
$[97] = resolvedFeatures;
|
|
483
|
-
$[98] = resolvedLabel;
|
|
484
|
-
$[99] = showCharacterCount;
|
|
485
|
-
$[100] = value;
|
|
486
|
-
$[101] = t29;
|
|
487
|
-
} else t29 = $[101];
|
|
488
|
-
let t30;
|
|
489
|
-
if ($[102] !== descriptionId || $[103] !== resolvedDescription) {
|
|
490
|
-
t30 = resolvedDescription && /* @__PURE__ */ jsx("p", {
|
|
491
|
-
id: descriptionId,
|
|
492
|
-
className: "text-muted-foreground text-xs",
|
|
493
|
-
children: resolvedDescription
|
|
494
|
-
});
|
|
495
|
-
$[102] = descriptionId;
|
|
496
|
-
$[103] = resolvedDescription;
|
|
497
|
-
$[104] = t30;
|
|
498
|
-
} else t30 = $[104];
|
|
499
|
-
let t31;
|
|
500
|
-
if ($[105] !== error || $[106] !== errorId) {
|
|
501
|
-
t31 = error && /* @__PURE__ */ jsx("p", {
|
|
502
|
-
id: errorId,
|
|
503
|
-
className: "text-destructive text-xs",
|
|
504
|
-
children: error
|
|
505
|
-
});
|
|
506
|
-
$[105] = error;
|
|
507
|
-
$[106] = errorId;
|
|
508
|
-
$[107] = t31;
|
|
509
|
-
} else t31 = $[107];
|
|
510
|
-
let t32;
|
|
511
|
-
if ($[108] !== t27 || $[109] !== t28 || $[110] !== t29 || $[111] !== t30 || $[112] !== t31) {
|
|
512
|
-
t32 = /* @__PURE__ */ jsxs("div", {
|
|
513
|
-
className: "space-y-2",
|
|
514
|
-
"data-disabled": t27,
|
|
515
|
-
children: [
|
|
516
|
-
t28,
|
|
517
|
-
t29,
|
|
518
|
-
t30,
|
|
519
|
-
t31
|
|
520
|
-
]
|
|
521
|
-
});
|
|
522
|
-
$[108] = t27;
|
|
523
|
-
$[109] = t28;
|
|
524
|
-
$[110] = t29;
|
|
525
|
-
$[111] = t30;
|
|
526
|
-
$[112] = t31;
|
|
527
|
-
$[113] = t32;
|
|
528
|
-
} else t32 = $[113];
|
|
529
|
-
return t32;
|
|
162
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
163
|
+
className: "space-y-2",
|
|
164
|
+
"data-disabled": disabled || readOnly,
|
|
165
|
+
children: [
|
|
166
|
+
resolvedLabel && /* @__PURE__ */ jsxs("div", {
|
|
167
|
+
className: "flex items-center gap-2",
|
|
168
|
+
children: [/* @__PURE__ */ jsxs(Label, {
|
|
169
|
+
htmlFor: name,
|
|
170
|
+
children: [resolvedLabel, required && /* @__PURE__ */ jsx("span", {
|
|
171
|
+
className: "text-destructive ml-1",
|
|
172
|
+
children: "*"
|
|
173
|
+
})]
|
|
174
|
+
}), localized && /* @__PURE__ */ jsx(LocaleBadge, { locale: locale || "i18n" })]
|
|
175
|
+
}),
|
|
176
|
+
resolvedExtensions ? /* @__PURE__ */ jsx(RichTextEditorCore, {
|
|
177
|
+
name,
|
|
178
|
+
ariaLabel: resolvedLabel ?? name,
|
|
179
|
+
ariaDescribedBy: describedBy || void 0,
|
|
180
|
+
value,
|
|
181
|
+
onChange,
|
|
182
|
+
disabled,
|
|
183
|
+
readOnly,
|
|
184
|
+
error,
|
|
185
|
+
locale,
|
|
186
|
+
features: resolvedFeatures,
|
|
187
|
+
resolvedExtensions,
|
|
188
|
+
showCharacterCount,
|
|
189
|
+
maxCharacters,
|
|
190
|
+
enableImages,
|
|
191
|
+
onImageUpload,
|
|
192
|
+
imageCollection,
|
|
193
|
+
enableMediaLibrary
|
|
194
|
+
}) : /* @__PURE__ */ jsx(RichTextEditorLoadingSkeleton, {
|
|
195
|
+
disabled,
|
|
196
|
+
readOnly,
|
|
197
|
+
error,
|
|
198
|
+
showToolbar: resolvedFeatures.toolbar
|
|
199
|
+
}),
|
|
200
|
+
resolvedDescription && /* @__PURE__ */ jsx("p", {
|
|
201
|
+
id: descriptionId,
|
|
202
|
+
className: "text-muted-foreground text-xs",
|
|
203
|
+
children: resolvedDescription
|
|
204
|
+
}),
|
|
205
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
206
|
+
id: errorId,
|
|
207
|
+
className: "text-destructive text-xs",
|
|
208
|
+
children: error
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
});
|
|
530
212
|
}
|
|
531
213
|
/**
|
|
532
214
|
* Core editor — only mounts when extensions are ready.
|
|
@@ -581,16 +263,16 @@ function RichTextEditorCore({ name, ariaLabel, ariaDescribedBy, value, onChange,
|
|
|
581
263
|
if (typeof options?.position === "number") chain.insertContentAt(options.position, imageNodes).run();
|
|
582
264
|
else chain.insertContent(imageNodes).run();
|
|
583
265
|
} catch (err) {
|
|
584
|
-
const
|
|
585
|
-
toast.error(
|
|
266
|
+
const error$1 = err instanceof Error ? err : new Error(t("upload.error"));
|
|
267
|
+
toast.error(error$1.message);
|
|
586
268
|
} finally {
|
|
587
269
|
setUploadingInlineImage(false);
|
|
588
270
|
}
|
|
589
271
|
}, [t, uploadImageFile]);
|
|
590
272
|
const handleEditorPaste = React.useCallback((event) => {
|
|
591
|
-
const
|
|
273
|
+
const currentEditor = editorRef.current;
|
|
592
274
|
const state = editorStateRef.current;
|
|
593
|
-
if (!
|
|
275
|
+
if (!currentEditor || !state.isEditable) return false;
|
|
594
276
|
const imageFiles = getImageFilesFromDataTransfer(event.clipboardData);
|
|
595
277
|
if (state.allowImages && imageFiles.length > 0) {
|
|
596
278
|
event.preventDefault();
|
|
@@ -598,32 +280,32 @@ function RichTextEditorCore({ name, ariaLabel, ariaDescribedBy, value, onChange,
|
|
|
598
280
|
return true;
|
|
599
281
|
}
|
|
600
282
|
const pastedText = event.clipboardData?.getData("text/plain") ?? "";
|
|
601
|
-
if (state.allowLinks && isLikelyLinkHref(pastedText) && !
|
|
283
|
+
if (state.allowLinks && isLikelyLinkHref(pastedText) && !currentEditor.state.selection.empty) {
|
|
602
284
|
event.preventDefault();
|
|
603
|
-
|
|
285
|
+
currentEditor.chain().focus().extendMarkRange("link").setLink(createLinkAttributes(pastedText)).run();
|
|
604
286
|
return true;
|
|
605
287
|
}
|
|
606
288
|
return false;
|
|
607
289
|
}, [insertUploadedImages]);
|
|
608
|
-
const handleEditorDrop = React.useCallback((view,
|
|
609
|
-
const
|
|
610
|
-
if (moved || !
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
|
|
290
|
+
const handleEditorDrop = React.useCallback((view, event, moved) => {
|
|
291
|
+
const state = editorStateRef.current;
|
|
292
|
+
if (moved || !state.isEditable || !state.allowImages) return false;
|
|
293
|
+
const imageFiles = getImageFilesFromDataTransfer(event.dataTransfer);
|
|
294
|
+
if (imageFiles.length === 0) return false;
|
|
295
|
+
event.preventDefault();
|
|
614
296
|
const position = view.posAtCoords({
|
|
615
|
-
left:
|
|
616
|
-
top:
|
|
297
|
+
left: event.clientX,
|
|
298
|
+
top: event.clientY
|
|
617
299
|
})?.pos;
|
|
618
|
-
insertUploadedImages(
|
|
300
|
+
insertUploadedImages(imageFiles, { position });
|
|
619
301
|
return true;
|
|
620
302
|
}, [insertUploadedImages]);
|
|
621
|
-
const handleEditorKeyDown = React.useCallback((
|
|
622
|
-
if (!isModifierShortcut(
|
|
623
|
-
const key =
|
|
303
|
+
const handleEditorKeyDown = React.useCallback((event) => {
|
|
304
|
+
if (!isModifierShortcut(event)) return false;
|
|
305
|
+
const key = event.key.toLowerCase();
|
|
624
306
|
if (key === "k" && allowLinks && isEditable) {
|
|
625
|
-
|
|
626
|
-
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
event.stopPropagation();
|
|
627
309
|
setLinkOpen(true);
|
|
628
310
|
return true;
|
|
629
311
|
}
|
|
@@ -634,7 +316,7 @@ function RichTextEditorCore({ name, ariaLabel, ariaDescribedBy, value, onChange,
|
|
|
634
316
|
"u",
|
|
635
317
|
"y",
|
|
636
318
|
"z"
|
|
637
|
-
].includes(key))
|
|
319
|
+
].includes(key)) event.stopPropagation();
|
|
638
320
|
return false;
|
|
639
321
|
}, [allowLinks, isEditable]);
|
|
640
322
|
const editor = useEditor({
|
|
@@ -650,14 +332,14 @@ function RichTextEditorCore({ name, ariaLabel, ariaDescribedBy, value, onChange,
|
|
|
650
332
|
...ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {},
|
|
651
333
|
...error ? { "aria-invalid": "true" } : {}
|
|
652
334
|
},
|
|
653
|
-
handleKeyDown: (_view,
|
|
654
|
-
handlePaste: (
|
|
655
|
-
handleDrop: (
|
|
335
|
+
handleKeyDown: (_view, event) => handleEditorKeyDown(event),
|
|
336
|
+
handlePaste: (_view, event) => handleEditorPaste(event),
|
|
337
|
+
handleDrop: (view, event, _slice, moved) => handleEditorDrop(view, event, moved)
|
|
656
338
|
},
|
|
657
339
|
editable: isEditable,
|
|
658
|
-
onUpdate: ({ editor:
|
|
340
|
+
onUpdate: ({ editor: currentEditor }) => {
|
|
659
341
|
if (disabled || readOnly) return;
|
|
660
|
-
const nextValue = getOutput(
|
|
342
|
+
const nextValue = getOutput(currentEditor);
|
|
661
343
|
lastEmittedValueRef.current = nextValue;
|
|
662
344
|
onChange?.(nextValue);
|
|
663
345
|
}
|
|
@@ -698,13 +380,13 @@ function RichTextEditorCore({ name, ariaLabel, ariaDescribedBy, value, onChange,
|
|
|
698
380
|
features,
|
|
699
381
|
disabled: !isEditable,
|
|
700
382
|
headingValue,
|
|
701
|
-
onHeadingChange: (
|
|
383
|
+
onHeadingChange: (value$1) => {
|
|
702
384
|
if (!editor) return;
|
|
703
|
-
if (
|
|
385
|
+
if (value$1 === "paragraph") {
|
|
704
386
|
editor.chain().focus().setParagraph().run();
|
|
705
387
|
return;
|
|
706
388
|
}
|
|
707
|
-
editor.chain().focus().toggleHeading({ level: Number(
|
|
389
|
+
editor.chain().focus().toggleHeading({ level: Number(value$1) }).run();
|
|
708
390
|
},
|
|
709
391
|
onLinkClick: () => setLinkOpen(true),
|
|
710
392
|
onImageClick: () => setImageOpen(true),
|