@namroodinc/liquid-editorial 0.15.0 → 0.16.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 (122) hide show
  1. package/README.md +283 -12
  2. package/UPGRADING.md +59 -0
  3. package/dist/chunks/EntryPicker-C7EBfpaw.cjs +2 -0
  4. package/dist/chunks/EntryPicker-C7EBfpaw.cjs.map +1 -0
  5. package/dist/chunks/{EntryPicker-BGWxiLJ_.js → EntryPicker-DBnDsgzi.js} +395 -395
  6. package/dist/chunks/EntryPicker-DBnDsgzi.js.map +1 -0
  7. package/dist/chunks/FormEditor-BG8bOXI8.js +35 -0
  8. package/dist/chunks/FormEditor-BG8bOXI8.js.map +1 -0
  9. package/dist/chunks/FormEditor-BJN0QuLI.cjs +2 -0
  10. package/dist/chunks/FormEditor-BJN0QuLI.cjs.map +1 -0
  11. package/dist/chunks/{NumberField-C90eJGny.js → NumberField-CVsK4l9P.js} +13 -13
  12. package/dist/chunks/{NumberField-C90eJGny.js.map → NumberField-CVsK4l9P.js.map} +1 -1
  13. package/dist/chunks/{NumberField-BrWFmPkW.cjs → NumberField-Ccjpa_1d.cjs} +2 -2
  14. package/dist/chunks/{NumberField-BrWFmPkW.cjs.map → NumberField-Ccjpa_1d.cjs.map} +1 -1
  15. package/dist/chunks/RichTextEditor-D4rNww9d.cjs +2 -0
  16. package/dist/chunks/RichTextEditor-D4rNww9d.cjs.map +1 -0
  17. package/dist/chunks/{RichTextEditor-CS2ED0HP.js → RichTextEditor-DSxiMLVd.js} +1147 -1017
  18. package/dist/chunks/RichTextEditor-DSxiMLVd.js.map +1 -0
  19. package/dist/components/Choice/index.cjs +1 -1
  20. package/dist/components/Choice/index.cjs.map +1 -1
  21. package/dist/components/Choice/index.js +5 -5
  22. package/dist/components/EntryPicker/index.cjs +1 -1
  23. package/dist/components/EntryPicker/index.js +1 -1
  24. package/dist/components/FormEditor/README.md +150 -161
  25. package/dist/components/FormEditor/control.d.cts +4 -4
  26. package/dist/components/FormEditor/control.d.cts.map +1 -1
  27. package/dist/components/FormEditor/control.d.ts +4 -4
  28. package/dist/components/FormEditor/control.d.ts.map +1 -1
  29. package/dist/components/FormEditor/form.d.cts +3 -3
  30. package/dist/components/FormEditor/form.d.cts.map +1 -1
  31. package/dist/components/FormEditor/form.d.ts +3 -3
  32. package/dist/components/FormEditor/form.d.ts.map +1 -1
  33. package/dist/components/FormEditor/index.cjs +1 -1
  34. package/dist/components/FormEditor/index.js +2 -2
  35. package/dist/components/FormEditor/model.d.cts +2 -0
  36. package/dist/components/FormEditor/model.d.cts.map +1 -1
  37. package/dist/components/FormEditor/model.d.ts +2 -0
  38. package/dist/components/FormEditor/model.d.ts.map +1 -1
  39. package/dist/components/FormEditor/rich-text-control.d.cts +1 -2
  40. package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -1
  41. package/dist/components/FormEditor/rich-text-control.d.ts +1 -2
  42. package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -1
  43. package/dist/components/ImageCropper/index.cjs +1 -1
  44. package/dist/components/ImageCropper/index.cjs.map +1 -1
  45. package/dist/components/ImageCropper/index.js +6 -6
  46. package/dist/components/NumberField/index.cjs +1 -1
  47. package/dist/components/NumberField/index.js +1 -1
  48. package/dist/components/RichTextEditor/block-plugins.d.cts +62 -0
  49. package/dist/components/RichTextEditor/block-plugins.d.cts.map +1 -0
  50. package/dist/components/RichTextEditor/block-plugins.d.ts +62 -0
  51. package/dist/components/RichTextEditor/block-plugins.d.ts.map +1 -0
  52. package/dist/components/RichTextEditor/content-block-view.d.cts +1 -1
  53. package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -1
  54. package/dist/components/RichTextEditor/content-block-view.d.ts +1 -1
  55. package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -1
  56. package/dist/components/RichTextEditor/content-block.d.cts +7 -21
  57. package/dist/components/RichTextEditor/content-block.d.cts.map +1 -1
  58. package/dist/components/RichTextEditor/content-block.d.ts +7 -21
  59. package/dist/components/RichTextEditor/content-block.d.ts.map +1 -1
  60. package/dist/components/RichTextEditor/document.d.cts +16 -3
  61. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  62. package/dist/components/RichTextEditor/document.d.ts +16 -3
  63. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  64. package/dist/components/RichTextEditor/index.cjs +1 -1
  65. package/dist/components/RichTextEditor/index.d.cts +6 -4
  66. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  67. package/dist/components/RichTextEditor/index.d.ts +6 -4
  68. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  69. package/dist/components/RichTextEditor/index.js +1 -1
  70. package/dist/components/RichTextEditor/picker-block.d.cts +25 -0
  71. package/dist/components/RichTextEditor/picker-block.d.cts.map +1 -0
  72. package/dist/components/RichTextEditor/picker-block.d.ts +25 -0
  73. package/dist/components/RichTextEditor/picker-block.d.ts.map +1 -0
  74. package/dist/components/RichTextEditor/use-blocks.d.cts +19 -0
  75. package/dist/components/RichTextEditor/use-blocks.d.cts.map +1 -0
  76. package/dist/components/RichTextEditor/use-blocks.d.ts +19 -0
  77. package/dist/components/RichTextEditor/use-blocks.d.ts.map +1 -0
  78. package/dist/components/SelectionCard/index.cjs +1 -1
  79. package/dist/components/SelectionCard/index.cjs.map +1 -1
  80. package/dist/components/SelectionCard/index.js +4 -4
  81. package/dist/components/SelectionCard/index.js.map +1 -1
  82. package/dist/index.cjs +1 -1
  83. package/dist/index.d.cts +2 -2
  84. package/dist/index.d.cts.map +1 -1
  85. package/dist/index.d.ts +2 -2
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +46 -46
  88. package/dist/internal/useStableValue.d.cts +8 -0
  89. package/dist/internal/useStableValue.d.cts.map +1 -0
  90. package/dist/internal/useStableValue.d.ts +8 -0
  91. package/dist/internal/useStableValue.d.ts.map +1 -0
  92. package/dist/rich-text-blocks.cjs +2 -0
  93. package/dist/rich-text-blocks.cjs.map +1 -0
  94. package/dist/rich-text-blocks.d.cts +20 -0
  95. package/dist/rich-text-blocks.d.cts.map +1 -0
  96. package/dist/rich-text-blocks.d.ts +20 -0
  97. package/dist/rich-text-blocks.d.ts.map +1 -0
  98. package/dist/rich-text-blocks.js +36 -0
  99. package/dist/rich-text-blocks.js.map +1 -0
  100. package/package.json +14 -1
  101. package/dist/chunks/EntryPicker-BGWxiLJ_.js.map +0 -1
  102. package/dist/chunks/EntryPicker-wVjzdlAO.cjs +0 -2
  103. package/dist/chunks/EntryPicker-wVjzdlAO.cjs.map +0 -1
  104. package/dist/chunks/FormEditor-BHVJG23r.js +0 -30
  105. package/dist/chunks/FormEditor-BHVJG23r.js.map +0 -1
  106. package/dist/chunks/FormEditor-DjUz7qQo.cjs +0 -2
  107. package/dist/chunks/FormEditor-DjUz7qQo.cjs.map +0 -1
  108. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs +0 -2
  109. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs.map +0 -1
  110. package/dist/chunks/RichTextEditor-CS2ED0HP.js.map +0 -1
  111. package/dist/components/RichTextEditor/embed-context.d.cts +0 -41
  112. package/dist/components/RichTextEditor/embed-context.d.cts.map +0 -1
  113. package/dist/components/RichTextEditor/embed-context.d.ts +0 -41
  114. package/dist/components/RichTextEditor/embed-context.d.ts.map +0 -1
  115. package/dist/components/RichTextEditor/embed-types.d.cts +0 -29
  116. package/dist/components/RichTextEditor/embed-types.d.cts.map +0 -1
  117. package/dist/components/RichTextEditor/embed-types.d.ts +0 -29
  118. package/dist/components/RichTextEditor/embed-types.d.ts.map +0 -1
  119. package/dist/components/RichTextEditor/use-embeds.d.cts +0 -31
  120. package/dist/components/RichTextEditor/use-embeds.d.cts.map +0 -1
  121. package/dist/components/RichTextEditor/use-embeds.d.ts +0 -31
  122. package/dist/components/RichTextEditor/use-embeds.d.ts.map +0 -1
@@ -9,48 +9,58 @@ import { Badge as p } from "../components/Badge/index.js";
9
9
  import { Field as m } from "../components/Field/index.js";
10
10
  import { Modal as h } from "../components/Modal/index.js";
11
11
  import { TextArea as g, TextField as _ } from "../components/TextField/index.js";
12
- import { a as v, c as y, i as b, l as x, n as S, o as C, r as w, s as T, t as E } from "./EntryPicker-BGWxiLJ_.js";
13
- import { Popover as D } from "../components/Popover/index.js";
14
- import { Menu as ee, MenuItem as te, MenuLabel as O, MenuSeparator as k } from "../components/Menu/index.js";
15
- import { Checkbox as ne, ChoiceGroup as A, Radio as j } from "../components/Choice/index.js";
16
- import { Container as re } from "../components/Container/index.js";
17
- import { n as ie } from "./decimal-hq_W9D3s.js";
18
- import { t as ae } from "./NumberField-C90eJGny.js";
19
- import { Select as oe } from "../components/Select/index.js";
20
- import { Switch as se } from "../components/Switch/index.js";
21
- import { i as M } from "./colour-CYEF4Q_n.js";
22
- import { i as N, n as ce, r as le, t as P } from "./Slider-Cab6NqhK.js";
23
- import { t as ue } from "./ColourField-BcuARZY4.js";
24
- import { a as de, n as fe } from "./DatePicker-VQUsbYdo.js";
25
- import { TagsInput as pe } from "../components/TagsInput/index.js";
26
- import { CheckboxCard as me, RadioCard as he, SelectionCardGroup as ge } from "../components/SelectionCard/index.js";
27
- import { createContext as _e, forwardRef as ve, useCallback as F, useContext as ye, useEffect as I, useId as L, useMemo as R, useRef as z, useState as B } from "react";
28
- import { createPortal as be } from "react-dom";
29
- import { Fragment as V, jsx as H, jsxs as U } from "react/jsx-runtime";
30
- import { EditorContent as xe, Node as Se, NodeViewWrapper as Ce, ReactNodeViewRenderer as we, ReactRenderer as Te, createDocument as Ee, getMarkRange as De, getSchema as Oe, mergeAttributes as ke, useEditor as Ae, useEditorState as je } from "@tiptap/react";
31
- import { Placeholder as Me } from "@tiptap/extension-placeholder";
32
- import { StarterKit as Ne } from "@tiptap/starter-kit";
33
- import { Link as Pe } from "@tiptap/extension-link";
34
- import { Table as Fe, TableKit as Ie, TableView as Le, createTable as Re } from "@tiptap/extension-table";
35
- import { Fragment as ze, Slice as Be } from "@tiptap/pm/model";
36
- import { EditorState as Ve, NodeSelection as W, Plugin as He, PluginKey as Ue, TextSelection as We } from "@tiptap/pm/state";
37
- import { closeHistory as G } from "@tiptap/pm/history";
38
- import { CellSelection as K, TableMap as Ge, addColumn as Ke, addRow as qe, cellAround as q, columnIsHeader as Je, deleteColumn as Ye, deleteRow as Xe, deleteTable as Ze, findTable as J, mergeCells as Qe, rowIsHeader as $e, selectedRect as et, splitCell as tt, toggleHeader as nt } from "@tiptap/pm/tables";
12
+ import { contentBlockRegistry as v, isBlockData as y, validContentBlock as b } from "../rich-text-blocks.js";
13
+ import { Popover as x } from "../components/Popover/index.js";
14
+ import { Menu as S, MenuItem as C, MenuLabel as w, MenuSeparator as T } from "../components/Menu/index.js";
15
+ import { Container as E } from "../components/Container/index.js";
16
+ import { a as D, c as O, i as ee, l as te, n as ne, o as re, r as k, s as ie, t as A } from "./EntryPicker-DBnDsgzi.js";
17
+ import { Checkbox as ae, ChoiceGroup as oe, Radio as se } from "../components/Choice/index.js";
18
+ import { n as ce } from "./decimal-hq_W9D3s.js";
19
+ import { t as le } from "./NumberField-CVsK4l9P.js";
20
+ import { Select as ue } from "../components/Select/index.js";
21
+ import { Switch as de } from "../components/Switch/index.js";
22
+ import { i as j } from "./colour-CYEF4Q_n.js";
23
+ import { i as M, n as N, r as P, t as fe } from "./Slider-Cab6NqhK.js";
24
+ import { t as pe } from "./ColourField-BcuARZY4.js";
25
+ import { a as me, n as he } from "./DatePicker-VQUsbYdo.js";
26
+ import { TagsInput as ge } from "../components/TagsInput/index.js";
27
+ import { CheckboxCard as _e, RadioCard as F, SelectionCardGroup as ve } from "../components/SelectionCard/index.js";
28
+ import { Fragment as ye, createContext as be, forwardRef as xe, useCallback as I, useContext as L, useEffect as R, useId as z, useMemo as B, useRef as V, useState as H, useSyncExternalStore as Se } from "react";
29
+ import { createPortal as Ce } from "react-dom";
30
+ import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
31
+ import { EditorContent as we, Extension as Te, Node as Ee, NodeViewWrapper as De, ReactNodeViewRenderer as Oe, ReactRenderer as ke, createDocument as Ae, getMarkRange as je, getSchema as Me, mergeAttributes as Ne, useEditor as Pe, useEditorState as Fe } from "@tiptap/react";
32
+ import { Placeholder as Ie } from "@tiptap/extension-placeholder";
33
+ import { EditorState as Le, NodeSelection as K, Plugin as Re, PluginKey as ze, TextSelection as Be } from "@tiptap/pm/state";
34
+ import { StarterKit as Ve } from "@tiptap/starter-kit";
35
+ import { Link as He } from "@tiptap/extension-link";
36
+ import { Table as Ue, TableKit as We, TableView as Ge, createTable as Ke } from "@tiptap/extension-table";
37
+ import { Fragment as qe, Slice as Je } from "@tiptap/pm/model";
38
+ import { closeHistory as q } from "@tiptap/pm/history";
39
+ import { CellSelection as J, TableMap as Ye, addColumn as Xe, addRow as Ze, cellAround as Qe, columnIsHeader as $e, deleteColumn as et, deleteRow as tt, deleteTable as nt, findTable as Y, mergeCells as rt, rowIsHeader as it, selectedRect as at, splitCell as ot, toggleHeader as st } from "@tiptap/pm/tables";
40
+ //#region src/internal/useStableValue.ts
41
+ function ct(e, t) {
42
+ return e.length === t.length && e.every((e, n) => Object.is(e, t[n]));
43
+ }
44
+ function lt(e, t) {
45
+ let [n, r] = H(e), i = Object.is(n, e) || t(n, e);
46
+ return i || r(e), i ? n : e;
47
+ }
48
+ //#endregion
39
49
  //#region src/components/RichTextEditor/expansion.tsx
