@namroodinc/liquid-editorial 0.13.5 → 0.14.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.
- package/README.md +1 -1
- package/UPGRADING.md +47 -0
- package/dist/chunks/{Avatar-UjhjcHh5.js → Avatar-BToMaTdL.js} +2 -2
- package/dist/chunks/{Avatar-UjhjcHh5.js.map → Avatar-BToMaTdL.js.map} +1 -1
- package/dist/chunks/{Avatar-BY0dAItT.cjs → Avatar-Dw7EWd_-.cjs} +2 -2
- package/dist/chunks/{Avatar-BY0dAItT.cjs.map → Avatar-Dw7EWd_-.cjs.map} +1 -1
- package/dist/chunks/{Board-CQ1GTuRB.cjs → Board-DeXtaWNO.cjs} +2 -2
- package/dist/chunks/{Board-CQ1GTuRB.cjs.map → Board-DeXtaWNO.cjs.map} +1 -1
- package/dist/chunks/{Board-DUX76d2R.js → Board-XeDG9nWP.js} +2 -2
- package/dist/chunks/{Board-DUX76d2R.js.map → Board-XeDG9nWP.js.map} +1 -1
- package/dist/chunks/{CollectionView-JRNdXHti.js → CollectionView-C0_bTO2v.js} +2 -2
- package/dist/chunks/{CollectionView-JRNdXHti.js.map → CollectionView-C0_bTO2v.js.map} +1 -1
- package/dist/chunks/{CollectionView-CIJdNwcq.cjs → CollectionView-Dbg4d_tA.cjs} +2 -2
- package/dist/chunks/{CollectionView-CIJdNwcq.cjs.map → CollectionView-Dbg4d_tA.cjs.map} +1 -1
- package/dist/chunks/{ColourField-BG5oGj9f.js → ColourField-Bb8H87fg.js} +3 -3
- package/dist/chunks/{ColourField-BG5oGj9f.js.map → ColourField-Bb8H87fg.js.map} +1 -1
- package/dist/chunks/{ColourField-DFvRASVe.cjs → ColourField-DAFzOIOq.cjs} +2 -2
- package/dist/chunks/{ColourField-DFvRASVe.cjs.map → ColourField-DAFzOIOq.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-LqaePc57.js → DatePicker-COm1giw8.js} +3 -3
- package/dist/chunks/{DatePicker-LqaePc57.js.map → DatePicker-COm1giw8.js.map} +1 -1
- package/dist/chunks/{DatePicker-ClOqS6oH.cjs → DatePicker-DOg3iQYy.cjs} +2 -2
- package/dist/chunks/{DatePicker-ClOqS6oH.cjs.map → DatePicker-DOg3iQYy.cjs.map} +1 -1
- package/dist/chunks/{Drawer-DdIH9jpe.cjs → Drawer-B2dcTh5l.cjs} +2 -2
- package/dist/chunks/{Drawer-DdIH9jpe.cjs.map → Drawer-B2dcTh5l.cjs.map} +1 -1
- package/dist/chunks/{Drawer-Ck5XKT_V.js → Drawer-nUTJtwX_.js} +3 -3
- package/dist/chunks/{Drawer-Ck5XKT_V.js.map → Drawer-nUTJtwX_.js.map} +1 -1
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs +2 -0
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +1 -0
- package/dist/chunks/{use-picker-session-BSpOwnQ-.js → EntryPicker-Ie9T47hA.js} +367 -202
- package/dist/chunks/EntryPicker-Ie9T47hA.js.map +1 -0
- package/dist/chunks/FormEditor-D1HUnjMI.cjs +2 -0
- package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +1 -0
- package/dist/chunks/FormEditor-DgDV5aeR.js +30 -0
- package/dist/chunks/FormEditor-DgDV5aeR.js.map +1 -0
- package/dist/chunks/Icon-Bxvp1-td.js +102 -0
- package/dist/chunks/Icon-Bxvp1-td.js.map +1 -0
- package/dist/chunks/{Icon-3ucBRgrd.cjs → Icon-CnnTrtNb.cjs} +2 -2
- package/dist/chunks/Icon-CnnTrtNb.cjs.map +1 -0
- package/dist/chunks/{Message-yhdaBpaz.cjs → Message-B0A5bz8V.cjs} +2 -2
- package/dist/chunks/{Message-yhdaBpaz.cjs.map → Message-B0A5bz8V.cjs.map} +1 -1
- package/dist/chunks/{Message-d6lqiMQ6.js → Message-VJTPhId7.js} +2 -2
- package/dist/chunks/{Message-d6lqiMQ6.js.map → Message-VJTPhId7.js.map} +1 -1
- package/dist/chunks/RichTextEditor-DPhEkDxi.js +2108 -0
- package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +1 -0
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +2 -0
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +1 -0
- package/dist/chunks/{dialogLabel-DT7rCr3_.js → dialogLabel-C153NosD.js} +2 -2
- package/dist/chunks/{dialogLabel-DT7rCr3_.js.map → dialogLabel-C153NosD.js.map} +1 -1
- package/dist/chunks/{dialogLabel-_-MTckE_.cjs → dialogLabel-CNNQbtob.cjs} +2 -2
- package/dist/chunks/{dialogLabel-_-MTckE_.cjs.map → dialogLabel-CNNQbtob.cjs.map} +1 -1
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs +2 -0
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +1 -0
- package/dist/chunks/{overlayLayer-lU4iWSjO.js → overlayLayer-Og07sIyl.js} +21 -3
- package/dist/chunks/overlayLayer-Og07sIyl.js.map +1 -0
- package/dist/chunks/{useTooltip-DnJEFBLg.js → useTooltip-Du8PutGX.js} +2 -2
- package/dist/chunks/{useTooltip-DnJEFBLg.js.map → useTooltip-Du8PutGX.js.map} +1 -1
- package/dist/chunks/{useTooltip-C7ON4nkV.cjs → useTooltip-ekdwMJFz.cjs} +2 -2
- package/dist/chunks/{useTooltip-C7ON4nkV.cjs.map → useTooltip-ekdwMJFz.cjs.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Banner/index.cjs +1 -1
- package/dist/components/Banner/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.js +5 -5
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.js +4 -4
- package/dist/components/EntryPicker/dialog.d.cts +11 -1
- package/dist/components/EntryPicker/dialog.d.cts.map +1 -1
- package/dist/components/EntryPicker/dialog.d.ts +11 -1
- package/dist/components/EntryPicker/dialog.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.cts +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.ts +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-picker-session.d.cts +4 -1
- package/dist/components/EntryPicker/use-picker-session.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-picker-session.d.ts +4 -1
- package/dist/components/EntryPicker/use-picker-session.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-selected-items.d.cts +2 -0
- package/dist/components/EntryPicker/use-selected-items.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-selected-items.d.ts +2 -0
- package/dist/components/EntryPicker/use-selected-items.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +155 -24
- package/dist/components/FormEditor/control.d.cts +11 -2
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +11 -2
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/form.d.cts +33 -0
- package/dist/components/FormEditor/form.d.cts.map +1 -0
- package/dist/components/FormEditor/form.d.ts +33 -0
- package/dist/components/FormEditor/form.d.ts.map +1 -0
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts +3 -27
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts +3 -27
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +3 -3
- package/dist/components/FormEditor/model.d.cts +2 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +2 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.cts +4 -0
- package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -0
- package/dist/components/FormEditor/rich-text-control.d.ts +4 -0
- package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -0
- package/dist/components/Icon/icons.d.cts +11 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +11 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts +3 -2
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts +3 -2
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +64 -51
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.js +1 -1
- package/dist/components/RichTextEditor/document.d.cts +6 -2
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts +6 -2
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/embed-context.d.cts +5 -0
- package/dist/components/RichTextEditor/embed-context.d.cts.map +1 -1
- package/dist/components/RichTextEditor/embed-context.d.ts +5 -0
- package/dist/components/RichTextEditor/embed-context.d.ts.map +1 -1
- package/dist/components/RichTextEditor/embed-types.d.cts +6 -4
- package/dist/components/RichTextEditor/embed-types.d.cts.map +1 -1
- package/dist/components/RichTextEditor/embed-types.d.ts +6 -4
- package/dist/components/RichTextEditor/embed-types.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +8 -0
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +8 -0
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -2
- package/dist/components/RichTextEditor/storyblock-view.d.cts.map +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts.map +1 -1
- package/dist/components/RichTextEditor/style.css +44 -46
- package/dist/components/RichTextEditor/tables.d.cts +7 -0
- package/dist/components/RichTextEditor/tables.d.cts.map +1 -0
- package/dist/components/RichTextEditor/tables.d.ts +7 -0
- package/dist/components/RichTextEditor/tables.d.ts.map +1 -0
- package/dist/components/RichTextEditor/use-embeds.d.cts.map +1 -1
- package/dist/components/RichTextEditor/use-embeds.d.ts.map +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.js +4 -4
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +28 -28
- package/dist/internal/dialogFocus.d.cts +6 -1
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +6 -1
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/package.json +8 -6
- package/dist/chunks/EntryPicker-B4dAsObz.cjs +0 -2
- package/dist/chunks/EntryPicker-B4dAsObz.cjs.map +0 -1
- package/dist/chunks/EntryPicker-DDXHytMN.js +0 -160
- package/dist/chunks/EntryPicker-DDXHytMN.js.map +0 -1
- package/dist/chunks/FormEditor-BGzE-rqk.cjs +0 -2
- package/dist/chunks/FormEditor-BGzE-rqk.cjs.map +0 -1
- package/dist/chunks/FormEditor-ChH4e5sB.js +0 -693
- package/dist/chunks/FormEditor-ChH4e5sB.js.map +0 -1
- package/dist/chunks/Icon-3ucBRgrd.cjs.map +0 -1
- package/dist/chunks/Icon-dPXyBYe5.js +0 -91
- package/dist/chunks/Icon-dPXyBYe5.js.map +0 -1
- package/dist/chunks/RichTextEditor-BFblqw8m.js +0 -1144
- package/dist/chunks/RichTextEditor-BFblqw8m.js.map +0 -1
- package/dist/chunks/RichTextEditor-DU9CVeRD.cjs +0 -2
- package/dist/chunks/RichTextEditor-DU9CVeRD.cjs.map +0 -1
- package/dist/chunks/overlayLayer-iGhuAByk.cjs +0 -2
- package/dist/chunks/overlayLayer-iGhuAByk.cjs.map +0 -1
- package/dist/chunks/overlayLayer-lU4iWSjO.js.map +0 -1
- package/dist/chunks/use-picker-session-BSpOwnQ-.js.map +0 -1
- package/dist/chunks/use-picker-session-ouqHBmVA.cjs +0 -2
- package/dist/chunks/use-picker-session-ouqHBmVA.cjs.map +0 -1
|
@@ -0,0 +1,2108 @@
|
|
|
1
|
+
import { t as e } from "./Icon-Bxvp1-td.js";
|
|
2
|
+
import { Button as t } from "../components/Button/index.js";
|
|
3
|
+
import { t as n } from "./mergeRefs-C6_5pADN.js";
|
|
4
|
+
import { d as r, p as i, s as a, u as o } from "./overlayLayer-Og07sIyl.js";
|
|
5
|
+
import { a as s, o as c } from "./dialogLabel-C153NosD.js";
|
|
6
|
+
import { t as l } from "./useIsomorphicLayoutEffect-Bc9hxFMc.js";
|
|
7
|
+
import { ButtonGroup as u } from "../components/ButtonGroup/index.js";
|
|
8
|
+
import { Badge as d } from "../components/Badge/index.js";
|
|
9
|
+
/* empty css */
|
|
10
|
+
import { Field as f } from "../components/Field/index.js";
|
|
11
|
+
import { Modal as p } from "../components/Modal/index.js";
|
|
12
|
+
import { TextArea as m, TextField as h } from "../components/TextField/index.js";
|
|
13
|
+
import { Menu as g, MenuItem as _, MenuSeparator as v } from "../components/Menu/index.js";
|
|
14
|
+
import { a as y, c as b, i as x, l as S, n as C, o as w, r as T, s as E, t as D } from "./EntryPicker-Ie9T47hA.js";
|
|
15
|
+
import { Checkbox as ee, ChoiceGroup as te, Radio as O } from "../components/Choice/index.js";
|
|
16
|
+
import { Container as k } from "../components/Container/index.js";
|
|
17
|
+
import { n as ne } from "./decimal-hq_W9D3s.js";
|
|
18
|
+
import { t as A } from "./NumberField-C90eJGny.js";
|
|
19
|
+
import { Select as j } from "../components/Select/index.js";
|
|
20
|
+
import { Switch as M } from "../components/Switch/index.js";
|
|
21
|
+
import { i as N } from "./colour-CYEF4Q_n.js";
|
|
22
|
+
import { i as P, n as re, r as ie, t as F } from "./Slider-Cab6NqhK.js";
|
|
23
|
+
import { t as ae } from "./ColourField-Bb8H87fg.js";
|
|
24
|
+
import { a as oe, n as se } from "./DatePicker-COm1giw8.js";
|
|
25
|
+
import { TagsInput as I } from "../components/TagsInput/index.js";
|
|
26
|
+
import { CheckboxCard as ce, RadioCard as le, SelectionCardGroup as ue } from "../components/SelectionCard/index.js";
|
|
27
|
+
import { Fragment as de, createContext as fe, forwardRef as pe, useCallback as L, useContext as me, useEffect as R, useId as z, useMemo as B, useRef as V, useState as H } from "react";
|
|
28
|
+
import { createPortal as he } from "react-dom";
|
|
29
|
+
import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
|
|
30
|
+
import { EditorContent as ge, Node as _e, NodeViewWrapper as ve, ReactNodeViewRenderer as ye, createDocument as be, getMarkRange as xe, getSchema as Se, mergeAttributes as Ce, useEditor as we, useEditorState as Te } from "@tiptap/react";
|
|
31
|
+
import { Placeholder as Ee } from "@tiptap/extension-placeholder";
|
|
32
|
+
import { StarterKit as De } from "@tiptap/starter-kit";
|
|
33
|
+
import { Link as Oe } from "@tiptap/extension-link";
|
|
34
|
+
import { Table as ke, TableKit as Ae, createTable as je } from "@tiptap/extension-table";
|
|
35
|
+
import { Fragment as Me, Slice as Ne } from "@tiptap/pm/model";
|
|
36
|
+
import { NodeSelection as Pe, Plugin as Fe, TextSelection as Ie } from "@tiptap/pm/state";
|
|
37
|
+
import { closeHistory as K } from "@tiptap/pm/history";
|
|
38
|
+
import { deleteColumn as Le, deleteRow as Re } from "@tiptap/pm/tables";
|
|
39
|
+
//#region src/components/RichTextEditor/expansion.tsx
|
|
40
|
+
function ze(e, t) {
|
|
41
|
+
let n = t.querySelector(".ds-rte__content");
|
|
42
|
+
if (!n) return;
|
|
43
|
+
let r = e.view.coordsAtPos(e.state.selection.head), i = n.getBoundingClientRect();
|
|
44
|
+
(r.top < i.top || r.bottom > i.bottom) && (n.scrollTop += r.top - i.top - i.height / 2);
|
|
45
|
+
}
|
|
46
|
+
function Be({ editor: e, disabled: n, isHeld: a = !1, invalid: o, label: u, labelledBy: d, expandedWidth: f, frameRef: m }) {
|
|
47
|
+
let h = c("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
|
+
g && n && !a && _(!1);
|
|
49
|
+
let E = L(() => {
|
|
50
|
+
C.current = document.activeElement === S.current, _(!1);
|
|
51
|
+
}, []);
|
|
52
|
+
l(() => {
|
|
53
|
+
h && (s(h, g ? x.current : b.current), w.current !== g && (w.current = g, n || !e ? r(document.activeElement) && i(m.current, { preventScroll: !0 }) : (ze(e, h), !g && C.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), C.current = !1)));
|
|
54
|
+
}, [
|
|
55
|
+
h,
|
|
56
|
+
g,
|
|
57
|
+
e,
|
|
58
|
+
n,
|
|
59
|
+
m
|
|
60
|
+
]);
|
|
61
|
+
let D = g ? "Collapse editor" : "Expand editor";
|
|
62
|
+
return {
|
|
63
|
+
expanded: g,
|
|
64
|
+
toggle: /* @__PURE__ */ W(t, {
|
|
65
|
+
ref: S,
|
|
66
|
+
size: "sm",
|
|
67
|
+
isIconOnly: !0,
|
|
68
|
+
iconStart: g ? "minimize-2" : "maximize-2",
|
|
69
|
+
className: "ds-rte__expand",
|
|
70
|
+
"aria-label": D,
|
|
71
|
+
title: D,
|
|
72
|
+
"aria-expanded": g,
|
|
73
|
+
"aria-controls": g ? T : void 0,
|
|
74
|
+
isDisabled: n || !e || !h,
|
|
75
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
76
|
+
onClick: () => {
|
|
77
|
+
g ? E() : (y(m.current.getBoundingClientRect().height), _(!0));
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
surfaceSlot: (e) => /* @__PURE__ */ W("div", {
|
|
81
|
+
ref: b,
|
|
82
|
+
className: "ds-rte__slot",
|
|
83
|
+
children: h ? he(e, h) : e
|
|
84
|
+
}),
|
|
85
|
+
dialog: /* @__PURE__ */ W(p, {
|
|
86
|
+
id: T,
|
|
87
|
+
isOpen: g,
|
|
88
|
+
onClose: E,
|
|
89
|
+
title: u,
|
|
90
|
+
hasHeader: !1,
|
|
91
|
+
size: f === "full" ? "full" : "wide",
|
|
92
|
+
className: "ds-rte__modal",
|
|
93
|
+
"data-invalid": o || void 0,
|
|
94
|
+
"aria-labelledby": d,
|
|
95
|
+
children: /* @__PURE__ */ W("div", {
|
|
96
|
+
ref: x,
|
|
97
|
+
className: "ds-rte__expanded-slot"
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
frameStyle: g ? { minBlockSize: v } : void 0
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/RichTextEditor/storyblock.ts
|
|
105
|
+
function Ve(e) {
|
|
106
|
+
let t = (e) => typeof e == "string" && e.trim().length > 0;
|
|
107
|
+
return [
|
|
108
|
+
"left",
|
|
109
|
+
"full",
|
|
110
|
+
"right"
|
|
111
|
+
].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);
|
|
112
|
+
}
|
|
113
|
+
function q(e) {
|
|
114
|
+
return {
|
|
115
|
+
...e,
|
|
116
|
+
...e.type === "storyblock" && e.attrs ? { attrs: {
|
|
117
|
+
type: e.attrs.type,
|
|
118
|
+
...e.attrs.type === "entry" ? {
|
|
119
|
+
id: e.attrs.id,
|
|
120
|
+
entryId: e.attrs.entryId
|
|
121
|
+
} : { assetId: e.attrs.assetId },
|
|
122
|
+
align: e.attrs.align ?? "full"
|
|
123
|
+
} } : {},
|
|
124
|
+
...e.content ? { content: e.content.map(q) } : {}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
var He = _e.create({
|
|
128
|
+
name: "storyblock",
|
|
129
|
+
group: "block",
|
|
130
|
+
atom: !0,
|
|
131
|
+
draggable: !0,
|
|
132
|
+
selectable: !0,
|
|
133
|
+
marks: "",
|
|
134
|
+
addAttributes() {
|
|
135
|
+
return Object.fromEntries([
|
|
136
|
+
"type",
|
|
137
|
+
"id",
|
|
138
|
+
"entryId",
|
|
139
|
+
"assetId",
|
|
140
|
+
"align"
|
|
141
|
+
].map((e) => [e, {
|
|
142
|
+
default: e === "align" ? "full" : null,
|
|
143
|
+
parseHTML: (t) => t.getAttribute(`data-storyblock-${e.toLowerCase()}`),
|
|
144
|
+
renderHTML: () => ({})
|
|
145
|
+
}]));
|
|
146
|
+
},
|
|
147
|
+
parseHTML() {
|
|
148
|
+
return [{
|
|
149
|
+
tag: "div[data-storyblock]",
|
|
150
|
+
getAttrs: (e) => Ve(Object.fromEntries([
|
|
151
|
+
"type",
|
|
152
|
+
"id",
|
|
153
|
+
"entryId",
|
|
154
|
+
"assetId",
|
|
155
|
+
"align"
|
|
156
|
+
].map((t) => [t, e.getAttribute(`data-storyblock-${t.toLowerCase()}`)]))) ? null : !1
|
|
157
|
+
}];
|
|
158
|
+
},
|
|
159
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
160
|
+
let n = q({
|
|
161
|
+
type: "storyblock",
|
|
162
|
+
attrs: e.attrs
|
|
163
|
+
}).attrs;
|
|
164
|
+
return ["div", Ce(t, {
|
|
165
|
+
"data-storyblock": "",
|
|
166
|
+
...Object.fromEntries(Object.entries(n).map(([e, t]) => [`data-storyblock-${e.toLowerCase()}`, t]))
|
|
167
|
+
})];
|
|
168
|
+
}
|
|
169
|
+
}), J = {
|
|
170
|
+
type: "doc",
|
|
171
|
+
content: [{ type: "paragraph" }]
|
|
172
|
+
}, Ue = [De.configure({
|
|
173
|
+
link: !1,
|
|
174
|
+
trailingNode: { notAfter: ["paragraph", "storyblock"] }
|
|
175
|
+
}), Oe.configure({
|
|
176
|
+
openOnClick: !1,
|
|
177
|
+
autolink: !0
|
|
178
|
+
})];
|
|
179
|
+
function We(e) {
|
|
180
|
+
if (!e.size) return e;
|
|
181
|
+
let t = [], n = !1;
|
|
182
|
+
return e.forEach((e) => {
|
|
183
|
+
let r = We(e.content), i = e.attrs.colwidth == null ? e.copy(r) : e.type.create({
|
|
184
|
+
...e.attrs,
|
|
185
|
+
colwidth: null
|
|
186
|
+
}, r, e.marks);
|
|
187
|
+
t.push(i), n ||= i !== e;
|
|
188
|
+
}), n ? Me.fromArray(t) : e;
|
|
189
|
+
}
|
|
190
|
+
function Ge() {
|
|
191
|
+
let e = null, t = (t) => (t.state.selection.empty || (e = t.state.selection.content()), !1);
|
|
192
|
+
return new Fe({ props: {
|
|
193
|
+
handleDOMEvents: {
|
|
194
|
+
copy: t,
|
|
195
|
+
cut: t
|
|
196
|
+
},
|
|
197
|
+
transformPasted(t, n) {
|
|
198
|
+
if ([e, n.dragging?.slice].some((e) => e?.eq(t))) return t;
|
|
199
|
+
let r = We(t.content);
|
|
200
|
+
return r === t.content ? t : new Ne(r, t.openStart, t.openEnd);
|
|
201
|
+
}
|
|
202
|
+
} });
|
|
203
|
+
}
|
|
204
|
+
var Ke = ke.extend({
|
|
205
|
+
addProseMirrorPlugins() {
|
|
206
|
+
return [...this.parent?.() ?? [], Ge()];
|
|
207
|
+
},
|
|
208
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
209
|
+
let n = [
|
|
210
|
+
"table",
|
|
211
|
+
Ce(this.options.HTMLAttributes, t),
|
|
212
|
+
["tbody", 0]
|
|
213
|
+
];
|
|
214
|
+
return e.firstChild?.children.some(({ attrs: e }) => Array.isArray(e.colwidth) && e.colwidth.some(Boolean)) ? this.parent?.({
|
|
215
|
+
node: e,
|
|
216
|
+
HTMLAttributes: t
|
|
217
|
+
}) ?? n : n;
|
|
218
|
+
}
|
|
219
|
+
}).configure({ cellMinWidth: 80 }), qe = Ae.configure({ table: !1 });
|
|
220
|
+
function Je(e = He, { tables: t = !0 } = {}) {
|
|
221
|
+
return t ? [
|
|
222
|
+
e,
|
|
223
|
+
...Ue,
|
|
224
|
+
Ke,
|
|
225
|
+
qe
|
|
226
|
+
] : [e, ...Ue];
|
|
227
|
+
}
|
|
228
|
+
var Ye = {
|
|
229
|
+
withTables: Se(Je()),
|
|
230
|
+
withoutTables: Se(Je(He, { tables: !1 }))
|
|
231
|
+
};
|
|
232
|
+
function Y(e) {
|
|
233
|
+
return e.content?.length ? e : {
|
|
234
|
+
...e,
|
|
235
|
+
content: J.content
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function Xe(e, { tables: t = !0 } = {}) {
|
|
239
|
+
let n = t ? Ye.withTables : Ye.withoutTables;
|
|
240
|
+
try {
|
|
241
|
+
if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
|
|
242
|
+
let t = (e) => {
|
|
243
|
+
let r = n.nodes[e.type ?? ""];
|
|
244
|
+
if (!r || Object.keys(e).some((e) => ![
|
|
245
|
+
"type",
|
|
246
|
+
"attrs",
|
|
247
|
+
"content",
|
|
248
|
+
"marks",
|
|
249
|
+
"text"
|
|
250
|
+
].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 === "storyblock" && (!Ve(e.attrs ?? {}) || e.marks?.length)) throw Error();
|
|
251
|
+
for (let t of e.marks ?? []) {
|
|
252
|
+
let e = n.marks[t.type];
|
|
253
|
+
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();
|
|
254
|
+
}
|
|
255
|
+
e.content?.forEach(t);
|
|
256
|
+
}, r = e;
|
|
257
|
+
t(r), n.nodeFromJSON(Y(r)).check();
|
|
258
|
+
} catch {
|
|
259
|
+
return "Unsupported or invalid rich-text document.";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/components/RichTextEditor/embed-context.ts
|
|
264
|
+
function X(e) {
|
|
265
|
+
return !!(e && (e.loadPage || e.items?.length || e.onCreate));
|
|
266
|
+
}
|
|
267
|
+
function Ze(e) {
|
|
268
|
+
return !!(e && (e.loadPage || e.items?.length));
|
|
269
|
+
}
|
|
270
|
+
var Qe = fe({
|
|
271
|
+
views: {},
|
|
272
|
+
disabled: !1,
|
|
273
|
+
busy: !1,
|
|
274
|
+
pickCount: 0,
|
|
275
|
+
replace: () => {},
|
|
276
|
+
seed: () => void 0,
|
|
277
|
+
forgetSeed: () => {}
|
|
278
|
+
}), $e = [], et = [
|
|
279
|
+
{
|
|
280
|
+
align: "left",
|
|
281
|
+
icon: "align-left",
|
|
282
|
+
label: "Align left"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
align: "full",
|
|
286
|
+
icon: "align-justify",
|
|
287
|
+
label: "Full width"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
align: "right",
|
|
291
|
+
icon: "align-right",
|
|
292
|
+
label: "Align right"
|
|
293
|
+
}
|
|
294
|
+
];
|
|
295
|
+
function tt(e, t) {
|
|
296
|
+
let { views: n, seed: r, forgetSeed: i } = me(Qe), a = n[e], o = a?.items ?? $e, s = B(() => [t], [t]), c = L((t) => r(e, t), [r, e]), l = E(s, o, a?.resolveItem, a?.refreshKey, c), u = r(e, t);
|
|
297
|
+
R(() => {
|
|
298
|
+
u && i(e, t, u);
|
|
299
|
+
}, [
|
|
300
|
+
i,
|
|
301
|
+
e,
|
|
302
|
+
t,
|
|
303
|
+
u
|
|
304
|
+
]);
|
|
305
|
+
let { known: d, failures: f } = l, p = !!a?.resolveItem, m = B(() => b({
|
|
306
|
+
selected: s,
|
|
307
|
+
items: o,
|
|
308
|
+
pageItems: $e,
|
|
309
|
+
known: d,
|
|
310
|
+
failures: f,
|
|
311
|
+
hasResolver: p,
|
|
312
|
+
itemLabel: e
|
|
313
|
+
})[0], [
|
|
314
|
+
s,
|
|
315
|
+
o,
|
|
316
|
+
d,
|
|
317
|
+
f,
|
|
318
|
+
p,
|
|
319
|
+
e
|
|
320
|
+
]), h = w(`Couldn't load ${e}`, l.status, l.error, l.retry), g = o.some((e) => e.id === t);
|
|
321
|
+
return {
|
|
322
|
+
view: a,
|
|
323
|
+
item: m,
|
|
324
|
+
missing: m.tone === "removed" || !g && d.has(t) && !d.get(t),
|
|
325
|
+
failure: h
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function nt({ kind: t, isMovable: n, onSelect: r }) {
|
|
329
|
+
return /* @__PURE__ */ G("span", {
|
|
330
|
+
className: "ds-storyblock__kind",
|
|
331
|
+
"data-drag-handle": n ? "" : void 0,
|
|
332
|
+
draggable: n || void 0,
|
|
333
|
+
title: n ? "Drag to move" : void 0,
|
|
334
|
+
onClick: n ? r : void 0,
|
|
335
|
+
children: [n && /* @__PURE__ */ W("span", {
|
|
336
|
+
className: "ds-storyblock__grip",
|
|
337
|
+
"aria-hidden": "true",
|
|
338
|
+
children: /* @__PURE__ */ W(e, {
|
|
339
|
+
name: "grip-vertical",
|
|
340
|
+
size: 16
|
|
341
|
+
})
|
|
342
|
+
}), /* @__PURE__ */ W(d, {
|
|
343
|
+
className: "ds-storyblock__kind-label",
|
|
344
|
+
shape: "tag",
|
|
345
|
+
size: "sm",
|
|
346
|
+
children: t
|
|
347
|
+
})]
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function rt({ kind: e, name: n, align: r, isSelected: i, isLocked: a, missing: o, canReplace: s, onEdit: c, onSelect: l, onAlign: d, onReplace: f, onRemove: p }) {
|
|
351
|
+
let [m, h] = H(!1), y = `Block actions for ${n}`, b = {
|
|
352
|
+
size: "sm",
|
|
353
|
+
isIconOnly: !0,
|
|
354
|
+
iconStart: "more-horizontal",
|
|
355
|
+
"aria-label": y
|
|
356
|
+
};
|
|
357
|
+
return /* @__PURE__ */ G("div", {
|
|
358
|
+
className: "ds-storyblock__bar ds-field-surface",
|
|
359
|
+
children: [/* @__PURE__ */ W(nt, {
|
|
360
|
+
kind: e,
|
|
361
|
+
isMovable: !a,
|
|
362
|
+
onSelect: l
|
|
363
|
+
}), a ? /* @__PURE__ */ W(t, {
|
|
364
|
+
...b,
|
|
365
|
+
variant: "simple",
|
|
366
|
+
isDisabled: !0,
|
|
367
|
+
"aria-haspopup": "menu",
|
|
368
|
+
"aria-expanded": !1
|
|
369
|
+
}) : /* @__PURE__ */ G(g, {
|
|
370
|
+
"aria-label": y,
|
|
371
|
+
align: "end",
|
|
372
|
+
trigger: (e) => /* @__PURE__ */ W(t, {
|
|
373
|
+
...e,
|
|
374
|
+
...b,
|
|
375
|
+
variant: e["aria-expanded"] ? "active" : "simple",
|
|
376
|
+
tabIndex: i || m || e["aria-expanded"] ? 0 : -1,
|
|
377
|
+
onFocus: () => h(!0),
|
|
378
|
+
onBlur: () => h(!1)
|
|
379
|
+
}),
|
|
380
|
+
children: [
|
|
381
|
+
/* @__PURE__ */ W(u, {
|
|
382
|
+
"aria-label": "Alignment",
|
|
383
|
+
children: et.map((e) => /* @__PURE__ */ W(t, {
|
|
384
|
+
role: "menuitemradio",
|
|
385
|
+
"aria-checked": r === e.align,
|
|
386
|
+
"aria-label": e.label,
|
|
387
|
+
title: e.label,
|
|
388
|
+
size: "sm",
|
|
389
|
+
isIconOnly: !0,
|
|
390
|
+
iconStart: e.icon,
|
|
391
|
+
variant: r === e.align ? "primary" : "neutral",
|
|
392
|
+
onClick: (t) => {
|
|
393
|
+
t.preventDefault(), d(e.align);
|
|
394
|
+
}
|
|
395
|
+
}, e.align))
|
|
396
|
+
}),
|
|
397
|
+
(c || s.isShown) && /* @__PURE__ */ W(v, {}),
|
|
398
|
+
c && /* @__PURE__ */ G(_, {
|
|
399
|
+
icon: "pencil",
|
|
400
|
+
onClick: c,
|
|
401
|
+
children: ["Edit ", e]
|
|
402
|
+
}),
|
|
403
|
+
s.isShown && /* @__PURE__ */ W(_, {
|
|
404
|
+
icon: "rotate-cw",
|
|
405
|
+
isDisabled: !s.isEnabled,
|
|
406
|
+
onClick: f,
|
|
407
|
+
children: o ? `Choose another ${e}` : "Replace"
|
|
408
|
+
}),
|
|
409
|
+
/* @__PURE__ */ W(v, {}),
|
|
410
|
+
/* @__PURE__ */ W(_, {
|
|
411
|
+
tone: "danger",
|
|
412
|
+
icon: "trash",
|
|
413
|
+
onClick: p,
|
|
414
|
+
children: "Remove from field"
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
})]
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function it({ kind: e, id: t, item: n, missing: r }) {
|
|
421
|
+
return /* @__PURE__ */ W("div", {
|
|
422
|
+
className: "ds-entry ds-storyblock__body",
|
|
423
|
+
children: r ? /* @__PURE__ */ G("span", {
|
|
424
|
+
className: "ds-entry__body",
|
|
425
|
+
children: [/* @__PURE__ */ W("em", {
|
|
426
|
+
className: "ds-entry__title",
|
|
427
|
+
children: `Unavailable ${e}`
|
|
428
|
+
}), /* @__PURE__ */ G("span", {
|
|
429
|
+
className: "ds-entry__meta",
|
|
430
|
+
children: [/* @__PURE__ */ W("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ W("code", { children: t })]
|
|
431
|
+
})]
|
|
432
|
+
}) : /* @__PURE__ */ W(S, { item: n })
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function at({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
|
|
436
|
+
let { disabled: a, busy: o, replace: s } = me(Qe), c = e.attrs.type, l = String(c === "entry" ? e.attrs.entryId : e.attrs.assetId), { view: u, item: d, missing: f, failure: p } = tt(c, l), m = e.attrs.align ?? "full", h = !f && !d.isUnavailable && !d.isDisabled && u?.onEditItem, g = t && !a, _ = () => {
|
|
437
|
+
let e = r();
|
|
438
|
+
e !== void 0 && n.chain().focus().setNodeSelection(e).run();
|
|
439
|
+
};
|
|
440
|
+
return /* @__PURE__ */ G(ve, {
|
|
441
|
+
className: "ds-storyblock ds-field-surface",
|
|
442
|
+
"data-align": m,
|
|
443
|
+
"data-selected": g || void 0,
|
|
444
|
+
"data-missing": f || void 0,
|
|
445
|
+
"data-tone": f ? "removed" : d.tone,
|
|
446
|
+
contentEditable: !1,
|
|
447
|
+
onMouseDown: (e) => {
|
|
448
|
+
let t = e.target;
|
|
449
|
+
t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), _()));
|
|
450
|
+
},
|
|
451
|
+
children: [
|
|
452
|
+
a ? /* @__PURE__ */ W("div", {
|
|
453
|
+
className: "ds-storyblock__bar ds-field-surface",
|
|
454
|
+
children: /* @__PURE__ */ W(nt, {
|
|
455
|
+
kind: c,
|
|
456
|
+
isMovable: !1
|
|
457
|
+
})
|
|
458
|
+
}) : /* @__PURE__ */ W(rt, {
|
|
459
|
+
kind: c,
|
|
460
|
+
name: f ? `Unavailable ${c}` : d.title,
|
|
461
|
+
align: m,
|
|
462
|
+
missing: f,
|
|
463
|
+
isSelected: g,
|
|
464
|
+
isLocked: !!u?.isDialogHidden,
|
|
465
|
+
canReplace: {
|
|
466
|
+
isShown: !!u?.canEmbed,
|
|
467
|
+
isEnabled: !!u?.canEmbed && !o
|
|
468
|
+
},
|
|
469
|
+
onEdit: h ? () => h(d) : void 0,
|
|
470
|
+
onSelect: _,
|
|
471
|
+
onAlign: (e) => i({ align: e }),
|
|
472
|
+
onReplace: () => {
|
|
473
|
+
let e = r();
|
|
474
|
+
e !== void 0 && s(c, e);
|
|
475
|
+
},
|
|
476
|
+
onRemove: () => {
|
|
477
|
+
let t = r();
|
|
478
|
+
t !== void 0 && n.chain().focus().setNodeSelection(t).deleteRange({
|
|
479
|
+
from: t,
|
|
480
|
+
to: t + e.nodeSize
|
|
481
|
+
}).run();
|
|
482
|
+
}
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ W(it, {
|
|
485
|
+
kind: c,
|
|
486
|
+
id: l,
|
|
487
|
+
item: d,
|
|
488
|
+
missing: f
|
|
489
|
+
}),
|
|
490
|
+
p && /* @__PURE__ */ W("div", {
|
|
491
|
+
className: "ds-storyblock__failure",
|
|
492
|
+
children: p
|
|
493
|
+
})
|
|
494
|
+
]
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/components/RichTextEditor/use-embeds.tsx
|
|
499
|
+
var ot = "ds-rte-embed-commit", st = ["entry", "asset"], ct = {
|
|
500
|
+
entry: {
|
|
501
|
+
itemLabel: "entry",
|
|
502
|
+
itemsLabel: "entries"
|
|
503
|
+
},
|
|
504
|
+
asset: {
|
|
505
|
+
itemLabel: "asset",
|
|
506
|
+
itemsLabel: "assets"
|
|
507
|
+
}
|
|
508
|
+
}, lt = {}, ut = [];
|
|
509
|
+
function dt(e, t, n) {
|
|
510
|
+
return {
|
|
511
|
+
type: e,
|
|
512
|
+
align: t,
|
|
513
|
+
...e === "entry" ? {
|
|
514
|
+
id: n.modelId,
|
|
515
|
+
entryId: n.id
|
|
516
|
+
} : { assetId: n.id }
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function ft(e, t, n, { replacing: r, multiple: i }) {
|
|
520
|
+
let a = e.chain().focus().setMeta(ot, !0);
|
|
521
|
+
return i && a.command(({ tr: e }) => (K(e), !0)), r ? a.setNodeSelection(t).updateAttributes("storyblock", n[0].attrs).run() : a.insertContentAt(t, n).setNodeSelection(t + n.length - 1).run();
|
|
522
|
+
}
|
|
523
|
+
function pt(e, t) {
|
|
524
|
+
if (t.tone === "removed") return {
|
|
525
|
+
label: t.removedLabel ?? "Removed",
|
|
526
|
+
description: `This ${e} was removed.`
|
|
527
|
+
};
|
|
528
|
+
if (t.isUnavailable) return {
|
|
529
|
+
label: "Unavailable",
|
|
530
|
+
description: `This ${e} is unavailable.`
|
|
531
|
+
};
|
|
532
|
+
if (!Ve(dt(e, "full", t))) return {
|
|
533
|
+
label: "Can't embed",
|
|
534
|
+
description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function mt(e, t) {
|
|
538
|
+
return !t.isDisabled && !pt(e, t);
|
|
539
|
+
}
|
|
540
|
+
function ht(e, t, n, r) {
|
|
541
|
+
let i = e.flatMap((e) => {
|
|
542
|
+
let i = r(e.item.id);
|
|
543
|
+
return i === void 0 ? [e] : !i || !mt(t, i) ? [] : i === e.item && Object.is(n, e.revision) ? [e] : [{
|
|
544
|
+
item: i,
|
|
545
|
+
revision: n
|
|
546
|
+
}];
|
|
547
|
+
});
|
|
548
|
+
return i.length !== e.length || i.some((t, n) => t !== e[n]) ? i : e;
|
|
549
|
+
}
|
|
550
|
+
var gt = {
|
|
551
|
+
entry: (e) => pt("entry", e),
|
|
552
|
+
asset: (e) => pt("asset", e)
|
|
553
|
+
};
|
|
554
|
+
function _t(e, t) {
|
|
555
|
+
return e?.type.name === "storyblock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
|
|
556
|
+
}
|
|
557
|
+
function vt(e) {
|
|
558
|
+
return e.flatMap((e) => e.mapping.maps);
|
|
559
|
+
}
|
|
560
|
+
function yt(e, t) {
|
|
561
|
+
let n = t;
|
|
562
|
+
for (let t of vt(e)) {
|
|
563
|
+
let e = n, r;
|
|
564
|
+
if (t.forEach((t, n, i, a) => {
|
|
565
|
+
r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
|
|
566
|
+
}), r !== void 0) {
|
|
567
|
+
n = r;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
let i = t.mapResult(e, 1);
|
|
571
|
+
if (i.deletedAfter) return null;
|
|
572
|
+
n = i.pos;
|
|
573
|
+
}
|
|
574
|
+
return n;
|
|
575
|
+
}
|
|
576
|
+
function bt(e, t, n) {
|
|
577
|
+
let r = t, i = n;
|
|
578
|
+
for (let t of vt(e)) {
|
|
579
|
+
if (r === i) {
|
|
580
|
+
r = i = t.map(i, -1);
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
let e = !1;
|
|
584
|
+
if (t.forEach((t, n, a, o) => {
|
|
585
|
+
let s = i - r === 1 && t === r && n === i && o - a === 1;
|
|
586
|
+
e ||= t <= r && i <= n && !s;
|
|
587
|
+
}), r = t.map(r, 1), i = t.map(i, -1), e || i <= r) return null;
|
|
588
|
+
}
|
|
589
|
+
return {
|
|
590
|
+
from: r,
|
|
591
|
+
to: i
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function xt(e, t) {
|
|
595
|
+
let n = e.resolve(Math.min(t, e.content.size));
|
|
596
|
+
return n.depth ? n.after(1) : n.pos;
|
|
597
|
+
}
|
|
598
|
+
function St(e, t, n) {
|
|
599
|
+
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = X(e);
|
|
600
|
+
return B(() => r ? {
|
|
601
|
+
resolveItem: i ? t : void 0,
|
|
602
|
+
refreshKey: o,
|
|
603
|
+
items: s,
|
|
604
|
+
isDialogHidden: c,
|
|
605
|
+
canEmbed: l,
|
|
606
|
+
onEditItem: a ? n : void 0
|
|
607
|
+
} : void 0, [
|
|
608
|
+
r,
|
|
609
|
+
i,
|
|
610
|
+
a,
|
|
611
|
+
o,
|
|
612
|
+
s,
|
|
613
|
+
c,
|
|
614
|
+
l,
|
|
615
|
+
t,
|
|
616
|
+
n
|
|
617
|
+
]);
|
|
618
|
+
}
|
|
619
|
+
function Ct({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: s }) {
|
|
620
|
+
let { itemLabel: c, itemsLabel: l } = ct[e.kind], { multiple: u } = e, d = !!t.isCreating, [f, p] = H([]), [m, h] = H(""), g = o(f.length), _ = B(() => e.replaceId ? [e.replaceId] : f.map(({ item: e }) => e.id), [e, f]), v = C(_, t.items ?? ut, {
|
|
621
|
+
...t,
|
|
622
|
+
resolveItem: u ? t.resolveItem : void 0,
|
|
623
|
+
mode: u ? "multiple" : "single",
|
|
624
|
+
max: void 0
|
|
625
|
+
}, {
|
|
626
|
+
isOpen: !0,
|
|
627
|
+
isDisabled: n || d,
|
|
628
|
+
itemLabel: c,
|
|
629
|
+
itemsLabel: l,
|
|
630
|
+
close: i,
|
|
631
|
+
recheckSelection: u,
|
|
632
|
+
restrict: gt[e.kind]
|
|
633
|
+
}), b = w(`Couldn't load selected ${l}`, v.selection.status, v.selection.error, v.selection.retry), x = e.replaceId ? "Replace" : "Embed", S = ht(f, e.kind, t.refreshKey, (e) => v.isRemote ? v.selection.current.get(e) : t.items?.find((t) => t.id === e) ?? null), T = f.length - S.length;
|
|
634
|
+
S !== f && p(S), T > 0 && h(`${T} unavailable ${T === 1 ? c : l} removed from selection.`);
|
|
635
|
+
let E = !n && !d && v.selection.status === "ready" && S.length > 0 && T === 0, D = () => {
|
|
636
|
+
E && s(S);
|
|
637
|
+
};
|
|
638
|
+
return /* @__PURE__ */ W(y, {
|
|
639
|
+
...v.dialog,
|
|
640
|
+
isOpen: !0,
|
|
641
|
+
onClose: i,
|
|
642
|
+
onToggle: (e) => {
|
|
643
|
+
let t = v.choice(e);
|
|
644
|
+
if (!t) return;
|
|
645
|
+
let n = {
|
|
646
|
+
item: t,
|
|
647
|
+
revision: v.revision
|
|
648
|
+
};
|
|
649
|
+
u ? (h(""), _.includes(e) ? p((t) => t.filter(({ item: t }) => t.id !== e)) : (v.selection.remember([t], n.revision, [..._, e]), p((e) => [...e, n]))) : s([n]);
|
|
650
|
+
},
|
|
651
|
+
addLabel: `${x} ${u ? l : c}`,
|
|
652
|
+
confirm: u ? {
|
|
653
|
+
label: "Insert selected",
|
|
654
|
+
isDisabled: !E,
|
|
655
|
+
onClick: D
|
|
656
|
+
} : void 0,
|
|
657
|
+
selectionNotice: m,
|
|
658
|
+
selectionFailure: b,
|
|
659
|
+
onCreate: t.onCreate ? () => t.onCreate?.({
|
|
660
|
+
available: () => g.current === 0 && a.available(),
|
|
661
|
+
commit: (e) => g.current === 0 && a.commit(e)
|
|
662
|
+
}) : void 0,
|
|
663
|
+
isCreateDisabled: f.length > 0,
|
|
664
|
+
isCreating: t.isCreating,
|
|
665
|
+
dialogTitle: t.dialogTitle,
|
|
666
|
+
dialogDescription: `${u ? `Choose ${l}` : `Choose one ${c}`} to embed in ${r}. ${t.dialogDescription ?? ""}`.trim(),
|
|
667
|
+
isDialogHidden: t.isDialogHidden
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function wt(e, n = lt, r, i) {
|
|
671
|
+
let [a, s] = H(null), c = V(0), l = V({
|
|
672
|
+
session: null,
|
|
673
|
+
editor: null,
|
|
674
|
+
from: 0,
|
|
675
|
+
to: 0,
|
|
676
|
+
alive: !1
|
|
677
|
+
}), d = V(/* @__PURE__ */ new Map()), [f, p] = H(0), m = L(() => {
|
|
678
|
+
l.current.alive = !1, s(null);
|
|
679
|
+
}, []), h = a ? n[a.kind] : void 0, g = a && X(h) && (!r || h?.isCreating) ? a : null;
|
|
680
|
+
a && !g && s(null);
|
|
681
|
+
let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = o({
|
|
682
|
+
editor: e,
|
|
683
|
+
sources: n,
|
|
684
|
+
disabled: r,
|
|
685
|
+
busy: _
|
|
686
|
+
});
|
|
687
|
+
R(() => {
|
|
688
|
+
if (!e || !a) return;
|
|
689
|
+
if (l.current.session === a && l.current.editor !== e) {
|
|
690
|
+
m();
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
l.current.alive = !0;
|
|
694
|
+
let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
|
|
695
|
+
let r = [t, ...n];
|
|
696
|
+
if (!l.current.alive || !r.some((e) => e.docChanged)) return;
|
|
697
|
+
let { from: i, to: o } = l.current;
|
|
698
|
+
if (a.replaceId === void 0) {
|
|
699
|
+
let e = bt(r, i, o);
|
|
700
|
+
e ? Object.assign(l.current, e) : m();
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
let s = yt(r, i);
|
|
704
|
+
s === null || !_t(e.state.doc.nodeAt(s), a) ? m() : Object.assign(l.current, {
|
|
705
|
+
from: s,
|
|
706
|
+
to: s + 1
|
|
707
|
+
});
|
|
708
|
+
};
|
|
709
|
+
return e.on("transaction", t), () => {
|
|
710
|
+
e.off("transaction", t), l.current.session === a && (l.current.alive = !1);
|
|
711
|
+
};
|
|
712
|
+
}, [
|
|
713
|
+
e,
|
|
714
|
+
a,
|
|
715
|
+
m
|
|
716
|
+
]);
|
|
717
|
+
let y = (e) => {
|
|
718
|
+
let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
|
|
719
|
+
return !(!t || t.isDestroyed || l.current.session !== e || l.current.editor !== t || !l.current.alive || !X(i) || r && !i?.isCreating);
|
|
720
|
+
}, b = (e, t, n = !1) => {
|
|
721
|
+
let r = v.current.editor, i = e.replaceId !== void 0;
|
|
722
|
+
if (!r || !y(e) || !t.length || (!n || i) && t.length !== 1 || t.some(({ item: t }) => !mt(e.kind, t))) return !1;
|
|
723
|
+
let { doc: a } = r.state, o = i ? a.nodeAt(l.current.from) : null;
|
|
724
|
+
if (i && !_t(o, e)) return !1;
|
|
725
|
+
let s = t.map(({ item: t }) => ({
|
|
726
|
+
type: "storyblock",
|
|
727
|
+
attrs: dt(e.kind, o?.attrs.align ?? "full", t)
|
|
728
|
+
})), c = i ? l.current.from : xt(a, l.current.to);
|
|
729
|
+
l.current.alive = !1, d.current = new Map(t.map((t) => [`${e.kind}:${t.item.id}`, t]));
|
|
730
|
+
let u = !1;
|
|
731
|
+
try {
|
|
732
|
+
u = ft(r, c, s, {
|
|
733
|
+
replacing: i,
|
|
734
|
+
multiple: n
|
|
735
|
+
});
|
|
736
|
+
} catch {
|
|
737
|
+
u = !1;
|
|
738
|
+
} finally {
|
|
739
|
+
m();
|
|
740
|
+
}
|
|
741
|
+
return u ? (n && !r.isDestroyed && r.view.dispatch(K(r.state.tr)), p((e) => e + 1)) : d.current.clear(), u;
|
|
742
|
+
}, x = (e, t) => {
|
|
743
|
+
let { editor: n, sources: r, disabled: i, busy: a } = v.current;
|
|
744
|
+
if (!n || i || a || !X(r[e])) return;
|
|
745
|
+
let o = t === void 0 ? null : n.state.doc.nodeAt(t);
|
|
746
|
+
if (t !== void 0 && (o?.type.name !== "storyblock" || o.attrs.type !== e)) return;
|
|
747
|
+
let { $from: u, from: d, to: f } = n.state.selection, p = {
|
|
748
|
+
id: c.current += 1,
|
|
749
|
+
kind: e,
|
|
750
|
+
multiple: t === void 0 && Ze(r[e]),
|
|
751
|
+
replaceId: o ? String(e === "entry" ? o.attrs.entryId : o.attrs.assetId) : void 0
|
|
752
|
+
}, m = t === void 0 ? u.depth ? {
|
|
753
|
+
from: u.before(1),
|
|
754
|
+
to: u.after(1)
|
|
755
|
+
} : {
|
|
756
|
+
from: d,
|
|
757
|
+
to: f
|
|
758
|
+
} : {
|
|
759
|
+
from: t,
|
|
760
|
+
to: t + 1
|
|
761
|
+
};
|
|
762
|
+
l.current = {
|
|
763
|
+
session: p,
|
|
764
|
+
editor: n,
|
|
765
|
+
...m,
|
|
766
|
+
alive: !0
|
|
767
|
+
}, s(p);
|
|
768
|
+
}, S = o({ open: x }), [C] = H(() => ({
|
|
769
|
+
replace: (e, t) => S.current.open(e, t),
|
|
770
|
+
seed: (e, t) => d.current.get(`${e}:${t}`),
|
|
771
|
+
forgetSeed: (e, t, n) => {
|
|
772
|
+
d.current.get(`${e}:${t}`) === n && d.current.delete(`${e}:${t}`);
|
|
773
|
+
},
|
|
774
|
+
resolve: {
|
|
775
|
+
entry: (e) => v.current.sources.entry?.resolveItem?.(e) ?? null,
|
|
776
|
+
asset: (e) => v.current.sources.asset?.resolveItem?.(e) ?? null
|
|
777
|
+
},
|
|
778
|
+
edit: {
|
|
779
|
+
entry: (e) => {
|
|
780
|
+
v.current.sources.entry?.onEditItem?.(e);
|
|
781
|
+
},
|
|
782
|
+
asset: (e) => {
|
|
783
|
+
v.current.sources.asset?.onEditItem?.(e);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
})), w = St(n.entry, C.resolve.entry, C.edit.entry), T = St(n.asset, C.resolve.asset, C.edit.asset), E = B(() => ({
|
|
787
|
+
views: {
|
|
788
|
+
entry: w,
|
|
789
|
+
asset: T
|
|
790
|
+
},
|
|
791
|
+
disabled: r,
|
|
792
|
+
busy: _,
|
|
793
|
+
pickCount: f,
|
|
794
|
+
replace: C.replace,
|
|
795
|
+
seed: C.seed,
|
|
796
|
+
forgetSeed: C.forgetSeed
|
|
797
|
+
}), [
|
|
798
|
+
w,
|
|
799
|
+
T,
|
|
800
|
+
r,
|
|
801
|
+
_,
|
|
802
|
+
f,
|
|
803
|
+
C
|
|
804
|
+
]), D = st.filter((e) => X(n[e]));
|
|
805
|
+
return {
|
|
806
|
+
context: E,
|
|
807
|
+
isCreating: st.some((e) => n[e]?.isCreating),
|
|
808
|
+
toolbar: D.length > 0 && /* @__PURE__ */ W(u, {
|
|
809
|
+
"aria-label": "Embed",
|
|
810
|
+
children: D.map((i) => {
|
|
811
|
+
let a = `Embed ${Ze(n[i]) ? ct[i].itemsLabel : i}`;
|
|
812
|
+
return /* @__PURE__ */ W(t, {
|
|
813
|
+
size: "sm",
|
|
814
|
+
isIconOnly: !0,
|
|
815
|
+
iconStart: i === "entry" ? "file-text" : "image",
|
|
816
|
+
"aria-label": a,
|
|
817
|
+
title: a,
|
|
818
|
+
"aria-pressed": g?.kind === i,
|
|
819
|
+
variant: g?.kind === i ? "primary" : "neutral",
|
|
820
|
+
isDisabled: r || _ || !e,
|
|
821
|
+
onClick: () => x(i)
|
|
822
|
+
}, i);
|
|
823
|
+
})
|
|
824
|
+
}),
|
|
825
|
+
dialog: e && g && h && /* @__PURE__ */ W(Ct, {
|
|
826
|
+
session: g,
|
|
827
|
+
source: h,
|
|
828
|
+
disabled: r,
|
|
829
|
+
label: i,
|
|
830
|
+
close: m,
|
|
831
|
+
target: {
|
|
832
|
+
available: () => y(g),
|
|
833
|
+
commit: (e) => b(g, [{
|
|
834
|
+
item: e,
|
|
835
|
+
revision: v.current.sources[g.kind]?.refreshKey
|
|
836
|
+
}])
|
|
837
|
+
},
|
|
838
|
+
pick: (e) => b(g, e, g.multiple)
|
|
839
|
+
}, g.id)
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
//#endregion
|
|
843
|
+
//#region src/components/RichTextEditor/expanded-width.ts
|
|
844
|
+
var Tt = ["wide", "full"], Et = [
|
|
845
|
+
"sm",
|
|
846
|
+
"md",
|
|
847
|
+
"lg"
|
|
848
|
+
], Dt = /* @__PURE__ */ new Set([
|
|
849
|
+
"shortText",
|
|
850
|
+
"longText",
|
|
851
|
+
"richText",
|
|
852
|
+
"number",
|
|
853
|
+
"boolean",
|
|
854
|
+
"dateTime",
|
|
855
|
+
"asset",
|
|
856
|
+
"reference",
|
|
857
|
+
"select",
|
|
858
|
+
"slider",
|
|
859
|
+
"rangeSlider",
|
|
860
|
+
"colour",
|
|
861
|
+
"radioGroup",
|
|
862
|
+
"checkboxGroup",
|
|
863
|
+
"tags",
|
|
864
|
+
"date",
|
|
865
|
+
"divider"
|
|
866
|
+
]);
|
|
867
|
+
function Ot(e) {
|
|
868
|
+
let t = /* @__PURE__ */ new Set();
|
|
869
|
+
for (let n of e.fields) {
|
|
870
|
+
if (!n.id?.trim() || t.has(n.id)) throw Error("Form field IDs must be nonempty and unique.");
|
|
871
|
+
if (!Dt.has(n.type)) throw Error(`Unsupported form field type: ${n.type}`);
|
|
872
|
+
if ("labelHint" in n) throw Error(`Field ${n.id} uses the removed labelHint; move its content into hint.`);
|
|
873
|
+
n.type !== "divider" && (kt(n), Rt(n), Mt(n)), t.add(n.id);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function kt(e) {
|
|
877
|
+
switch (e.type) {
|
|
878
|
+
case "select":
|
|
879
|
+
case "radioGroup":
|
|
880
|
+
case "checkboxGroup": return Vt(e);
|
|
881
|
+
case "slider":
|
|
882
|
+
case "rangeSlider": return zt(e);
|
|
883
|
+
case "number": return Bt(e);
|
|
884
|
+
case "richText": if (e.tables !== void 0 && typeof e.tables != "boolean") throw Error(`Rich text field ${e.id} needs a boolean tables.`);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
var At = /* @__PURE__ */ new Set([
|
|
888
|
+
"shortText",
|
|
889
|
+
"longText",
|
|
890
|
+
"tags",
|
|
891
|
+
"asset",
|
|
892
|
+
"reference"
|
|
893
|
+
]);
|
|
894
|
+
function jt(e) {
|
|
895
|
+
return At.has(e.type);
|
|
896
|
+
}
|
|
897
|
+
function Mt(e) {
|
|
898
|
+
if (jt(e)) {
|
|
899
|
+
if (e.limitDisplay !== void 0 && !["used", "remaining"].includes(e.limitDisplay)) throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);
|
|
900
|
+
if (e.limitVisibility !== void 0 && !["always", "nearLimit"].includes(e.limitVisibility)) throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);
|
|
901
|
+
if (e.showLimitRing !== void 0 && typeof e.showLimitRing != "boolean") throw Error(`Field ${e.id} needs a boolean showLimitRing.`);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function Nt(e, t, n, r) {
|
|
905
|
+
return jt(e) ? {
|
|
906
|
+
limitDisplay: e.limitDisplay,
|
|
907
|
+
limitVisibility: e.limitVisibility,
|
|
908
|
+
showLimitRing: e.showLimitRing,
|
|
909
|
+
limit: Pt(e, t, n ?? [], r)
|
|
910
|
+
} : {};
|
|
911
|
+
}
|
|
912
|
+
function Pt(e, t, n, r) {
|
|
913
|
+
switch (e.type) {
|
|
914
|
+
case "shortText":
|
|
915
|
+
case "longText": return e.maxLength === void 0 ? void 0 : {
|
|
916
|
+
count: It(t).length,
|
|
917
|
+
max: e.maxLength
|
|
918
|
+
};
|
|
919
|
+
case "tags": return e.max === void 0 ? void 0 : {
|
|
920
|
+
count: Q(t).length,
|
|
921
|
+
max: e.max
|
|
922
|
+
};
|
|
923
|
+
default: {
|
|
924
|
+
let { mode: t, max: i } = Lt(e, r);
|
|
925
|
+
return x(t, n.length, i);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
function Ft(e, t, n, r) {
|
|
930
|
+
if (n !== void 0 && (e.type === "asset" || e.type === "reference")) {
|
|
931
|
+
let { mode: t, max: i } = Lt(e, r);
|
|
932
|
+
return T(t, n.length, i);
|
|
933
|
+
}
|
|
934
|
+
return e.type === "checkboxGroup" ? Q(t).length : void 0;
|
|
935
|
+
}
|
|
936
|
+
function It(e) {
|
|
937
|
+
return typeof e == "string" ? e : "";
|
|
938
|
+
}
|
|
939
|
+
function Lt(e, t) {
|
|
940
|
+
let n = t?.mode ?? (e.multiple ? "multiple" : "single");
|
|
941
|
+
if (!e.multiple) return {
|
|
942
|
+
mode: n,
|
|
943
|
+
max: n === "multiple" ? 1 : void 0
|
|
944
|
+
};
|
|
945
|
+
let r = [Wt(e).max, t?.max].filter((e) => e !== void 0 && Number.isFinite(e));
|
|
946
|
+
return {
|
|
947
|
+
mode: n,
|
|
948
|
+
max: r.length > 0 ? Math.min(...r) : void 0
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function Rt(e) {
|
|
952
|
+
if (e.width !== void 0 && !Et.includes(e.width)) throw Error(`Field ${e.id} needs a width of sm, md or lg.`);
|
|
953
|
+
if (e.type === "richText" && e.expandedWidth !== void 0 && !Tt.includes(e.expandedWidth)) throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`);
|
|
954
|
+
}
|
|
955
|
+
function zt(e) {
|
|
956
|
+
let { min: t, max: n, step: r } = P(e);
|
|
957
|
+
if (![
|
|
958
|
+
t,
|
|
959
|
+
n,
|
|
960
|
+
r
|
|
961
|
+
].every(Number.isFinite) || t >= n || r <= 0) throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);
|
|
962
|
+
if (e.type === "rangeSlider" && r > ne(n, -t)) throw Error(`Range slider ${e.id} needs room for at least one step.`);
|
|
963
|
+
}
|
|
964
|
+
function Bt(e) {
|
|
965
|
+
let { min: t, max: n, step: r = "any" } = e;
|
|
966
|
+
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".`);
|
|
967
|
+
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.`);
|
|
968
|
+
}
|
|
969
|
+
function Vt(e) {
|
|
970
|
+
if (!Array.isArray(e.options)) {
|
|
971
|
+
let t = e.type === "select" ? "Select" : "Choice";
|
|
972
|
+
throw Error(`${t} field ${e.id} needs an options array.`);
|
|
973
|
+
}
|
|
974
|
+
if (e.type === "select") return;
|
|
975
|
+
let t = e.options.map((e) => e.value);
|
|
976
|
+
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.`);
|
|
977
|
+
}
|
|
978
|
+
var Ht = {
|
|
979
|
+
asset: {
|
|
980
|
+
key: "assetId",
|
|
981
|
+
itemLabel: "asset",
|
|
982
|
+
itemsLabel: "assets"
|
|
983
|
+
},
|
|
984
|
+
reference: {
|
|
985
|
+
key: "entryId",
|
|
986
|
+
itemLabel: "entry",
|
|
987
|
+
itemsLabel: "entries"
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
function Ut(e) {
|
|
991
|
+
return e.type === "asset" || e.type === "reference" ? e.picker?.label ?? e.label : e.label;
|
|
992
|
+
}
|
|
993
|
+
function Wt(e) {
|
|
994
|
+
let t = Ht[e.type], { addLabel: n = `Choose ${Ut(e)}`, emptyLabel: r, itemLabel: i = t.itemLabel, itemsLabel: a = t.itemsLabel, max: o, isReorderable: s } = e.picker ?? {};
|
|
995
|
+
return {
|
|
996
|
+
addLabel: n,
|
|
997
|
+
emptyLabel: r,
|
|
998
|
+
itemLabel: i,
|
|
999
|
+
itemsLabel: a,
|
|
1000
|
+
max: o,
|
|
1001
|
+
isReorderable: s
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
function Gt(e, t) {
|
|
1005
|
+
let { key: n } = Ht[e.type];
|
|
1006
|
+
return (Array.isArray(t) ? t : t === void 0 ? [] : [t]).flatMap((e) => qt(e, n) ? [e[n]] : []);
|
|
1007
|
+
}
|
|
1008
|
+
function Kt(e) {
|
|
1009
|
+
if (typeof e != "string") return;
|
|
1010
|
+
let t = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);
|
|
1011
|
+
if (!t) return;
|
|
1012
|
+
let n = `${t[1]}:${t[2] ?? "00"}.${(t[3] ?? "").padEnd(3, "0")}Z`, r = new Date(n);
|
|
1013
|
+
if (Number.isFinite(r.getTime()) && r.toISOString() === n) return n;
|
|
1014
|
+
}
|
|
1015
|
+
function qt(e, t) {
|
|
1016
|
+
return !!e && typeof e == "object" && t in e && typeof e[t] == "string" && e[t].trim().length > 0;
|
|
1017
|
+
}
|
|
1018
|
+
function Jt(e) {
|
|
1019
|
+
return !!e.text?.trim() || e.type === "horizontalRule" || e.type === "storyblock" || !!e.content?.some(Jt);
|
|
1020
|
+
}
|
|
1021
|
+
function Z(e) {
|
|
1022
|
+
return `${Ut(e)} is required.`;
|
|
1023
|
+
}
|
|
1024
|
+
function Yt(e, t) {
|
|
1025
|
+
if (typeof t != "string") return "Enter text.";
|
|
1026
|
+
if (e.required && !t.trim()) return Z(e);
|
|
1027
|
+
if ((e.type === "shortText" || e.type === "longText") && e.maxLength !== void 0 && t.length > e.maxLength) return `Enter no more than ${e.maxLength} characters.`;
|
|
1028
|
+
}
|
|
1029
|
+
function Xt(e, t) {
|
|
1030
|
+
let n = Xe(t, { tables: e.type !== "richText" || e.tables !== !1 });
|
|
1031
|
+
if (n) return n;
|
|
1032
|
+
if (e.required && !Jt(t)) return Z(e);
|
|
1033
|
+
}
|
|
1034
|
+
function Zt(e, t) {
|
|
1035
|
+
if (typeof t != "string") return "Choose an available option.";
|
|
1036
|
+
if (t === "") return e.required ? Z(e) : void 0;
|
|
1037
|
+
if ((e.type === "select" || e.type === "radioGroup") && e.options.length > 0 && !e.options.some((e) => e.value === t)) return "Choose an available option.";
|
|
1038
|
+
}
|
|
1039
|
+
function Q(e) {
|
|
1040
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
1041
|
+
}
|
|
1042
|
+
function Qt(e, t) {
|
|
1043
|
+
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.";
|
|
1044
|
+
if (e.required && !t.length) return Z(e);
|
|
1045
|
+
if (e.type === "tags" && e.max !== void 0 && t.length > e.max) return `Enter no more than ${e.max} tags.`;
|
|
1046
|
+
if (e.type === "checkboxGroup" && e.options.length && t.some((t) => !e.options.some((e) => e.value === t))) return "Choose available options.";
|
|
1047
|
+
}
|
|
1048
|
+
function $(e, t) {
|
|
1049
|
+
if (typeof t != "number" || !Number.isFinite(t)) return "Enter a finite number.";
|
|
1050
|
+
let { min: n, max: r } = e.type === "slider" || e.type === "rangeSlider" ? P(e) : e.type === "number" ? e : {};
|
|
1051
|
+
if (n !== void 0 && t < n) return `Enter a number of at least ${n}.`;
|
|
1052
|
+
if (r !== void 0 && t > r) return `Enter a number no greater than ${r}.`;
|
|
1053
|
+
}
|
|
1054
|
+
function $t(e, t) {
|
|
1055
|
+
if (typeof t != "string") return "Enter a valid calendar date (YYYY-MM-DD).";
|
|
1056
|
+
if (!t) return e.required ? Z(e) : void 0;
|
|
1057
|
+
if (!oe(t)) return "Enter a valid calendar date (YYYY-MM-DD).";
|
|
1058
|
+
if (e.type === "date") {
|
|
1059
|
+
if (e.min && t < e.min) return `Choose a date on or after ${e.min}.`;
|
|
1060
|
+
if (e.max && t > e.max) return `Choose a date on or before ${e.max}.`;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
function en(e, t) {
|
|
1064
|
+
return typeof e == "number" && Number.isFinite(e) ? ie(e, t) : void 0;
|
|
1065
|
+
}
|
|
1066
|
+
function tn(e, t) {
|
|
1067
|
+
let n = e, r = en(n?.min, t), i = en(n?.max, t);
|
|
1068
|
+
if (r === void 0 && i === void 0) return;
|
|
1069
|
+
let [a, o] = [r ?? t.min, i ?? t.max].sort((e, t) => e - t);
|
|
1070
|
+
return {
|
|
1071
|
+
min: a,
|
|
1072
|
+
max: o
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
function nn(e, t) {
|
|
1076
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return "Enter a range.";
|
|
1077
|
+
let n = t, r = n.min, i = n.max, a = $(e, r) ?? $(e, i);
|
|
1078
|
+
if (a) return a;
|
|
1079
|
+
if (r > i) return "The start must not be greater than the end.";
|
|
1080
|
+
if (e.type === "rangeSlider" && ne(i, -r) < P(e).step) return "Keep the range endpoints at least one step apart.";
|
|
1081
|
+
}
|
|
1082
|
+
function rn(e, t) {
|
|
1083
|
+
return typeof t == "string" ? t.trim() ? N(t) ? void 0 : "Enter a valid colour." : e.required ? Z(e) : void 0 : "Enter a valid colour.";
|
|
1084
|
+
}
|
|
1085
|
+
function an(e, t) {
|
|
1086
|
+
if (e.type !== "asset" && e.type !== "reference") return;
|
|
1087
|
+
let { key: n, itemLabel: r, itemsLabel: i } = Ht[e.type];
|
|
1088
|
+
if (!e.multiple) return qt(t, n) ? void 0 : `Choose an ${r}.`;
|
|
1089
|
+
if (!Array.isArray(t) || !t.every((e) => qt(e, n))) return `Choose a list of ${i}.`;
|
|
1090
|
+
if (e.required && t.length === 0) return Z(e);
|
|
1091
|
+
let a = e.picker?.max;
|
|
1092
|
+
if (a !== void 0 && t.length > a) return `Choose no more than ${a} ${Wt(e).itemsLabel}.`;
|
|
1093
|
+
}
|
|
1094
|
+
var on = {
|
|
1095
|
+
shortText: Yt,
|
|
1096
|
+
longText: Yt,
|
|
1097
|
+
richText: Xt,
|
|
1098
|
+
number: $,
|
|
1099
|
+
slider: $,
|
|
1100
|
+
rangeSlider: nn,
|
|
1101
|
+
date: $t,
|
|
1102
|
+
colour: rn,
|
|
1103
|
+
radioGroup: Zt,
|
|
1104
|
+
checkboxGroup: Qt,
|
|
1105
|
+
tags: Qt,
|
|
1106
|
+
boolean: (e, t) => typeof t == "boolean" ? void 0 : "Choose a boolean value.",
|
|
1107
|
+
dateTime: (e, t) => Kt(t) ? void 0 : "Enter a valid UTC date and time.",
|
|
1108
|
+
select: Zt,
|
|
1109
|
+
asset: an,
|
|
1110
|
+
reference: an
|
|
1111
|
+
};
|
|
1112
|
+
function sn(e, t) {
|
|
1113
|
+
return t === void 0 ? e.required ? Z(e) : void 0 : on[e.type](e, t);
|
|
1114
|
+
}
|
|
1115
|
+
function cn(e, t) {
|
|
1116
|
+
return Ot(e), Object.fromEntries(e.fields.flatMap((e) => {
|
|
1117
|
+
if (e.type === "divider") return [];
|
|
1118
|
+
let n = sn(e, Object.hasOwn(t, e.id) ? t[e.id] : void 0);
|
|
1119
|
+
return n ? [[e.id, n]] : [];
|
|
1120
|
+
}));
|
|
1121
|
+
}
|
|
1122
|
+
//#endregion
|
|
1123
|
+
//#region src/components/FormEditor/choice-control.tsx
|
|
1124
|
+
function ln({ field: e, option: t, name: n, checked: r, isDisabled: i, invalid: a, onChange: o }) {
|
|
1125
|
+
let s = {
|
|
1126
|
+
name: n,
|
|
1127
|
+
value: t.value,
|
|
1128
|
+
checked: r,
|
|
1129
|
+
disabled: i || t.isDisabled,
|
|
1130
|
+
"aria-invalid": a,
|
|
1131
|
+
onChange: () => {
|
|
1132
|
+
!i && !t.isDisabled && o();
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
if (e.appearance === "card") {
|
|
1136
|
+
let n = e.type === "radioGroup" ? le : ce;
|
|
1137
|
+
return /* @__PURE__ */ W(n, {
|
|
1138
|
+
...s,
|
|
1139
|
+
title: t.label,
|
|
1140
|
+
description: t.description
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
let c = e.type === "radioGroup" ? O : ee;
|
|
1144
|
+
return /* @__PURE__ */ W(c, {
|
|
1145
|
+
...s,
|
|
1146
|
+
children: /* @__PURE__ */ G("span", { children: [t.label, t.description && /* @__PURE__ */ W("span", {
|
|
1147
|
+
className: "ds-form-editor__option-description",
|
|
1148
|
+
children: t.description
|
|
1149
|
+
})] })
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
function un({ field: e, stored: n, isDisabled: r, required: i, accessibility: a, onChange: o }) {
|
|
1153
|
+
let s = e.type === "checkboxGroup", c = s ? Q(n) : typeof n == "string" && n ? [n] : [], l = e.appearance === "card" ? ue : te;
|
|
1154
|
+
return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(l, {
|
|
1155
|
+
...a,
|
|
1156
|
+
label: e.label,
|
|
1157
|
+
columns: e.columns ?? (e.appearance === "card" ? 2 : 1),
|
|
1158
|
+
children: e.options.map((t) => /* @__PURE__ */ W(ln, {
|
|
1159
|
+
field: e,
|
|
1160
|
+
option: t,
|
|
1161
|
+
name: a.id,
|
|
1162
|
+
checked: c.includes(t.value),
|
|
1163
|
+
isDisabled: r,
|
|
1164
|
+
invalid: a["aria-invalid"],
|
|
1165
|
+
onChange: () => {
|
|
1166
|
+
o(s ? c.includes(t.value) ? c.filter((e) => e !== t.value) : [...c, t.value] : t.value);
|
|
1167
|
+
}
|
|
1168
|
+
}, t.value))
|
|
1169
|
+
}), !s && !i && c.length > 0 && /* @__PURE__ */ G(t, {
|
|
1170
|
+
variant: "simple",
|
|
1171
|
+
size: "sm",
|
|
1172
|
+
isDisabled: r,
|
|
1173
|
+
onClick: () => o(void 0),
|
|
1174
|
+
children: ["Clear ", e.label]
|
|
1175
|
+
})] });
|
|
1176
|
+
}
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/components/FormEditor/additional-control.tsx
|
|
1179
|
+
function dn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
|
|
1180
|
+
let a = P(e), o = en(t, a);
|
|
1181
|
+
return /* @__PURE__ */ W(re, {
|
|
1182
|
+
...r,
|
|
1183
|
+
...a,
|
|
1184
|
+
prefix: e.prefix,
|
|
1185
|
+
suffix: e.suffix,
|
|
1186
|
+
hasValueLabel: e.hasValueLabel,
|
|
1187
|
+
valueText: o === void 0 ? e.placeholder ?? "Not set" : void 0,
|
|
1188
|
+
autoFocus: e.autoFocus,
|
|
1189
|
+
isDisabled: n,
|
|
1190
|
+
value: o ?? a.min,
|
|
1191
|
+
onValueChange: i,
|
|
1192
|
+
onValueCommit: (e) => {
|
|
1193
|
+
o === void 0 && i(e);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
function fn({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
|
|
1198
|
+
let a = P(e), o = tn(t, a);
|
|
1199
|
+
return /* @__PURE__ */ W(F, {
|
|
1200
|
+
...r,
|
|
1201
|
+
...a,
|
|
1202
|
+
prefix: e.prefix,
|
|
1203
|
+
suffix: e.suffix,
|
|
1204
|
+
hasValueLabel: e.hasValueLabel,
|
|
1205
|
+
minLabel: `${e.label} minimum`,
|
|
1206
|
+
maxLabel: `${e.label} maximum`,
|
|
1207
|
+
isDisabled: n,
|
|
1208
|
+
valueText: o === void 0 ? e.placeholder ?? "Not set" : void 0,
|
|
1209
|
+
hasFill: o !== void 0,
|
|
1210
|
+
value: o ?? {
|
|
1211
|
+
min: a.min,
|
|
1212
|
+
max: a.max
|
|
1213
|
+
},
|
|
1214
|
+
onValueChange: i,
|
|
1215
|
+
onValueCommit: (e) => {
|
|
1216
|
+
o === void 0 && i(e);
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
function pn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
1221
|
+
let o = {
|
|
1222
|
+
stored: t,
|
|
1223
|
+
isDisabled: n,
|
|
1224
|
+
required: r,
|
|
1225
|
+
accessibility: i,
|
|
1226
|
+
onChange: a
|
|
1227
|
+
};
|
|
1228
|
+
switch (e.type) {
|
|
1229
|
+
case "radioGroup":
|
|
1230
|
+
case "checkboxGroup": return /* @__PURE__ */ W(un, {
|
|
1231
|
+
field: e,
|
|
1232
|
+
...o
|
|
1233
|
+
});
|
|
1234
|
+
case "rangeSlider": return /* @__PURE__ */ W(fn, {
|
|
1235
|
+
field: e,
|
|
1236
|
+
...o
|
|
1237
|
+
});
|
|
1238
|
+
case "slider": return /* @__PURE__ */ W(dn, {
|
|
1239
|
+
field: e,
|
|
1240
|
+
...o
|
|
1241
|
+
});
|
|
1242
|
+
case "colour": return /* @__PURE__ */ W(ae, {
|
|
1243
|
+
...i,
|
|
1244
|
+
required: r,
|
|
1245
|
+
placeholder: e.placeholder,
|
|
1246
|
+
presets: e.presets,
|
|
1247
|
+
showPresets: e.showPresets,
|
|
1248
|
+
picker: e.picker,
|
|
1249
|
+
placement: e.placement,
|
|
1250
|
+
readOnly: e.readOnly,
|
|
1251
|
+
autoFocus: e.autoFocus,
|
|
1252
|
+
isDisabled: n,
|
|
1253
|
+
value: typeof t == "string" ? t : "",
|
|
1254
|
+
onInput: (e) => {
|
|
1255
|
+
let t = e.currentTarget.value;
|
|
1256
|
+
t.trim() && !N(t) && a(t);
|
|
1257
|
+
},
|
|
1258
|
+
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
1259
|
+
});
|
|
1260
|
+
case "tags": return /* @__PURE__ */ W(I, {
|
|
1261
|
+
...i,
|
|
1262
|
+
required: r,
|
|
1263
|
+
placeholder: e.placeholder,
|
|
1264
|
+
max: e.max,
|
|
1265
|
+
isDisabled: n,
|
|
1266
|
+
value: Q(t),
|
|
1267
|
+
onValueChange: a
|
|
1268
|
+
});
|
|
1269
|
+
case "date": return /* @__PURE__ */ W(se, {
|
|
1270
|
+
...i,
|
|
1271
|
+
placeholder: e.placeholder,
|
|
1272
|
+
min: e.min,
|
|
1273
|
+
max: e.max,
|
|
1274
|
+
placement: e.placement,
|
|
1275
|
+
isDisabled: n,
|
|
1276
|
+
isClearable: !0,
|
|
1277
|
+
clearLabel: `Clear ${e.label}`,
|
|
1278
|
+
value: typeof t == "string" ? t : "",
|
|
1279
|
+
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
//#endregion
|
|
1284
|
+
//#region src/components/FormEditor/control.tsx
|
|
1285
|
+
function mn(e, t) {
|
|
1286
|
+
if (e.type === "asset") {
|
|
1287
|
+
let n = t.map((e) => ({ assetId: e }));
|
|
1288
|
+
return e.multiple ? n : n[0];
|
|
1289
|
+
}
|
|
1290
|
+
let n = t.map((e) => ({ entryId: e }));
|
|
1291
|
+
return e.multiple ? n : n[0];
|
|
1292
|
+
}
|
|
1293
|
+
var hn = fe(null);
|
|
1294
|
+
function gn({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
1295
|
+
return /* @__PURE__ */ W(A, {
|
|
1296
|
+
...i,
|
|
1297
|
+
required: r,
|
|
1298
|
+
isDisabled: n,
|
|
1299
|
+
placeholder: e.placeholder,
|
|
1300
|
+
min: e.min,
|
|
1301
|
+
max: e.max,
|
|
1302
|
+
step: e.step ?? "any",
|
|
1303
|
+
hasSteppers: e.hasSteppers,
|
|
1304
|
+
prefix: e.prefix,
|
|
1305
|
+
suffix: e.suffix,
|
|
1306
|
+
autoFocus: e.autoFocus,
|
|
1307
|
+
decreaseLabel: e.decreaseLabel ?? `Decrease ${e.label}`,
|
|
1308
|
+
increaseLabel: e.increaseLabel ?? `Increase ${e.label}`,
|
|
1309
|
+
value: typeof t == "number" && Number.isFinite(t) ? t : "",
|
|
1310
|
+
onValueChange: (e) => {
|
|
1311
|
+
(e === "" || Number.isFinite(e)) && a(e === "" ? void 0 : e);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
function _n({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
1316
|
+
let o = !r && !e.options.some((e) => e.value === "");
|
|
1317
|
+
return /* @__PURE__ */ W(j, {
|
|
1318
|
+
...i,
|
|
1319
|
+
"aria-required": r || void 0,
|
|
1320
|
+
isDisabled: n,
|
|
1321
|
+
isInvalid: i["aria-invalid"],
|
|
1322
|
+
options: o ? [{
|
|
1323
|
+
value: "",
|
|
1324
|
+
label: e.placeholder ?? "None"
|
|
1325
|
+
}, ...e.options] : e.options,
|
|
1326
|
+
placeholder: e.placeholder,
|
|
1327
|
+
autoFocus: e.autoFocus,
|
|
1328
|
+
value: typeof t == "string" ? t : "",
|
|
1329
|
+
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
function vn({ field: e, selected: t, items: n, source: r, isDisabled: i, accessibility: a, onChange: o }) {
|
|
1333
|
+
return /* @__PURE__ */ W(D, {
|
|
1334
|
+
...a,
|
|
1335
|
+
...r,
|
|
1336
|
+
items: n,
|
|
1337
|
+
value: t,
|
|
1338
|
+
...Wt(e),
|
|
1339
|
+
...Lt(e, r),
|
|
1340
|
+
isDisabled: i,
|
|
1341
|
+
onValueChange: (t) => o(mn(e, t))
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
function yn({ embeds: e, field: t, stored: n, selected: r, items: i, source: a, isDisabled: o, accessibility: { required: s, ...c }, onChange: l }) {
|
|
1345
|
+
let u = me(hn), d = {
|
|
1346
|
+
stored: n,
|
|
1347
|
+
isDisabled: o,
|
|
1348
|
+
required: s,
|
|
1349
|
+
accessibility: c,
|
|
1350
|
+
onChange: l
|
|
1351
|
+
};
|
|
1352
|
+
switch (t.type) {
|
|
1353
|
+
case "shortText": return /* @__PURE__ */ W(h, {
|
|
1354
|
+
...c,
|
|
1355
|
+
required: s,
|
|
1356
|
+
disabled: o,
|
|
1357
|
+
placeholder: t.placeholder,
|
|
1358
|
+
type: t.inputType,
|
|
1359
|
+
maxLength: t.maxLength,
|
|
1360
|
+
readOnly: t.readOnly,
|
|
1361
|
+
autoFocus: t.autoFocus,
|
|
1362
|
+
value: It(n),
|
|
1363
|
+
onChange: (e) => l(e.target.value)
|
|
1364
|
+
});
|
|
1365
|
+
case "longText": return /* @__PURE__ */ W(m, {
|
|
1366
|
+
...c,
|
|
1367
|
+
required: s,
|
|
1368
|
+
disabled: o,
|
|
1369
|
+
placeholder: t.placeholder,
|
|
1370
|
+
rows: t.rows,
|
|
1371
|
+
maxLength: t.maxLength,
|
|
1372
|
+
readOnly: t.readOnly,
|
|
1373
|
+
autoFocus: t.autoFocus,
|
|
1374
|
+
value: It(n),
|
|
1375
|
+
onChange: (e) => l(e.target.value)
|
|
1376
|
+
});
|
|
1377
|
+
case "number": return /* @__PURE__ */ W(gn, {
|
|
1378
|
+
field: t,
|
|
1379
|
+
...d
|
|
1380
|
+
});
|
|
1381
|
+
case "boolean": return /* @__PURE__ */ W(M, {
|
|
1382
|
+
...c,
|
|
1383
|
+
isDisabled: o,
|
|
1384
|
+
autoFocus: t.autoFocus,
|
|
1385
|
+
isSelected: n === !0,
|
|
1386
|
+
onSelectedChange: l
|
|
1387
|
+
});
|
|
1388
|
+
case "dateTime": return /* @__PURE__ */ W(h, {
|
|
1389
|
+
...c,
|
|
1390
|
+
required: s,
|
|
1391
|
+
disabled: o,
|
|
1392
|
+
type: "datetime-local",
|
|
1393
|
+
step: "0.001",
|
|
1394
|
+
autoFocus: t.autoFocus,
|
|
1395
|
+
value: Kt(n)?.slice(0, -1) ?? "",
|
|
1396
|
+
onChange: (e) => l(Kt(`${e.target.value}Z`))
|
|
1397
|
+
});
|
|
1398
|
+
case "richText":
|
|
1399
|
+
if (!u) throw Error(`Rich text field ${t.id} needs FormEditor's rich-text control.`);
|
|
1400
|
+
return u({
|
|
1401
|
+
field: t,
|
|
1402
|
+
embeds: e,
|
|
1403
|
+
...d
|
|
1404
|
+
});
|
|
1405
|
+
case "select": return /* @__PURE__ */ W(_n, {
|
|
1406
|
+
field: t,
|
|
1407
|
+
...d
|
|
1408
|
+
});
|
|
1409
|
+
case "asset":
|
|
1410
|
+
case "reference": return /* @__PURE__ */ W(vn, {
|
|
1411
|
+
field: t,
|
|
1412
|
+
items: i,
|
|
1413
|
+
source: a,
|
|
1414
|
+
selected: r ?? [],
|
|
1415
|
+
...d
|
|
1416
|
+
});
|
|
1417
|
+
default: return /* @__PURE__ */ W(pn, {
|
|
1418
|
+
field: t,
|
|
1419
|
+
...d
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
//#endregion
|
|
1424
|
+
//#region src/components/FormEditor/form.tsx
|
|
1425
|
+
function bn({ field: e, stored: t, items: n, source: r, embeds: i, isDisabled: a, error: o, isErrorVisible: s, onChange: c }) {
|
|
1426
|
+
let l = B(() => o === void 0 && s ? sn(e, t) : void 0, [
|
|
1427
|
+
o,
|
|
1428
|
+
s,
|
|
1429
|
+
e,
|
|
1430
|
+
t
|
|
1431
|
+
]), u = B(() => e.type === "asset" || e.type === "reference" ? Gt(e, t) : void 0, [e, t]);
|
|
1432
|
+
return /* @__PURE__ */ W(k, {
|
|
1433
|
+
width: e.width,
|
|
1434
|
+
padded: !1,
|
|
1435
|
+
center: !1,
|
|
1436
|
+
className: "ds-form-editor__field",
|
|
1437
|
+
children: /* @__PURE__ */ W(f, {
|
|
1438
|
+
...Nt(e, t, u, r),
|
|
1439
|
+
label: e.type === "dateTime" ? `${e.label} (UTC)` : Ut(e),
|
|
1440
|
+
hint: e.hint,
|
|
1441
|
+
error: o ?? l,
|
|
1442
|
+
isRequired: e.required,
|
|
1443
|
+
count: Ft(e, t, u, r),
|
|
1444
|
+
isGroup: u !== void 0 || xn.has(e.type),
|
|
1445
|
+
children: (o) => /* @__PURE__ */ W(yn, {
|
|
1446
|
+
field: e,
|
|
1447
|
+
stored: t,
|
|
1448
|
+
selected: u,
|
|
1449
|
+
items: n,
|
|
1450
|
+
source: r,
|
|
1451
|
+
embeds: i,
|
|
1452
|
+
isDisabled: a,
|
|
1453
|
+
accessibility: o,
|
|
1454
|
+
onChange: c
|
|
1455
|
+
})
|
|
1456
|
+
})
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
var xn = /* @__PURE__ */ new Set([
|
|
1460
|
+
"radioGroup",
|
|
1461
|
+
"checkboxGroup",
|
|
1462
|
+
"rangeSlider"
|
|
1463
|
+
]), Sn = /* @__PURE__ */ new Set([
|
|
1464
|
+
"slider",
|
|
1465
|
+
"rangeSlider",
|
|
1466
|
+
"date",
|
|
1467
|
+
"colour"
|
|
1468
|
+
]);
|
|
1469
|
+
function Cn({ 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 }) {
|
|
1470
|
+
let [h, g] = H(n), [_, v] = H(() => /* @__PURE__ */ new Set()), y = t ?? h;
|
|
1471
|
+
B(() => Ot(e), [e]);
|
|
1472
|
+
let b = (e, n) => {
|
|
1473
|
+
let i = { ...y };
|
|
1474
|
+
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 });
|
|
1475
|
+
}, x = u === "auto" ? { "--form-editor-min-column": d } : {
|
|
1476
|
+
"--form-editor-columns": u,
|
|
1477
|
+
"--form-editor-min-column": d
|
|
1478
|
+
};
|
|
1479
|
+
return /* @__PURE__ */ W("div", {
|
|
1480
|
+
className: [
|
|
1481
|
+
"ds-form-editor",
|
|
1482
|
+
u === "auto" && "ds-form-editor--auto",
|
|
1483
|
+
f
|
|
1484
|
+
].filter(Boolean).join(" "),
|
|
1485
|
+
style: {
|
|
1486
|
+
...x,
|
|
1487
|
+
...p
|
|
1488
|
+
},
|
|
1489
|
+
...m,
|
|
1490
|
+
children: e.fields.map((e) => {
|
|
1491
|
+
if (e.type === "divider") return /* @__PURE__ */ W("hr", { className: "ds-form-editor__divider" }, e.id);
|
|
1492
|
+
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 && Sn.has(e.type) || e.type === "number" && typeof t == "number";
|
|
1493
|
+
return /* @__PURE__ */ W(bn, {
|
|
1494
|
+
field: e,
|
|
1495
|
+
stored: t,
|
|
1496
|
+
items: i[e.id] ?? [],
|
|
1497
|
+
source: a[e.id],
|
|
1498
|
+
embeds: o[e.id],
|
|
1499
|
+
isDisabled: n,
|
|
1500
|
+
error: s[e.id],
|
|
1501
|
+
isErrorVisible: d,
|
|
1502
|
+
onChange: (t) => {
|
|
1503
|
+
(!r || e.type === "richText" && (o[e.id]?.entry?.isCreating || o[e.id]?.asset?.isCreating)) && b(e.id, t);
|
|
1504
|
+
}
|
|
1505
|
+
}, e.id);
|
|
1506
|
+
})
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
//#endregion
|
|
1510
|
+
//#region src/components/RichTextEditor/tables.tsx
|
|
1511
|
+
var wn = 50, Tn = { fields: [
|
|
1512
|
+
{
|
|
1513
|
+
id: "rows",
|
|
1514
|
+
type: "number",
|
|
1515
|
+
label: "Rows",
|
|
1516
|
+
required: !0,
|
|
1517
|
+
min: 1,
|
|
1518
|
+
max: wn,
|
|
1519
|
+
step: 1,
|
|
1520
|
+
decreaseLabel: "Fewer rows",
|
|
1521
|
+
increaseLabel: "More rows"
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
id: "cols",
|
|
1525
|
+
type: "number",
|
|
1526
|
+
label: "Columns",
|
|
1527
|
+
required: !0,
|
|
1528
|
+
min: 1,
|
|
1529
|
+
max: wn,
|
|
1530
|
+
step: 1,
|
|
1531
|
+
decreaseLabel: "Fewer columns",
|
|
1532
|
+
increaseLabel: "More columns"
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
id: "withHeaderRow",
|
|
1536
|
+
type: "boolean",
|
|
1537
|
+
label: "Include header row"
|
|
1538
|
+
}
|
|
1539
|
+
] }, En = {
|
|
1540
|
+
rows: 3,
|
|
1541
|
+
cols: 3,
|
|
1542
|
+
withHeaderRow: !0
|
|
1543
|
+
}, Dn = "Enter a whole number.";
|
|
1544
|
+
function On(e) {
|
|
1545
|
+
return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= wn ? e : void 0;
|
|
1546
|
+
}
|
|
1547
|
+
function kn(e) {
|
|
1548
|
+
return typeof e == "number" && !Number.isInteger(e) ? Dn : void 0;
|
|
1549
|
+
}
|
|
1550
|
+
function An(e, t, { rows: n, cols: r, withHeaderRow: i }) {
|
|
1551
|
+
e.chain().focus().command(({ tr: a, dispatch: o }) => {
|
|
1552
|
+
let s = t.getBookmark().resolve(a.doc), c = je(e.schema, n, r, i), l = s instanceof Pe ? s.node.isInline ? s.$to.after() : s.to : null;
|
|
1553
|
+
if (l !== null) {
|
|
1554
|
+
let e = a.doc.resolve(l);
|
|
1555
|
+
if (!e.parent.canReplaceWith(e.index(), e.index(), c.type)) return !1;
|
|
1556
|
+
}
|
|
1557
|
+
if (o) {
|
|
1558
|
+
K(a);
|
|
1559
|
+
let e;
|
|
1560
|
+
l === null ? (e = s.from + 1, a.setSelection(s).replaceSelectionWith(c)) : (e = l + 1, a.insert(l, c)), a.setSelection(Ie.near(a.doc.resolve(e))).scrollIntoView();
|
|
1561
|
+
}
|
|
1562
|
+
return !0;
|
|
1563
|
+
}).run() && !e.isDestroyed && e.view.dispatch(K(e.state.tr));
|
|
1564
|
+
}
|
|
1565
|
+
function jn({ editor: e, selection: n, onClose: r }) {
|
|
1566
|
+
let i = z(), [a, o] = H(En), [s, c] = H(!1), l = On(a.rows), u = On(a.cols);
|
|
1567
|
+
return R(() => {
|
|
1568
|
+
let t = () => {
|
|
1569
|
+
e.state.doc.eq(n.$from.doc) || r();
|
|
1570
|
+
};
|
|
1571
|
+
return e.on("transaction", t), () => {
|
|
1572
|
+
e.off("transaction", t);
|
|
1573
|
+
};
|
|
1574
|
+
}, [
|
|
1575
|
+
e,
|
|
1576
|
+
r,
|
|
1577
|
+
n
|
|
1578
|
+
]), /* @__PURE__ */ W(p, {
|
|
1579
|
+
isOpen: !0,
|
|
1580
|
+
title: "Insert table",
|
|
1581
|
+
size: "dialog",
|
|
1582
|
+
onClose: r,
|
|
1583
|
+
footer: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(t, {
|
|
1584
|
+
onClick: r,
|
|
1585
|
+
children: "Cancel"
|
|
1586
|
+
}), /* @__PURE__ */ W(t, {
|
|
1587
|
+
variant: "primary",
|
|
1588
|
+
type: "submit",
|
|
1589
|
+
form: i,
|
|
1590
|
+
children: "Insert table"
|
|
1591
|
+
})] }),
|
|
1592
|
+
children: /* @__PURE__ */ W("form", {
|
|
1593
|
+
id: i,
|
|
1594
|
+
noValidate: !0,
|
|
1595
|
+
onSubmit: (t) => {
|
|
1596
|
+
t.preventDefault(), t.stopPropagation(), c(!0), l !== void 0 && u !== void 0 && (!e.isDestroyed && e.isEditable && e.state.doc.eq(n.$from.doc) && An(e, n, {
|
|
1597
|
+
rows: l,
|
|
1598
|
+
cols: u,
|
|
1599
|
+
withHeaderRow: a.withHeaderRow === !0
|
|
1600
|
+
}), r());
|
|
1601
|
+
},
|
|
1602
|
+
children: /* @__PURE__ */ W(Cn, {
|
|
1603
|
+
schema: Tn,
|
|
1604
|
+
value: a,
|
|
1605
|
+
onValueChange: o,
|
|
1606
|
+
errors: {
|
|
1607
|
+
rows: kn(a.rows),
|
|
1608
|
+
cols: kn(a.cols)
|
|
1609
|
+
},
|
|
1610
|
+
showAllErrors: s,
|
|
1611
|
+
columns: 2,
|
|
1612
|
+
minColumnWidth: "8rem"
|
|
1613
|
+
})
|
|
1614
|
+
})
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
var Mn = [
|
|
1618
|
+
[
|
|
1619
|
+
{
|
|
1620
|
+
label: "Add row above",
|
|
1621
|
+
command: "addRowBefore",
|
|
1622
|
+
icon: "rows-2-plus-top"
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
label: "Add row below",
|
|
1626
|
+
command: "addRowAfter",
|
|
1627
|
+
icon: "rows-2-plus-bottom"
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
label: "Delete row",
|
|
1631
|
+
command: "deleteRow",
|
|
1632
|
+
icon: "table-rows-split"
|
|
1633
|
+
}
|
|
1634
|
+
],
|
|
1635
|
+
[
|
|
1636
|
+
{
|
|
1637
|
+
label: "Add column before",
|
|
1638
|
+
command: "addColumnBefore",
|
|
1639
|
+
icon: "columns-2-plus-left",
|
|
1640
|
+
isInline: !0
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
label: "Add column after",
|
|
1644
|
+
command: "addColumnAfter",
|
|
1645
|
+
icon: "columns-2-plus-right",
|
|
1646
|
+
isInline: !0
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
label: "Delete column",
|
|
1650
|
+
command: "deleteColumn",
|
|
1651
|
+
icon: "table-columns-split"
|
|
1652
|
+
}
|
|
1653
|
+
],
|
|
1654
|
+
[{
|
|
1655
|
+
label: "Merge cells",
|
|
1656
|
+
command: "mergeCells",
|
|
1657
|
+
icon: "table-cells-merge"
|
|
1658
|
+
}, {
|
|
1659
|
+
label: "Toggle header row",
|
|
1660
|
+
command: "toggleHeaderRow",
|
|
1661
|
+
icon: "panel-top"
|
|
1662
|
+
}]
|
|
1663
|
+
], Nn = () => {}, Pn = {
|
|
1664
|
+
deleteRow: (e) => Re(e.state, Nn),
|
|
1665
|
+
deleteColumn: (e) => Le(e.state, Nn)
|
|
1666
|
+
};
|
|
1667
|
+
function Fn(e) {
|
|
1668
|
+
let t = [...Mn.flat().map(({ command: e }) => e), "deleteTable"];
|
|
1669
|
+
return new Set(t.filter((t) => Pn[t]?.(e) ?? e.can()[t]()));
|
|
1670
|
+
}
|
|
1671
|
+
function In({ editor: e, disabled: n, inTable: r }) {
|
|
1672
|
+
let [i, a] = H(null), [o, s] = H(() => /* @__PURE__ */ new Set()), c = L(() => a(null), []);
|
|
1673
|
+
return n && i && a(null), /* @__PURE__ */ G(U, { children: [e && r && !n ? /* @__PURE__ */ G(g, {
|
|
1674
|
+
"aria-label": "Table actions",
|
|
1675
|
+
trigger: (n) => /* @__PURE__ */ W(t, {
|
|
1676
|
+
...n,
|
|
1677
|
+
size: "sm",
|
|
1678
|
+
isIconOnly: !0,
|
|
1679
|
+
iconStart: "grid-2x2-plus",
|
|
1680
|
+
"aria-label": "Table actions",
|
|
1681
|
+
title: "Table actions",
|
|
1682
|
+
onClick: () => {
|
|
1683
|
+
s(Fn(e)), n.onClick();
|
|
1684
|
+
}
|
|
1685
|
+
}),
|
|
1686
|
+
children: [
|
|
1687
|
+
Mn.map((t, n) => /* @__PURE__ */ G(de, { children: [n > 0 && /* @__PURE__ */ W(v, {}), t.map(({ label: t, command: n, icon: r, isInline: i }) => /* @__PURE__ */ W(_, {
|
|
1688
|
+
icon: r,
|
|
1689
|
+
className: i ? "ds-rte__table-action--inline" : void 0,
|
|
1690
|
+
isDisabled: !o.has(n),
|
|
1691
|
+
onClick: () => e.chain().focus()[n]().run(),
|
|
1692
|
+
children: t
|
|
1693
|
+
}, n))] }, t[0].command)),
|
|
1694
|
+
/* @__PURE__ */ W(v, {}),
|
|
1695
|
+
/* @__PURE__ */ W(_, {
|
|
1696
|
+
tone: "danger",
|
|
1697
|
+
icon: "grid-2x2-x",
|
|
1698
|
+
isDisabled: !o.has("deleteTable"),
|
|
1699
|
+
onClick: () => e.chain().focus().deleteTable().run(),
|
|
1700
|
+
children: "Delete table"
|
|
1701
|
+
})
|
|
1702
|
+
]
|
|
1703
|
+
}) : /* @__PURE__ */ W(t, {
|
|
1704
|
+
size: "sm",
|
|
1705
|
+
isIconOnly: !0,
|
|
1706
|
+
iconStart: "table",
|
|
1707
|
+
"aria-label": "Insert table",
|
|
1708
|
+
title: "Insert table",
|
|
1709
|
+
"aria-haspopup": "dialog",
|
|
1710
|
+
isDisabled: n || !e || r,
|
|
1711
|
+
onClick: () => e && a(e.state.selection)
|
|
1712
|
+
}), e && i && !n && /* @__PURE__ */ W(jn, {
|
|
1713
|
+
editor: e,
|
|
1714
|
+
selection: i,
|
|
1715
|
+
onClose: c
|
|
1716
|
+
})] });
|
|
1717
|
+
}
|
|
1718
|
+
//#endregion
|
|
1719
|
+
//#region src/components/RichTextEditor/index.tsx
|
|
1720
|
+
function Ln({ editor: e, selection: n, onClose: r }) {
|
|
1721
|
+
let [i, a] = H(n.href), [o, s] = H(), c = z();
|
|
1722
|
+
R(() => {
|
|
1723
|
+
let t = () => {
|
|
1724
|
+
e.state.doc.eq(n.document) || r();
|
|
1725
|
+
};
|
|
1726
|
+
return e.on("transaction", t), () => {
|
|
1727
|
+
e.off("transaction", t);
|
|
1728
|
+
};
|
|
1729
|
+
}, [
|
|
1730
|
+
e,
|
|
1731
|
+
n,
|
|
1732
|
+
r
|
|
1733
|
+
]);
|
|
1734
|
+
let l = () => !e.isDestroyed && e.isEditable && e.state.doc.eq(n.document), u = () => {
|
|
1735
|
+
if (!l()) {
|
|
1736
|
+
r();
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
let t = i.trim();
|
|
1740
|
+
if (!t || !e.can().setLink({ href: t })) {
|
|
1741
|
+
s(t ? "Enter a valid link URL." : "Enter a link URL.");
|
|
1742
|
+
return;
|
|
1743
|
+
}
|
|
1744
|
+
let a = e.chain().focus().setTextSelection({
|
|
1745
|
+
from: n.from,
|
|
1746
|
+
to: n.to
|
|
1747
|
+
});
|
|
1748
|
+
n.from === n.to && !n.isEditing ? a.setLink({ href: t }).insertContent({
|
|
1749
|
+
type: "text",
|
|
1750
|
+
text: t,
|
|
1751
|
+
marks: [{
|
|
1752
|
+
type: "link",
|
|
1753
|
+
attrs: { href: t }
|
|
1754
|
+
}]
|
|
1755
|
+
}).run() : a.setLink({ href: t }).run(), r();
|
|
1756
|
+
};
|
|
1757
|
+
return /* @__PURE__ */ W(p, {
|
|
1758
|
+
isOpen: !0,
|
|
1759
|
+
title: n.isEditing ? "Edit link" : "Add link",
|
|
1760
|
+
size: "dialog",
|
|
1761
|
+
onClose: r,
|
|
1762
|
+
footer: /* @__PURE__ */ G(U, { children: [
|
|
1763
|
+
n.isEditing && /* @__PURE__ */ W(t, {
|
|
1764
|
+
variant: "danger",
|
|
1765
|
+
onClick: () => {
|
|
1766
|
+
l() && e.chain().focus().setTextSelection({
|
|
1767
|
+
from: n.from,
|
|
1768
|
+
to: n.to
|
|
1769
|
+
}).unsetLink().run(), r();
|
|
1770
|
+
},
|
|
1771
|
+
children: "Remove link"
|
|
1772
|
+
}),
|
|
1773
|
+
/* @__PURE__ */ W(t, {
|
|
1774
|
+
onClick: r,
|
|
1775
|
+
children: "Cancel"
|
|
1776
|
+
}),
|
|
1777
|
+
/* @__PURE__ */ W(t, {
|
|
1778
|
+
variant: "primary",
|
|
1779
|
+
type: "submit",
|
|
1780
|
+
form: c,
|
|
1781
|
+
children: "Save"
|
|
1782
|
+
})
|
|
1783
|
+
] }),
|
|
1784
|
+
children: /* @__PURE__ */ W("form", {
|
|
1785
|
+
id: c,
|
|
1786
|
+
noValidate: !0,
|
|
1787
|
+
onSubmit: (e) => {
|
|
1788
|
+
e.preventDefault(), e.stopPropagation(), u();
|
|
1789
|
+
},
|
|
1790
|
+
children: /* @__PURE__ */ W(f, {
|
|
1791
|
+
label: "URL",
|
|
1792
|
+
isRequired: !0,
|
|
1793
|
+
error: o,
|
|
1794
|
+
children: (e) => /* @__PURE__ */ W(h, {
|
|
1795
|
+
...e,
|
|
1796
|
+
value: i,
|
|
1797
|
+
inputMode: "url",
|
|
1798
|
+
autoComplete: "url",
|
|
1799
|
+
placeholder: "https://example.com",
|
|
1800
|
+
onChange: (e) => {
|
|
1801
|
+
a(e.target.value), s(void 0);
|
|
1802
|
+
}
|
|
1803
|
+
})
|
|
1804
|
+
})
|
|
1805
|
+
})
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
var Rn = [
|
|
1809
|
+
[
|
|
1810
|
+
{
|
|
1811
|
+
id: "bold",
|
|
1812
|
+
icon: "bold",
|
|
1813
|
+
label: "Bold",
|
|
1814
|
+
run: (e) => e.chain().focus().toggleBold().run(),
|
|
1815
|
+
active: (e) => e.isActive("bold")
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
id: "italic",
|
|
1819
|
+
icon: "italic",
|
|
1820
|
+
label: "Italic",
|
|
1821
|
+
run: (e) => e.chain().focus().toggleItalic().run(),
|
|
1822
|
+
active: (e) => e.isActive("italic")
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
id: "strike",
|
|
1826
|
+
icon: "strikethrough",
|
|
1827
|
+
label: "Strikethrough",
|
|
1828
|
+
run: (e) => e.chain().focus().toggleStrike().run(),
|
|
1829
|
+
active: (e) => e.isActive("strike")
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
id: "code",
|
|
1833
|
+
icon: "code",
|
|
1834
|
+
label: "Inline code",
|
|
1835
|
+
run: (e) => e.chain().focus().toggleCode().run(),
|
|
1836
|
+
active: (e) => e.isActive("code")
|
|
1837
|
+
}
|
|
1838
|
+
],
|
|
1839
|
+
[
|
|
1840
|
+
{
|
|
1841
|
+
id: "h2",
|
|
1842
|
+
icon: "heading-2",
|
|
1843
|
+
label: "Heading",
|
|
1844
|
+
run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
1845
|
+
active: (e) => e.isActive("heading", { level: 2 })
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
id: "h3",
|
|
1849
|
+
icon: "heading-3",
|
|
1850
|
+
label: "Subheading",
|
|
1851
|
+
run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
1852
|
+
active: (e) => e.isActive("heading", { level: 3 })
|
|
1853
|
+
},
|
|
1854
|
+
{
|
|
1855
|
+
id: "quote",
|
|
1856
|
+
icon: "quote",
|
|
1857
|
+
label: "Quote",
|
|
1858
|
+
run: (e) => e.chain().focus().toggleBlockquote().run(),
|
|
1859
|
+
active: (e) => e.isActive("blockquote")
|
|
1860
|
+
}
|
|
1861
|
+
],
|
|
1862
|
+
[{
|
|
1863
|
+
id: "ul",
|
|
1864
|
+
icon: "list",
|
|
1865
|
+
label: "Bulleted list",
|
|
1866
|
+
run: (e) => e.chain().focus().toggleBulletList().run(),
|
|
1867
|
+
active: (e) => e.isActive("bulletList")
|
|
1868
|
+
}, {
|
|
1869
|
+
id: "ol",
|
|
1870
|
+
icon: "list-ordered",
|
|
1871
|
+
label: "Numbered list",
|
|
1872
|
+
run: (e) => e.chain().focus().toggleOrderedList().run(),
|
|
1873
|
+
active: (e) => e.isActive("orderedList")
|
|
1874
|
+
}],
|
|
1875
|
+
[{
|
|
1876
|
+
id: "undo",
|
|
1877
|
+
icon: "undo",
|
|
1878
|
+
label: "Undo",
|
|
1879
|
+
run: (e) => e.chain().focus().undo().run()
|
|
1880
|
+
}, {
|
|
1881
|
+
id: "redo",
|
|
1882
|
+
icon: "redo",
|
|
1883
|
+
label: "Redo",
|
|
1884
|
+
run: (e) => e.chain().focus().redo().run()
|
|
1885
|
+
}]
|
|
1886
|
+
];
|
|
1887
|
+
function zn({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c, tables: l }) {
|
|
1888
|
+
return /* @__PURE__ */ G("div", {
|
|
1889
|
+
className: "ds-rte__toolbar ds-field-surface",
|
|
1890
|
+
role: "toolbar",
|
|
1891
|
+
"aria-label": `${i} formatting`,
|
|
1892
|
+
children: [
|
|
1893
|
+
Rn.map((i, a) => /* @__PURE__ */ W(u, {
|
|
1894
|
+
"aria-label": `Formatting ${a + 1}`,
|
|
1895
|
+
children: i.map((i) => /* @__PURE__ */ W(t, {
|
|
1896
|
+
size: "sm",
|
|
1897
|
+
isIconOnly: !0,
|
|
1898
|
+
iconStart: i.icon,
|
|
1899
|
+
"aria-label": i.label,
|
|
1900
|
+
title: i.label,
|
|
1901
|
+
"aria-pressed": i.active ? n?.active[i.id] : void 0,
|
|
1902
|
+
variant: n?.active[i.id] ? "primary" : "neutral",
|
|
1903
|
+
isDisabled: r || !e,
|
|
1904
|
+
onClick: () => e && i.run(e)
|
|
1905
|
+
}, i.id))
|
|
1906
|
+
}, a)),
|
|
1907
|
+
/* @__PURE__ */ W(u, {
|
|
1908
|
+
"aria-label": "Link",
|
|
1909
|
+
children: /* @__PURE__ */ W(t, {
|
|
1910
|
+
size: "sm",
|
|
1911
|
+
isIconOnly: !0,
|
|
1912
|
+
iconStart: "link",
|
|
1913
|
+
"aria-label": n?.linkActive ? "Edit link" : "Add link",
|
|
1914
|
+
title: n?.linkActive ? "Edit link" : "Add link",
|
|
1915
|
+
variant: n?.linkActive ? "primary" : "neutral",
|
|
1916
|
+
isDisabled: r || !e,
|
|
1917
|
+
onClick: () => e && o(e.state, e.isActive("link") ? e.state.selection.from : void 0)
|
|
1918
|
+
})
|
|
1919
|
+
}),
|
|
1920
|
+
l && /* @__PURE__ */ W(In, {
|
|
1921
|
+
editor: e,
|
|
1922
|
+
disabled: r,
|
|
1923
|
+
inTable: n?.tableActive ?? !1
|
|
1924
|
+
}),
|
|
1925
|
+
c,
|
|
1926
|
+
a,
|
|
1927
|
+
s
|
|
1928
|
+
]
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
var Bn = pe(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: o, contentError: s, errorId: c, surface: l, children: u }, d) {
|
|
1932
|
+
return /* @__PURE__ */ W(a.Provider, {
|
|
1933
|
+
value: e,
|
|
1934
|
+
children: /* @__PURE__ */ G("div", {
|
|
1935
|
+
ref: d,
|
|
1936
|
+
className: ["ds-rte", t].filter(Boolean).join(" "),
|
|
1937
|
+
style: n.frameStyle,
|
|
1938
|
+
"data-expanded": n.expanded || void 0,
|
|
1939
|
+
"data-focused": r && !n.expanded || void 0,
|
|
1940
|
+
"data-disabled": i || void 0,
|
|
1941
|
+
"data-invalid": o || void 0,
|
|
1942
|
+
"aria-invalid": o || void 0,
|
|
1943
|
+
children: [
|
|
1944
|
+
s && /* @__PURE__ */ W("p", {
|
|
1945
|
+
id: c,
|
|
1946
|
+
role: "alert",
|
|
1947
|
+
className: "ds-field__error",
|
|
1948
|
+
children: s
|
|
1949
|
+
}),
|
|
1950
|
+
n.expanded && /* @__PURE__ */ W("p", {
|
|
1951
|
+
className: "ds-rte__placeholder",
|
|
1952
|
+
children: "Editing in expanded view. Press Esc to return."
|
|
1953
|
+
}),
|
|
1954
|
+
n.surfaceSlot(/* @__PURE__ */ W("div", {
|
|
1955
|
+
className: "ds-rte__surface",
|
|
1956
|
+
hidden: !!s,
|
|
1957
|
+
"data-expanded": n.expanded || void 0,
|
|
1958
|
+
"data-focused": r || void 0,
|
|
1959
|
+
"data-disabled": i || void 0,
|
|
1960
|
+
"data-invalid": o || void 0,
|
|
1961
|
+
children: l
|
|
1962
|
+
})),
|
|
1963
|
+
n.dialog,
|
|
1964
|
+
u
|
|
1965
|
+
]
|
|
1966
|
+
})
|
|
1967
|
+
});
|
|
1968
|
+
}), Vn = He.extend({ addNodeView() {
|
|
1969
|
+
return ye(at, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
|
|
1970
|
+
} });
|
|
1971
|
+
function Hn(e, t) {
|
|
1972
|
+
return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
|
|
1973
|
+
}
|
|
1974
|
+
function Un(e, { format: t, value: n }, r, i, a) {
|
|
1975
|
+
if (n === void 0 && e && !e.isDestroyed) return t === "json" ? Xe(r, { tables: i }) ? void 0 : q(e.getJSON()) : i || a ? e.getHTML() : void 0;
|
|
1976
|
+
}
|
|
1977
|
+
var Wn = pe(function(e, t) {
|
|
1978
|
+
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 = V(null), b = B(() => n(y, t), [t]), [x, S] = H(!1), [C, w] = H(null), T = L(() => w(null), []), [E, D] = H(() => e.defaultValue ?? (e.format === "json" ? J : "")), [ee, te] = H(!1), O = e.value === void 0 ? E : e.value, k = B(() => e.format === "json" ? Xe(O, { tables: d }) : void 0, [
|
|
1979
|
+
e.format,
|
|
1980
|
+
O,
|
|
1981
|
+
d
|
|
1982
|
+
]), ne = z(), A = s || !!k || v, j = o || !!k;
|
|
1983
|
+
j && C && w(null);
|
|
1984
|
+
let M = L((e, t) => {
|
|
1985
|
+
if (j) return;
|
|
1986
|
+
let n = t === void 0 ? void 0 : xe(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
|
|
1987
|
+
w({
|
|
1988
|
+
from: n?.from ?? e.selection.from,
|
|
1989
|
+
to: n?.to ?? e.selection.to,
|
|
1990
|
+
href: r?.attrs.href ?? "",
|
|
1991
|
+
isEditing: !!r,
|
|
1992
|
+
document: e.doc
|
|
1993
|
+
});
|
|
1994
|
+
}, [j]), N = B(() => ({
|
|
1995
|
+
role: "textbox",
|
|
1996
|
+
...g ? {} : { "aria-label": h ?? c },
|
|
1997
|
+
"aria-multiline": "true",
|
|
1998
|
+
...f ? { id: f } : {},
|
|
1999
|
+
...g ? { "aria-labelledby": g } : {},
|
|
2000
|
+
..._ ? { "aria-describedby": _ } : {},
|
|
2001
|
+
...A ? { "aria-invalid": String(A) } : {},
|
|
2002
|
+
...p || m ? { "aria-required": "true" } : {}
|
|
2003
|
+
}), [
|
|
2004
|
+
c,
|
|
2005
|
+
h,
|
|
2006
|
+
f,
|
|
2007
|
+
g,
|
|
2008
|
+
_,
|
|
2009
|
+
A,
|
|
2010
|
+
p,
|
|
2011
|
+
m
|
|
2012
|
+
]), P = B(() => ({
|
|
2013
|
+
attributes: N,
|
|
2014
|
+
handleDOMEvents: {
|
|
2015
|
+
keydown: Hn,
|
|
2016
|
+
click: (e, t) => {
|
|
2017
|
+
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
2018
|
+
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && M(e.state, e.posAtDOM(n, 0)), !0);
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}), [N, M]), re = B(() => [...Je(Vn, { tables: d }), Ee.configure({ placeholder: r })], [r, d]), ie = B(() => k ? J : typeof O == "string" ? O : Y(O), [O, k]), F = we({
|
|
2022
|
+
immediatelyRender: !1,
|
|
2023
|
+
editable: !j,
|
|
2024
|
+
content: ie,
|
|
2025
|
+
extensions: re,
|
|
2026
|
+
editorProps: P,
|
|
2027
|
+
onFocus: () => S(!0),
|
|
2028
|
+
onBlur: () => S(!1),
|
|
2029
|
+
onUpdate: ({ editor: t, transaction: n }) => {
|
|
2030
|
+
(!j || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(q(t.getJSON())) : (e.value === void 0 && !t.schema.nodes.table && te(!0), e.onChange?.(t.getHTML())));
|
|
2031
|
+
}
|
|
2032
|
+
}, [d]), [ae, oe] = H(d);
|
|
2033
|
+
if (ae !== d) {
|
|
2034
|
+
oe(d), S(!1), te(!1);
|
|
2035
|
+
let t = Un(F, e, O, ae, ee);
|
|
2036
|
+
t !== void 0 && D(t);
|
|
2037
|
+
}
|
|
2038
|
+
R(() => {
|
|
2039
|
+
F && !F.isDestroyed && (F.setEditable(!j, !1), F.setOptions({ editorProps: P }));
|
|
2040
|
+
}, [
|
|
2041
|
+
F,
|
|
2042
|
+
j,
|
|
2043
|
+
P
|
|
2044
|
+
]), R(() => {
|
|
2045
|
+
if (!F || F.isDestroyed || e.value === void 0 || k) return;
|
|
2046
|
+
let t = typeof e.value == "string" ? be(e.value, F.schema) : F.schema.nodeFromJSON(Y(e.value));
|
|
2047
|
+
t.eq(F.state.doc) || F.commands.setContent(t, { emitUpdate: !1 });
|
|
2048
|
+
}, [
|
|
2049
|
+
F,
|
|
2050
|
+
e.value,
|
|
2051
|
+
k
|
|
2052
|
+
]);
|
|
2053
|
+
let se = Te({
|
|
2054
|
+
editor: F,
|
|
2055
|
+
selector: ({ editor: e }) => e ? {
|
|
2056
|
+
active: Object.fromEntries(Rn.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
2057
|
+
linkActive: e.isActive("link"),
|
|
2058
|
+
tableActive: e.isActive("table")
|
|
2059
|
+
} : null
|
|
2060
|
+
}), I = wt(F, k ? void 0 : e.embeds, j, c), ce = Be({
|
|
2061
|
+
editor: F,
|
|
2062
|
+
disabled: j,
|
|
2063
|
+
isHeld: I.isCreating,
|
|
2064
|
+
invalid: !!A,
|
|
2065
|
+
label: h ?? c,
|
|
2066
|
+
labelledBy: g,
|
|
2067
|
+
expandedWidth: a,
|
|
2068
|
+
frameRef: y
|
|
2069
|
+
});
|
|
2070
|
+
return /* @__PURE__ */ W(Qe.Provider, {
|
|
2071
|
+
value: I.context,
|
|
2072
|
+
children: /* @__PURE__ */ G(Bn, {
|
|
2073
|
+
ref: b,
|
|
2074
|
+
scopeRef: y,
|
|
2075
|
+
className: l,
|
|
2076
|
+
expansion: ce,
|
|
2077
|
+
isFocused: x,
|
|
2078
|
+
disabled: j,
|
|
2079
|
+
invalid: !!A,
|
|
2080
|
+
contentError: k,
|
|
2081
|
+
errorId: ne,
|
|
2082
|
+
surface: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(zn, {
|
|
2083
|
+
editor: F,
|
|
2084
|
+
state: se,
|
|
2085
|
+
disabled: j,
|
|
2086
|
+
label: c,
|
|
2087
|
+
toolbarExtra: u,
|
|
2088
|
+
openLink: M,
|
|
2089
|
+
expandControl: ce.toggle,
|
|
2090
|
+
embedControl: I.toolbar,
|
|
2091
|
+
tables: d
|
|
2092
|
+
}), /* @__PURE__ */ W("div", {
|
|
2093
|
+
className: "ds-rte__content ds-field-surface",
|
|
2094
|
+
"data-size": i,
|
|
2095
|
+
children: /* @__PURE__ */ W(ge, { editor: F })
|
|
2096
|
+
})] }),
|
|
2097
|
+
children: [I.dialog, F && C && !j && /* @__PURE__ */ W(Ln, {
|
|
2098
|
+
editor: F,
|
|
2099
|
+
selection: C,
|
|
2100
|
+
onClose: T
|
|
2101
|
+
})]
|
|
2102
|
+
})
|
|
2103
|
+
});
|
|
2104
|
+
});
|
|
2105
|
+
//#endregion
|
|
2106
|
+
export { J as a, cn as i, Cn as n, hn as r, Wn as t };
|
|
2107
|
+
|
|
2108
|
+
//# sourceMappingURL=RichTextEditor-DPhEkDxi.js.map
|