40
- function rt(e, t) {
50
+ function ut(e, t) {
41
51
  let n = t.querySelector(".ds-rte__content");
42
52
  if (!n) return;
43
53
  let r = e.view.coordsAtPos(e.state.selection.head), i = n.getBoundingClientRect();
44
54
  (r.top < i.top || r.bottom > i.bottom) && (n.scrollTop += r.top - i.top - i.height / 2);
45
55
  }
46
- function it({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labelledBy: u, expandedWidth: f, frameRef: p }) {
47
- let m = o("ds-rte__host"), [g, _] = B(!1), [v, y] = B(0), b = z(null), x = z(null), S = z(null), C = z(!1), w = z(!1), T = L();
56
+ function dt({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labelledBy: u, expandedWidth: f, frameRef: p }) {
57
+ let m = o("ds-rte__host"), [g, _] = H(!1), [v, y] = H(0), b = V(null), x = V(null), S = V(null), C = V(!1), w = V(!1), T = z();
48
58
  g && n && !i && _(!1);
49
- let E = F(() => {
59
+ let E = I(() => {
50
60
  C.current = document.activeElement === S.current, _(!1);
51
61
  }, []);
52
62
  d(() => {
53
- m && (c(m, g ? x.current : b.current), w.current !== g && (w.current = g, n || !e ? a(document.activeElement) && r(p.current, { preventScroll: !0 }) : (rt(e, m), !g && C.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), C.current = !1)));
63
+ m && (c(m, g ? x.current : b.current), w.current !== g && (w.current = g, n || !e ? a(document.activeElement) && r(p.current, { preventScroll: !0 }) : (ut(e, m), !g && C.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), C.current = !1)));
54
64
  }, [
55
65
  m,
56
66
  g,
@@ -61,7 +71,7 @@ function it({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labe
61
71
  let D = g ? "Collapse editor" : "Expand editor";
62
72
  return {
63
73
  expanded: g,
64
- toggle: /* @__PURE__ */ H(t, {
74
+ toggle: /* @__PURE__ */ W(t, {
65
75
  ref: S,
66
76
  size: "sm",
67
77
  isIconOnly: !0,
@@ -77,12 +87,12 @@ function it({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labe
77
87
  g ? E() : (y(p.current.getBoundingClientRect().height), _(!0));
78
88
  }
79
89
  }),
80
- surfaceSlot: (e) => /* @__PURE__ */ H("div", {
90
+ surfaceSlot: (e) => /* @__PURE__ */ W("div", {
81
91
  ref: b,
82
92
  className: "ds-rte__slot",
83
- children: m ? be(e, m) : e
93
+ children: m ? Ce(e, m) : e
84
94
  }),
85
- dialog: /* @__PURE__ */ H(h, {
95
+ dialog: /* @__PURE__ */ W(h, {
86
96
  id: T,
87
97
  isOpen: g,
88
98
  onClose: E,
@@ -92,7 +102,7 @@ function it({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labe
92
102
  className: "ds-rte__modal",
93
103
  "data-invalid": s || void 0,
94
104
  "aria-labelledby": u,
95
- children: /* @__PURE__ */ H("div", {
105
+ children: /* @__PURE__ */ W("div", {
96
106
  ref: x,
97
107
  className: "ds-rte__expanded-slot"
98
108
  })
@@ -102,50 +112,28 @@ function it({ editor: e, disabled: n, isHeld: i = !1, invalid: s, label: l, labe
102
112
  }
103
113
  //#endregion
104
114
  //#region src/components/RichTextEditor/content-block.ts
105
- var at = [
106
- "type",
107
- "id",
108
- "entryId",
109
- "assetId",
110
- "align"
111
- ], ot = "storyblock";
112
- function st(e) {
113
- let t = (e) => typeof e == "string" && e.trim().length > 0;
114
- return [
115
- "left",
116
- "full",
117
- "right"
118
- ].includes(e.align == null ? "full" : e.align) && (e.type === "entry" ? t(e.id) && t(e.entryId) && e.assetId == null : e.type === "asset" && t(e.assetId) && e.id == null && e.entryId == null);
119
- }
120
- function ct(e) {
121
- let t = e.content?.map(ct), n = !!t && t.some((t, n) => t !== e.content[n]);
122
- return e.type !== ot && !n ? e : {
123
- ...e,
124
- ...e.type === ot ? { type: "contentBlock" } : {},
125
- ...n ? { content: t } : {}
126
- };
115
+ function ft(e) {
116
+ try {
117
+ return JSON.parse(e.getAttribute("data-content-block-data") ?? "null");
118
+ } catch {
119
+ return null;
120
+ }
127
121
  }
128
- function lt(e) {
122
+ function pt(e) {
129
123
  return {
130
- ...e,
131
- ...e.type === "contentBlock" && e.attrs ? { attrs: {
132
- type: e.attrs.type,
133
- ...e.attrs.type === "entry" ? {
134
- id: e.attrs.id,
135
- entryId: e.attrs.entryId
136
- } : { assetId: e.attrs.assetId },
137
- align: e.attrs.align ?? "full"
138
- } } : {},
139
- ...e.content ? { content: e.content.map(lt) } : {}
124
+ type: e.getAttribute("data-content-block-type"),
125
+ align: e.getAttribute("data-content-block-align") ?? "full",
126
+ data: ft(e)
140
127
  };
141
128
  }
142
- function ut(e) {
143
- return e.hasAttribute("data-content-block") ? "data-content-block" : `data-${ot}`;
144
- }
145
- function dt(e, t) {
146
- return e.getAttribute(`${ut(e)}-${t.toLowerCase()}`);
129
+ function mt(e, t) {
130
+ return {
131
+ default: t,
132
+ parseHTML: (t) => pt(t)[e],
133
+ renderHTML: () => ({})
134
+ };
147
135
  }
148
- var ft = Se.create({
136
+ var ht = Ee.create({
149
137
  name: "contentBlock",
150
138
  group: "block",
151
139
  atom: !0,
@@ -153,71 +141,67 @@ var ft = Se.create({
153
141
  selectable: !0,
154
142
  marks: "",
155
143
  addAttributes() {
156
- return Object.fromEntries(at.map((e) => [e, {
157
- default: e === "align" ? "full" : null,
158
- parseHTML: (t) => dt(t, e),
159
- renderHTML: () => ({})
160
- }]));
144
+ return {
145
+ type: mt("type", null),
146
+ align: mt("align", "full"),
147
+ data: mt("data", null)
148
+ };
161
149
  },
162
150
  parseHTML() {
163
- return ["div[data-content-block]", `div[data-${ot}]`].map((e) => ({
164
- tag: e,
165
- getAttrs: (e) => st(Object.fromEntries(at.map((t) => [t, dt(e, t)]))) ? null : !1
166
- }));
151
+ return [{ tag: "div[data-content-block]" }];
167
152
  },
168
- renderHTML({ node: e, HTMLAttributes: t }) {
169
- let n = lt({
170
- type: "contentBlock",
171
- attrs: e.attrs
172
- }).attrs;
173
- return ["div", ke(t, {
153
+ renderHTML({ node: e }) {
154
+ let { type: t, align: n, data: r } = e.attrs;
155
+ return ["div", Ne({
174
156
  "data-content-block": "",
175
- ...Object.fromEntries(Object.entries(n).map(([e, t]) => [`data-content-block-${e.toLowerCase()}`, t]))
157
+ "data-content-block-type": t,
158
+ "data-content-block-align": n,
159
+ "data-content-block-data": y(r) ? JSON.stringify(r) : ""
176
160
  })];
177
161
  }
178
- }), pt = {
162
+ }), gt = {
179
163
  type: "doc",
180
164
  content: [{ type: "paragraph" }]
181
- }, mt = [Ne.configure({
165
+ }, _t = [Ve.configure({
182
166
  link: !1,
183
167
  trailingNode: { notAfter: ["paragraph", "contentBlock"] }
184
- }), Pe.configure({
168
+ }), He.configure({
185
169
  openOnClick: !1,
186
170
  autolink: !0
187
171
  })];
188
- function ht(e) {
172
+ function vt(e) {
189
173
  if (!e.size) return e;
190
174
  let t = [], n = !1;
191
175
  return e.forEach((e) => {
192
- let r = ht(e.content), i = e.attrs.colwidth == null ? e.copy(r) : e.type.create({
176
+ let r = vt(e.content), i = e.attrs.colwidth == null ? e.copy(r) : e.type.create({
193
177
  ...e.attrs,
194
178
  colwidth: null
195
179
  }, r, e.marks);
196
180
  t.push(i), n ||= i !== e;
197
- }), n ? ze.fromArray(t) : e;
181
+ }), n ? qe.fromArray(t) : e;
198
182
  }
199
- function gt() {
183
+ function yt() {
200
184
  let e = null, t = (t) => (t.state.selection.empty || (e = t.state.selection.content()), !1);
201
- return new He({ props: {
185
+ return new Re({ props: {
202
186
  handleDOMEvents: {
203
187
  copy: t,
204
188
  cut: t
205
189
  },
206
190
  transformPasted(t, n) {
207
191
  if ([e, n.dragging?.slice].some((e) => e?.eq(t))) return t;
208
- let r = ht(t.content);
209
- return r === t.content ? t : new Be(r, t.openStart, t.openEnd);
192
+ let r = vt(t.content);
193
+ return r === t.content ? t : new Je(r, t.openStart, t.openEnd);
210
194
  }
211
195
  } });
212
196
  }
213
- var _t = Fe.extend({
197
+ var bt = Ue.extend({
214
198
  addProseMirrorPlugins() {
215
- return [...this.parent?.() ?? [], gt()];
199
+ return [...this.parent?.() ?? [], yt()];
216
200
  },
217
201
  renderHTML({ node: e, HTMLAttributes: t }) {
218
202
  let n = [
219
203
  "table",
220
- ke(this.options.HTMLAttributes, t),
204
+ Ne(this.options.HTMLAttributes, t),
221
205
  ["tbody", 0]
222
206
  ];
223
207
  return e.firstChild?.children.some(({ attrs: e }) => Array.isArray(e.colwidth) && e.colwidth.some(Boolean)) ? this.parent?.({
@@ -225,56 +209,104 @@ var _t = Fe.extend({
225
209
  HTMLAttributes: t
226
210
  }) ?? n : n;
227
211
  }
228
- }).configure({ cellMinWidth: 80 }), vt = Ie.configure({ table: !1 });
229
- function yt(e = ft, { tables: t = !0 } = {}, n = _t) {
212
+ }).configure({ cellMinWidth: 80 }), xt = We.configure({ table: !1 });
213
+ function St(e = ht, { tables: t = !0 } = {}, n = bt) {
230
214
  return t ? [
231
215
  e,
232
- ...mt,
216
+ ..._t,
233
217
  n,
234
- vt
235
- ] : [e, ...mt];
218
+ xt
219
+ ] : [e, ..._t];
236
220
  }
237
- var bt = {
238
- withTables: Oe(yt()),
239
- withoutTables: Oe(yt(ft, { tables: !1 }))
221
+ var Ct = {
222
+ withTables: Me(St()),
223
+ withoutTables: Me(St(ht, { tables: !1 }))
240
224
  };
241
- function xt(e) {
242
- let t = ct(e);
243
- return t.content?.length ? t : {
244
- ...t,
245
- content: pt.content
225
+ function wt(e) {
226
+ return e.content == null || Array.isArray(e.content) && !e.content.length ? {
227
+ ...e,
228
+ content: gt.content
229
+ } : e;
230
+ }
231
+ var Tt = "Unsupported or invalid rich-text document.";
232
+ function Et(e) {
233
+ return {
234
+ definitions: e,
235
+ passed: /* @__PURE__ */ new WeakSet()
246
236
  };
247
237
  }
248
- function St(e, { tables: t = !0 } = {}) {
249
- let n = t ? bt.withTables : bt.withoutTables;
238
+ function Dt(e, t) {
239
+ if (t.passed.has(e)) return !0;
240
+ if (e.type.name === "contentBlock") {
241
+ if (!b(e.attrs, t.definitions)) return !1;
242
+ } else if (!e.isTextblock) {
243
+ for (let n = 0; n < e.childCount; n += 1) if (!Dt(e.child(n), t)) return !1;
244
+ }
245
+ return t.passed.add(e), !0;
246
+ }
247
+ function Ot(e, t) {
248
+ if (typeof DOMParser > "u" || !/data-(content-block|storyblock)/i.test(e)) return;
249
+ let n = v(t), { body: r } = new DOMParser().parseFromString(e, "text/html"), i = r.querySelectorAll("[data-content-block], [data-storyblock]");
250
+ return Array.from(i).some((e) => e.tagName !== "DIV" || e.hasAttribute("data-storyblock") || !b(pt(e), n)) ? Tt : void 0;
251
+ }
252
+ function kt(e, { tables: t = !0, blockDefinitions: n = [] } = {}) {
253
+ let r = v(n), i = t ? Ct.withTables : Ct.withoutTables;
250
254
  try {
251
255
  if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
252
256
  let t = (e) => {
253
- let r = n.nodes[e.type ?? ""];
254
- if (!r || Object.keys(e).some((e) => ![
257
+ let n = i.nodes[e.type ?? ""];
258
+ if (!n || Object.keys(e).some((e) => ![
255
259
  "type",
256
260
  "attrs",
257
261
  "content",
258
262
  "marks",
259
263
  "text"
260
- ].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(r.spec.attrs ?? {}, e)) || e.type === "contentBlock" && (!st(e.attrs ?? {}) || e.marks?.length)) throw Error();
264
+ ].includes(e)) || e.text !== void 0 && e.type !== "text" || e.content != null && !Array.isArray(e.content) || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e)) || e.type === "contentBlock" && (!b(e.attrs, r) || e.marks?.length)) throw Error();
261
265
  for (let t of e.marks ?? []) {
262
- let e = n.marks[t.type];
266
+ let e = i.marks[t.type];
263
267
  if (!e || Object.keys(t).some((e) => !["type", "attrs"].includes(e)) || Object.keys(t.attrs ?? {}).some((t) => !Object.hasOwn(e.spec.attrs ?? {}, t))) throw Error();
264
268
  }
265
269
  e.content?.forEach(t);
266
- }, r = xt(e);
267
- t(r), n.nodeFromJSON(r).check();
270
+ }, n = wt(e);
271
+ t(n), i.nodeFromJSON(n).check();
268
272
  } catch {
269
- return "Unsupported or invalid rich-text document.";
273
+ return Tt;
270
274
  }
271
275
  }
272
276
  //#endregion
273
- //#region src/components/RichTextEditor/content-block-frame.tsx
274
- var Ct = "ds-content-block ds-field-surface";
275
- function wt({ action: e, groupDescription: t }) {
276
- let n = L(), r = [e.description && n, e.disabled && t].filter(Boolean);
277
- return /* @__PURE__ */ H(te, {
277
+ //#region src/components/RichTextEditor/block-plugins.ts
278
+ var At = [], jt = /* @__PURE__ */ new WeakMap();
279
+ function Mt(e, t) {
280
+ if (e === t) return !0;
281
+ let n = jt.get(e), r = jt.get(t);
282
+ if (!n || !r || !ct(n, r)) return !1;
283
+ let i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
284
+ return Array.from(i).every((n) => {
285
+ let r = e[n], i = t[n];
286
+ return typeof r == "function" && typeof i == "function" || Object.is(r, i);
287
+ });
288
+ }
289
+ function Nt(e, t) {
290
+ if (e === t) return !0;
291
+ if (e.size !== t.size) return !1;
292
+ for (let [n, r] of t) {
293
+ let t = e.get(n);
294
+ if (!t || !Mt(t, r)) return !1;
295
+ }
296
+ return !0;
297
+ }
298
+ var X = be({
299
+ plugins: /* @__PURE__ */ new Map(),
300
+ latest: () => void 0,
301
+ picks: /* @__PURE__ */ new Map(),
302
+ disabled: !1,
303
+ busy: !1,
304
+ revision: 0,
305
+ open: () => {}
306
+ }), Pt = "ds-content-block ds-field-surface";
307
+ function Ft({ action: e, groupDescription: t }) {
308
+ let n = z(), r = [e.description && n, e.disabled && t].filter(Boolean);
309
+ return /* @__PURE__ */ W(C, {
278
310
  icon: e.icon,
279
311
  tone: e.tone,
280
312
  isDisabled: e.disabled,
@@ -282,26 +314,26 @@ function wt({ action: e, groupDescription: t }) {
282
314
  "aria-label": e.description ? e.label : void 0,
283
315
  "aria-describedby": r.length ? r.join(" ") : void 0,
284
316
  onClick: e.run,
285
- children: e.description ? /* @__PURE__ */ U("span", { children: [e.label, /* @__PURE__ */ H("span", {
317
+ children: e.description ? /* @__PURE__ */ G("span", { children: [e.label, /* @__PURE__ */ W("span", {
286
318
  id: n,
287
319
  className: "ds-content-block__description",
288
320
  children: e.description
289
321
  })] }) : e.label
290
322
  });
291
323
  }
292
- function Tt({ group: { label: e, description: n, actions: r, choices: i, keepOpen: a, separate: o } }) {
293
- let s = L();
294
- return /* @__PURE__ */ U(V, { children: [
295
- o && /* @__PURE__ */ H(k, {}),
296
- e && /* @__PURE__ */ H(O, { children: e }),
297
- n && /* @__PURE__ */ H("span", {
324
+ function It({ group: { label: e, description: n, actions: r, choices: i, keepOpen: a, separate: o } }) {
325
+ let s = z();
326
+ return /* @__PURE__ */ G(U, { children: [
327
+ o && /* @__PURE__ */ W(T, {}),
328
+ e && /* @__PURE__ */ W(w, { children: e }),
329
+ n && /* @__PURE__ */ W("span", {
298
330
  id: s,
299
331
  className: "ds-content-block__description ds-content-block__group-description",
300
332
  children: n
301
333
  }),
302
- i ? /* @__PURE__ */ H(f, {
334
+ i ? /* @__PURE__ */ W(f, {
303
335
  "aria-label": e,
304
- children: r.map((e) => /* @__PURE__ */ H(t, {
336
+ children: r.map((e) => /* @__PURE__ */ W(t, {
305
337
  role: "menuitemradio",
306
338
  "aria-checked": e.checked,
307
339
  "aria-label": e.label,
@@ -315,73 +347,73 @@ function Tt({ group: { label: e, description: n, actions: r, choices: i, keepOpe
315
347
  a && t.preventDefault(), e.run();
316
348
  }
317
349
  }, e.label))
318
- }) : r.map((e) => /* @__PURE__ */ H(wt, {
350
+ }) : r.map((e) => /* @__PURE__ */ W(Ft, {
319
351
  action: e,
320
352
  groupDescription: n ? s : void 0
321
353
  }, e.label))
322
354
  ] });
323
355
  }
324
- function Et({ groups: e }) {
325
- return e.map((e) => /* @__PURE__ */ H(Tt, { group: e }, e.label ?? e.actions[0]?.label));
356
+ function Lt({ groups: e }) {
357
+ return e.map((e) => /* @__PURE__ */ W(It, { group: e }, e.label ?? e.actions[0]?.label));
326
358
  }
327
- function Dt({ kind: t, meta: n, isMovable: r, onSelect: i }) {
328
- return /* @__PURE__ */ U("span", {
359
+ function Rt({ kind: t, meta: n, isMovable: r, onSelect: i }) {
360
+ return /* @__PURE__ */ G("span", {
329
361
  className: "ds-content-block__kind",
330
362
  "data-drag-handle": r ? "" : void 0,
331
363
  draggable: r || void 0,
332
364
  title: r ? "Drag to move" : void 0,
333
365
  onClick: r ? i : void 0,
334
366
  children: [
335
- r && /* @__PURE__ */ H("span", {
367
+ r && /* @__PURE__ */ W("span", {
336
368
  className: "ds-content-block__grip",
337
369
  "aria-hidden": "true",
338
- children: /* @__PURE__ */ H(e, {
370
+ children: /* @__PURE__ */ W(e, {
339
371
  name: "grip-vertical",
340
372
  size: 16
341
373
  })
342
374
  }),
343
- /* @__PURE__ */ H(p, {
375
+ /* @__PURE__ */ W(p, {
344
376
  className: "ds-content-block__kind-label",
345
377
  shape: "tag",
346
378
  size: "sm",
347
379
  children: t
348
380
  }),
349
- n && /* @__PURE__ */ H("bdi", {
381
+ n && /* @__PURE__ */ W("bdi", {
350
382
  className: "ds-rte__block-meta",
351
383
  children: n
352
384
  })
353
385
  ]
354
386
  });
355
387
  }
356
- function Ot({ kind: e, meta: n, isSelected: r, isDisabled: i, isLocked: a, menuLabel: o, actions: s, onSelect: c }) {
357
- let [l, u] = B(!1), [d, f] = B("end"), [p, m] = B([]), h = {
388
+ function zt({ kind: e, meta: n, isSelected: r, isDisabled: i, isLocked: a, menuLabel: o, actions: s, onSelect: c }) {
389
+ let [l, u] = H(!1), [d, f] = H("end"), [p, m] = H([]), h = {
358
390
  size: "sm",
359
391
  isIconOnly: !0,
360
392
  iconStart: "more-horizontal",
361
393
  "aria-label": o,
362
394
  title: o
363
395
  };
364
- return /* @__PURE__ */ U("div", {
396
+ return /* @__PURE__ */ G("div", {
365
397
  className: "ds-content-block__bar ds-field-surface",
366
398
  onMouseDown: (e) => {
367
399
  let t = e.target;
368
400
  !i && !a && t instanceof Element && e.currentTarget.contains(t) && !t.closest("button, [data-drag-handle]") && (e.preventDefault(), c());
369
401
  },
370
- children: [/* @__PURE__ */ H(Dt, {
402
+ children: [/* @__PURE__ */ W(Rt, {
371
403
  kind: e,
372
404
  meta: n,
373
405
  isMovable: !i && !a,
374
406
  onSelect: c
375
- }), !i && (a ? /* @__PURE__ */ H(t, {
407
+ }), !i && (a ? /* @__PURE__ */ W(t, {
376
408
  ...h,
377
409
  variant: "simple",
378
410
  isDisabled: !0,
379
411
  "aria-haspopup": "menu",
380
412
  "aria-expanded": !1
381
- }) : /* @__PURE__ */ H(ee, {
413
+ }) : /* @__PURE__ */ W(S, {
382
414
  "aria-label": o,
383
415
  align: d,
384
- trigger: (e) => /* @__PURE__ */ H(t, {
416
+ trigger: (e) => /* @__PURE__ */ W(t, {
385
417
  ...e,
386
418
  ...h,
387
419
  variant: e["aria-expanded"] ? "active" : "simple",
@@ -397,27 +429,13 @@ function Ot({ kind: e, meta: n, isSelected: r, isDisabled: i, isLocked: a, menuL
397
429
  e.onClick();
398
430
  }
399
431
  }),
400
- children: /* @__PURE__ */ H(Et, { groups: typeof s == "function" ? p : s })
432
+ children: /* @__PURE__ */ W(Lt, { groups: typeof s == "function" ? p : s })
401
433
  }))]
402
434
  });
403
435
  }
404
436
  //#endregion
405
- //#region src/components/RichTextEditor/embed-context.ts
406
- function Y(e) {
407
- return !!(e && (e.loadPage || e.items?.length || e.onCreate));
408
- }
409
- function kt(e) {
410
- return !!(e && (e.loadPage || e.items?.length));
411
- }
412
- var At = _e({
413
- views: {},
414
- disabled: !1,
415
- busy: !1,
416
- pickCount: 0,
417
- replace: () => {},
418
- seed: () => void 0,
419
- forgetSeed: () => {}
420
- }), jt = [], Mt = [
437
+ //#region src/components/RichTextEditor/content-block-view.tsx
438
+ var Bt = [
421
439
  {
422
440
  align: "left",
423
441
  icon: "align-left",
@@ -434,111 +452,68 @@ var At = _e({
434
452
  label: "Align right"
435
453
  }
436
454
  ];
437
- function Nt(e, t) {
438
- let { views: n, seed: r, forgetSeed: i } = ye(At), a = n[e], o = a?.items ?? jt, s = R(() => [t], [t]), c = F((t) => r(e, t), [r, e]), l = T(s, o, a?.resolveItem, a?.refreshKey, c), u = r(e, t);
439
- I(() => {
440
- u && i(e, t, u);
441
- }, [
442
- i,
443
- e,
444
- t,
445
- u
446
- ]);
447
- let { known: d, failures: f } = l, p = !!a?.resolveItem, m = R(() => y({
448
- selected: s,
449
- items: o,
450
- pageItems: jt,
451
- known: d,
452
- failures: f,
453
- hasResolver: p,
454
- itemLabel: e
455
- })[0], [
456
- s,
457
- o,
458
- d,
459
- f,
460
- p,
461
- e
462
- ]), h = C(`Couldn't load ${e}`, l.status, l.error, l.retry), g = o.some((e) => e.id === t);
463
- return {
464
- view: a,
465
- item: m,
466
- missing: m.tone === "removed" || !g && d.has(t) && !d.get(t),
467
- failure: h
468
- };
469
- }
470
- function Pt({ kind: e, id: t, item: n, missing: r }) {
471
- return /* @__PURE__ */ H("div", {
472
- className: "ds-entry ds-content-block__body",
473
- children: r ? /* @__PURE__ */ U("span", {
474
- className: "ds-entry__body",
475
- children: [/* @__PURE__ */ H("em", {
476
- className: "ds-entry__title",
477
- children: `Unavailable ${e}`
478
- }), /* @__PURE__ */ U("span", {
479
- className: "ds-entry__meta",
480
- children: [/* @__PURE__ */ H("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ H("code", { children: t })]
481
- })]
482
- }) : /* @__PURE__ */ H(x, { item: n })
483
- });
484
- }
485
- function Ft({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
486
- let { disabled: a, busy: o, replace: s } = ye(At), c = e.attrs.type, l = String(c === "entry" ? e.attrs.entryId : e.attrs.assetId), { view: u, item: d, missing: f, failure: p } = Nt(c, l), m = e.attrs.align ?? "full", h = !f && !d.isUnavailable && !d.isDisabled && u?.onEditItem, g = t && !a, _ = () => {
455
+ function Vt({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
456
+ let { disabled: a, busy: o, open: s, plugins: c } = L(X), l = String(e.attrs.type), u = c.get(l), d = B(() => !!u && b(e.attrs, /* @__PURE__ */ new Map([[l, u.definition]])), [
457
+ u,
458
+ e.attrs,
459
+ l
460
+ ]) ? u : void 0, f = u?.label ?? l, p = e.attrs.data, m = e.attrs.align ?? "full", h = t && !a, g = () => {
487
461
  let e = r();
488
462
  e !== void 0 && n.chain().focus().setNodeSelection(e).run();
489
- }, v = () => {
463
+ }, _ = () => {
490
464
  let t = r();
491
465
  t !== void 0 && n.chain().focus().setNodeSelection(t).deleteRange({
492
466
  from: t,
493
467
  to: t + e.nodeSize
494
468
  }).run();
495
- }, y = (e) => {
469
+ }, v = (e) => {
496
470
  let t = e.target;
497
- !e.defaultPrevented && t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), _()));
498
- }, b = [];
499
- return h && b.push({
500
- label: `Edit ${c}`,
501
- icon: "pencil",
502
- run: () => h(d)
503
- }), u?.canEmbed && b.push({
504
- label: f ? `Choose another ${c}` : "Replace",
505
- icon: "rotate-cw",
506
- disabled: o,
507
- run: () => {
508
- let e = r();
509
- e !== void 0 && s(c, e);
510
- }
511
- }), /* @__PURE__ */ U(Ce, {
512
- className: Ct,
513
- "data-kind": c,
514
- "data-align": m,
515
- "data-selected": g || void 0,
516
- "data-missing": f || void 0,
517
- "data-tone": f ? "removed" : d.tone,
518
- contentEditable: !1,
519
- onMouseDown: y,
520
- children: [
521
- /* @__PURE__ */ H(Ot, {
522
- kind: c,
523
- isSelected: g,
471
+ !e.defaultPrevented && t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), g()));
472
+ }, y = (e) => {
473
+ let t = r();
474
+ t !== void 0 && s(l, e, t);
475
+ }, x = ({ title: e, body: t, tone: n, missing: r, onEdit: s, replaceLabel: c }) => {
476
+ let p = [];
477
+ return (s || d?.editLabel && d.renderEditor) && p.push({
478
+ label: d?.editLabel ?? `Edit ${f}`,
479
+ icon: "pencil",
480
+ disabled: !s && o,
481
+ run: s ?? (() => y("edit"))
482
+ }), d?.replaceLabel && d.renderEditor && p.push({
483
+ label: c ?? d.replaceLabel,
484
+ icon: "rotate-cw",
485
+ disabled: o,
486
+ run: () => y("replace")
487
+ }), /* @__PURE__ */ G(De, {
488
+ className: Pt,
489
+ "data-kind": l,
490
+ "data-align": m,
491
+ "data-selected": h || void 0,
492
+ "data-missing": r || void 0,
493
+ "data-tone": r ? "removed" : n,
494
+ contentEditable: !1,
495
+ onMouseDown: v,
496
+ children: [/* @__PURE__ */ W(zt, {
497
+ kind: f,
498
+ isSelected: h,
524
499
  isDisabled: a,
525
500
  isLocked: !!u?.isDialogHidden,
526
- menuLabel: `Block actions for ${f ? `Unavailable ${c}` : d.title}`,
527
- onSelect: _,
501
+ menuLabel: `Block actions for ${e ?? f}`,
502
+ onSelect: g,
528
503
  actions: [
529
504
  {
530
505
  label: "Alignment",
531
506
  choices: !0,
532
507
  keepOpen: !0,
533
- actions: Mt.map((e) => ({
508
+ actions: Bt.map((e) => ({
534
509
  label: e.label,
535
510
  icon: e.icon,
536
511
  checked: m === e.align,
537
512
  run: () => i({ align: e.align })
538
513
  }))
539
514
  },
540
- ...b.length ? [{
541
- actions: b,
515
+ ...p.length ? [{
516
+ actions: p,
542
517
  separate: !0
543
518
  }] : [],
544
519
  {
@@ -547,90 +522,37 @@ function Ft({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i })
547
522
  label: "Remove from field",
548
523
  icon: "trash",
549
524
  tone: "danger",
550
- run: v
525
+ run: _
551
526
  }]
552
527
  }
553
528
  ]
554
- }),
555
- /* @__PURE__ */ H(Pt, {
556
- kind: c,
557
- id: l,
558
- item: d,
559
- missing: f
560
- }),
561
- p && /* @__PURE__ */ H("div", {
562
- className: "ds-content-block__failure",
563
- children: p
564
- })
565
- ]
566
- });
567
- }
568
- //#endregion
569
- //#region src/components/RichTextEditor/use-embeds.tsx
570
- var It = "ds-rte-embed-commit", Lt = ["entry", "asset"], Rt = {
571
- entry: {
572
- itemLabel: "entry",
573
- itemsLabel: "entries"
574
- },
575
- asset: {
576
- itemLabel: "asset",
577
- itemsLabel: "assets"
578
- }
579
- }, zt = {}, Bt = [];
580
- function Vt(e, t, n) {
581
- return {
582
- type: e,
583
- align: t,
584
- ...e === "entry" ? {
585
- id: n.modelId,
586
- entryId: n.id
587
- } : { assetId: n.id }
529
+ }), t]
530
+ });
588
531
  };
532
+ return d?.renderPreview ? d.renderPreview(p, x) : x({});
589
533
  }
590
- function Ht(e, t, n, { replacing: r, multiple: i }) {
591
- let a = e.chain().focus().setMeta(It, !0);
592
- return i && a.command(({ tr: e }) => (G(e), !0)), r ? a.setNodeSelection(t).updateAttributes("contentBlock", n[0].attrs).run() : a.insertContentAt(t, n).setNodeSelection(t + n.length - 1).run();
593
- }
534
+ //#endregion
535
+ //#region src/components/RichTextEditor/use-blocks.tsx
536
+ var Ht = "ds-rte-block-commit";
594
537
  function Ut(e, t) {
595
- if (t.tone === "removed") return {
596
- label: t.removedLabel ?? "Removed",
597
- description: `This ${e} was removed.`
598
- };
599
- if (t.isUnavailable) return {
600
- label: "Unavailable",
601
- description: `This ${e} is unavailable.`
602
- };
603
- if (!st(Vt(e, "full", t))) return {
604
- label: "Can't embed",
605
- description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
606
- };
538
+ return !!e && !!t.node && e.type === t.node.type && e.hasMarkup(t.node.type, {
539
+ ...t.node.attrs,
540
+ align: e.attrs.align
541
+ }, t.node.marks);
607
542
  }
608
543
  function Wt(e, t) {
609
- return !t.isDisabled && !Ut(e, t);
610
- }
611
- function Gt(e, t, n, r) {
612
- let i = e.flatMap((e) => {
613
- let i = r(e.item.id);
614
- return i === void 0 ? [e] : !i || !Wt(t, i) ? [] : i === e.item && Object.is(n, e.revision) ? [e] : [{
615
- item: i,
616
- revision: n
617
- }];
618
- });
619
- return i.length !== e.length || i.some((t, n) => t !== e[n]) ? i : e;
620
- }
621
- var Kt = {
622
- entry: (e) => Ut("entry", e),
623
- asset: (e) => Ut("asset", e)
624
- };
625
- function qt(e, t) {
626
- return e?.type.name === "contentBlock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
544
+ if (e?.renderEditor) switch (t) {
545
+ case "insert": return e.insertLabel;
546
+ case "edit": return e.editLabel;
547
+ case "replace": return e.replaceLabel;
548
+ }
627
549
  }
628
- function Jt(e) {
550
+ function Gt(e) {
629
551
  return e.flatMap((e) => e.mapping.maps);
630
552
  }
631
- function Yt(e, t) {
553
+ function Kt(e, t) {
632
554
  let n = t;
633
- for (let t of Jt(e)) {
555
+ for (let t of Gt(e)) {
634
556
  let e = n, r;
635
557
  if (t.forEach((t, n, i, a) => {
636
558
  r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
@@ -644,9 +566,9 @@ function Yt(e, t) {
644
566
  }
645
567
  return n;
646
568
  }
647
- function Xt(e, t, n) {
569
+ function qt(e, t, n) {
648
570
  let r = t, i = n;
649
- for (let t of Jt(e)) {
571
+ for (let t of Gt(e)) {
650
572
  if (r === i) {
651
573
  r = i = t.map(i, -1);
652
574
  continue;
@@ -662,261 +584,171 @@ function Xt(e, t, n) {
662
584
  to: i
663
585
  };
664
586
  }
665
- function Zt(e, t) {
587
+ function Jt(e, t) {
666
588
  let n = e.resolve(Math.min(t, e.content.size));
667
589
  return n.depth ? n.after(1) : n.pos;
668
590
  }
669
- function Qt(e, t, n) {
670
- let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = Y(e);
671
- return R(() => r ? {
672
- resolveItem: i ? t : void 0,
673
- refreshKey: o,
674
- items: s,
675
- isDialogHidden: c,
676
- canEmbed: l,
677
- onEditItem: a ? n : void 0
678
- } : void 0, [
679
- r,
680
- i,
681
- a,
682
- o,
683
- s,
684
- c,
685
- l,
686
- t,
687
- n
688
- ]);
689
- }
690
- function $t({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: o }) {
691
- let { itemLabel: s, itemsLabel: c } = Rt[e.kind], { multiple: l } = e, d = !!t.isCreating, [f, p] = B([]), [m, h] = B(""), g = u(f.length), _ = R(() => e.replaceId ? [e.replaceId] : f.map(({ item: e }) => e.id), [e, f]), y = S(_, t.items ?? Bt, {
692
- ...t,
693
- resolveItem: l ? t.resolveItem : void 0,
694
- mode: l ? "multiple" : "single",
695
- max: void 0
696
- }, {
697
- isOpen: !0,
698
- isDisabled: n || d,
699
- itemLabel: s,
700
- itemsLabel: c,
701
- close: i,
702
- recheckSelection: l,
703
- restrict: Kt[e.kind]
704
- }), b = C(`Couldn't load selected ${c}`, y.selection.status, y.selection.error, y.selection.retry), x = e.replaceId ? "Replace" : "Embed", w = Gt(f, e.kind, t.refreshKey, (e) => y.isRemote ? y.selection.current.get(e) : t.items?.find((t) => t.id === e) ?? null), T = f.length - w.length;
705
- w !== f && p(w), T > 0 && h(`${T} unavailable ${T === 1 ? s : c} removed from selection.`);
706
- let E = !n && !d && y.selection.status === "ready" && w.length > 0 && T === 0, D = () => {
707
- E && o(w);
708
- };
709
- return /* @__PURE__ */ H(v, {
710
- ...y.dialog,
711
- isOpen: !0,
712
- onClose: i,
713
- onToggle: (e) => {
714
- let t = y.choice(e);
715
- if (!t) return;
716
- let n = {
717
- item: t,
718
- revision: y.revision
719
- };
720
- l ? (h(""), _.includes(e) ? p((t) => t.filter(({ item: t }) => t.id !== e)) : (y.selection.remember([t], n.revision, [..._, e]), p((e) => [...e, n]))) : o([n]);
721
- },
722
- addLabel: `${x} ${l ? c : s}`,
723
- confirm: l ? {
724
- label: "Insert selected",
725
- isDisabled: !E,
726
- onClick: D
727
- } : void 0,
728
- selectionNotice: m,
729
- selectionFailure: b,
730
- onCreate: t.onCreate ? () => t.onCreate?.({
731
- available: () => g.current === 0 && a.available(),
732
- commit: (e) => g.current === 0 && a.commit(e)
733
- }) : void 0,
734
- isCreateDisabled: f.length > 0,
735
- isCreating: t.isCreating,
736
- dialogTitle: t.dialogTitle,
737
- dialogDescription: `${l ? `Choose ${c}` : `Choose one ${s}`} to embed in ${r}. ${t.dialogDescription ?? ""}`.trim(),
738
- isDialogHidden: t.isDialogHidden
739
- });
740
- }
741
- function en(e, n = zt, r, i) {
742
- let [a, o] = B(null), s = z(0), c = z({
743
- session: null,
744
- editor: null,
745
- from: 0,
746
- to: 0,
747
- alive: !1
748
- }), l = z(/* @__PURE__ */ new Map()), [d, p] = B(0), m = F(() => {
749
- c.current.alive = !1, o(null);
750
- }, []), h = a ? n[a.kind] : void 0, g = a && Y(h) && (!r || h?.isCreating) ? a : null;
751
- a && !g && o(null);
752
- let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = u({
591
+ function Yt(e, n, r, i) {
592
+ let [a, o] = H(null), s = V(0), c = V(null), [l, d] = H(0), p = I(() => {
593
+ c.current && (c.current.alive = !1), o(null);
594
+ }, []), m = a ? n.get(a.kind) : void 0, h = a && Wt(m, a.mode) && (!r || m?.isCreating);
595
+ a && !h && o(null);
596
+ let g = !!(h && (m?.isDialogHidden || m?.isCreating)), _ = u({
753
597
  editor: e,
754
- sources: n,
598
+ plugins: n,
755
599
  disabled: r,
756
- busy: _
757
- });
758
- I(() => {
759
- if (!e || !a) return;
760
- if (c.current.session === a && c.current.editor !== e) {
761
- m();
600
+ busy: g
601
+ }), v = lt(n, Nt), y = I((e) => _.current.plugins.get(e), [_]), [x] = H(() => /* @__PURE__ */ new Map());
602
+ R(() => {
603
+ let t = c.current;
604
+ if (!e || !a || t?.session !== a) return;
605
+ if (t.editor !== e) {
606
+ p();
762
607
  return;
763
608
  }
764
- c.current.alive = !0;
765
- let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
766
- let r = [t, ...n];
767
- if (!c.current.alive || !r.some((e) => e.docChanged)) return;
768
- let { from: i, to: o } = c.current;
769
- if (a.replaceId === void 0) {
770
- let e = Xt(r, i, o);
771
- e ? Object.assign(c.current, e) : m();
609
+ let n = ({ editor: e, transaction: n, appendedTransactions: r }) => {
610
+ let i = [n, ...r];
611
+ if (!t.alive || !i.some((e) => e.docChanged)) return;
612
+ if (a.mode === "insert") {
613
+ let e = qt(i, t.from, t.to);
614
+ e ? Object.assign(t, e) : p();
772
615
  return;
773
616
  }
774
- let s = Yt(r, i);
775
- s === null || !qt(e.state.doc.nodeAt(s), a) ? m() : Object.assign(c.current, {
776
- from: s,
777
- to: s + 1
617
+ let o = Kt(i, t.from);
618
+ o === null || !Ut(e.state.doc.nodeAt(o), a) ? p() : Object.assign(t, {
619
+ from: o,
620
+ to: o + 1
778
621
  });
779
622
  };
780
- return e.on("transaction", t), () => {
781
- e.off("transaction", t), c.current.session === a && (c.current.alive = !1);
623
+ return e.on("transaction", n), () => {
624
+ e.off("transaction", n), t.alive = !1;
782
625
  };
783
626
  }, [
784
627
  e,
785
628
  a,
786
- m
629
+ p
787
630
  ]);
788
- let y = (e) => {
789
- let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
790
- return !(!t || t.isDestroyed || c.current.session !== e || c.current.editor !== t || !c.current.alive || !Y(i) || r && !i?.isCreating);
791
- }, b = (e, t, n = !1) => {
792
- let r = v.current.editor, i = e.replaceId !== void 0;
793
- if (!r || !y(e) || !t.length || (!n || i) && t.length !== 1 || t.some(({ item: t }) => !Wt(e.kind, t))) return !1;
794
- let { doc: a } = r.state, o = i ? a.nodeAt(c.current.from) : null;
795
- if (i && !qt(o, e)) return !1;
796
- let s = t.map(({ item: t }) => ({
797
- type: "contentBlock",
798
- attrs: Vt(e.kind, o?.attrs.align ?? "full", t)
799
- })), u = i ? c.current.from : Zt(a, c.current.to);
800
- c.current.alive = !1, l.current = new Map(t.map((t) => [`${e.kind}:${t.item.id}`, t]));
801
- let d = !1;
631
+ let S = I((e) => {
632
+ let { editor: t, plugins: n, disabled: r } = _.current, i = c.current, a = n.get(e.kind);
633
+ return !(!t || t.isDestroyed || i?.session !== e || i.editor !== t || !i.alive || !Wt(a, e.mode) || r && !a?.isCreating);
634
+ }, [_]), C = I((e, t) => {
635
+ let n = _.current.editor, r = c.current, i = _.current.plugins.get(e.kind)?.definition, a = e.mode !== "insert", o = Array.isArray(t) ? t : [t];
636
+ if (!n || !r || !i || !S(e) || !o.length || a && o.length !== 1) return !1;
637
+ let s = a ? n.state.doc.nodeAt(r.from) : null;
638
+ if (a && !Ut(s, e)) return !1;
639
+ let l = /* @__PURE__ */ new Map([[e.kind, i]]), u = o.map((t) => ({
640
+ type: e.kind,
641
+ align: s?.attrs.align ?? "full",
642
+ data: t
643
+ }));
644
+ if (!u.every((e) => b(e, l))) return !1;
645
+ let f = a ? r.from : Jt(n.state.doc, r.to);
646
+ r.alive = !1;
647
+ let m;
802
648
  try {
803
- d = Ht(r, u, s, {
804
- replacing: i,
805
- multiple: n
806
- });
649
+ let e = n.chain().focus().setMeta(Ht, !0).command(({ tr: e }) => (q(e), !0));
650
+ m = a ? e.setNodeSelection(f).updateAttributes("contentBlock", u[0]).run() : e.insertContentAt(f, u.map((e) => ({
651
+ type: "contentBlock",
652
+ attrs: e
653
+ }))).setNodeSelection(f + u.length - 1).run();
807
654
  } catch {
808
- d = !1;
655
+ m = !1;
809
656
  } finally {
810
- m();
657
+ p();
811
658
  }
812
- return d ? (n && !r.isDestroyed && r.view.dispatch(G(r.state.tr)), p((e) => e + 1)) : l.current.clear(), d;
813
- }, x = (e, t) => {
814
- let { editor: n, sources: r, disabled: i, busy: a } = v.current;
815
- if (!n || i || a || !Y(r[e])) return;
816
- let l = t === void 0 ? null : n.state.doc.nodeAt(t);
817
- if (t !== void 0 && (l?.type.name !== "contentBlock" || l.attrs.type !== e)) return;
818
- let { $from: u, from: d, to: f } = n.state.selection, p = {
819
- id: s.current += 1,
659
+ return m && (n.isDestroyed || n.view.dispatch(q(n.state.tr)), d((e) => e + 1)), m;
660
+ }, [
661
+ S,
662
+ p,
663
+ _
664
+ ]), w = I((e, t, n) => {
665
+ let { editor: r, plugins: i, disabled: a, busy: l } = _.current;
666
+ if (!r || a || l || !Wt(i.get(e), t)) return;
667
+ let u = n === void 0 ? null : r.state.doc.nodeAt(n);
668
+ if (t !== "insert" && (u?.type.name !== "contentBlock" || u.attrs.type !== e)) return;
669
+ let { $from: d, from: f, to: m } = r.state.selection, h = {
670
+ id: ++s.current,
820
671
  kind: e,
821
- multiple: t === void 0 && kt(r[e]),
822
- replaceId: l ? String(e === "entry" ? l.attrs.entryId : l.attrs.assetId) : void 0
823
- }, m = t === void 0 ? u.depth ? {
824
- from: u.before(1),
825
- to: u.after(1)
672
+ mode: t,
673
+ node: u,
674
+ target: {
675
+ available: () => S(h),
676
+ commit: (e) => C(h, e),
677
+ close: () => {
678
+ c.current?.session === h && p();
679
+ }
680
+ }
681
+ }, g = n === void 0 ? d.depth ? {
682
+ from: d.before(1),
683
+ to: d.after(1)
826
684
  } : {
827
- from: d,
828
- to: f
685
+ from: f,
686
+ to: m
829
687
  } : {
830
- from: t,
831
- to: t + 1
688
+ from: n,
689
+ to: n + 1
832
690
  };
833
691
  c.current = {
834
- session: p,
835
- editor: n,
836
- ...m,
692
+ session: h,
693
+ editor: r,
694
+ ...g,
837
695
  alive: !0
838
- }, o(p);
839
- }, S = u({ open: x }), [C] = B(() => ({
840
- replace: (e, t) => S.current.open(e, t),
841
- seed: (e, t) => l.current.get(`${e}:${t}`),
842
- forgetSeed: (e, t, n) => {
843
- l.current.get(`${e}:${t}`) === n && l.current.delete(`${e}:${t}`);
844
- },
845
- resolve: {
846
- entry: (e) => v.current.sources.entry?.resolveItem?.(e) ?? null,
847
- asset: (e) => v.current.sources.asset?.resolveItem?.(e) ?? null
848
- },
849
- edit: {
850
- entry: (e) => {
851
- v.current.sources.entry?.onEditItem?.(e);
852
- },
853
- asset: (e) => {
854
- v.current.sources.asset?.onEditItem?.(e);
855
- }
856
- }
857
- })), w = Qt(n.entry, C.resolve.entry, C.edit.entry), T = Qt(n.asset, C.resolve.asset, C.edit.asset), E = R(() => ({
858
- views: {
859
- entry: w,
860
- asset: T
861
- },
696
+ }, o(h);
697
+ }, [
698
+ S,
699
+ p,
700
+ C,
701
+ _
702
+ ]), T = B(() => ({
703
+ plugins: v,
704
+ latest: y,
705
+ picks: x,
862
706
  disabled: r,
863
- busy: _,
864
- pickCount: d,
865
- replace: C.replace,
866
- seed: C.seed,
867
- forgetSeed: C.forgetSeed
707
+ busy: g,
708
+ revision: l,
709
+ open: w
868
710
  }), [
869
- w,
870
- T,
711
+ v,
712
+ y,
713
+ x,
871
714
  r,
872
- _,
873
- d,
874
- C
875
- ]), D = Lt.filter((e) => Y(n[e]));
715
+ g,
716
+ l,
717
+ w
718
+ ]), E = Array.from(n.values()), D = E.filter((e) => Wt(e, "insert")), O = h && a.mode === "insert" ? a.kind : void 0;
876
719
  return {
877
- context: E,
878
- isCreating: Lt.some((e) => n[e]?.isCreating),
879
- toolbar: D.length > 0 && /* @__PURE__ */ H(f, {
880
- "aria-label": "Embed",
881
- children: D.map((i) => {
882
- let a = `Embed ${kt(n[i]) ? Rt[i].itemsLabel : i}`;
883
- return /* @__PURE__ */ H(t, {
884
- size: "sm",
885
- isIconOnly: !0,
886
- iconStart: i === "entry" ? "file-text" : "image",
887
- "aria-label": a,
888
- title: a,
889
- "aria-pressed": g?.kind === i,
890
- variant: g?.kind === i ? "primary" : "neutral",
891
- isDisabled: r || _ || !e,
892
- onClick: () => x(i)
893
- }, i);
894
- })
720
+ context: T,
721
+ isCreating: E.some((e) => e.isCreating),
722
+ toolbar: D.length > 0 && /* @__PURE__ */ W(f, {
723
+ "aria-label": "Insert content block",
724
+ children: D.map(({ definition: n, insertLabel: i, icon: a }) => /* @__PURE__ */ W(t, {
725
+ size: "sm",
726
+ isIconOnly: !0,
727
+ iconStart: a,
728
+ "aria-label": i,
729
+ title: i,
730
+ "aria-pressed": O === n.type,
731
+ variant: O === n.type ? "primary" : "neutral",
732
+ isDisabled: r || !e || g,
733
+ onClick: () => w(n.type, "insert")
734
+ }, n.type))
895
735
  }),
896
- dialog: e && g && h && /* @__PURE__ */ H($t, {
897
- session: g,
898
- source: h,
899
- disabled: r,
900
- label: i,
901
- close: m,
902
- target: {
903
- available: () => y(g),
904
- commit: (e) => b(g, [{
905
- item: e,
906
- revision: v.current.sources[g.kind]?.refreshKey
907
- }])
908
- },
909
- pick: (e) => b(g, e, g.multiple)
910
- }, g.id)
736
+ dialog: h && /* @__PURE__ */ W(ye, { children: m?.renderEditor?.({
737
+ mode: a.mode,
738
+ data: a.node?.attrs.data,
739
+ target: a.target,
740
+ isDisabled: r,
741
+ fieldLabel: i
742
+ }) }, a.id)
911
743
  };
912
744
  }
913
745
  //#endregion
914
746
  //#region src/components/RichTextEditor/expanded-width.ts
915
- var tn = ["wide", "full"], nn = [
747
+ var Xt = ["wide", "full"], Zt = [
916
748
  "sm",
917
749
  "md",
918
750
  "lg"
919
- ], rn = /* @__PURE__ */ new Set([
751
+ ], Qt = /* @__PURE__ */ new Set([
920
752
  "shortText",
921
753
  "longText",
922
754
  "richText",
@@ -935,109 +767,122 @@ var tn = ["wide", "full"], nn = [
935
767
  "date",
936
768
  "divider"
937
769
  ]);
938
- function an(e) {
770
+ function $t(e) {
939
771
  let t = /* @__PURE__ */ new Set();
940
772
  for (let n of e.fields) {
941
773
  if (!n.id?.trim() || t.has(n.id)) throw Error("Form field IDs must be nonempty and unique.");
942
- if (!rn.has(n.type)) throw Error(`Unsupported form field type: ${n.type}`);
774
+ if (!Qt.has(n.type)) throw Error(`Unsupported form field type: ${n.type}`);
943
775
  if ("labelHint" in n) throw Error(`Field ${n.id} uses the removed labelHint; move its content into hint.`);
944
- n.type !== "divider" && (on(n), hn(n), ln(n)), t.add(n.id);
776
+ n.type !== "divider" && (en(n), dn(n), an(n)), t.add(n.id);
945
777
  }
946
778
  }
947
- function on(e) {
779
+ function en(e) {
948
780
  switch (e.type) {
949
781
  case "select":
950
782
  case "radioGroup":
951
- case "checkboxGroup": return vn(e);
783
+ case "checkboxGroup": return mn(e);
952
784
  case "slider":
953
- case "rangeSlider": return gn(e);
954
- case "number": return _n(e);
955
- case "richText": if (e.tables !== void 0 && typeof e.tables != "boolean") throw Error(`Rich text field ${e.id} needs a boolean tables.`);
785
+ case "rangeSlider": return fn(e);
786
+ case "number": return pn(e);
787
+ case "richText":
788
+ if (e.tables !== void 0 && typeof e.tables != "boolean") throw Error(`Rich text field ${e.id} needs a boolean tables.`);
789
+ return tn(e);
790
+ }
791
+ }
792
+ function tn(e) {
793
+ if (e.blockDefinitions !== void 0) {
794
+ if (!Array.isArray(e.blockDefinitions)) throw Error(`Rich text field ${e.id} needs an array of blockDefinitions.`);
795
+ try {
796
+ v(e.blockDefinitions);
797
+ } catch (t) {
798
+ let n = t instanceof Error ? ` ${t.message}` : "";
799
+ throw Error(`Rich text field ${e.id} has invalid blockDefinitions.${n}`);
800
+ }
956
801
  }
957
802
  }
958
- var sn = /* @__PURE__ */ new Set([
803
+ var nn = /* @__PURE__ */ new Set([
959
804
  "shortText",
960
805
  "longText",
961
806
  "tags",
962
807
  "asset",
963
808
  "reference"
964
809
  ]);
965
- function cn(e) {
966
- return sn.has(e.type);
810
+ function rn(e) {
811
+ return nn.has(e.type);
967
812
  }
968
- function ln(e) {
969
- if (cn(e)) {
813
+ function an(e) {
814
+ if (rn(e)) {
970
815
  if (e.limitDisplay !== void 0 && !["used", "remaining"].includes(e.limitDisplay)) throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);
971
816
  if (e.limitVisibility !== void 0 && !["always", "nearLimit"].includes(e.limitVisibility)) throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);
972
817
  if (e.showLimitRing !== void 0 && typeof e.showLimitRing != "boolean") throw Error(`Field ${e.id} needs a boolean showLimitRing.`);
973
818
  }
974
819
  }
975
- function un(e, t, n, r) {
976
- return cn(e) ? {
820
+ function on(e, t, n, r) {
821
+ return rn(e) ? {
977
822
  limitDisplay: e.limitDisplay,
978
823
  limitVisibility: e.limitVisibility,
979
824
  showLimitRing: e.showLimitRing,
980
- limit: dn(e, t, n ?? [], r)
825
+ limit: sn(e, t, n ?? [], r)
981
826
  } : {};
982
827
  }
983
- function dn(e, t, n, r) {
828
+ function sn(e, t, n, r) {
984
829
  switch (e.type) {
985
830
  case "shortText":
986
831
  case "longText": return e.maxLength === void 0 ? void 0 : {
987
- count: pn(t).length,
832
+ count: ln(t).length,
988
833
  max: e.maxLength
989
834
  };
990
835
  case "tags": return e.max === void 0 ? void 0 : {
991
- count: kn(t).length,
836
+ count: Tn(t).length,
992
837
  max: e.max
993
838
  };
994
839
  default: {
995
- let { mode: t, max: i } = mn(e, r);
996
- return b(t, n.length, i);
840
+ let { mode: t, max: i } = un(e, r);
841
+ return D(t, n.length, i);
997
842
  }
998
843
  }
999
844
  }
1000
- function fn(e, t, n, r) {
845
+ function cn(e, t, n, r) {
1001
846
  if (n !== void 0 && (e.type === "asset" || e.type === "reference")) {
1002
- let { mode: t, max: i } = mn(e, r);
1003
- return w(t, n.length, i);
847
+ let { mode: t, max: i } = un(e, r);
848
+ return ee(t, n.length, i);
1004
849
  }
1005
- return e.type === "checkboxGroup" ? kn(t).length : void 0;
850
+ return e.type === "checkboxGroup" ? Tn(t).length : void 0;
1006
851
  }
1007
- function pn(e) {
852
+ function ln(e) {
1008
853
  return typeof e == "string" ? e : "";
1009
854
  }
1010
- function mn(e, t) {
855
+ function un(e, t) {
1011
856
  let n = t?.mode ?? (e.multiple ? "multiple" : "single");
1012
857
  if (!e.multiple) return {
1013
858
  mode: n,
1014
859
  max: n === "multiple" ? 1 : void 0
1015
860
  };
1016
- let r = [xn(e).max, t?.max].filter((e) => e !== void 0 && Number.isFinite(e));
861
+ let r = [_n(e).max, t?.max].filter((e) => e !== void 0 && Number.isFinite(e));
1017
862
  return {
1018
863
  mode: n,
1019
864
  max: r.length > 0 ? Math.min(...r) : void 0
1020
865
  };
1021
866
  }
1022
- function hn(e) {
1023
- if (e.width !== void 0 && !nn.includes(e.width)) throw Error(`Field ${e.id} needs a width of sm, md or lg.`);
1024
- if (e.type === "richText" && e.expandedWidth !== void 0 && !tn.includes(e.expandedWidth)) throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`);
867
+ function dn(e) {
868
+ if (e.width !== void 0 && !Zt.includes(e.width)) throw Error(`Field ${e.id} needs a width of sm, md or lg.`);
869
+ if (e.type === "richText" && e.expandedWidth !== void 0 && !Xt.includes(e.expandedWidth)) throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`);
1025
870
  }
1026
- function gn(e) {
1027
- let { min: t, max: n, step: r } = N(e);
871
+ function fn(e) {
872
+ let { min: t, max: n, step: r } = M(e);
1028
873
  if (![
1029
874
  t,
1030
875
  n,
1031
876
  r
1032
877
  ].every(Number.isFinite) || t >= n || r <= 0) throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);
1033
- if (e.type === "rangeSlider" && r > ie(n, -t)) throw Error(`Range slider ${e.id} needs room for at least one step.`);
878
+ if (e.type === "rangeSlider" && r > ce(n, -t)) throw Error(`Range slider ${e.id} needs room for at least one step.`);
1034
879
  }
1035
- function _n(e) {
880
+ function pn(e) {
1036
881
  let { min: t, max: n, step: r = "any" } = e;
1037
882
  if ([t, n].some((e) => e !== void 0 && !Number.isFinite(e)) || t !== void 0 && n !== void 0 && t > n || r !== "any" && !(Number.isFinite(r) && r > 0)) throw Error(`Number field ${e.id} needs finite min <= max and a positive step or "any".`);
1038
883
  if ([e.decreaseLabel, e.increaseLabel].some((e) => e !== void 0 && (typeof e != "string" || !e.trim()))) throw Error(`Number field ${e.id} needs nonempty stepper labels.`);
1039
884
  }
1040
- function vn(e) {
885
+ function mn(e) {
1041
886
  if (!Array.isArray(e.options)) {
1042
887
  let t = e.type === "select" ? "Select" : "Choice";
1043
888
  throw Error(`${t} field ${e.id} needs an options array.`);
@@ -1046,7 +891,7 @@ function vn(e) {
1046
891
  let t = e.options.map((e) => e.value);
1047
892
  if (t.some((e) => typeof e != "string" || !e.trim()) || new Set(t).size !== t.length) throw Error(`Choice field ${e.id} needs nonempty, unique option values.`);
1048
893
  }
1049
- var yn = {
894
+ var hn = {
1050
895
  asset: {
1051
896
  key: "assetId",
1052
897
  itemLabel: "asset",
@@ -1058,11 +903,11 @@ var yn = {
1058
903
  itemsLabel: "entries"
1059
904
  }
1060
905
  };
1061
- function bn(e) {
906
+ function gn(e) {
1062
907
  return e.type === "asset" || e.type === "reference" ? e.picker?.label ?? e.label : e.label;
1063
908
  }
1064
- function xn(e) {
1065
- let t = yn[e.type], { addLabel: n = `Choose ${bn(e)}`, emptyLabel: r, itemLabel: i = t.itemLabel, itemsLabel: a = t.itemsLabel, max: o, isReorderable: s } = e.picker ?? {};
909
+ function _n(e) {
910
+ let t = hn[e.type], { addLabel: n = `Choose ${gn(e)}`, emptyLabel: r, itemLabel: i = t.itemLabel, itemsLabel: a = t.itemsLabel, max: o, isReorderable: s } = e.picker ?? {};
1066
911
  return {
1067
912
  addLabel: n,
1068
913
  emptyLabel: r,
@@ -1072,70 +917,73 @@ function xn(e) {
1072
917
  isReorderable: s
1073
918
  };
1074
919
  }
1075
- function Sn(e, t) {
1076
- let { key: n } = yn[e.type];
1077
- return (Array.isArray(t) ? t : t === void 0 ? [] : [t]).flatMap((e) => wn(e, n) ? [e[n]] : []);
920
+ function vn(e, t) {
921
+ let { key: n } = hn[e.type];
922
+ return (Array.isArray(t) ? t : t === void 0 ? [] : [t]).flatMap((e) => bn(e, n) ? [e[n]] : []);
1078
923
  }
1079
- function Cn(e) {
924
+ function yn(e) {
1080
925
  if (typeof e != "string") return;
1081
926
  let t = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);
1082
927
  if (!t) return;
1083
928
  let n = `${t[1]}:${t[2] ?? "00"}.${(t[3] ?? "").padEnd(3, "0")}Z`, r = new Date(n);
1084
929
  if (Number.isFinite(r.getTime()) && r.toISOString() === n) return n;
1085
930
  }
1086
- function wn(e, t) {
931
+ function bn(e, t) {
1087
932
  return !!e && typeof e == "object" && t in e && typeof e[t] == "string" && e[t].trim().length > 0;
1088
933
  }
1089
- function Tn(e) {
1090
- return !!e.text?.trim() || e.type === "horizontalRule" || e.type === "contentBlock" || !!e.content?.some(Tn);
934
+ function xn(e) {
935
+ return !!e.text?.trim() || e.type === "horizontalRule" || e.type === "contentBlock" || !!e.content?.some(xn);
1091
936
  }
1092
- function X(e) {
1093
- return `${bn(e)} is required.`;
937
+ function Z(e) {
938
+ return `${gn(e)} is required.`;
1094
939
  }
1095
- function En(e, t) {
940
+ function Sn(e, t) {
1096
941
  if (typeof t != "string") return "Enter text.";
1097
- if (e.required && !t.trim()) return X(e);
942
+ if (e.required && !t.trim()) return Z(e);
1098
943
  if ((e.type === "shortText" || e.type === "longText") && e.maxLength !== void 0 && t.length > e.maxLength) return `Enter no more than ${e.maxLength} characters.`;
1099
944
  }
1100
- function Dn(e, t) {
1101
- let n = St(t, { tables: e.type !== "richText" || e.tables !== !1 });
945
+ function Cn(e, t) {
946
+ let n = kt(t, {
947
+ tables: e.type !== "richText" || e.tables !== !1,
948
+ blockDefinitions: e.type === "richText" ? e.blockDefinitions : void 0
949
+ });
1102
950
  if (n) return n;
1103
- if (e.required && !Tn(xt(t))) return X(e);
951
+ if (e.required && !xn(wt(t))) return Z(e);
1104
952
  }
1105
- function On(e, t) {
953
+ function wn(e, t) {
1106
954
  if (typeof t != "string") return "Choose an available option.";
1107
- if (t === "") return e.required ? X(e) : void 0;
955
+ if (t === "") return e.required ? Z(e) : void 0;
1108
956
  if ((e.type === "select" || e.type === "radioGroup") && e.options.length > 0 && !e.options.some((e) => e.value === t)) return "Choose an available option.";
1109
957
  }
1110
- function kn(e) {
958
+ function Tn(e) {
1111
959
  return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
1112
960
  }
1113
- function An(e, t) {
961
+ function En(e, t) {
1114
962
  if (!Array.isArray(t) || !t.every((e) => typeof e == "string" && e.trim()) || new Set(t).size !== t.length) return "Enter a list of unique, nonempty text values.";
1115
- if (e.required && !t.length) return X(e);
963
+ if (e.required && !t.length) return Z(e);
1116
964
  if (e.type === "tags" && e.max !== void 0 && t.length > e.max) return `Enter no more than ${e.max} tags.`;
1117
965
  if (e.type === "checkboxGroup" && e.options.length && t.some((t) => !e.options.some((e) => e.value === t))) return "Choose available options.";
1118
966
  }
1119
- function jn(e, t) {
967
+ function Dn(e, t) {
1120
968
  if (typeof t != "number" || !Number.isFinite(t)) return "Enter a finite number.";
1121
- let { min: n, max: r } = e.type === "slider" || e.type === "rangeSlider" ? N(e) : e.type === "number" ? e : {};
969
+ let { min: n, max: r } = e.type === "slider" || e.type === "rangeSlider" ? M(e) : e.type === "number" ? e : {};
1122
970
  if (n !== void 0 && t < n) return `Enter a number of at least ${n}.`;
1123
971
  if (r !== void 0 && t > r) return `Enter a number no greater than ${r}.`;
1124
972
  }
1125
- function Mn(e, t) {
973
+ function On(e, t) {
1126
974
  if (typeof t != "string") return "Enter a valid calendar date (YYYY-MM-DD).";
1127
- if (!t) return e.required ? X(e) : void 0;
1128
- if (!de(t)) return "Enter a valid calendar date (YYYY-MM-DD).";
975
+ if (!t) return e.required ? Z(e) : void 0;
976
+ if (!me(t)) return "Enter a valid calendar date (YYYY-MM-DD).";
1129
977
  if (e.type === "date") {
1130
978
  if (e.min && t < e.min) return `Choose a date on or after ${e.min}.`;
1131
979
  if (e.max && t > e.max) return `Choose a date on or before ${e.max}.`;
1132
980
  }
1133
981
  }
1134
- function Nn(e, t) {
1135
- return typeof e == "number" && Number.isFinite(e) ? le(e, t) : void 0;
982
+ function kn(e, t) {
983
+ return typeof e == "number" && Number.isFinite(e) ? P(e, t) : void 0;
1136
984
  }
1137
- function Pn(e, t) {
1138
- let n = e, r = Nn(n?.min, t), i = Nn(n?.max, t);
985
+ function An(e, t) {
986
+ let n = e, r = kn(n?.min, t), i = kn(n?.max, t);
1139
987
  if (r === void 0 && i === void 0) return;
1140
988
  let [a, o] = [r ?? t.min, i ?? t.max].sort((e, t) => e - t);
1141
989
  return {
@@ -1143,56 +991,56 @@ function Pn(e, t) {
1143
991
  max: o
1144
992
  };
1145
993
  }
1146
- function Fn(e, t) {
994
+ function jn(e, t) {
1147
995
  if (!t || typeof t != "object" || Array.isArray(t)) return "Enter a range.";
1148
- let n = t, r = n.min, i = n.max, a = jn(e, r) ?? jn(e, i);
996
+ let n = t, r = n.min, i = n.max, a = Dn(e, r) ?? Dn(e, i);
1149
997
  if (a) return a;
1150
998
  if (r > i) return "The start must not be greater than the end.";
1151
- if (e.type === "rangeSlider" && ie(i, -r) < N(e).step) return "Keep the range endpoints at least one step apart.";
999
+ if (e.type === "rangeSlider" && ce(i, -r) < M(e).step) return "Keep the range endpoints at least one step apart.";
1152
1000
  }
1153
- function In(e, t) {
1154
- return typeof t == "string" ? t.trim() ? M(t) ? void 0 : "Enter a valid colour." : e.required ? X(e) : void 0 : "Enter a valid colour.";
1001
+ function Mn(e, t) {
1002
+ return typeof t == "string" ? t.trim() ? j(t) ? void 0 : "Enter a valid colour." : e.required ? Z(e) : void 0 : "Enter a valid colour.";
1155
1003
  }
1156
- function Ln(e, t) {
1004
+ function Nn(e, t) {
1157
1005
  if (e.type !== "asset" && e.type !== "reference") return;
1158
- let { key: n, itemLabel: r, itemsLabel: i } = yn[e.type];
1159
- if (!e.multiple) return wn(t, n) ? void 0 : `Choose an ${r}.`;
1160
- if (!Array.isArray(t) || !t.every((e) => wn(e, n))) return `Choose a list of ${i}.`;
1161
- if (e.required && t.length === 0) return X(e);
1006
+ let { key: n, itemLabel: r, itemsLabel: i } = hn[e.type];
1007
+ if (!e.multiple) return bn(t, n) ? void 0 : `Choose an ${r}.`;
1008
+ if (!Array.isArray(t) || !t.every((e) => bn(e, n))) return `Choose a list of ${i}.`;
1009
+ if (e.required && t.length === 0) return Z(e);
1162
1010
  let a = e.picker?.max;
1163
- if (a !== void 0 && t.length > a) return `Choose no more than ${a} ${xn(e).itemsLabel}.`;
1164
- }
1165
- var Rn = {
1166
- shortText: En,
1167
- longText: En,
1168
- richText: Dn,
1169
- number: jn,
1170
- slider: jn,
1171
- rangeSlider: Fn,
1172
- date: Mn,
1173
- colour: In,
1174
- radioGroup: On,
1175
- checkboxGroup: An,
1176
- tags: An,
1011
+ if (a !== void 0 && t.length > a) return `Choose no more than ${a} ${_n(e).itemsLabel}.`;
1012
+ }
1013
+ var Pn = {
1014
+ shortText: Sn,
1015
+ longText: Sn,
1016
+ richText: Cn,
1017
+ number: Dn,
1018
+ slider: Dn,
1019
+ rangeSlider: jn,
1020
+ date: On,
1021
+ colour: Mn,
1022
+ radioGroup: wn,
1023
+ checkboxGroup: En,
1024
+ tags: En,
1177
1025
  boolean: (e, t) => typeof t == "boolean" ? void 0 : "Choose a boolean value.",
1178
- dateTime: (e, t) => Cn(t) ? void 0 : "Enter a valid UTC date and time.",
1179
- select: On,
1180
- asset: Ln,
1181
- reference: Ln
1026
+ dateTime: (e, t) => yn(t) ? void 0 : "Enter a valid UTC date and time.",
1027
+ select: wn,
1028
+ asset: Nn,
1029
+ reference: Nn
1182
1030
  };
1183
- function zn(e, t) {
1184
- return t === void 0 ? e.required ? X(e) : void 0 : Rn[e.type](e, t);
1031
+ function Fn(e, t) {
1032
+ return t === void 0 ? e.required ? Z(e) : void 0 : Pn[e.type](e, t);
1185
1033
  }
1186
- function Bn(e, t) {
1187
- return an(e), Object.fromEntries(e.fields.flatMap((e) => {
1034
+ function In(e, t) {
1035
+ return $t(e), Object.fromEntries(e.fields.flatMap((e) => {
1188
1036
  if (e.type === "divider") return [];
1189
- let n = zn(e, Object.hasOwn(t, e.id) ? t[e.id] : void 0);
1037
+ let n = Fn(e, Object.hasOwn(t, e.id) ? t[e.id] : void 0);
1190
1038
  return n ? [[e.id, n]] : [];
1191
1039
  }));
1192
1040
  }
1193
1041
  //#endregion
1194
1042
  //#region src/components/FormEditor/choice-control.tsx
1195
- function Vn({ field: e, option: t, name: n, checked: r, isDisabled: i, invalid: a, onChange: o }) {
1043
+ function Ln({ field: e, option: t, name: n, checked: r, isDisabled: i, invalid: a, onChange: o }) {
1196
1044
  let s = {
1197
1045
  name: n,
1198
1046
  value: t.value,
@@ -1204,29 +1052,29 @@ function Vn({ field: e, option: t, name: n, checked: r, isDisabled: i, invalid:
1204
1052
  }
1205
1053
  };
1206
1054
  if (e.appearance === "card") {
1207
- let n = e.type === "radioGroup" ? he : me;
1208
- return /* @__PURE__ */ H(n, {
1055
+ let n = e.type === "radioGroup" ? F : _e;
1056
+ return /* @__PURE__ */ W(n, {
1209
1057
  ...s,
1210
1058
  title: t.label,
1211
1059
  description: t.description
1212
1060
  });
1213
1061
  }
1214
- let c = e.type === "radioGroup" ? j : ne;
1215
- return /* @__PURE__ */ H(c, {
1062
+ let c = e.type === "radioGroup" ? se : ae;
1063
+ return /* @__PURE__ */ W(c, {
1216
1064
  ...s,
1217
- children: /* @__PURE__ */ U("span", { children: [t.label, t.description && /* @__PURE__ */ H("span", {
1065
+ children: /* @__PURE__ */ G("span", { children: [t.label, t.description && /* @__PURE__ */ W("span", {
1218
1066
  className: "ds-form-editor__option-description",
1219
1067
  children: t.description
1220
1068
  })] })
1221
1069
  });
1222
1070
  }
1223
- function Hn({ field: e, stored: n, isDisabled: r, required: i, accessibility: a, onChange: o }) {
1224
- let s = e.type === "checkboxGroup", c = s ? kn(n) : typeof n == "string" && n ? [n] : [], l = e.appearance === "card" ? ge : A;
1225
- return /* @__PURE__ */ U(V, { children: [/* @__PURE__ */ H(l, {
1071
+ function Rn({ field: e, stored: n, isDisabled: r, required: i, accessibility: a, onChange: o }) {
1072
+ let s = e.type === "checkboxGroup", c = s ? Tn(n) : typeof n == "string" && n ? [n] : [], l = e.appearance === "card" ? ve : oe;
1073
+ return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(l, {
1226
1074
  ...a,
1227
1075
  label: e.label,
1228
1076
  columns: e.columns ?? (e.appearance === "card" ? 2 : 1),
1229
- children: e.options.map((t) => /* @__PURE__ */ H(Vn, {
1077
+ children: e.options.map((t) => /* @__PURE__ */ W(Ln, {
1230
1078
  field: e,
1231
1079
  option: t,
1232
1080
  name: a.id,
@@ -1237,7 +1085,7 @@ function Hn({ field: e, stored: n, isDisabled: r, required: i, accessibility: a,
1237
1085
  o(s ? c.includes(t.value) ? c.filter((e) => e !== t.value) : [...c, t.value] : t.value);
1238
1086
  }
1239
1087
  }, t.value))
1240
- }), !s && !i && c.length > 0 && /* @__PURE__ */ U(t, {
1088
+ }), !s && !i && c.length > 0 && /* @__PURE__ */ G(t, {
1241
1089
  variant: "simple",
1242
1090
  size: "sm",
1243
1091
  isDisabled: r,
@@ -1247,9 +1095,9 @@ function Hn({ field: e, stored: n, isDisabled: r, required: i, accessibility: a,
1247
1095
  }
1248
1096
  //#endregion
1249
1097
  //#region src/components/FormEditor/additional-control.tsx
1250
- function Un({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
1251
- let a = N(e), o = Nn(t, a);
1252
- return /* @__PURE__ */ H(ce, {
1098
+ function zn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
1099
+ let a = M(e), o = kn(t, a);
1100
+ return /* @__PURE__ */ W(N, {
1253
1101
  ...r,
1254
1102
  ...a,
1255
1103
  prefix: e.prefix,
@@ -1265,9 +1113,9 @@ function Un({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i
1265
1113
  }
1266
1114
  });
1267
1115
  }
1268
- function Wn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
1269
- let a = N(e), o = Pn(t, a);
1270
- return /* @__PURE__ */ H(P, {
1116
+ function Bn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
1117
+ let a = M(e), o = An(t, a);
1118
+ return /* @__PURE__ */ W(fe, {
1271
1119
  ...r,
1272
1120
  ...a,
1273
1121
  prefix: e.prefix,
@@ -1288,7 +1136,7 @@ function Wn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i
1288
1136
  }
1289
1137
  });
1290
1138
  }
1291
- function Gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1139
+ function Vn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1292
1140
  let o = {
1293
1141
  stored: t,
1294
1142
  isDisabled: n,
@@ -1298,19 +1146,19 @@ function Gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i,
1298
1146
  };
1299
1147
  switch (e.type) {
1300
1148
  case "radioGroup":
1301
- case "checkboxGroup": return /* @__PURE__ */ H(Hn, {
1149
+ case "checkboxGroup": return /* @__PURE__ */ W(Rn, {
1302
1150
  field: e,
1303
1151
  ...o
1304
1152
  });
1305
- case "rangeSlider": return /* @__PURE__ */ H(Wn, {
1153
+ case "rangeSlider": return /* @__PURE__ */ W(Bn, {
1306
1154
  field: e,
1307
1155
  ...o
1308
1156
  });
1309
- case "slider": return /* @__PURE__ */ H(Un, {
1157
+ case "slider": return /* @__PURE__ */ W(zn, {
1310
1158
  field: e,
1311
1159
  ...o
1312
1160
  });
1313
- case "colour": return /* @__PURE__ */ H(ue, {
1161
+ case "colour": return /* @__PURE__ */ W(pe, {
1314
1162
  ...i,
1315
1163
  required: r,
1316
1164
  placeholder: e.placeholder,
@@ -1324,20 +1172,20 @@ function Gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i,
1324
1172
  value: typeof t == "string" ? t : "",
1325
1173
  onInput: (e) => {
1326
1174
  let t = e.currentTarget.value;
1327
- t.trim() && !M(t) && a(t);
1175
+ t.trim() && !j(t) && a(t);
1328
1176
  },
1329
1177
  onValueChange: (e) => a(e === "" ? void 0 : e)
1330
1178
  });
1331
- case "tags": return /* @__PURE__ */ H(pe, {
1179
+ case "tags": return /* @__PURE__ */ W(ge, {
1332
1180
  ...i,
1333
1181
  required: r,
1334
1182
  placeholder: e.placeholder,
1335
1183
  max: e.max,
1336
1184
  isDisabled: n,
1337
- value: kn(t),
1185
+ value: Tn(t),
1338
1186
  onValueChange: a
1339
1187
  });
1340
- case "date": return /* @__PURE__ */ H(fe, {
1188
+ case "date": return /* @__PURE__ */ W(he, {
1341
1189
  ...i,
1342
1190
  placeholder: e.placeholder,
1343
1191
  min: e.min,
@@ -1353,7 +1201,7 @@ function Gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i,
1353
1201
  }
1354
1202
  //#endregion
1355
1203
  //#region src/components/FormEditor/control.tsx
1356
- function Kn(e, t) {
1204
+ function Hn(e, t) {
1357
1205
  if (e.type === "asset") {
1358
1206
  let n = t.map((e) => ({ assetId: e }));
1359
1207
  return e.multiple ? n : n[0];
@@ -1361,9 +1209,9 @@ function Kn(e, t) {
1361
1209
  let n = t.map((e) => ({ entryId: e }));
1362
1210
  return e.multiple ? n : n[0];
1363
1211
  }
1364
- var qn = _e(null);
1365
- function Jn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1366
- return /* @__PURE__ */ H(ae, {
1212
+ var Un = be(null);
1213
+ function Wn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1214
+ return /* @__PURE__ */ W(le, {
1367
1215
  ...i,
1368
1216
  required: r,
1369
1217
  isDisabled: n,
@@ -1383,9 +1231,9 @@ function Jn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i,
1383
1231
  }
1384
1232
  });
1385
1233
  }
1386
- function Yn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1234
+ function Gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
1387
1235
  let o = !r && !e.options.some((e) => e.value === "");
1388
- return /* @__PURE__ */ H(oe, {
1236
+ return /* @__PURE__ */ W(ue, {
1389
1237
  ...i,
1390
1238
  "aria-required": r || void 0,
1391
1239
  isDisabled: n,
@@ -1400,20 +1248,20 @@ function Yn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i,
1400
1248
  onValueChange: (e) => a(e === "" ? void 0 : e)
1401
1249
  });
1402
1250
  }
1403
- function Xn({ field: e, selected: t, items: n, source: r, isDisabled: i, accessibility: a, onChange: o }) {
1404
- return /* @__PURE__ */ H(E, {
1251
+ function Kn({ field: e, selected: t, items: n, source: r, isDisabled: i, accessibility: a, onChange: o }) {
1252
+ return /* @__PURE__ */ W(A, {
1405
1253
  ...a,
1406
1254
  ...r,
1407
1255
  items: n,
1408
1256
  value: t,
1409
- ...xn(e),
1410
- ...mn(e, r),
1257
+ ..._n(e),
1258
+ ...un(e, r),
1411
1259
  isDisabled: i,
1412
- onValueChange: (t) => o(Kn(e, t))
1260
+ onValueChange: (t) => o(Hn(e, t))
1413
1261
  });
1414
1262
  }
1415
- function Zn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a, isDisabled: o, accessibility: { required: s, ...c }, onChange: l }) {
1416
- let u = ye(qn), d = {
1263
+ function qn({ blockPlugins: e, field: t, stored: n, selected: r, items: i, source: a, isDisabled: o, accessibility: { required: s, ...c }, onChange: l }) {
1264
+ let u = L(Un), d = {
1417
1265
  stored: n,
1418
1266
  isDisabled: o,
1419
1267
  required: s,
@@ -1421,7 +1269,7 @@ function Zn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a,
1421
1269
  onChange: l
1422
1270
  };
1423
1271
  switch (t.type) {
1424
- case "shortText": return /* @__PURE__ */ H(_, {
1272
+ case "shortText": return /* @__PURE__ */ W(_, {
1425
1273
  ...c,
1426
1274
  required: s,
1427
1275
  disabled: o,
@@ -1430,10 +1278,10 @@ function Zn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a,
1430
1278
  maxLength: t.maxLength,
1431
1279
  readOnly: t.readOnly,
1432
1280
  autoFocus: t.autoFocus,
1433
- value: pn(n),
1281
+ value: ln(n),
1434
1282
  onChange: (e) => l(e.target.value)
1435
1283
  });
1436
- case "longText": return /* @__PURE__ */ H(g, {
1284
+ case "longText": return /* @__PURE__ */ W(g, {
1437
1285
  ...c,
1438
1286
  required: s,
1439
1287
  disabled: o,
@@ -1442,50 +1290,50 @@ function Zn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a,
1442
1290
  maxLength: t.maxLength,
1443
1291
  readOnly: t.readOnly,
1444
1292
  autoFocus: t.autoFocus,
1445
- value: pn(n),
1293
+ value: ln(n),
1446
1294
  onChange: (e) => l(e.target.value)
1447
1295
  });
1448
- case "number": return /* @__PURE__ */ H(Jn, {
1296
+ case "number": return /* @__PURE__ */ W(Wn, {
1449
1297
  field: t,
1450
1298
  ...d
1451
1299
  });
1452
- case "boolean": return /* @__PURE__ */ H(se, {
1300
+ case "boolean": return /* @__PURE__ */ W(de, {
1453
1301
  ...c,
1454
1302
  isDisabled: o,
1455
1303
  autoFocus: t.autoFocus,
1456
1304
  isSelected: n === !0,
1457
1305
  onSelectedChange: l
1458
1306
  });
1459
- case "dateTime": return /* @__PURE__ */ H(_, {
1307
+ case "dateTime": return /* @__PURE__ */ W(_, {
1460
1308
  ...c,
1461
1309
  required: s,
1462
1310
  disabled: o,
1463
1311
  type: "datetime-local",
1464
1312
  step: "0.001",
1465
1313
  autoFocus: t.autoFocus,
1466
- value: Cn(n)?.slice(0, -1) ?? "",
1467
- onChange: (e) => l(Cn(`${e.target.value}Z`))
1314
+ value: yn(n)?.slice(0, -1) ?? "",
1315
+ onChange: (e) => l(yn(`${e.target.value}Z`))
1468
1316
  });
1469
1317
  case "richText":
1470
1318
  if (!u) throw Error(`Rich text field ${t.id} needs FormEditor's rich-text control.`);
1471
1319
  return u({
1472
1320
  field: t,
1473
- embeds: e,
1321
+ blockPlugins: e,
1474
1322
  ...d
1475
1323
  });
1476
- case "select": return /* @__PURE__ */ H(Yn, {
1324
+ case "select": return /* @__PURE__ */ W(Gn, {
1477
1325
  field: t,
1478
1326
  ...d
1479
1327
  });
1480
1328
  case "asset":
1481
- case "reference": return /* @__PURE__ */ H(Xn, {
1329
+ case "reference": return /* @__PURE__ */ W(Kn, {
1482
1330
  field: t,
1483
1331
  items: i,
1484
1332
  source: a,
1485
1333
  selected: r ?? [],
1486
1334
  ...d
1487
1335
  });
1488
- default: return /* @__PURE__ */ H(Gn, {
1336
+ default: return /* @__PURE__ */ W(Vn, {
1489
1337
  field: t,
1490
1338
  ...d
1491
1339
  });
@@ -1493,33 +1341,33 @@ function Zn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a,
1493
1341
  }
1494
1342
  //#endregion
1495
1343
  //#region src/components/FormEditor/form.tsx
1496
- function Qn({ field: e, stored: t, items: n, source: r, embeds: i, isDisabled: a, error: o, isErrorVisible: s, onChange: c }) {
1497
- let l = R(() => o === void 0 && s ? zn(e, t) : void 0, [
1344
+ function Jn({ field: e, stored: t, items: n, source: r, blockPlugins: i, isDisabled: a, error: o, isErrorVisible: s, onChange: c }) {
1345
+ let l = B(() => o === void 0 && s ? Fn(e, t) : void 0, [
1498
1346
  o,
1499
1347
  s,
1500
1348
  e,
1501
1349
  t
1502
- ]), u = R(() => e.type === "asset" || e.type === "reference" ? Sn(e, t) : void 0, [e, t]);
1503
- return /* @__PURE__ */ H(re, {
1350
+ ]), u = B(() => e.type === "asset" || e.type === "reference" ? vn(e, t) : void 0, [e, t]);
1351
+ return /* @__PURE__ */ W(E, {
1504
1352
  width: e.width,
1505
1353
  padded: !1,
1506
1354
  center: !1,
1507
1355
  className: "ds-form-editor__field",
1508
- children: /* @__PURE__ */ H(m, {
1509
- ...un(e, t, u, r),
1510
- label: e.type === "dateTime" ? `${e.label} (UTC)` : bn(e),
1356
+ children: /* @__PURE__ */ W(m, {
1357
+ ...on(e, t, u, r),
1358
+ label: e.type === "dateTime" ? `${e.label} (UTC)` : gn(e),
1511
1359
  hint: e.hint,
1512
1360
  error: o ?? l,
1513
1361
  isRequired: e.required,
1514
- count: fn(e, t, u, r),
1515
- isGroup: u !== void 0 || $n.has(e.type),
1516
- children: (o) => /* @__PURE__ */ H(Zn, {
1362
+ count: cn(e, t, u, r),
1363
+ isGroup: u !== void 0 || Yn.has(e.type),
1364
+ children: (o) => /* @__PURE__ */ W(qn, {
1517
1365
  field: e,
1518
1366
  stored: t,
1519
1367
  selected: u,
1520
1368
  items: n,
1521
1369
  source: r,
1522
- embeds: i,
1370
+ blockPlugins: i,
1523
1371
  isDisabled: a,
1524
1372
  accessibility: o,
1525
1373
  onChange: c
@@ -1527,19 +1375,19 @@ function Qn({ field: e, stored: t, items: n, source: r, embeds: i, isDisabled: a
1527
1375
  })
1528
1376
  });
1529
1377
  }
1530
- var $n = /* @__PURE__ */ new Set([
1378
+ var Yn = /* @__PURE__ */ new Set([
1531
1379
  "radioGroup",
1532
1380
  "checkboxGroup",
1533
1381
  "rangeSlider"
1534
- ]), er = /* @__PURE__ */ new Set([
1382
+ ]), Xn = /* @__PURE__ */ new Set([
1535
1383
  "slider",
1536
1384
  "rangeSlider",
1537
1385
  "date",
1538
1386
  "colour"
1539
1387
  ]);
1540
- function tr({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, pickerItems: i = {}, pickerSources: a = {}, embedSources: o = {}, errors: s = {}, isDisabled: c = !1, showAllErrors: l = !1, columns: u = 1, minColumnWidth: d = "16rem", className: f, style: p, ...m }) {
1541
- let [h, g] = B(n), [_, v] = B(() => /* @__PURE__ */ new Set()), y = t ?? h;
1542
- R(() => an(e), [e]);
1388
+ function Zn({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, pickerItems: i = {}, pickerSources: a = {}, blockPlugins: o = {}, errors: s = {}, isDisabled: c = !1, showAllErrors: l = !1, columns: u = 1, minColumnWidth: d = "16rem", className: f, style: p, ...m }) {
1389
+ let [h, g] = H(n), [_, v] = H(() => /* @__PURE__ */ new Set()), y = t ?? h;
1390
+ B(() => $t(e), [e]);
1543
1391
  let b = (e, n) => {
1544
1392
  let i = { ...y };
1545
1393
  n === void 0 ? delete i[e] : i[e] = n, t === void 0 && g(i), v((t) => new Set(t).add(e)), r?.(i, { fieldId: e });
@@ -1547,7 +1395,7 @@ function tr({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, picke
1547
1395
  "--form-editor-columns": u,
1548
1396
  "--form-editor-min-column": d
1549
1397
  };
1550
- return /* @__PURE__ */ H("div", {
1398
+ return /* @__PURE__ */ W("div", {
1551
1399
  className: [
1552
1400
  "ds-form-editor",
1553
1401
  u === "auto" && "ds-form-editor--auto",
@@ -1559,19 +1407,19 @@ function tr({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, picke
1559
1407
  },
1560
1408
  ...m,
1561
1409
  children: e.fields.map((e) => {
1562
- if (e.type === "divider") return /* @__PURE__ */ H("hr", { className: "ds-form-editor__divider" }, e.id);
1563
- let t = Object.hasOwn(y, e.id) ? y[e.id] : void 0, n = c || !!e.isDisabled, r = n || "readOnly" in e && !!e.readOnly, u = typeof t == "string" ? t.trim() !== "" : t !== void 0, d = l || _.has(e.id) || u && er.has(e.type) || e.type === "number" && typeof t == "number";
1564
- return /* @__PURE__ */ H(Qn, {
1410
+ if (e.type === "divider") return /* @__PURE__ */ W("hr", { className: "ds-form-editor__divider" }, e.id);
1411
+ let t = Object.hasOwn(y, e.id) ? y[e.id] : void 0, n = c || !!e.isDisabled, r = n || "readOnly" in e && !!e.readOnly, u = typeof t == "string" ? t.trim() !== "" : t !== void 0, d = l || _.has(e.id) || u && Xn.has(e.type) || e.type === "number" && typeof t == "number";
1412
+ return /* @__PURE__ */ W(Jn, {
1565
1413
  field: e,
1566
1414
  stored: t,
1567
1415
  items: i[e.id] ?? [],
1568
1416
  source: a[e.id],
1569
- embeds: o[e.id],
1417
+ blockPlugins: o[e.id],
1570
1418
  isDisabled: n,
1571
1419
  error: s[e.id],
1572
1420
  isErrorVisible: d,
1573
1421
  onChange: (t) => {
1574
- (!r || e.type === "richText" && (o[e.id]?.entry?.isCreating || o[e.id]?.asset?.isCreating)) && b(e.id, t);
1422
+ (!r || e.type === "richText" && o[e.id]?.some((e) => e.isCreating)) && b(e.id, t);
1575
1423
  }
1576
1424
  }, e.id);
1577
1425
  })
@@ -1579,14 +1427,14 @@ function tr({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, picke
1579
1427
  }
1580
1428
  //#endregion
1581
1429
  //#region src/components/RichTextEditor/tables.tsx
1582
- var nr = 50, rr = { fields: [
1430
+ var Qn = 50, $n = { fields: [
1583
1431
  {
1584
1432
  id: "rows",
1585
1433
  type: "number",
1586
1434
  label: "Rows",
1587
1435
  required: !0,
1588
1436
  min: 1,
1589
- max: nr,
1437
+ max: Qn,
1590
1438
  step: 1,
1591
1439
  decreaseLabel: "Fewer rows",
1592
1440
  increaseLabel: "More rows"
@@ -1597,7 +1445,7 @@ var nr = 50, rr = { fields: [
1597
1445
  label: "Columns",
1598
1446
  required: !0,
1599
1447
  min: 1,
1600
- max: nr,
1448
+ max: Qn,
1601
1449
  step: 1,
1602
1450
  decreaseLabel: "Fewer columns",
1603
1451
  increaseLabel: "More columns"
@@ -1607,70 +1455,70 @@ var nr = 50, rr = { fields: [
1607
1455
  type: "boolean",
1608
1456
  label: "Include header row"
1609
1457
  }
1610
- ] }, Z = {
1458
+ ] }, er = {
1611
1459
  rows: 3,
1612
1460
  cols: 3
1613
- }, ir = {
1614
- ...Z,
1461
+ }, tr = {
1462
+ ...er,
1615
1463
  withHeaderRow: !0
1616
- }, ar = "Enter a whole number.";
1617
- function or(e) {
1618
- return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= nr ? e : void 0;
1464
+ }, nr = "Enter a whole number.";
1465
+ function rr(e) {
1466
+ return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= Qn ? e : void 0;
1619
1467
  }
1620
- function sr(e) {
1621
- return typeof e == "number" && !Number.isInteger(e) ? ar : void 0;
1468
+ function ir(e) {
1469
+ return typeof e == "number" && !Number.isInteger(e) ? nr : void 0;
1622
1470
  }
1623
- function cr(e, t, { rows: n, cols: r, withHeaderRow: i }) {
1471
+ function ar(e, t, { rows: n, cols: r, withHeaderRow: i }) {
1624
1472
  e.chain().focus().command(({ tr: a, dispatch: o }) => {
1625
- let s = t.getBookmark().resolve(a.doc), c = Re(e.schema, n, r, i), l = s instanceof W ? s.node.isInline ? s.$to.after() : s.to : null;
1473
+ let s = t.getBookmark().resolve(a.doc), c = Ke(e.schema, n, r, i), l = s instanceof K ? s.node.isInline ? s.$to.after() : s.to : null;
1626
1474
  if (l !== null) {
1627
1475
  let e = a.doc.resolve(l);
1628
1476
  if (!e.parent.canReplaceWith(e.index(), e.index(), c.type)) return !1;
1629
1477
  }
1630
1478
  if (o) {
1631
- G(a);
1479
+ q(a);
1632
1480
  let e;
1633
- l === null ? (e = s.from + 1, a.setSelection(s).replaceSelectionWith(c)) : (e = l + 1, a.insert(l, c)), a.setSelection(We.near(a.doc.resolve(e))).scrollIntoView();
1481
+ l === null ? (e = s.from + 1, a.setSelection(s).replaceSelectionWith(c)) : (e = l + 1, a.insert(l, c)), a.setSelection(Be.near(a.doc.resolve(e))).scrollIntoView();
1634
1482
  }
1635
1483
  return !0;
1636
- }).run() && !e.isDestroyed && (e.view.dispatch(G(e.state.tr)), e.view.focus());
1484
+ }).run() && !e.isDestroyed && (e.view.dispatch(q(e.state.tr)), e.view.focus());
1637
1485
  }
1638
- function lr({ editor: e, selection: n, withHeaderRow: r, onClose: i }) {
1639
- let a = L(), [o, s] = B(() => ({
1640
- ...ir,
1486
+ function or({ editor: e, selection: n, withHeaderRow: r, onClose: i }) {
1487
+ let a = z(), [o, s] = H(() => ({
1488
+ ...tr,
1641
1489
  withHeaderRow: r
1642
- })), [c, l] = B(!1), u = or(o.rows), d = or(o.cols);
1643
- return /* @__PURE__ */ H(h, {
1490
+ })), [c, l] = H(!1), u = rr(o.rows), d = rr(o.cols);
1491
+ return /* @__PURE__ */ W(h, {
1644
1492
  isOpen: !0,
1645
1493
  title: "Insert table",
1646
1494
  size: "dialog",
1647
1495
  onClose: i,
1648
- footer: /* @__PURE__ */ U(V, { children: [/* @__PURE__ */ H(t, {
1496
+ footer: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(t, {
1649
1497
  onClick: i,
1650
1498
  children: "Cancel"
1651
- }), /* @__PURE__ */ H(t, {
1499
+ }), /* @__PURE__ */ W(t, {
1652
1500
  variant: "primary",
1653
1501
  type: "submit",
1654
1502
  form: a,
1655
1503
  children: "Insert table"
1656
1504
  })] }),
1657
- children: /* @__PURE__ */ H("form", {
1505
+ children: /* @__PURE__ */ W("form", {
1658
1506
  id: a,
1659
1507
  noValidate: !0,
1660
1508
  onSubmit: (t) => {
1661
- t.preventDefault(), t.stopPropagation(), l(!0), u !== void 0 && d !== void 0 && (!e.isDestroyed && e.isEditable && e.state.doc.eq(n.$from.doc) && cr(e, n, {
1509
+ t.preventDefault(), t.stopPropagation(), l(!0), u !== void 0 && d !== void 0 && (!e.isDestroyed && e.isEditable && e.state.doc.eq(n.$from.doc) && ar(e, n, {
1662
1510
  rows: u,
1663
1511
  cols: d,
1664
1512
  withHeaderRow: o.withHeaderRow === !0
1665
1513
  }), i());
1666
1514
  },
1667
- children: /* @__PURE__ */ H(tr, {
1668
- schema: rr,
1515
+ children: /* @__PURE__ */ W(Zn, {
1516
+ schema: $n,
1669
1517
  value: o,
1670
1518
  onValueChange: s,
1671
1519
  errors: {
1672
- rows: sr(o.rows),
1673
- cols: sr(o.cols)
1520
+ rows: ir(o.rows),
1521
+ cols: ir(o.cols)
1674
1522
  },
1675
1523
  showAllErrors: c,
1676
1524
  columns: 2,
@@ -1679,83 +1527,83 @@ function lr({ editor: e, selection: n, withHeaderRow: r, onClose: i }) {
1679
1527
  })
1680
1528
  });
1681
1529
  }
1682
- var ur = 6, dr = 8, fr = Array.from({ length: ur }, (e, t) => t + 1), pr = Array.from({ length: dr }, (e, t) => t + 1);
1683
- function mr({ editor: e, selection: t }) {
1530
+ var sr = 6, cr = 8, lr = Array.from({ length: sr }, (e, t) => t + 1), ur = Array.from({ length: cr }, (e, t) => t + 1);
1531
+ function dr({ editor: e, selection: t }) {
1684
1532
  return !e.isDestroyed && e.isEditable && e.state.doc.eq(t.$from.doc);
1685
1533
  }
1686
- function hr({ editor: e, disabled: n, inTable: r }) {
1687
- let [a, o] = B(null), [c, l] = B(!0), [u, f] = B(Z), [p, m] = B(Z), [h, g] = B(!1), _ = z(null), v = z(null), y = z(null), b = z(null), x = L(), S = F(() => o(null), []), C = n || !e || r, w = !C && a?.editor === e ? a : null, T = s(w?.mode === "grid");
1688
- return a && !w && o(null), I(() => {
1689
- if (!w) return;
1690
- let e = w.editor, t = () => {
1691
- mr(w) || S();
1534
+ function fr({ editor: e, disabled: n, inTable: r }) {
1535
+ let [a, o] = H(null), [c, l] = H(!0), [u, f] = H(er), [p, m] = H(er), [h, g] = H(!1), _ = V(null), v = V(null), y = V(null), b = V(null), S = z(), C = I(() => o(null), []), E = n || !e || r, D = !E && a?.editor === e ? a : null, O = s(D?.mode === "grid");
1536
+ return a && !D && o(null), R(() => {
1537
+ if (!D) return;
1538
+ let e = D.editor, t = () => {
1539
+ dr(D) || C();
1692
1540
  };
1693
1541
  return e.on("transaction", t), t(), () => {
1694
1542
  e.off("transaction", t);
1695
1543
  };
1696
- }, [w, S]), d(() => {
1697
- T && y.current?.querySelector("button[tabindex='0']")?.focus();
1698
- }, [T]), I(() => {
1699
- if (!T) return;
1544
+ }, [D, C]), d(() => {
1545
+ O && y.current?.querySelector("button[tabindex='0']")?.focus();
1546
+ }, [O]), R(() => {
1547
+ if (!O) return;
1700
1548
  let e = (e) => {
1701
1549
  let t = e.target;
1702
- !v.current?.contains(t) && !y.current?.contains(t) && S();
1550
+ !v.current?.contains(t) && !y.current?.contains(t) && C();
1703
1551
  }, t = (e) => {
1704
- e.key === "Escape" && !e.defaultPrevented && !e.isComposing && (e.preventDefault(), S(), _.current?.focus());
1552
+ e.key === "Escape" && !e.defaultPrevented && !e.isComposing && (e.preventDefault(), C(), _.current?.focus());
1705
1553
  };
1706
1554
  return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
1707
1555
  document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
1708
1556
  };
1709
- }, [T, S]), /* @__PURE__ */ U("span", {
1557
+ }, [O, C]), /* @__PURE__ */ G("span", {
1710
1558
  ref: v,
1711
1559
  children: [
1712
- /* @__PURE__ */ H(t, {
1560
+ /* @__PURE__ */ W(t, {
1713
1561
  ref: _,
1714
1562
  size: "sm",
1715
1563
  isIconOnly: !0,
1716
1564
  iconStart: "table",
1717
- variant: T ? "active" : "neutral",
1565
+ variant: O ? "active" : "neutral",
1718
1566
  "aria-label": "Insert table",
1719
1567
  title: "Insert table",
1720
1568
  "aria-haspopup": "dialog",
1721
- "aria-expanded": T,
1722
- "aria-controls": T ? x : void 0,
1723
- isDisabled: C,
1569
+ "aria-expanded": O,
1570
+ "aria-controls": O ? S : void 0,
1571
+ isDisabled: E,
1724
1572
  onClick: (t) => {
1725
- T ? S() : e && (g(getComputedStyle(t.currentTarget).direction === "rtl"), f(Z), m(Z), l(!0), o({
1573
+ O ? C() : e && (g(getComputedStyle(t.currentTarget).direction === "rtl"), f(er), m(er), l(!0), o({
1726
1574
  editor: e,
1727
1575
  selection: e.state.selection,
1728
1576
  mode: "grid"
1729
1577
  }));
1730
1578
  }
1731
1579
  }),
1732
- /* @__PURE__ */ H(D, {
1580
+ /* @__PURE__ */ W(x, {
1733
1581
  anchorRef: _,
1734
1582
  panelRef: y,
1735
- id: x,
1736
- isOpen: T,
1583
+ id: S,
1584
+ isOpen: O,
1737
1585
  placement: "bottom",
1738
1586
  align: h ? "end" : "start",
1739
1587
  role: "dialog",
1740
1588
  "aria-label": "Insert table",
1741
1589
  tabIndex: -1,
1742
1590
  className: "ds-rte__table-picker ds-surface-raised ds-field-surface",
1743
- children: /* @__PURE__ */ U("div", {
1591
+ children: /* @__PURE__ */ G("div", {
1744
1592
  className: "ds-rte__table-picker-content",
1745
1593
  onKeyDown: (e) => {
1746
1594
  if (e.key !== "Tab") return;
1747
1595
  let t = e.target.hasAttribute("data-cell");
1748
- e.shiftKey && t ? (e.preventDefault(), S(), _.current?.focus()) : !e.shiftKey && e.target === b.current && v.current && (e.preventDefault(), S(), i(v.current));
1596
+ e.shiftKey && t ? (e.preventDefault(), C(), _.current?.focus()) : !e.shiftKey && e.target === b.current && v.current && (e.preventDefault(), C(), i(v.current));
1749
1597
  },
1750
1598
  children: [
1751
- /* @__PURE__ */ U("div", {
1599
+ /* @__PURE__ */ G("div", {
1752
1600
  className: "ds-rte__table-picker-heading",
1753
- children: [/* @__PURE__ */ H(O, { children: "Insert table" }), /* @__PURE__ */ H("bdi", {
1601
+ children: [/* @__PURE__ */ W(w, { children: "Insert table" }), /* @__PURE__ */ W("bdi", {
1754
1602
  dir: "ltr",
1755
1603
  children: `${p.rows} × ${p.cols}`
1756
1604
  })]
1757
1605
  }),
1758
- /* @__PURE__ */ H("div", {
1606
+ /* @__PURE__ */ W("div", {
1759
1607
  className: "ds-rte__table-picker-grid",
1760
1608
  role: "grid",
1761
1609
  "aria-label": "Table size",
@@ -1783,24 +1631,24 @@ function hr({ editor: e, disabled: n, inTable: r }) {
1783
1631
  },
1784
1632
  End: {
1785
1633
  rows: t,
1786
- cols: dr
1634
+ cols: cr
1787
1635
  }
1788
1636
  }[e.key];
1789
1637
  if (r) {
1790
1638
  e.preventDefault();
1791
- let t = Math.max(1, Math.min(ur, r.rows)), n = Math.max(1, Math.min(dr, r.cols));
1639
+ let t = Math.max(1, Math.min(sr, r.rows)), n = Math.max(1, Math.min(cr, r.cols));
1792
1640
  e.currentTarget.querySelector(`[data-cell="${t}:${n}"]`)?.focus();
1793
1641
  }
1794
1642
  },
1795
1643
  onMouseLeave: () => m(u),
1796
- children: fr.map((e) => /* @__PURE__ */ H("div", {
1644
+ children: lr.map((e) => /* @__PURE__ */ W("div", {
1797
1645
  role: "row",
1798
1646
  className: "ds-rte__table-picker-row",
1799
- children: pr.map((n) => {
1647
+ children: ur.map((n) => {
1800
1648
  let r = e <= p.rows && n <= p.cols;
1801
- return /* @__PURE__ */ H("div", {
1649
+ return /* @__PURE__ */ W("div", {
1802
1650
  role: "gridcell",
1803
- children: /* @__PURE__ */ H(t, {
1651
+ children: /* @__PURE__ */ W(t, {
1804
1652
  size: "xs",
1805
1653
  isIconOnly: !0,
1806
1654
  tabIndex: e === u.rows && n === u.cols ? 0 : -1,
@@ -1822,54 +1670,54 @@ function hr({ editor: e, disabled: n, inTable: r }) {
1822
1670
  f(t), m(t);
1823
1671
  },
1824
1672
  onClick: () => {
1825
- w && mr(w) && cr(w.editor, w.selection, {
1673
+ D && dr(D) && ar(D.editor, D.selection, {
1826
1674
  rows: e,
1827
1675
  cols: n,
1828
1676
  withHeaderRow: c
1829
- }), S();
1677
+ }), C();
1830
1678
  }
1831
1679
  })
1832
1680
  }, n);
1833
1681
  })
1834
1682
  }, e))
1835
1683
  }),
1836
- /* @__PURE__ */ H(se, {
1684
+ /* @__PURE__ */ W(de, {
1837
1685
  isSelected: c,
1838
1686
  onSelectedChange: l,
1839
1687
  children: "Include header row"
1840
1688
  }),
1841
- /* @__PURE__ */ H(k, {}),
1842
- /* @__PURE__ */ U(t, {
1689
+ /* @__PURE__ */ W(T, {}),
1690
+ /* @__PURE__ */ G(t, {
1843
1691
  ref: b,
1844
1692
  size: "sm",
1845
1693
  variant: "simple",
1846
1694
  className: "ds-rte__table-picker-custom",
1847
1695
  onClick: () => {
1848
- w && (_.current?.focus(), o({
1849
- ...w,
1696
+ D && (_.current?.focus(), o({
1697
+ ...D,
1850
1698
  mode: "custom"
1851
1699
  }));
1852
1700
  },
1853
- children: ["Custom size…", /* @__PURE__ */ H("span", { children: "up to 50 × 50" })]
1701
+ children: ["Custom size…", /* @__PURE__ */ W("span", { children: "up to 50 × 50" })]
1854
1702
  })
1855
1703
  ]
1856
1704
  })
1857
1705
  }),
1858
- w?.mode === "custom" && /* @__PURE__ */ H(lr, {
1859
- editor: w.editor,
1860
- selection: w.selection,
1706
+ D?.mode === "custom" && /* @__PURE__ */ W(or, {
1707
+ editor: D.editor,
1708
+ selection: D.selection,
1861
1709
  withHeaderRow: c,
1862
- onClose: S
1710
+ onClose: C
1863
1711
  })
1864
1712
  ]
1865
1713
  });
1866
1714
  }
1867
1715
  //#endregion
1868
1716
  //#region src/components/RichTextEditor/table-bands.ts
1869
- function gr(e, t) {
1717
+ function pr(e, t) {
1870
1718
  return t === "row" ? e.height : e.width;
1871
1719
  }
1872
- function _r(e, t) {
1720
+ function mr(e, t) {
1873
1721
  let { map: n, table: r } = e;
1874
1722
  for (let e = 0; e < n.height; e += 1) for (let i = 0; i < n.width; i += 1) {
1875
1723
  let a = e * n.width + i, o = n.map[a];
@@ -1878,47 +1726,47 @@ function _r(e, t) {
1878
1726
  s && t(s, e, i);
1879
1727
  }
1880
1728
  }
1881
- function vr(e, t) {
1729
+ function hr(e, t) {
1882
1730
  let n = /* @__PURE__ */ new Set();
1883
- _r(e, (e, r, i) => {
1731
+ mr(e, (e, r, i) => {
1884
1732
  let a = t === "row" ? r : i, o = Number(t === "row" ? e.attrs.rowspan : e.attrs.colspan);
1885
1733
  for (let e = a + 1; e < a + o; e += 1) n.add(e);
1886
1734
  });
1887
- let r = [], i = gr(e.map, t), a = 0;
1735
+ let r = [], i = pr(e.map, t), a = 0;
1888
1736
  for (let e = 1; e <= i; e += 1) n.has(e) || (r.push({
1889
1737
  start: a,
1890
1738
  end: e
1891
1739
  }), a = e);
1892
1740
  return r;
1893
1741
  }
1894
- function yr(e, t, n) {
1742
+ function gr(e, t, n) {
1895
1743
  return (n < t.start || n > t.end) && (n === 0 || e.some(({ end: e }) => e === n));
1896
1744
  }
1897
- function br(e, t, n, r) {
1745
+ function _r(e, t, n, r) {
1898
1746
  let { pos: i, map: a } = t, { start: o, end: s } = r, c = n === "row" ? o * a.width : o, l = n === "row" ? s * a.width - 1 : (a.height - 1) * a.width + s - 1, u = e.resolve(i + 1 + a.map[c]), d = e.resolve(i + 1 + a.map[l]);
1899
- return n === "row" ? K.rowSelection(u, d) : K.colSelection(u, d);
1747
+ return n === "row" ? J.rowSelection(u, d) : J.colSelection(u, d);
1900
1748
  }
1901
- function xr(e, t, n, r) {
1902
- let { map: i, table: a } = e, o = vr(e, t), s = o.find(({ start: e, end: t }) => n >= e && n < t);
1903
- if (!s || !yr(o, s, r)) return null;
1904
- let c = Array.from({ length: gr(i, t) }, (e, t) => t), l = c.splice(s.start, s.end - s.start), u = r > s.end ? r - l.length : r;
1749
+ function vr(e, t, n, r) {
1750
+ let { map: i, table: a } = e, o = hr(e, t), s = o.find(({ start: e, end: t }) => n >= e && n < t);
1751
+ if (!s || !gr(o, s, r)) return null;
1752
+ let c = Array.from({ length: pr(i, t) }, (e, t) => t), l = c.splice(s.start, s.end - s.start), u = r > s.end ? r - l.length : r;
1905
1753
  c.splice(u, 0, ...l);
1906
1754
  let d = c.map(() => 0);
1907
1755
  c.forEach((e, t) => {
1908
1756
  d[e] = t;
1909
1757
  });
1910
1758
  let f = Array.from({ length: i.height }, () => /* @__PURE__ */ new Map());
1911
- return _r(e, (e, n, r) => {
1759
+ return mr(e, (e, n, r) => {
1912
1760
  let o = t === "row" ? d[n] : n, s = t === "column" ? d[r] : r, c = a.nodeAt(i.map[o * i.width + s])?.type ?? e.type;
1913
1761
  f[o].set(s, c === e.type ? e : c.createChecked(e.attrs, e.content, e.marks));
1914
1762
  }), {
1915
- table: a.copy(ze.fromArray(f.map((e, n) => a.child(t === "row" ? c[n] : n).copy(ze.fromArray([...e.entries()].sort(([e], [t]) => e - t).map(([, e]) => e)))))),
1763
+ table: a.copy(qe.fromArray(f.map((e, n) => a.child(t === "row" ? c[n] : n).copy(qe.fromArray([...e.entries()].sort(([e], [t]) => e - t).map(([, e]) => e)))))),
1916
1764
  index: d[n]
1917
1765
  };
1918
1766
  }
1919
1767
  //#endregion
1920
1768
  //#region src/components/RichTextEditor/table-actions.ts
1921
- var Sr = [
1769
+ var yr = [
1922
1770
  {
1923
1771
  align: "left",
1924
1772
  icon: "align-left",
@@ -1938,7 +1786,7 @@ var Sr = [
1938
1786
  function Q(e, t) {
1939
1787
  e.view.dispatch(t.scrollIntoView()), e.view.focus();
1940
1788
  }
1941
- function Cr({ map: e, table: t, pos: n }) {
1789
+ function br({ map: e, table: t, pos: n }) {
1942
1790
  return {
1943
1791
  map: e,
1944
1792
  table: t,
@@ -1949,29 +1797,29 @@ function Cr({ map: e, table: t, pos: n }) {
1949
1797
  right: e.width
1950
1798
  };
1951
1799
  }
1952
- function wr({ map: e, table: t }, n, r) {
1953
- return n !== "row" || r !== 0 || !$e(e, t, 0);
1800
+ function xr({ map: e, table: t }, n, r) {
1801
+ return n !== "row" || r !== 0 || !it(e, t, 0);
1954
1802
  }
1955
- function Tr(e, t, n, r) {
1956
- if (!e.isEditable || e.state.doc.nodeAt(t.pos) !== t.table || !wr(t, n, r)) return;
1957
- let { pos: i } = t, a = (n === "row" ? qe : Ke)(G(e.state.tr), Cr(t), r), o = a.doc.nodeAt(i), s = {
1803
+ function Sr(e, t, n, r) {
1804
+ if (!e.isEditable || e.state.doc.nodeAt(t.pos) !== t.table || !xr(t, n, r)) return;
1805
+ let { pos: i } = t, a = (n === "row" ? Ze : Xe)(q(e.state.tr), br(t), r), o = a.doc.nodeAt(i), s = {
1958
1806
  table: o,
1959
1807
  pos: i,
1960
- map: Ge.get(o)
1808
+ map: Ye.get(o)
1961
1809
  };
1962
- Q(e, a.setSelection(br(a.doc, s, n, {
1810
+ Q(e, a.setSelection(_r(a.doc, s, n, {
1963
1811
  start: r,
1964
1812
  end: r + 1
1965
1813
  })));
1966
1814
  }
1967
- function Er(e, t, n, r, i) {
1815
+ function Cr(e, t, n, r, i) {
1968
1816
  if (!e.isEditable || e.state.doc.nodeAt(t.pos) !== t.table) return !1;
1969
- let a = xr(t, n, n === "row" ? r.top : r.left, i);
1817
+ let a = vr(t, n, n === "row" ? r.top : r.left, i);
1970
1818
  if (!a) return !1;
1971
- let { pos: o, table: s } = t, c = G(e.state.tr).replaceWith(o, o + s.nodeSize, a.table), l = Ge.get(a.table), u = n === "row" ? a.index : r.top, d = n === "column" ? a.index : r.left, f = l.map[u * l.width + d];
1972
- return Q(e, c.setSelection(new K(c.doc.resolve(o + 1 + f)))), !0;
1819
+ let { pos: o, table: s } = t, c = q(e.state.tr).replaceWith(o, o + s.nodeSize, a.table), l = Ye.get(a.table), u = n === "row" ? a.index : r.top, d = n === "column" ? a.index : r.left, f = l.map[u * l.width + d];
1820
+ return Q(e, c.setSelection(new J(c.doc.resolve(o + 1 + f)))), !0;
1973
1821
  }
1974
- var Dr = {
1822
+ var wr = {
1975
1823
  row: {
1976
1824
  group: "Row",
1977
1825
  insertBefore: {
@@ -2005,7 +1853,7 @@ var Dr = {
2005
1853
  }
2006
1854
  }
2007
1855
  };
2008
- function Or(e, t, n, r) {
1856
+ function Tr(e, t, n, r) {
2009
1857
  let i = { boundary: n?.start }, a = { boundary: r?.end };
2010
1858
  if (e === "row") return [{
2011
1859
  label: "Move row up",
@@ -2027,20 +1875,20 @@ function Or(e, t, n, r) {
2027
1875
  ...s
2028
1876
  }];
2029
1877
  }
2030
- function kr(e, t, n) {
1878
+ function Er(e, t, n) {
2031
1879
  return n === "row" ? e.top === 0 && e.bottom === t.height : e.left === 0 && e.right === t.width;
2032
1880
  }
2033
- function Ar(e, t, n, r) {
2034
- let { doc: i } = e.state, { map: a, pos: o } = t, s = o + 1, c = a.map[0], l = n !== null, u = K.create(i, s + c, s + a.map[a.map.length - 1]), d = Ve.create({
1881
+ function Dr(e, t, n, r) {
1882
+ let { doc: i } = e.state, { map: a, pos: o } = t, s = o + 1, c = a.map[0], l = n !== null, u = J.create(i, s + c, s + a.map[a.map.length - 1]), d = Le.create({
2035
1883
  doc: i,
2036
1884
  selection: n ?? u
2037
- }), f = n ? n instanceof K ? n.$headCell : q(n.$head) : null, p = f ? f.pos - s : c, m = a.map.includes(p) ? p : c, h = a.findCell(m), g = new K(i.resolve(s + m)), _ = Ve.create({
1885
+ }), f = n ? n instanceof J ? n.$headCell : Qe(n.$head) : null, p = f ? f.pos - s : c, m = a.map.includes(p) ? p : c, h = a.findCell(m), g = new J(i.resolve(s + m)), _ = Le.create({
2038
1886
  doc: i,
2039
1887
  selection: g
2040
- }), v = n instanceof K ? d : _, y = et(v), b = (t) => () => {
1888
+ }), v = n instanceof J ? d : _, y = at(v), b = (t) => () => {
2041
1889
  !e.isDestroyed && e.isEditable && e.state.doc === i && t();
2042
- }, x = d.selection instanceof K ? d.selection : g, S = (t) => {
2043
- let n = G(d.tr);
1890
+ }, x = d.selection instanceof J ? d.selection : g, S = (t) => {
1891
+ let n = q(d.tr);
2044
1892
  x.forEachCell((e, r) => {
2045
1893
  (e.attrs.align ?? "left") !== t && n.setNodeMarkup(r, null, {
2046
1894
  ...e.attrs,
@@ -2049,43 +1897,43 @@ function Ar(e, t, n, r) {
2049
1897
  }), n.docChanged ? Q(e, n) : e.view.focus();
2050
1898
  }, C = /* @__PURE__ */ new Set();
2051
1899
  x.forEachCell((e) => C.add(e.attrs.align ?? "left"));
2052
- let w = l && Qe(d), T = [{
1900
+ let w = l && rt(d), T = [{
2053
1901
  label: "Merge cells",
2054
1902
  icon: "table-cells-merge",
2055
1903
  description: w ? void 0 : "Drag across 2 or more cells",
2056
1904
  disabled: !w,
2057
- run: b(() => Qe(d, (t) => Q(e, t)))
1905
+ run: b(() => rt(d, (t) => Q(e, t)))
2058
1906
  }];
2059
- l && tt(d) && T.push({
1907
+ l && ot(d) && T.push({
2060
1908
  label: "Split cell",
2061
1909
  icon: "table-cells-split",
2062
- run: b(() => tt(d, (t) => Q(e, t)))
1910
+ run: b(() => ot(d, (t) => Q(e, t)))
2063
1911
  });
2064
1912
  let E = (n) => {
2065
- let { group: i, insertBefore: o, insertAfter: s, remove: c } = Dr[n], u = n === "row" ? h.top : h.left, d = n === "row" ? h.bottom : h.right, f = kr(y, a, n), p = vr(t, n), m = p.findIndex(({ start: e, end: t }) => u >= e && u < t), g = [
2066
- ...Or(n, r, p[m - 1], p[m + 1]).map(({ label: r, icon: i, boundary: a }) => ({
1913
+ let { group: i, insertBefore: o, insertAfter: s, remove: c } = wr[n], u = n === "row" ? h.top : h.left, d = n === "row" ? h.bottom : h.right, f = Er(y, a, n), p = hr(t, n), m = p.findIndex(({ start: e, end: t }) => u >= e && u < t), g = [
1914
+ ...Tr(n, r, p[m - 1], p[m + 1]).map(({ label: r, icon: i, boundary: a }) => ({
2067
1915
  label: r,
2068
1916
  icon: i,
2069
1917
  disabled: a === void 0,
2070
1918
  run: b(() => {
2071
- a !== void 0 && Er(e, t, n, h, a);
1919
+ a !== void 0 && Cr(e, t, n, h, a);
2072
1920
  })
2073
1921
  })),
2074
1922
  {
2075
1923
  ...o,
2076
- disabled: !wr(t, n, u),
2077
- run: b(() => Tr(e, t, n, u))
1924
+ disabled: !xr(t, n, u),
1925
+ run: b(() => Sr(e, t, n, u))
2078
1926
  },
2079
1927
  {
2080
1928
  ...s,
2081
- run: b(() => Tr(e, t, n, d))
1929
+ run: b(() => Sr(e, t, n, d))
2082
1930
  },
2083
1931
  {
2084
1932
  ...c,
2085
1933
  tone: "danger",
2086
1934
  disabled: f,
2087
1935
  run: b(() => {
2088
- l && !f && (n === "row" ? Xe : Ye)(v, (t) => Q(e, G(t)));
1936
+ l && !f && (n === "row" ? tt : et)(v, (t) => Q(e, q(t)));
2089
1937
  })
2090
1938
  }
2091
1939
  ];
@@ -2099,7 +1947,7 @@ function Ar(e, t, n, r) {
2099
1947
  }))
2100
1948
  };
2101
1949
  }, D = (n) => {
2102
- let r = n === "row", { table: i, map: a } = t, o = r ? $e(a, i, 0) : Je(a, i, 0), s = !1, c = nt(n);
1950
+ let r = n === "row", { table: i, map: a } = t, o = r ? it(a, i, 0) : $e(a, i, 0), s = !1, c = st(n);
2103
1951
  return c(_, (e) => {
2104
1952
  s = e.docChanged;
2105
1953
  }), {
@@ -2114,7 +1962,7 @@ function Ar(e, t, n, r) {
2114
1962
  {
2115
1963
  label: "Cell alignment",
2116
1964
  choices: !0,
2117
- actions: Sr.map(({ align: e, icon: t, label: n }) => ({
1965
+ actions: yr.map(({ align: e, icon: t, label: n }) => ({
2118
1966
  label: n,
2119
1967
  icon: t,
2120
1968
  checked: C.size === 1 && C.has(e),
@@ -2139,38 +1987,38 @@ function Ar(e, t, n, r) {
2139
1987
  label: "Delete table",
2140
1988
  icon: "grid-2x2-x",
2141
1989
  tone: "danger",
2142
- run: b(() => Ze(d, (t) => Q(e, t)))
1990
+ run: b(() => nt(d, (t) => Q(e, t)))
2143
1991
  }]
2144
1992
  }
2145
1993
  ];
2146
1994
  }
2147
1995
  //#endregion
2148
1996
  //#region src/components/RichTextEditor/table-view.tsx
2149
- var jr = new Ue("tableCellContext"), Mr = /* @__PURE__ */ new WeakMap(), $ = (e) => e.type.spec.tableRole === "table", Nr = (e) => e.type.name === "contentBlock";
2150
- function Pr(e) {
2151
- return e instanceof W && $(e.node) || !!J(e.$from) || !!J(e.$to);
1997
+ var Or = new ze("tableCellContext"), kr = /* @__PURE__ */ new WeakMap(), $ = (e) => e.type.spec.tableRole === "table", Ar = (e) => e.type.name === "contentBlock";
1998
+ function jr(e) {
1999
+ return e instanceof K && $(e.node) || !!Y(e.$from) || !!Y(e.$to);
2152
2000
  }
2153
- function Fr(e, t) {
2154
- let n = e instanceof K ? e.$anchorCell : e.$from, r = e instanceof K ? e.$headCell : e.$to;
2155
- return J(n)?.pos === t && J(r)?.pos === t;
2001
+ function Mr(e, t) {
2002
+ let n = e instanceof J ? e.$anchorCell : e.$from, r = e instanceof J ? e.$headCell : e.$to;
2003
+ return Y(n)?.pos === t && Y(r)?.pos === t;
2156
2004
  }
2157
- function Ir(e, t, n = !1) {
2158
- let { state: r } = e, i = Fr(r.selection, t) ? r.selection : null, a = W.create(r.doc, t), o = r.tr.setSelection(a);
2159
- i && o.setMeta(jr, i), e.dispatch(n ? G(o) : o);
2005
+ function Nr(e, t, n = !1) {
2006
+ let { state: r } = e, i = Mr(r.selection, t) ? r.selection : null, a = K.create(r.doc, t), o = r.tr.setSelection(a);
2007
+ i && o.setMeta(Or, i), e.dispatch(n ? q(o) : o);
2160
2008
  }
2161
- function Lr(e, t) {
2009
+ function Pr(e, t) {
2162
2010
  let n = !1;
2163
2011
  return e.content.descendants((e) => (n ||= t(e), !n)), n;
2164
2012
  }
2165
- function Rr({ node: e, isSelected: t, frame: n, onSelect: r, actions: i }) {
2166
- let { disabled: a } = ye(At), { height: o, width: s } = Ge.get(e), c = `${o} ${o === 1 ? "row" : "rows"}`, l = `${s} ${s === 1 ? "column" : "columns"}`;
2013
+ function Fr({ node: e, isSelected: t, frame: n, onSelect: r, actions: i }) {
2014
+ let { disabled: a } = L(X), { height: o, width: s } = Ye.get(e), c = `${o} ${o === 1 ? "row" : "rows"}`, l = `${s} ${s === 1 ? "column" : "columns"}`;
2167
2015
  return d(() => {
2168
2016
  n.toggleAttribute("data-selected", t && !a);
2169
2017
  }, [
2170
2018
  a,
2171
2019
  n,
2172
2020
  t
2173
- ]), /* @__PURE__ */ H(Ot, {
2021
+ ]), /* @__PURE__ */ W(zt, {
2174
2022
  kind: "Table",
2175
2023
  meta: `${c} · ${l}`,
2176
2024
  isSelected: t,
@@ -2180,29 +2028,29 @@ function Rr({ node: e, isSelected: t, frame: n, onSelect: r, actions: i }) {
2180
2028
  actions: i
2181
2029
  });
2182
2030
  }
2183
- var zr = /* @__PURE__ */ new WeakMap();
2184
- function Br(e, t) {
2185
- zr.get(e)?.();
2031
+ var Ir = /* @__PURE__ */ new WeakMap();
2032
+ function Lr(e, t) {
2033
+ Ir.get(e)?.();
2186
2034
  let n = () => {
2187
- e.removeEventListener("contextmenu", r, !0), e.removeEventListener("pointerdown", n, !0), e.removeEventListener("mousedown", n, !0), e.removeEventListener("keydown", i, !0), zr.get(e) === n && zr.delete(e);
2035
+ e.removeEventListener("contextmenu", r, !0), e.removeEventListener("pointerdown", n, !0), e.removeEventListener("mousedown", n, !0), e.removeEventListener("keydown", i, !0), Ir.get(e) === n && Ir.delete(e);
2188
2036
  }, r = (e) => {
2189
2037
  e.preventDefault(), n();
2190
2038
  }, i = (e) => {
2191
2039
  e.key !== t && n();
2192
2040
  };
2193
- e.addEventListener("contextmenu", r, !0), e.addEventListener("pointerdown", n, !0), e.addEventListener("mousedown", n, !0), e.addEventListener("keydown", i, !0), zr.set(e, n);
2041
+ e.addEventListener("contextmenu", r, !0), e.addEventListener("pointerdown", n, !0), e.addEventListener("mousedown", n, !0), e.addEventListener("keydown", i, !0), Ir.set(e, n);
2194
2042
  }
2195
- function Vr(e) {
2043
+ function Rr(e) {
2196
2044
  if (!e.isEditable) return null;
2197
- let { selection: t } = e.state, n = t instanceof K ? t.$headCell : t.$head, r = t instanceof W && $(t.node) ? t.from : J(n)?.pos, i = r === void 0 ? null : e.view.nodeDOM(r);
2045
+ let { selection: t } = e.state, n = t instanceof J ? t.$headCell : t.$head, r = t instanceof K && $(t.node) ? t.from : Y(n)?.pos, i = r === void 0 ? null : e.view.nodeDOM(r);
2198
2046
  return i instanceof HTMLElement ? i.querySelector(".ds-rte__table-bar-host button") : null;
2199
2047
  }
2200
- var Hr = class extends Le {
2048
+ var zr = class extends Ge {
2201
2049
  bar;
2202
2050
  constructor({ editor: e, node: t, view: n, getPos: r, HTMLAttributes: i }, a) {
2203
2051
  super(t, a, n, i);
2204
2052
  let o = this.dom, s = o.ownerDocument;
2205
- this.dom = s.createElement("div"), this.dom.className = Ct, this.dom.dataset.kind = "table", this.dom.dataset.align = "full", this.bar = new Te(Rr, {
2053
+ this.dom = s.createElement("div"), this.dom.className = Pt, this.dom.dataset.kind = "table", this.dom.dataset.align = "full", this.bar = new ke(Fr, {
2206
2054
  editor: e,
2207
2055
  className: "ds-rte__table-bar-host",
2208
2056
  props: {
@@ -2211,15 +2059,15 @@ var Hr = class extends Le {
2211
2059
  frame: this.dom,
2212
2060
  onSelect: () => {
2213
2061
  let e = r();
2214
- n.editable && e !== void 0 && (Ir(n, e), n.focus());
2062
+ n.editable && e !== void 0 && (Nr(n, e), n.focus());
2215
2063
  },
2216
2064
  actions: (t) => {
2217
2065
  let i = r(), { state: a } = n, o = i === void 0 ? null : a.doc.nodeAt(i);
2218
2066
  if (i === void 0 || !o || !$(o)) return [];
2219
- let s = Ge.get(o);
2067
+ let s = Ye.get(o);
2220
2068
  if (!s.map.length) return [];
2221
- let c = jr.getState(a), l = Fr(a.selection, i) ? a.selection : c && Fr(c, i) ? c : null;
2222
- return Ar(e, {
2069
+ let c = Or.getState(a), l = Mr(a.selection, i) ? a.selection : c && Mr(c, i) ? c : null;
2070
+ return Dr(e, {
2223
2071
  table: o,
2224
2072
  map: s,
2225
2073
  pos: i
@@ -2228,8 +2076,8 @@ var Hr = class extends Le {
2228
2076
  }
2229
2077
  }), this.bar.element.contentEditable = "false", this.dom.append(this.bar.element, o), this.bar.element.addEventListener("dragstart", (e) => {
2230
2078
  let t = r();
2231
- n.editable && t !== void 0 && e.dataTransfer && e.target instanceof Element && e.target.closest("[data-drag-handle]") && (Ir(n, t, !0), n.state.selection instanceof W && Mr.set(n, n.state.selection), e.dataTransfer.setDragImage?.(this.dom, 12, 12));
2232
- }), this.bar.element.addEventListener("dragend", () => Mr.delete(n));
2079
+ n.editable && t !== void 0 && e.dataTransfer && e.target instanceof Element && e.target.closest("[data-drag-handle]") && (Nr(n, t, !0), n.state.selection instanceof K && kr.set(n, n.state.selection), e.dataTransfer.setDragImage?.(this.dom, 12, 12));
2080
+ }), this.bar.element.addEventListener("dragend", () => kr.delete(n));
2233
2081
  }
2234
2082
  update(e) {
2235
2083
  return super.update(e) ? (this.bar.updateProps({ node: e }), !0) : !1;
@@ -2249,27 +2097,27 @@ var Hr = class extends Le {
2249
2097
  destroy() {
2250
2098
  this.bar.destroy();
2251
2099
  }
2252
- }, Ur = _t.extend({
2100
+ }, Br = bt.extend({
2253
2101
  addNodeView() {
2254
- return (e) => new Hr(e, this.options.cellMinWidth);
2102
+ return (e) => new zr(e, this.options.cellMinWidth);
2255
2103
  },
2256
2104
  addKeyboardShortcuts() {
2257
2105
  let e = this.parent?.(), t = (e) => ({ editor: t }) => {
2258
- let n = Vr(t);
2259
- return n ? (n.click(), Br(t.view.dom.ownerDocument, e), !0) : !1;
2106
+ let n = Rr(t);
2107
+ return n ? (n.click(), Lr(t.view.dom.ownerDocument, e), !0) : !1;
2260
2108
  };
2261
2109
  return {
2262
2110
  ...e,
2263
2111
  "Shift-F10": t("F10"),
2264
2112
  ContextMenu: t("ContextMenu"),
2265
2113
  Escape: ({ editor: e }) => {
2266
- let t = J(e.state.selection.$from);
2267
- return !e.isEditable || !t ? !1 : (Ir(e.view, t.pos), !0);
2114
+ let t = Y(e.state.selection.$from);
2115
+ return !e.isEditable || !t ? !1 : (Nr(e.view, t.pos), !0);
2268
2116
  },
2269
2117
  Tab: ({ editor: t }) => {
2270
2118
  let { selection: n } = t.state;
2271
- if (t.isEditable && n instanceof W && $(n.node)) {
2272
- let e = Vr(t);
2119
+ if (t.isEditable && n instanceof K && $(n.node)) {
2120
+ let e = Rr(t);
2273
2121
  if (e) return e.focus(), !0;
2274
2122
  }
2275
2123
  return e?.Tab?.({ editor: t }) ?? !1;
@@ -2278,42 +2126,244 @@ var Hr = class extends Le {
2278
2126
  },
2279
2127
  addProseMirrorPlugins() {
2280
2128
  return [
2281
- new He({ props: { handlePaste(e, t, n) {
2129
+ new Re({ props: { handlePaste(e, t, n) {
2282
2130
  let { selection: r } = e.state;
2283
- return (r instanceof K || !!q(r.$from) || !!q(r.$head)) && Lr(n, Nr);
2131
+ return (r instanceof J || !!Qe(r.$from) || !!Qe(r.$head)) && Pr(n, Ar);
2284
2132
  } } }),
2285
2133
  ...this.parent?.() ?? [],
2286
- new He({
2287
- key: jr,
2134
+ new Re({
2135
+ key: Or,
2288
2136
  state: {
2289
2137
  init: () => null,
2290
2138
  apply(e, t) {
2291
- return e.docChanged || !(e.selection instanceof W) || !$(e.selection.node) ? null : e.getMeta(jr) ?? (t && Fr(t, e.selection.from) ? t : null);
2139
+ return e.docChanged || !(e.selection instanceof K) || !$(e.selection.node) ? null : e.getMeta(Or) ?? (t && Mr(t, e.selection.from) ? t : null);
2292
2140
  }
2293
2141
  },
2294
2142
  props: {
2295
2143
  handleDrop(e, t, n, r) {
2296
- let i = Mr.get(e);
2297
- if (Mr.delete(e), r && i && (i.$from.doc !== e.state.doc || !i.eq(e.state.selection))) return !0;
2144
+ let i = kr.get(e);
2145
+ if (kr.delete(e), r && i && (i.$from.doc !== e.state.doc || !i.eq(e.state.selection))) return !0;
2298
2146
  let a = e.posAtCoords({
2299
2147
  left: t.clientX,
2300
2148
  top: t.clientY
2301
2149
  });
2302
2150
  if (!a) return !1;
2303
2151
  let { doc: o } = e.state, s = o.resolve(a.pos);
2304
- return !!(q(s) ?? (a.inside >= 0 ? q(o.resolve(a.inside + 1)) : null)) && Lr(n, Nr) || !!J(s) && Lr(n, $);
2152
+ return !!(Qe(s) ?? (a.inside >= 0 ? Qe(o.resolve(a.inside + 1)) : null)) && Pr(n, Ar) || !!Y(s) && Pr(n, $);
2305
2153
  },
2306
- handlePaste: (e, t, n) => !!J(e.state.selection.$from) && Lr(n, $)
2154
+ handlePaste: (e, t, n) => !!Y(e.state.selection.$from) && Pr(n, $)
2307
2155
  }
2308
2156
  })
2309
2157
  ];
2310
2158
  }
2311
- }).configure({ allowTableNodeSelection: !0 });
2159
+ }).configure({ allowTableNodeSelection: !0 }), Vr = [], Hr = /* @__PURE__ */ new WeakMap();
2160
+ function Ur(e, t) {
2161
+ return `${e}:${t}`;
2162
+ }
2163
+ function Wr(e) {
2164
+ let { latest: t } = L(X);
2165
+ return I(() => {
2166
+ let n = t(e.definition.type);
2167
+ return (n && Hr.get(n)) ?? e;
2168
+ }, [t, e]);
2169
+ }
2170
+ function Gr(e) {
2171
+ return !!(e.loadPage || e.items?.length);
2172
+ }
2173
+ function Kr(e, t) {
2174
+ let { itemLabel: n, toData: r, definition: i, invalidItemReason: a } = e;
2175
+ if (t.tone === "removed") return {
2176
+ label: t.removedLabel ?? "Removed",
2177
+ description: `This ${n} was removed.`
2178
+ };
2179
+ if (t.isUnavailable) return {
2180
+ label: "Unavailable",
2181
+ description: `This ${n} is unavailable.`
2182
+ };
2183
+ let o = r(t);
2184
+ if (!y(o) || !i.validate(o)) return {
2185
+ label: "Can't embed",
2186
+ description: a?.(t) ?? `This ${n} can't be embedded.`
2187
+ };
2188
+ }
2189
+ function qr(e, t, n, r) {
2190
+ let i = e.flatMap((e) => {
2191
+ let i = r(e.item.id);
2192
+ return i === void 0 ? [e] : !i || i.isDisabled || Kr(t, i) ? [] : i === e.item && Object.is(n, e.revision) ? [e] : [{
2193
+ item: i,
2194
+ revision: n
2195
+ }];
2196
+ });
2197
+ return i.length !== e.length || i.some((t, n) => t !== e[n]) ? i : e;
2198
+ }
2199
+ function Jr({ config: e, data: t, frame: n }) {
2200
+ let { picks: r } = L(X), i = Wr(e), { itemLabel: a, itemId: o, source: s, definition: c } = e, l = o(t), u = s?.items ?? Vr, d = B(() => [l], [l]), f = I((e) => r.get(Ur(c.type, e)), [r, c.type]), p = s.resolveItem ? (e) => i().source.resolveItem?.(e) ?? null : void 0, m = k(d, u, p, s.refreshKey, f), h = Ur(c.type, l), g = r.get(h);
2201
+ R(() => {
2202
+ g && r.get(h) === g && r.delete(h);
2203
+ }, [
2204
+ r,
2205
+ h,
2206
+ g
2207
+ ]);
2208
+ let { known: _, failures: v } = m, y = !!s?.resolveItem, b = B(() => re({
2209
+ selected: d,
2210
+ items: u,
2211
+ pageItems: Vr,
2212
+ known: _,
2213
+ failures: v,
2214
+ hasResolver: y,
2215
+ itemLabel: a
2216
+ })[0], [
2217
+ d,
2218
+ u,
2219
+ _,
2220
+ v,
2221
+ y,
2222
+ a
2223
+ ]), x = te(`Couldn't load ${a}`, m.status, m.error, m.retry), S = u.some((e) => e.id === l), C = b.tone === "removed" || !S && _.has(l) && !_.get(l), w = !C && !b.isUnavailable && !b.isDisabled && s.onEditItem;
2224
+ return n({
2225
+ title: C ? `Unavailable ${a}` : b.title,
2226
+ tone: b.tone,
2227
+ missing: C,
2228
+ onEdit: w ? () => i().source.onEditItem?.(b) : void 0,
2229
+ replaceLabel: C ? `Choose another ${a}` : void 0,
2230
+ body: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(Yr, {
2231
+ kind: a,
2232
+ id: l,
2233
+ item: b,
2234
+ missing: C
2235
+ }), x && /* @__PURE__ */ W("div", {
2236
+ className: "ds-content-block__failure",
2237
+ children: x
2238
+ })] })
2239
+ });
2240
+ }
2241
+ function Yr({ kind: e, id: t, item: n, missing: r }) {
2242
+ return /* @__PURE__ */ W("div", {
2243
+ className: "ds-entry ds-content-block__body",
2244
+ children: r ? /* @__PURE__ */ G("span", {
2245
+ className: "ds-entry__body",
2246
+ children: [/* @__PURE__ */ W("em", {
2247
+ className: "ds-entry__title",
2248
+ children: `Unavailable ${e}`
2249
+ }), /* @__PURE__ */ G("span", {
2250
+ className: "ds-entry__meta",
2251
+ children: [/* @__PURE__ */ W("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ W("code", { children: t })]
2252
+ })]
2253
+ }) : /* @__PURE__ */ W(O, { item: n })
2254
+ });
2255
+ }
2256
+ function Xr(e, t, n, r, i) {
2257
+ let a = [];
2258
+ for (let e of n) {
2259
+ let n = t.toData(e.item);
2260
+ if (!n || e.item.isDisabled || Kr(t, e.item)) return !1;
2261
+ a.push(n);
2262
+ }
2263
+ i.clear();
2264
+ for (let e of n) i.set(Ur(t.definition.type, e.item.id), e);
2265
+ let o = e.target.commit(r ? a : a[0]);
2266
+ return o || i.clear(), o;
2267
+ }
2268
+ function Zr(e, t, n, r) {
2269
+ let { itemLabel: i, itemsLabel: a, source: o } = t, { isDisabled: s, target: c } = e, l = c.close, d = e.data && t.itemId(e.data), f = I((e) => Kr(t, e), [t]), p = !!o.isCreating, [m, h] = H([]), [g, _] = H(""), v = u(m.length), y = B(() => d ? [d] : m.map(({ item: e }) => e.id), [d, m]), b = ne(y, o.items ?? Vr, {
2270
+ ...o,
2271
+ resolveItem: n ? o.resolveItem : void 0,
2272
+ mode: n ? "multiple" : "single",
2273
+ max: void 0
2274
+ }, {
2275
+ isOpen: !0,
2276
+ isDisabled: s || p,
2277
+ itemLabel: i,
2278
+ itemsLabel: a,
2279
+ close: l,
2280
+ recheckSelection: n,
2281
+ restrict: f
2282
+ }), x = qr(m, t, o.refreshKey, (e) => b.isRemote ? b.selection.current.get(e) : o.items?.find((t) => t.id === e) ?? null), S = m.length - x.length;
2283
+ return x !== m && h(x), S > 0 && _(`${S} unavailable ${S === 1 ? i : a} removed from selection.`), {
2284
+ canInsert: !s && !p && b.selection.status === "ready" && x.length > 0 && S === 0,
2285
+ choices: x,
2286
+ pendingCount: v,
2287
+ hasPending: m.length > 0,
2288
+ picker: b,
2289
+ selectionNotice: g,
2290
+ toggle: (e) => {
2291
+ let t = b.choice(e);
2292
+ if (!t) return;
2293
+ let i = {
2294
+ item: t,
2295
+ revision: b.revision
2296
+ };
2297
+ n ? (_(""), y.includes(e) ? h((t) => t.filter(({ item: t }) => t.id !== e)) : (b.selection.remember([t], i.revision, [...y, e]), h((e) => [...e, i]))) : r([i]);
2298
+ }
2299
+ };
2300
+ }
2301
+ function Qr({ session: e, config: t }) {
2302
+ let { itemLabel: n, itemsLabel: r, source: i } = t, { fieldLabel: a, target: o } = e, s = o.close, c = e.mode === "replace", l = !c && Gr(i), { picks: d } = L(X), f = (n) => Xr(e, t, n, l, d), p = u({
2303
+ source: i,
2304
+ pick: f
2305
+ }), { canInsert: m, choices: h, pendingCount: g, hasPending: _, picker: v, selectionNotice: y, toggle: b } = Zr(e, t, l, f), x = te(`Couldn't load selected ${r}`, v.selection.status, v.selection.error, v.selection.retry), S = c ? "Replace" : "Embed", C = () => {
2306
+ m && f(h);
2307
+ };
2308
+ return /* @__PURE__ */ W(ie, {
2309
+ ...v.dialog,
2310
+ isOpen: !0,
2311
+ onClose: s,
2312
+ onToggle: b,
2313
+ addLabel: `${S} ${l ? r : n}`,
2314
+ confirm: l ? {
2315
+ label: "Insert selected",
2316
+ isDisabled: !m,
2317
+ onClick: C
2318
+ } : void 0,
2319
+ selectionNotice: y,
2320
+ selectionFailure: x,
2321
+ onCreate: i.onCreate ? () => i.onCreate?.({
2322
+ available: () => g.current === 0 && o.available(),
2323
+ commit: (e) => g.current === 0 && p.current.pick([{
2324
+ item: e,
2325
+ revision: p.current.source.refreshKey
2326
+ }])
2327
+ }) : void 0,
2328
+ isCreateDisabled: _,
2329
+ isCreating: i.isCreating,
2330
+ dialogTitle: i.dialogTitle,
2331
+ dialogDescription: `${l ? `Choose ${r}` : `Choose one ${n}`} to embed in ${a}. ${i.dialogDescription ?? ""}`.trim(),
2332
+ isDialogHidden: i.isDialogHidden
2333
+ });
2334
+ }
2335
+ function $r(e) {
2336
+ let { definition: t, itemLabel: n, itemsLabel: r, icon: i, source: a } = e, o = Gr(a) || !!a.onCreate, s = {
2337
+ definition: t,
2338
+ label: n,
2339
+ icon: i,
2340
+ insertLabel: o ? `Embed ${Gr(a) ? r : n}` : void 0,
2341
+ replaceLabel: o ? "Replace" : void 0,
2342
+ isCreating: a.isCreating,
2343
+ isDialogHidden: a.isDialogHidden,
2344
+ renderPreview: (t, n) => /* @__PURE__ */ W(Jr, {
2345
+ config: e,
2346
+ data: t,
2347
+ frame: n
2348
+ }),
2349
+ renderEditor: (t) => /* @__PURE__ */ W(Qr, {
2350
+ session: t,
2351
+ config: e
2352
+ })
2353
+ };
2354
+ return Hr.set(s, e), jt.set(s, [
2355
+ a.items,
2356
+ a.refreshKey,
2357
+ !!a.resolveItem,
2358
+ !!a.onEditItem
2359
+ ]), s;
2360
+ }
2312
2361
  //#endregion
2313
2362
  //#region src/components/RichTextEditor/index.tsx
2314
- function Wr({ editor: e, selection: n, onClose: r }) {
2315
- let [i, a] = B(n.href), [o, s] = B(), c = L();
2316
- I(() => {
2363
+ var ei = /* @__PURE__ */ new Map();
2364
+ function ti({ editor: e, selection: n, onClose: r }) {
2365
+ let [i, a] = H(n.href), [o, s] = H(), c = z();
2366
+ R(() => {
2317
2367
  let t = () => {
2318
2368
  e.state.doc.eq(n.document) || r();
2319
2369
  };
@@ -2348,13 +2398,13 @@ function Wr({ editor: e, selection: n, onClose: r }) {
2348
2398
  }]
2349
2399
  }).run() : a.setLink({ href: t }).run(), r();
2350
2400
  };
2351
- return /* @__PURE__ */ H(h, {
2401
+ return /* @__PURE__ */ W(h, {
2352
2402
  isOpen: !0,
2353
2403
  title: n.isEditing ? "Edit link" : "Add link",
2354
2404
  size: "dialog",
2355
2405
  onClose: r,
2356
- footer: /* @__PURE__ */ U(V, { children: [
2357
- n.isEditing && /* @__PURE__ */ H(t, {
2406
+ footer: /* @__PURE__ */ G(U, { children: [
2407
+ n.isEditing && /* @__PURE__ */ W(t, {
2358
2408
  variant: "danger",
2359
2409
  onClick: () => {
2360
2410
  l() && e.chain().focus().setTextSelection({
@@ -2364,28 +2414,28 @@ function Wr({ editor: e, selection: n, onClose: r }) {
2364
2414
  },
2365
2415
  children: "Remove link"
2366
2416
  }),
2367
- /* @__PURE__ */ H(t, {
2417
+ /* @__PURE__ */ W(t, {
2368
2418
  onClick: r,
2369
2419
  children: "Cancel"
2370
2420
  }),
2371
- /* @__PURE__ */ H(t, {
2421
+ /* @__PURE__ */ W(t, {
2372
2422
  variant: "primary",
2373
2423
  type: "submit",
2374
2424
  form: c,
2375
2425
  children: "Save"
2376
2426
  })
2377
2427
  ] }),
2378
- children: /* @__PURE__ */ H("form", {
2428
+ children: /* @__PURE__ */ W("form", {
2379
2429
  id: c,
2380
2430
  noValidate: !0,
2381
2431
  onSubmit: (e) => {
2382
2432
  e.preventDefault(), e.stopPropagation(), u();
2383
2433
  },
2384
- children: /* @__PURE__ */ H(m, {
2434
+ children: /* @__PURE__ */ W(m, {
2385
2435
  label: "URL",
2386
2436
  isRequired: !0,
2387
2437
  error: o,
2388
- children: (e) => /* @__PURE__ */ H(_, {
2438
+ children: (e) => /* @__PURE__ */ W(_, {
2389
2439
  ...e,
2390
2440
  value: i,
2391
2441
  inputMode: "url",
@@ -2399,7 +2449,7 @@ function Wr({ editor: e, selection: n, onClose: r }) {
2399
2449
  })
2400
2450
  });
2401
2451
  }
2402
- var Gr = [
2452
+ var ni = [
2403
2453
  [
2404
2454
  {
2405
2455
  id: "bold",
@@ -2478,15 +2528,15 @@ var Gr = [
2478
2528
  run: (e) => e.chain().focus().redo().run()
2479
2529
  }]
2480
2530
  ];
2481
- function Kr({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c, tables: l }) {
2482
- return /* @__PURE__ */ U("div", {
2531
+ function ri({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c, tables: l }) {
2532
+ return /* @__PURE__ */ G("div", {
2483
2533
  className: "ds-rte__toolbar ds-field-surface",
2484
2534
  role: "toolbar",
2485
2535
  "aria-label": `${i} formatting`,
2486
2536
  children: [
2487
- Gr.map((i, a) => /* @__PURE__ */ H(f, {
2537
+ ni.map((i, a) => /* @__PURE__ */ W(f, {
2488
2538
  "aria-label": `Formatting ${a + 1}`,
2489
- children: i.map((i) => /* @__PURE__ */ H(t, {
2539
+ children: i.map((i) => /* @__PURE__ */ W(t, {
2490
2540
  size: "sm",
2491
2541
  isIconOnly: !0,
2492
2542
  iconStart: i.icon,
@@ -2498,9 +2548,9 @@ function Kr({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
2498
2548
  onClick: () => e && i.run(e)
2499
2549
  }, i.id))
2500
2550
  }, a)),
2501
- /* @__PURE__ */ H(f, {
2551
+ /* @__PURE__ */ W(f, {
2502
2552
  "aria-label": "Link",
2503
- children: /* @__PURE__ */ H(t, {
2553
+ children: /* @__PURE__ */ W(t, {
2504
2554
  size: "sm",
2505
2555
  isIconOnly: !0,
2506
2556
  iconStart: "link",
@@ -2511,7 +2561,7 @@ function Kr({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
2511
2561
  onClick: () => e && o(e.state, e.isActive("link") ? e.state.selection.from : void 0)
2512
2562
  })
2513
2563
  }),
2514
- l && /* @__PURE__ */ H(hr, {
2564
+ l && /* @__PURE__ */ W(fr, {
2515
2565
  editor: e,
2516
2566
  disabled: r,
2517
2567
  inTable: n?.tableActive ?? !1
@@ -2522,10 +2572,10 @@ function Kr({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
2522
2572
  ]
2523
2573
  });
2524
2574
  }
2525
- var qr = ve(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: a, contentError: o, errorId: s, surface: c, children: u }, d) {
2526
- return /* @__PURE__ */ H(l.Provider, {
2575
+ var ii = xe(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: a, contentError: o, errorId: s, surface: c, children: u }, d) {
2576
+ return /* @__PURE__ */ W(l.Provider, {
2527
2577
  value: e,
2528
- children: /* @__PURE__ */ U("div", {
2578
+ children: /* @__PURE__ */ G("div", {
2529
2579
  ref: d,
2530
2580
  className: ["ds-rte", t].filter(Boolean).join(" "),
2531
2581
  style: n.frameStyle,
@@ -2535,17 +2585,17 @@ var qr = ve(function({ scopeRef: e, className: t, expansion: n, isFocused: r, di
2535
2585
  "data-invalid": a || void 0,
2536
2586
  "aria-invalid": a || void 0,
2537
2587
  children: [
2538
- o && /* @__PURE__ */ H("p", {
2588
+ o && /* @__PURE__ */ W("p", {
2539
2589
  id: s,
2540
2590
  role: "alert",
2541
2591
  className: "ds-field__error",
2542
2592
  children: o
2543
2593
  }),
2544
- n.expanded && /* @__PURE__ */ H("p", {
2594
+ n.expanded && /* @__PURE__ */ W("p", {
2545
2595
  className: "ds-rte__placeholder",
2546
2596
  children: "Editing in expanded view. Press Esc to return."
2547
2597
  }),
2548
- n.surfaceSlot(/* @__PURE__ */ H("div", {
2598
+ n.surfaceSlot(/* @__PURE__ */ W("div", {
2549
2599
  className: "ds-rte__surface",
2550
2600
  hidden: !!o,
2551
2601
  "data-expanded": n.expanded || void 0,
@@ -2559,144 +2609,224 @@ var qr = ve(function({ scopeRef: e, className: t, expansion: n, isFocused: r, di
2559
2609
  ]
2560
2610
  })
2561
2611
  });
2562
- }), Jr = ft.extend({ addNodeView() {
2563
- return we(Ft, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
2612
+ }), ai = ht.extend({ addNodeView() {
2613
+ return Oe(Vt, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
2564
2614
  } });
2565
- function Yr(e, t) {
2615
+ function oi(e, t) {
2566
2616
  return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
2567
2617
  }
2568
- function Xr(e, { format: t, value: n }, r, i, a) {
2569
- if (n === void 0 && e && !e.isDestroyed) return t === "json" ? St(r, { tables: i }) ? void 0 : lt(e.getJSON()) : i || a ? e.getHTML() : void 0;
2618
+ function si(e, { format: t, value: n }, r, i, a, o) {
2619
+ if (n === void 0 && e && !e.isDestroyed) {
2620
+ if (t !== "json") {
2621
+ let t = typeof r == "string" && Ot(r, o);
2622
+ return (i || a) && !t ? e.getHTML() : void 0;
2623
+ }
2624
+ return kt(r, {
2625
+ tables: i,
2626
+ blockDefinitions: o
2627
+ }) ? void 0 : e.getJSON();
2628
+ }
2570
2629
  }
2571
- var Zr = ve(function(e, t) {
2572
- let { placeholder: r = "Write something…", size: i = "md", expandedWidth: a = "wide", isDisabled: o = !1, isInvalid: s = !1, label: c = "Rich text editor", className: l, toolbarExtra: u, tables: d = !0, id: f, isRequired: p, required: m, "aria-label": h, "aria-labelledby": g, "aria-describedby": _, "aria-invalid": v } = e, y = z(null), b = R(() => n(y, t), [t]), [x, S] = B(!1), [C, w] = B(null), T = F(() => w(null), []), [E, D] = B(() => e.defaultValue ?? (e.format === "json" ? pt : "")), [ee, te] = B(!1), O = e.value === void 0 ? E : e.value, k = R(() => e.format === "json" ? St(O, { tables: d }) : void 0, [
2630
+ var ci = Te.create({
2631
+ name: "contentBlockGuard",
2632
+ addOptions() {
2633
+ let e = Et(/* @__PURE__ */ new Map());
2634
+ return { check: () => e };
2635
+ },
2636
+ addProseMirrorPlugins() {
2637
+ let { check: e } = this.options;
2638
+ return [new Re({ filterTransaction: (t) => !t.docChanged || Dt(t.doc, e()) })];
2639
+ }
2640
+ });
2641
+ function li(e, t, { definitions: n, check: r }) {
2642
+ if (Ot(e, n)) return !0;
2643
+ let i = !1;
2644
+ return t.content.forEach((e) => {
2645
+ i ||= !Dt(e, r);
2646
+ }), i;
2647
+ }
2648
+ var ui = () => () => {}, di = () => typeof DOMParser < "u", fi = () => !1;
2649
+ function pi() {
2650
+ return Se(ui, di, fi);
2651
+ }
2652
+ var mi = xe(function(e, t) {
2653
+ let { placeholder: r = "Write something…", size: i = "md", expandedWidth: a = "wide", isDisabled: o = !1, isInvalid: s = !1, label: c = "Rich text editor", className: l, toolbarExtra: d, tables: f = !0, blockPlugins: p = At, id: m, isRequired: h, required: g, "aria-label": _, "aria-labelledby": y, "aria-describedby": b, "aria-invalid": x } = e, S = V(null), C = B(() => n(S, t), [t]), [w, T] = H(!1), [E, D] = H(null), O = I(() => D(null), []), [ee, te] = H(() => e.defaultValue ?? (e.format === "json" ? gt : "")), [ne, re] = H(!1), k = e.value === void 0 ? ee : e.value, ie = B(() => new Map(p.map((e) => [e.definition.type, e])), [p]), A = lt(B(() => p.map(({ definition: e }) => e), [p]), ct), ae = B(() => Et(v(A)), [A]), oe = u(ae), se = I(() => oe.current, [oe]), ce = pi(), [le, ue] = H(null), de = le !== null && Object.is(le.value, k) && le.check === ae && le.tables === f, j = B(() => {
2654
+ if (!de) return typeof k == "string" && e.format !== "json" ? ce ? Ot(k, A) : void 0 : kt(k, {
2655
+ tables: f,
2656
+ blockDefinitions: A
2657
+ });
2658
+ }, [
2659
+ de,
2660
+ k,
2573
2661
  e.format,
2574
- O,
2575
- d
2576
- ]), ne = L(), A = s || !!k || v, j = o || !!k;
2577
- j && C && w(null);
2578
- let re = F((e, t) => {
2579
- if (j) return;
2580
- let n = t === void 0 ? void 0 : De(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
2581
- w({
2662
+ ce,
2663
+ f,
2664
+ A
2665
+ ]), M = z(), N = s || !!j || x, P = o || !!j;
2666
+ P && E && D(null);
2667
+ let fe = I((e, t) => {
2668
+ if (P) return;
2669
+ let n = t === void 0 ? void 0 : je(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
2670
+ D({
2582
2671
  from: n?.from ?? e.selection.from,
2583
2672
  to: n?.to ?? e.selection.to,
2584
2673
  href: r?.attrs.href ?? "",
2585
2674
  isEditing: !!r,
2586
2675
  document: e.doc
2587
2676
  });
2588
- }, [j]), ie = R(() => ({
2677
+ }, [P]), pe = B(() => ({
2589
2678
  role: "textbox",
2590
- ...g ? {} : { "aria-label": h ?? c },
2679
+ ...y ? {} : { "aria-label": _ ?? c },
2591
2680
  "aria-multiline": "true",
2592
- ...f ? { id: f } : {},
2593
- ...g ? { "aria-labelledby": g } : {},
2594
- ..._ ? { "aria-describedby": _ } : {},
2595
- ...A ? { "aria-invalid": String(A) } : {},
2596
- ...p || m ? { "aria-required": "true" } : {}
2681
+ ...m ? { id: m } : {},
2682
+ ...y ? { "aria-labelledby": y } : {},
2683
+ ...b ? { "aria-describedby": b } : {},
2684
+ ...N ? { "aria-invalid": String(N) } : {},
2685
+ ...h || g ? { "aria-required": "true" } : {}
2597
2686
  }), [
2598
2687
  c,
2599
- h,
2600
- f,
2601
- g,
2602
2688
  _,
2603
- A,
2604
- p,
2605
- m
2606
- ]), ae = R(() => ({
2607
- attributes: ie,
2689
+ m,
2690
+ y,
2691
+ b,
2692
+ N,
2693
+ h,
2694
+ g
2695
+ ]), me = u({
2696
+ definitions: A,
2697
+ check: ae
2698
+ }), he = B(() => ({
2699
+ attributes: pe,
2700
+ handlePaste: (e, t, n) => li(t.clipboardData?.getData("text/html") ?? "", n, me.current),
2701
+ handleDrop: (e, t, n) => li(t.dataTransfer?.getData("text/html") ?? "", n, me.current),
2608
2702
  handleDOMEvents: {
2609
- keydown: Yr,
2703
+ keydown: oi,
2610
2704
  click: (e, t) => {
2611
2705
  let n = t.target instanceof Element ? t.target.closest("a") : null;
2612
- return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && re(e.state, e.posAtDOM(n, 0)), !0);
2706
+ return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && fe(e.state, e.posAtDOM(n, 0)), !0);
2613
2707
  }
2614
2708
  }
2615
- }), [ie, re]), oe = R(() => [...yt(Jr, { tables: d }, Ur), Me.configure({ placeholder: r })], [r, d]), se = R(() => k ? pt : typeof O == "string" ? O : xt(O), [O, k]), M = Ae({
2709
+ }), [
2710
+ pe,
2711
+ fe,
2712
+ me
2713
+ ]), ge = B(() => [
2714
+ ...St(ai, { tables: f }, Br),
2715
+ Ie.configure({ placeholder: r }),
2716
+ ci.configure({ check: se })
2717
+ ], [
2718
+ r,
2719
+ f,
2720
+ se
2721
+ ]), _e = B(() => j ? gt : typeof k == "string" ? k : wt(k), [k, j]), F = Pe({
2616
2722
  immediatelyRender: !1,
2617
- editable: !j,
2618
- content: se,
2619
- extensions: oe,
2620
- editorProps: ae,
2621
- onFocus: () => S(!0),
2622
- onBlur: () => S(!1),
2723
+ editable: !P,
2724
+ content: _e,
2725
+ extensions: ge,
2726
+ editorProps: he,
2727
+ onFocus: () => T(!0),
2728
+ onBlur: () => T(!1),
2623
2729
  onUpdate: ({ editor: t, transaction: n }) => {
2624
- (!j || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(lt(t.getJSON())) : (e.value === void 0 && !t.schema.nodes.table && te(!0), e.onChange?.(t.getHTML())));
2730
+ if (P && !n.getMeta("ds-rte-block-commit")) return;
2731
+ let r = (n) => {
2732
+ ue({
2733
+ value: n,
2734
+ check: oe.current,
2735
+ tables: !!t.schema.nodes.table
2736
+ }), e.value === void 0 && te(n);
2737
+ };
2738
+ if (e.format === "json") {
2739
+ let n = t.getJSON();
2740
+ r(n), e.onChange?.(n);
2741
+ } else {
2742
+ e.value === void 0 && !t.schema.nodes.table && re(!0);
2743
+ let n = t.getHTML();
2744
+ r(n), e.onChange?.(n);
2745
+ }
2625
2746
  }
2626
- }, [d]), [N, ce] = B(d);
2627
- if (N !== d) {
2628
- ce(d), S(!1), te(!1);
2629
- let t = Xr(M, e, O, N, ee);
2630
- t !== void 0 && D(t);
2747
+ }, [f]), [ve, ye] = H(f);
2748
+ if (ve !== f) {
2749
+ ye(f), T(!1), re(!1);
2750
+ let t = si(F, e, k, ve, ne, A);
2751
+ t !== void 0 && te(t);
2631
2752
  }
2632
- I(() => {
2633
- M && !M.isDestroyed && (M.setEditable(!j, !1), M.setOptions({ editorProps: ae }));
2753
+ R(() => {
2754
+ F && !F.isDestroyed && (F.setEditable(!P, !1), F.setOptions({ editorProps: he }));
2634
2755
  }, [
2635
- M,
2636
- j,
2637
- ae
2638
- ]), I(() => {
2639
- if (!M || M.isDestroyed || e.value === void 0 || k) return;
2640
- let t = typeof e.value == "string" ? Ee(e.value, M.schema) : M.schema.nodeFromJSON(xt(e.value));
2641
- t.eq(M.state.doc) || M.commands.setContent(t, { emitUpdate: !1 });
2756
+ F,
2757
+ P,
2758
+ he
2759
+ ]);
2760
+ let be = V(!1);
2761
+ R(() => {
2762
+ if (!F || F.isDestroyed) return;
2763
+ if (j) {
2764
+ be.current = !0;
2765
+ return;
2766
+ }
2767
+ let t = e.value ?? (be.current ? k : void 0);
2768
+ if (be.current = !1, t === void 0) return;
2769
+ let n = typeof t == "string" ? Ae(t, F.schema) : F.schema.nodeFromJSON(wt(t));
2770
+ n.eq(F.state.doc) || F.commands.setContent(n, { emitUpdate: !1 });
2642
2771
  }, [
2643
- M,
2772
+ F,
2644
2773
  e.value,
2645
- k
2774
+ k,
2775
+ j
2646
2776
  ]);
2647
- let le = je({
2648
- editor: M,
2777
+ let xe = Fe({
2778
+ editor: F,
2649
2779
  selector: ({ editor: e }) => e ? {
2650
- active: Object.fromEntries(Gr.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
2780
+ active: Object.fromEntries(ni.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
2651
2781
  linkActive: e.isActive("link"),
2652
- tableActive: Pr(e.state.selection)
2782
+ tableActive: jr(e.state.selection)
2653
2783
  } : null
2654
- }), P = en(M, k ? void 0 : e.embeds, j, c), ue = it({
2655
- editor: M,
2656
- disabled: j,
2657
- isHeld: P.isCreating,
2658
- invalid: !!A,
2659
- label: h ?? c,
2660
- labelledBy: g,
2784
+ }), L = Yt(F, j ? ei : ie, P, c), Se = dt({
2785
+ editor: F,
2786
+ disabled: P,
2787
+ isHeld: L.isCreating,
2788
+ invalid: !!N,
2789
+ label: _ ?? c,
2790
+ labelledBy: y,
2661
2791
  expandedWidth: a,
2662
- frameRef: y
2792
+ frameRef: S
2663
2793
  });
2664
- return /* @__PURE__ */ H(At.Provider, {
2665
- value: P.context,
2666
- children: /* @__PURE__ */ U(qr, {
2667
- ref: b,
2668
- scopeRef: y,
2794
+ return /* @__PURE__ */ W(X.Provider, {
2795
+ value: L.context,
2796
+ children: /* @__PURE__ */ G(ii, {
2797
+ ref: C,
2798
+ scopeRef: S,
2669
2799
  className: l,
2670
- expansion: ue,
2671
- isFocused: x,
2672
- disabled: j,
2673
- invalid: !!A,
2674
- contentError: k,
2675
- errorId: ne,
2676
- surface: /* @__PURE__ */ U(V, { children: [/* @__PURE__ */ H(Kr, {
2677
- editor: M,
2678
- state: le,
2679
- disabled: j,
2800
+ expansion: Se,
2801
+ isFocused: w,
2802
+ disabled: P,
2803
+ invalid: !!N,
2804
+ contentError: j,
2805
+ errorId: M,
2806
+ surface: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(ri, {
2807
+ editor: F,
2808
+ state: xe,
2809
+ disabled: P,
2680
2810
  label: c,
2681
- toolbarExtra: u,
2682
- openLink: re,
2683
- expandControl: ue.toggle,
2684
- embedControl: P.toolbar,
2685
- tables: d
2686
- }), /* @__PURE__ */ H("div", {
2811
+ toolbarExtra: d,
2812
+ openLink: fe,
2813
+ expandControl: Se.toggle,
2814
+ embedControl: L.toolbar,
2815
+ tables: f
2816
+ }), /* @__PURE__ */ W("div", {
2687
2817
  className: "ds-rte__content ds-field-surface",
2688
2818
  "data-size": i,
2689
- children: /* @__PURE__ */ H(xe, { editor: M })
2819
+ children: /* @__PURE__ */ W(we, { editor: F })
2690
2820
  })] }),
2691
- children: [P.dialog, M && C && !j && /* @__PURE__ */ H(Wr, {
2692
- editor: M,
2693
- selection: C,
2694
- onClose: T
2821
+ children: [L.dialog, F && E && !P && /* @__PURE__ */ W(ti, {
2822
+ editor: F,
2823
+ selection: E,
2824
+ onClose: O
2695
2825
  })]
2696
2826
  })
2697
2827
  });
2698
2828
  });
2699
2829
  //#endregion
2700
- export { pt as a, Bn as i, tr as n, qn as r, Zr as t };
2830
+ export { In as a, Un as i, $r as n, gt as o, Zn as r, mi as t };
2701
2831
 
2702
- //# sourceMappingURL=RichTextEditor-CS2ED0HP.js.map
2832
+ //# sourceMappingURL=RichTextEditor-DSxiMLVd.js.map