@namroodinc/liquid-editorial 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/UPGRADING.md +90 -0
- package/dist/chunks/{Avatar-DPnrvkwd.cjs → Avatar-BY0dAItT.cjs} +2 -2
- package/dist/chunks/{Avatar-DPnrvkwd.cjs.map → Avatar-BY0dAItT.cjs.map} +1 -1
- package/dist/chunks/{Avatar-BK8IdL5W.js → Avatar-UjhjcHh5.js} +2 -2
- package/dist/chunks/{Avatar-BK8IdL5W.js.map → Avatar-UjhjcHh5.js.map} +1 -1
- package/dist/chunks/{Board-BCS7sDXg.js → Board-6fXt1YFp.js} +2 -2
- package/dist/chunks/{Board-BCS7sDXg.js.map → Board-6fXt1YFp.js.map} +1 -1
- package/dist/chunks/{Board-CNVy8gHI.cjs → Board-DfVQSb_L.cjs} +2 -2
- package/dist/chunks/{Board-CNVy8gHI.cjs.map → Board-DfVQSb_L.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-DrszOUOt.cjs → CollectionView-CIJdNwcq.cjs} +2 -2
- package/dist/chunks/{CollectionView-DrszOUOt.cjs.map → CollectionView-CIJdNwcq.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-B0ZJxkNK.js → CollectionView-JRNdXHti.js} +2 -2
- package/dist/chunks/{CollectionView-B0ZJxkNK.js.map → CollectionView-JRNdXHti.js.map} +1 -1
- package/dist/chunks/{ColourField-C39pcjkG.js → ColourField-YaCEWiPA.js} +147 -153
- package/dist/chunks/ColourField-YaCEWiPA.js.map +1 -0
- package/dist/chunks/ColourField-bgi6TLOM.cjs +2 -0
- package/dist/chunks/ColourField-bgi6TLOM.cjs.map +1 -0
- package/dist/chunks/{DatePicker-Dpvfomrm.cjs → DatePicker-CCygKPuy.cjs} +2 -2
- package/dist/chunks/{DatePicker-Dpvfomrm.cjs.map → DatePicker-CCygKPuy.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-DDc1nDTb.js → DatePicker-CHJYSaLU.js} +22 -22
- package/dist/chunks/{DatePicker-DDc1nDTb.js.map → DatePicker-CHJYSaLU.js.map} +1 -1
- package/dist/chunks/{Drawer-C3mWT9Kh.js → Drawer-Ck5XKT_V.js} +3 -3
- package/dist/chunks/{Drawer-C3mWT9Kh.js.map → Drawer-Ck5XKT_V.js.map} +1 -1
- package/dist/chunks/{Drawer-DTKZptua.cjs → Drawer-DdIH9jpe.cjs} +2 -2
- package/dist/chunks/{Drawer-DTKZptua.cjs.map → Drawer-DdIH9jpe.cjs.map} +1 -1
- package/dist/chunks/{EntryPicker-CgWbgWnc.cjs → EntryPicker-DmiAnu9l.cjs} +2 -2
- package/dist/chunks/{EntryPicker-CgWbgWnc.cjs.map → EntryPicker-DmiAnu9l.cjs.map} +1 -1
- package/dist/chunks/{EntryPicker-DlEsVCvA.js → EntryPicker-WERMwe0h.js} +3 -3
- package/dist/chunks/{EntryPicker-DlEsVCvA.js.map → EntryPicker-WERMwe0h.js.map} +1 -1
- package/dist/chunks/{FormEditor-iACd0El-.cjs → FormEditor-B8USzAky.cjs} +2 -2
- package/dist/chunks/{FormEditor-iACd0El-.cjs.map → FormEditor-B8USzAky.cjs.map} +1 -1
- package/dist/chunks/{FormEditor-CLLOHKiO.js → FormEditor-BG2RhC71.js} +16 -16
- package/dist/chunks/{FormEditor-CLLOHKiO.js.map → FormEditor-BG2RhC71.js.map} +1 -1
- package/dist/chunks/{Icon-CD3oeiNA.cjs → Icon-C12r4frL.cjs} +2 -2
- package/dist/chunks/Icon-C12r4frL.cjs.map +1 -0
- package/dist/chunks/{Icon-CYXOo0Kt.js → Icon-Peb0houB.js} +38 -36
- package/dist/chunks/Icon-Peb0houB.js.map +1 -0
- package/dist/chunks/{Message-CyLq9ef-.js → Message-CMoH7jcg.js} +5 -9
- package/dist/chunks/{Message-CyLq9ef-.js.map → Message-CMoH7jcg.js.map} +1 -1
- package/dist/chunks/{Message-D3b8HDhm.cjs → Message-qguX0uZk.cjs} +2 -2
- package/dist/chunks/{Message-D3b8HDhm.cjs.map → Message-qguX0uZk.cjs.map} +1 -1
- package/dist/chunks/RichTextEditor-BSA4uzKm.cjs +2 -0
- package/dist/chunks/RichTextEditor-BSA4uzKm.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-B0P53GFt.js → RichTextEditor-D8VQAM5h.js} +396 -375
- package/dist/chunks/RichTextEditor-D8VQAM5h.js.map +1 -0
- package/dist/chunks/{dialogLabel-D18maX-p.js → dialogLabel-DT7rCr3_.js} +19 -19
- package/dist/chunks/{dialogLabel-D18maX-p.js.map → dialogLabel-DT7rCr3_.js.map} +1 -1
- package/dist/chunks/{dialogLabel-2HRYMHbF.cjs → dialogLabel-_-MTckE_.cjs} +2 -2
- package/dist/chunks/{dialogLabel-2HRYMHbF.cjs.map → dialogLabel-_-MTckE_.cjs.map} +1 -1
- package/dist/chunks/overlayLayer-iGhuAByk.cjs +2 -0
- package/dist/chunks/overlayLayer-iGhuAByk.cjs.map +1 -0
- package/dist/chunks/{overlayLayer-IuoPVwTO.js → overlayLayer-lU4iWSjO.js} +32 -28
- package/dist/chunks/overlayLayer-lU4iWSjO.js.map +1 -0
- package/dist/chunks/{group-7Z_xRlQx.js → style-7Z_xRlQx.js} +1 -1
- package/dist/chunks/{group-7Z_xRlQx.js.map → style-7Z_xRlQx.js.map} +1 -1
- package/dist/chunks/{group-nulIa2_8.cjs → style-nulIa2_8.cjs} +1 -1
- package/dist/chunks/{group-nulIa2_8.cjs.map → style-nulIa2_8.cjs.map} +1 -1
- package/dist/chunks/{use-picker-session-DbfOJstX.cjs → use-picker-session-CM0zcEbf.cjs} +2 -2
- package/dist/chunks/{use-picker-session-DbfOJstX.cjs.map → use-picker-session-CM0zcEbf.cjs.map} +1 -1
- package/dist/chunks/{use-picker-session-BnMxbGAZ.js → use-picker-session-GCDShVBy.js} +3 -3
- package/dist/chunks/{use-picker-session-BnMxbGAZ.js.map → use-picker-session-GCDShVBy.js.map} +1 -1
- package/dist/chunks/{useTooltip-BXAvQwt4.cjs → useTooltip-C7ON4nkV.cjs} +2 -2
- package/dist/chunks/{useTooltip-BXAvQwt4.cjs.map → useTooltip-C7ON4nkV.cjs.map} +1 -1
- package/dist/chunks/{useTooltip-BrC7FdeH.js → useTooltip-DnJEFBLg.js} +2 -2
- package/dist/chunks/{useTooltip-BrC7FdeH.js.map → useTooltip-DnJEFBLg.js.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/Badge/style.css +9 -9
- 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/Board/style.css +3 -3
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/style.css +4 -8
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.js +3 -3
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/Choice/style.css +29 -18
- 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.d.cts.map +1 -1
- package/dist/components/ColourField/index.d.ts.map +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/ColourField/style.css +4 -4
- 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/Drawer/style.css +2 -4
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.js +4 -4
- package/dist/components/EditLayout/style.css +1 -7
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/style.css +3 -1
- package/dist/components/Field/style.css +1 -1
- package/dist/components/FormEditor/README.md +28 -33
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/style.css +1 -0
- package/dist/components/Icon/icons.d.cts +2 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +2 -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/LimitReading/style.css +1 -1
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/style.css +3 -2
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/Modal/style.css +1 -3
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +58 -55
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- 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 +141 -61
- 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.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js +2 -2
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SelectionCard/style.css +20 -65
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/Skeleton/style.css +1 -1
- package/dist/components/Slider/style.css +12 -23
- 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/Switch/index.cjs +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js +2 -1
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +14 -2
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TagsInput/style.css +3 -21
- 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/elements.css +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +30 -30
- package/dist/internal/dialogFocus.d.cts +2 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +2 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/message.css +5 -3
- package/dist/tokens.css +83 -309
- package/package.json +1 -1
- package/dist/chunks/ColourField-BdobU76j.cjs +0 -2
- package/dist/chunks/ColourField-BdobU76j.cjs.map +0 -1
- package/dist/chunks/ColourField-C39pcjkG.js.map +0 -1
- package/dist/chunks/Icon-CD3oeiNA.cjs.map +0 -1
- package/dist/chunks/Icon-CYXOo0Kt.js.map +0 -1
- package/dist/chunks/RichTextEditor-B0P53GFt.js.map +0 -1
- package/dist/chunks/RichTextEditor-Wu_yjvD7.cjs +0 -2
- package/dist/chunks/RichTextEditor-Wu_yjvD7.cjs.map +0 -1
- package/dist/chunks/overlayLayer-IuoPVwTO.js.map +0 -1
- package/dist/chunks/overlayLayer-seJG-EFn.cjs +0 -2
- package/dist/chunks/overlayLayer-seJG-EFn.cjs.map +0 -1
- package/dist/components/ColourField/focus.d.cts +0 -3
- package/dist/components/ColourField/focus.d.cts.map +0 -1
- package/dist/components/ColourField/focus.d.ts +0 -3
- package/dist/components/ColourField/focus.d.ts.map +0 -1
|
@@ -1,90 +1,92 @@
|
|
|
1
|
-
import { t as e } from "./Icon-
|
|
1
|
+
import { t as e } from "./Icon-Peb0houB.js";
|
|
2
2
|
import { Button as t } from "../components/Button/index.js";
|
|
3
3
|
import { t as n } from "./mergeRefs-C6_5pADN.js";
|
|
4
|
-
import { d as r, f as i,
|
|
5
|
-
import { a as
|
|
6
|
-
import { t as
|
|
7
|
-
import { ButtonGroup as
|
|
8
|
-
import { Badge as
|
|
4
|
+
import { d as r, f as i, g as a, o, p as s, s as c, u as l } from "./overlayLayer-lU4iWSjO.js";
|
|
5
|
+
import { a as u, o as d } from "./dialogLabel-DT7rCr3_.js";
|
|
6
|
+
import { t as f } from "./useIsomorphicLayoutEffect-Bc9hxFMc.js";
|
|
7
|
+
import { ButtonGroup as p } from "../components/ButtonGroup/index.js";
|
|
8
|
+
import { Badge as m } from "../components/Badge/index.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import { Field as
|
|
11
|
-
import { Modal as
|
|
12
|
-
import { TextField as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
10
|
+
import { Field as h } from "../components/Field/index.js";
|
|
11
|
+
import { Modal as g } from "../components/Modal/index.js";
|
|
12
|
+
import { TextField as _ } from "../components/TextField/index.js";
|
|
13
|
+
import { Popover as v } from "../components/Popover/index.js";
|
|
14
|
+
import { MenuSeparator as y } from "../components/Menu/index.js";
|
|
15
|
+
import { a as b, i as x, l as S, o as C, s as w, t as T } from "./use-picker-session-GCDShVBy.js";
|
|
16
|
+
import { createContext as E, forwardRef as D, useCallback as O, useContext as k, useEffect as A, useId as j, useMemo as M, useRef as N, useState as P } from "react";
|
|
17
|
+
import { createPortal as F } from "react-dom";
|
|
18
|
+
import { Fragment as ee, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
19
|
+
import { EditorContent as te, Node as R, NodeViewWrapper as z, ReactNodeViewRenderer as B, createDocument as ne, getMarkRange as re, getSchema as V, mergeAttributes as H, useEditor as ie, useEditorState as ae } from "@tiptap/react";
|
|
20
|
+
import { Placeholder as oe } from "@tiptap/extension-placeholder";
|
|
21
|
+
import { StarterKit as se } from "@tiptap/starter-kit";
|
|
22
|
+
import { Link as U } from "@tiptap/extension-link";
|
|
21
23
|
//#region src/components/RichTextEditor/expansion.tsx
|
|
22
|
-
function
|
|
24
|
+
function ce(e, t) {
|
|
23
25
|
let n = t.querySelector(".ds-rte__content");
|
|
24
26
|
if (!n) return;
|
|
25
27
|
let r = e.view.coordsAtPos(e.state.selection.head), i = n.getBoundingClientRect();
|
|
26
28
|
(r.top < i.top || r.bottom > i.bottom) && (n.scrollTop += r.top - i.top - i.height / 2);
|
|
27
29
|
}
|
|
28
|
-
function
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
30
|
+
function le({ editor: e, disabled: n, isHeld: i = !1, invalid: a, label: o, labelledBy: c, expandedWidth: l, frameRef: p }) {
|
|
31
|
+
let m = d("ds-rte__host"), [h, _] = P(!1), [v, y] = P(0), b = N(null), x = N(null), S = N(null), C = N(!1), w = N(!1), T = j();
|
|
32
|
+
h && n && !i && _(!1);
|
|
33
|
+
let E = O(() => {
|
|
34
|
+
C.current = document.activeElement === S.current, _(!1);
|
|
33
35
|
}, []);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
f(() => {
|
|
37
|
+
m && (u(m, h ? x.current : b.current), w.current !== h && (w.current = h, n || !e ? r(document.activeElement) && s(p.current, { preventScroll: !0 }) : (ce(e, m), !h && C.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), C.current = !1)));
|
|
36
38
|
}, [
|
|
39
|
+
m,
|
|
37
40
|
h,
|
|
38
|
-
g,
|
|
39
41
|
e,
|
|
40
42
|
n,
|
|
41
|
-
|
|
43
|
+
p
|
|
42
44
|
]);
|
|
43
|
-
let
|
|
45
|
+
let D = h ? "Collapse editor" : "Expand editor";
|
|
44
46
|
return {
|
|
45
|
-
expanded:
|
|
46
|
-
toggle: /* @__PURE__ */
|
|
47
|
+
expanded: h,
|
|
48
|
+
toggle: /* @__PURE__ */ I(t, {
|
|
47
49
|
ref: S,
|
|
48
50
|
size: "sm",
|
|
49
51
|
isIconOnly: !0,
|
|
50
|
-
iconStart:
|
|
52
|
+
iconStart: h ? "minimize-2" : "maximize-2",
|
|
51
53
|
className: "ds-rte__expand",
|
|
52
|
-
"aria-label":
|
|
53
|
-
title:
|
|
54
|
-
"aria-expanded":
|
|
55
|
-
"aria-controls":
|
|
56
|
-
isDisabled: n || !e || !
|
|
54
|
+
"aria-label": D,
|
|
55
|
+
title: D,
|
|
56
|
+
"aria-expanded": h,
|
|
57
|
+
"aria-controls": h ? T : void 0,
|
|
58
|
+
isDisabled: n || !e || !m,
|
|
57
59
|
onMouseDown: (e) => e.preventDefault(),
|
|
58
60
|
onClick: () => {
|
|
59
|
-
|
|
61
|
+
h ? E() : (y(p.current.getBoundingClientRect().height), _(!0));
|
|
60
62
|
}
|
|
61
63
|
}),
|
|
62
|
-
surfaceSlot: (e) => /* @__PURE__ */
|
|
64
|
+
surfaceSlot: (e) => /* @__PURE__ */ I("div", {
|
|
63
65
|
ref: b,
|
|
64
66
|
className: "ds-rte__slot",
|
|
65
|
-
children:
|
|
67
|
+
children: m ? F(e, m) : e
|
|
66
68
|
}),
|
|
67
|
-
dialog: /* @__PURE__ */
|
|
68
|
-
id:
|
|
69
|
-
isOpen:
|
|
70
|
-
onClose:
|
|
71
|
-
title:
|
|
69
|
+
dialog: /* @__PURE__ */ I(g, {
|
|
70
|
+
id: T,
|
|
71
|
+
isOpen: h,
|
|
72
|
+
onClose: E,
|
|
73
|
+
title: o,
|
|
72
74
|
hasHeader: !1,
|
|
73
|
-
size:
|
|
75
|
+
size: l === "full" ? "full" : "wide",
|
|
74
76
|
className: "ds-rte__modal",
|
|
75
|
-
"data-invalid":
|
|
76
|
-
"aria-labelledby":
|
|
77
|
-
children: /* @__PURE__ */
|
|
77
|
+
"data-invalid": a || void 0,
|
|
78
|
+
"aria-labelledby": c,
|
|
79
|
+
children: /* @__PURE__ */ I("div", {
|
|
78
80
|
ref: x,
|
|
79
81
|
className: "ds-rte__expanded-slot"
|
|
80
82
|
})
|
|
81
83
|
}),
|
|
82
|
-
frameStyle:
|
|
84
|
+
frameStyle: h ? { minBlockSize: v } : void 0
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
//#endregion
|
|
86
88
|
//#region src/components/RichTextEditor/storyblock.ts
|
|
87
|
-
function
|
|
89
|
+
function W(e) {
|
|
88
90
|
let t = (e) => typeof e == "string" && e.trim().length > 0;
|
|
89
91
|
return [
|
|
90
92
|
"left",
|
|
@@ -92,7 +94,7 @@ function B(e) {
|
|
|
92
94
|
"right"
|
|
93
95
|
].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);
|
|
94
96
|
}
|
|
95
|
-
function
|
|
97
|
+
function G(e) {
|
|
96
98
|
return {
|
|
97
99
|
...e,
|
|
98
100
|
...e.type === "storyblock" && e.attrs ? { attrs: {
|
|
@@ -103,10 +105,10 @@ function V(e) {
|
|
|
103
105
|
} : { assetId: e.attrs.assetId },
|
|
104
106
|
align: e.attrs.align ?? "full"
|
|
105
107
|
} } : {},
|
|
106
|
-
...e.content ? { content: e.content.map(
|
|
108
|
+
...e.content ? { content: e.content.map(G) } : {}
|
|
107
109
|
};
|
|
108
110
|
}
|
|
109
|
-
var
|
|
111
|
+
var K = R.create({
|
|
110
112
|
name: "storyblock",
|
|
111
113
|
group: "block",
|
|
112
114
|
atom: !0,
|
|
@@ -129,7 +131,7 @@ var H = te.create({
|
|
|
129
131
|
parseHTML() {
|
|
130
132
|
return [{
|
|
131
133
|
tag: "div[data-storyblock]",
|
|
132
|
-
getAttrs: (e) =>
|
|
134
|
+
getAttrs: (e) => W(Object.fromEntries([
|
|
133
135
|
"type",
|
|
134
136
|
"id",
|
|
135
137
|
"entryId",
|
|
@@ -139,64 +141,64 @@ var H = te.create({
|
|
|
139
141
|
}];
|
|
140
142
|
},
|
|
141
143
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
142
|
-
let n =
|
|
144
|
+
let n = G({
|
|
143
145
|
type: "storyblock",
|
|
144
146
|
attrs: e.attrs
|
|
145
147
|
}).attrs;
|
|
146
|
-
return ["div",
|
|
148
|
+
return ["div", H(t, {
|
|
147
149
|
"data-storyblock": "",
|
|
148
150
|
...Object.fromEntries(Object.entries(n).map(([e, t]) => [`data-storyblock-${e.toLowerCase()}`, t]))
|
|
149
151
|
})];
|
|
150
152
|
}
|
|
151
|
-
}),
|
|
153
|
+
}), q = {
|
|
152
154
|
type: "doc",
|
|
153
155
|
content: [{ type: "paragraph" }]
|
|
154
|
-
},
|
|
156
|
+
}, ue = [se.configure({
|
|
155
157
|
link: !1,
|
|
156
158
|
trailingNode: { notAfter: ["paragraph", "storyblock"] }
|
|
157
|
-
}),
|
|
159
|
+
}), U.configure({
|
|
158
160
|
openOnClick: !1,
|
|
159
161
|
autolink: !0
|
|
160
162
|
})];
|
|
161
|
-
function
|
|
162
|
-
return [e, ...
|
|
163
|
+
function de(e = K) {
|
|
164
|
+
return [e, ...ue];
|
|
163
165
|
}
|
|
164
|
-
var
|
|
165
|
-
function
|
|
166
|
+
var J = V(de());
|
|
167
|
+
function Y(e) {
|
|
166
168
|
return e.content?.length ? e : {
|
|
167
169
|
...e,
|
|
168
|
-
content:
|
|
170
|
+
content: q.content
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
|
-
function
|
|
173
|
+
function fe(e) {
|
|
172
174
|
try {
|
|
173
175
|
if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
|
|
174
176
|
let t = (e) => {
|
|
175
|
-
let n =
|
|
177
|
+
let n = J.nodes[e.type ?? ""];
|
|
176
178
|
if (!n || Object.keys(e).some((e) => ![
|
|
177
179
|
"type",
|
|
178
180
|
"attrs",
|
|
179
181
|
"content",
|
|
180
182
|
"marks",
|
|
181
183
|
"text"
|
|
182
|
-
].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e)) || e.type === "storyblock" && (!
|
|
184
|
+
].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e)) || e.type === "storyblock" && (!W(e.attrs ?? {}) || e.marks?.length)) throw Error();
|
|
183
185
|
for (let t of e.marks ?? []) {
|
|
184
|
-
let e =
|
|
186
|
+
let e = J.marks[t.type];
|
|
185
187
|
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();
|
|
186
188
|
}
|
|
187
189
|
e.content?.forEach(t);
|
|
188
190
|
}, n = e;
|
|
189
|
-
t(n),
|
|
191
|
+
t(n), J.nodeFromJSON(Y(n)).check();
|
|
190
192
|
} catch {
|
|
191
193
|
return "Unsupported or invalid rich-text document.";
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
//#endregion
|
|
195
197
|
//#region src/components/RichTextEditor/embed-context.ts
|
|
196
|
-
function
|
|
198
|
+
function X(e) {
|
|
197
199
|
return !!(e && (e.loadPage || e.items?.length || e.onCreate));
|
|
198
200
|
}
|
|
199
|
-
var
|
|
201
|
+
var Z = E({
|
|
200
202
|
views: {},
|
|
201
203
|
disabled: !1,
|
|
202
204
|
busy: !1,
|
|
@@ -204,64 +206,26 @@ var Y = x({
|
|
|
204
206
|
replace: () => {},
|
|
205
207
|
seed: () => void 0,
|
|
206
208
|
forgetSeed: () => {}
|
|
207
|
-
}),
|
|
209
|
+
}), pe = [], me = [
|
|
208
210
|
{
|
|
209
211
|
align: "left",
|
|
210
212
|
icon: "align-left",
|
|
211
|
-
label: "
|
|
213
|
+
label: "Left"
|
|
212
214
|
},
|
|
213
215
|
{
|
|
214
216
|
align: "full",
|
|
215
217
|
icon: "align-justify",
|
|
216
|
-
label: "Full
|
|
218
|
+
label: "Full"
|
|
217
219
|
},
|
|
218
220
|
{
|
|
219
221
|
align: "right",
|
|
220
222
|
icon: "align-right",
|
|
221
|
-
label: "
|
|
223
|
+
label: "Right"
|
|
222
224
|
}
|
|
223
|
-
]
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
"replace",
|
|
228
|
-
"edit",
|
|
229
|
-
"remove"
|
|
230
|
-
], de = /* @__PURE__ */ new Map([
|
|
231
|
-
["ArrowLeft", -1],
|
|
232
|
-
["ArrowRight", 1],
|
|
233
|
-
["Home", -Infinity],
|
|
234
|
-
["End", Infinity]
|
|
235
|
-
]);
|
|
236
|
-
function fe(e) {
|
|
237
|
-
let t = de.get(e.key);
|
|
238
|
-
if (t === void 0 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
239
|
-
let n = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)")), r = n.indexOf(e.target);
|
|
240
|
-
if (r === -1) return;
|
|
241
|
-
e.preventDefault();
|
|
242
|
-
let i = r + t;
|
|
243
|
-
n[Number.isFinite(i) ? (i + n.length) % n.length : Math.max(0, Math.min(i, n.length - 1))].focus();
|
|
244
|
-
}
|
|
245
|
-
function pe(e, t) {
|
|
246
|
-
let [n, r] = k(), [i, a] = k(!1), o = e || i, s = n && t.includes(n) ? n : t[0];
|
|
247
|
-
return {
|
|
248
|
-
control: (e) => ({
|
|
249
|
-
isDisabled: !t.includes(e),
|
|
250
|
-
tabIndex: o && e === s ? 0 : -1,
|
|
251
|
-
onFocus: () => r(e)
|
|
252
|
-
}),
|
|
253
|
-
barProps: {
|
|
254
|
-
onKeyDown: fe,
|
|
255
|
-
onFocus: () => a(!0),
|
|
256
|
-
onBlur: (e) => {
|
|
257
|
-
e.currentTarget.contains(e.relatedTarget) || a(!1);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function me(e, t) {
|
|
263
|
-
let { views: n, seed: r, forgetSeed: i } = w(Y), a = n[e], o = a?.items ?? X, s = D(() => [t], [t]), c = C((t) => r(e, t), [r, e]), l = v(s, o, a?.resolveItem, a?.refreshKey, c), u = r(e, t);
|
|
264
|
-
T(() => {
|
|
225
|
+
];
|
|
226
|
+
function he(e, t) {
|
|
227
|
+
let { views: n, seed: r, forgetSeed: i } = k(Z), a = n[e], o = a?.items ?? pe, s = M(() => [t], [t]), c = O((t) => r(e, t), [r, e]), l = C(s, o, a?.resolveItem, a?.refreshKey, c), u = r(e, t);
|
|
228
|
+
A(() => {
|
|
265
229
|
u && i(e, t, u);
|
|
266
230
|
}, [
|
|
267
231
|
i,
|
|
@@ -269,10 +233,10 @@ function me(e, t) {
|
|
|
269
233
|
t,
|
|
270
234
|
u
|
|
271
235
|
]);
|
|
272
|
-
let { known: d, failures: f } = l, p = !!a?.resolveItem, m =
|
|
236
|
+
let { known: d, failures: f } = l, p = !!a?.resolveItem, m = M(() => w({
|
|
273
237
|
selected: s,
|
|
274
238
|
items: o,
|
|
275
|
-
pageItems:
|
|
239
|
+
pageItems: pe,
|
|
276
240
|
known: d,
|
|
277
241
|
failures: f,
|
|
278
242
|
hasResolver: p,
|
|
@@ -284,29 +248,29 @@ function me(e, t) {
|
|
|
284
248
|
f,
|
|
285
249
|
p,
|
|
286
250
|
e
|
|
287
|
-
]),
|
|
251
|
+
]), h = b(`Couldn't load ${e}`, l.status, l.error, l.retry), g = o.some((e) => e.id === t);
|
|
288
252
|
return {
|
|
289
253
|
view: a,
|
|
290
254
|
item: m,
|
|
291
|
-
missing: m.tone === "removed" || !
|
|
292
|
-
failure:
|
|
255
|
+
missing: m.tone === "removed" || !g && d.has(t) && !d.get(t),
|
|
256
|
+
failure: h
|
|
293
257
|
};
|
|
294
258
|
}
|
|
295
|
-
function
|
|
296
|
-
return /* @__PURE__ */
|
|
259
|
+
function ge({ kind: t, isMovable: n, onSelect: r }) {
|
|
260
|
+
return /* @__PURE__ */ L("span", {
|
|
297
261
|
className: "ds-storyblock__kind",
|
|
298
262
|
"data-drag-handle": n ? "" : void 0,
|
|
299
263
|
draggable: n || void 0,
|
|
300
264
|
title: n ? "Drag to move" : void 0,
|
|
301
265
|
onClick: n ? r : void 0,
|
|
302
|
-
children: [n && /* @__PURE__ */
|
|
266
|
+
children: [n && /* @__PURE__ */ I("span", {
|
|
303
267
|
className: "ds-storyblock__grip",
|
|
304
268
|
"aria-hidden": "true",
|
|
305
|
-
children: /* @__PURE__ */
|
|
269
|
+
children: /* @__PURE__ */ I(e, {
|
|
306
270
|
name: "grip-vertical",
|
|
307
271
|
size: 16
|
|
308
272
|
})
|
|
309
|
-
}), /* @__PURE__ */
|
|
273
|
+
}), /* @__PURE__ */ I(m, {
|
|
310
274
|
className: "ds-storyblock__kind-label",
|
|
311
275
|
shape: "tag",
|
|
312
276
|
size: "sm",
|
|
@@ -314,119 +278,172 @@ function he({ kind: t, isMovable: n, onSelect: r }) {
|
|
|
314
278
|
})]
|
|
315
279
|
});
|
|
316
280
|
}
|
|
317
|
-
function
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
281
|
+
function _e({ kind: e, name: n, align: r, isSelected: s, isLocked: c, missing: l, canReplace: u, onEdit: d, onSelect: f, onAlign: m, onReplace: h, onRemove: g }) {
|
|
282
|
+
let [_, b] = P(!1), [x, S] = P(!1), C = N(null), w = N(null), T = j(), E = o(_) && !c, D = `Block actions for ${n}`;
|
|
283
|
+
_ && c && b(!1), A(() => {
|
|
284
|
+
if (!E) return;
|
|
285
|
+
w.current?.querySelector("[aria-pressed=\"true\"]")?.focus({ preventScroll: !0 });
|
|
286
|
+
let e = (e) => {
|
|
287
|
+
let t = e.target;
|
|
288
|
+
t instanceof Node && !C.current?.contains(t) && !w.current?.contains(t) && b(!1);
|
|
289
|
+
};
|
|
290
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
291
|
+
}, [E]);
|
|
292
|
+
let O = () => {
|
|
293
|
+
b(!1), C.current?.focus({ preventScroll: !0 });
|
|
294
|
+
};
|
|
295
|
+
return /* @__PURE__ */ L("div", {
|
|
327
296
|
className: "ds-storyblock__bar ds-field-surface",
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
297
|
+
onKeyDown: (e) => {
|
|
298
|
+
let t = w.current;
|
|
299
|
+
if (!E || !t) return;
|
|
300
|
+
if (e.key === "Escape" && !e.nativeEvent.isComposing) {
|
|
301
|
+
e.preventDefault(), e.stopPropagation(), O();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (e.key !== "Tab" || !(e.target instanceof Node) || !t.contains(e.target)) return;
|
|
305
|
+
let n = a(t), r = e.shiftKey ? n[0] : n.at(-1);
|
|
306
|
+
e.target === t && !e.shiftKey ? (e.preventDefault(), n[0]?.focus({ preventScroll: !0 })) : (e.target === r || e.target === t) && (e.preventDefault(), e.shiftKey ? O() : (b(!1), i(e.currentTarget)));
|
|
307
|
+
},
|
|
308
|
+
onBlur: ({ relatedTarget: e }) => {
|
|
309
|
+
E && e && e !== C.current && !w.current?.contains(e) && b(!1);
|
|
310
|
+
},
|
|
331
311
|
children: [
|
|
332
|
-
/* @__PURE__ */
|
|
312
|
+
/* @__PURE__ */ I(ge, {
|
|
333
313
|
kind: e,
|
|
334
|
-
isMovable: !
|
|
335
|
-
onSelect:
|
|
314
|
+
isMovable: !c,
|
|
315
|
+
onSelect: f
|
|
336
316
|
}),
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
|
|
339
|
-
"
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
317
|
+
/* @__PURE__ */ I(t, {
|
|
318
|
+
ref: C,
|
|
319
|
+
variant: E ? "active" : "simple",
|
|
320
|
+
size: "sm",
|
|
321
|
+
isIconOnly: !0,
|
|
322
|
+
iconStart: "more-horizontal",
|
|
323
|
+
isDisabled: c,
|
|
324
|
+
tabIndex: !c && (s || x || E) ? 0 : -1,
|
|
325
|
+
"aria-label": D,
|
|
326
|
+
"aria-haspopup": "dialog",
|
|
327
|
+
"aria-expanded": E,
|
|
328
|
+
"aria-controls": E ? T : void 0,
|
|
329
|
+
onFocus: () => S(!0),
|
|
330
|
+
onBlur: () => S(!1),
|
|
331
|
+
onClick: () => E ? O() : b(!0)
|
|
351
332
|
}),
|
|
352
|
-
/* @__PURE__ */
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
333
|
+
/* @__PURE__ */ I(v, {
|
|
334
|
+
anchorRef: C,
|
|
335
|
+
panelRef: w,
|
|
336
|
+
isOpen: E,
|
|
337
|
+
align: "end",
|
|
338
|
+
role: "dialog",
|
|
339
|
+
tabIndex: -1,
|
|
340
|
+
"aria-label": D,
|
|
341
|
+
id: T,
|
|
342
|
+
className: "ds-storyblock__popover ds-surface-raised ds-field-surface",
|
|
343
|
+
children: /* @__PURE__ */ L("div", {
|
|
344
|
+
className: "ds-storyblock__popover-content",
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ L("div", {
|
|
347
|
+
className: "ds-storyblock__popover-section",
|
|
348
|
+
children: [/* @__PURE__ */ I("div", {
|
|
349
|
+
className: "ds-storyblock__popover-label",
|
|
350
|
+
children: "Alignment"
|
|
351
|
+
}), /* @__PURE__ */ I(p, {
|
|
352
|
+
className: "ds-storyblock__alignment",
|
|
353
|
+
"aria-label": "Alignment",
|
|
354
|
+
children: me.map((e) => /* @__PURE__ */ I(t, {
|
|
355
|
+
size: "sm",
|
|
356
|
+
iconStart: e.icon,
|
|
357
|
+
"aria-pressed": r === e.align,
|
|
358
|
+
variant: r === e.align ? "primary" : "neutral",
|
|
359
|
+
onClick: () => m(e.align),
|
|
360
|
+
children: e.label
|
|
361
|
+
}, e.align))
|
|
362
|
+
})]
|
|
363
|
+
}),
|
|
364
|
+
(d || u.isShown) && /* @__PURE__ */ L("div", {
|
|
365
|
+
className: "ds-storyblock__popover-section",
|
|
366
|
+
children: [d && /* @__PURE__ */ L(t, {
|
|
367
|
+
className: "ds-storyblock__action",
|
|
368
|
+
variant: "simple",
|
|
369
|
+
size: "md",
|
|
370
|
+
iconStart: "pencil",
|
|
371
|
+
onClick: () => {
|
|
372
|
+
O(), d();
|
|
373
|
+
},
|
|
374
|
+
children: ["Edit ", e]
|
|
375
|
+
}), u.isShown && /* @__PURE__ */ I(t, {
|
|
376
|
+
className: "ds-storyblock__action",
|
|
377
|
+
variant: "simple",
|
|
378
|
+
size: "md",
|
|
379
|
+
iconStart: "rotate-cw",
|
|
380
|
+
isDisabled: !u.isEnabled,
|
|
381
|
+
onClick: () => {
|
|
382
|
+
O(), h();
|
|
383
|
+
},
|
|
384
|
+
children: l ? `Choose another ${e}…` : "Replace…"
|
|
385
|
+
})]
|
|
386
|
+
}),
|
|
387
|
+
/* @__PURE__ */ I(y, {}),
|
|
388
|
+
/* @__PURE__ */ I(t, {
|
|
389
|
+
className: "ds-storyblock__action",
|
|
390
|
+
variant: "danger",
|
|
391
|
+
size: "md",
|
|
392
|
+
iconStart: "trash",
|
|
393
|
+
onClick: () => {
|
|
394
|
+
b(!1), g();
|
|
395
|
+
},
|
|
396
|
+
children: "Remove from field"
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
})
|
|
384
400
|
})
|
|
385
401
|
]
|
|
386
402
|
});
|
|
387
403
|
}
|
|
388
|
-
function
|
|
389
|
-
return /* @__PURE__ */
|
|
404
|
+
function ve({ kind: e, id: t, item: n, missing: r }) {
|
|
405
|
+
return /* @__PURE__ */ I("div", {
|
|
390
406
|
className: "ds-entry ds-storyblock__body",
|
|
391
|
-
children: r ? /* @__PURE__ */
|
|
407
|
+
children: r ? /* @__PURE__ */ L("span", {
|
|
392
408
|
className: "ds-entry__body",
|
|
393
|
-
children: [/* @__PURE__ */
|
|
409
|
+
children: [/* @__PURE__ */ I("em", {
|
|
394
410
|
className: "ds-entry__title",
|
|
395
411
|
children: `Unavailable ${e}`
|
|
396
|
-
}), /* @__PURE__ */
|
|
412
|
+
}), /* @__PURE__ */ L("span", {
|
|
397
413
|
className: "ds-entry__meta",
|
|
398
|
-
children: [/* @__PURE__ */
|
|
414
|
+
children: [/* @__PURE__ */ I("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ I("code", { children: t })]
|
|
399
415
|
})]
|
|
400
|
-
}) : /* @__PURE__ */
|
|
416
|
+
}) : /* @__PURE__ */ I(S, { item: n })
|
|
401
417
|
});
|
|
402
418
|
}
|
|
403
|
-
function
|
|
404
|
-
let { disabled: a, busy: o, replace: s } =
|
|
419
|
+
function ye({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
|
|
420
|
+
let { disabled: a, busy: o, replace: s } = k(Z), c = e.attrs.type, l = String(c === "entry" ? e.attrs.entryId : e.attrs.assetId), { view: u, item: d, missing: f, failure: p } = he(c, l), m = e.attrs.align ?? "full", h = !f && !d.isUnavailable && !d.isDisabled && u?.onEditItem, g = t && !a, _ = () => {
|
|
405
421
|
let e = r();
|
|
406
422
|
e !== void 0 && n.chain().focus().setNodeSelection(e).run();
|
|
407
423
|
};
|
|
408
|
-
return /* @__PURE__ */
|
|
409
|
-
className: "ds-storyblock",
|
|
424
|
+
return /* @__PURE__ */ L(z, {
|
|
425
|
+
className: "ds-storyblock ds-field-surface",
|
|
410
426
|
"data-align": m,
|
|
411
427
|
"data-selected": g || void 0,
|
|
412
428
|
"data-missing": f || void 0,
|
|
413
429
|
"data-tone": f ? "removed" : d.tone,
|
|
414
430
|
contentEditable: !1,
|
|
415
431
|
onMouseDown: (e) => {
|
|
416
|
-
let t = e.target
|
|
417
|
-
t
|
|
432
|
+
let t = e.target;
|
|
433
|
+
t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), _()));
|
|
418
434
|
},
|
|
419
435
|
children: [
|
|
420
|
-
a ? /* @__PURE__ */
|
|
436
|
+
a ? /* @__PURE__ */ I("div", {
|
|
421
437
|
className: "ds-storyblock__bar ds-field-surface",
|
|
422
|
-
children: /* @__PURE__ */
|
|
438
|
+
children: /* @__PURE__ */ I(ge, {
|
|
423
439
|
kind: c,
|
|
424
440
|
isMovable: !1
|
|
425
441
|
})
|
|
426
|
-
}) : /* @__PURE__ */
|
|
442
|
+
}) : /* @__PURE__ */ I(_e, {
|
|
427
443
|
kind: c,
|
|
428
444
|
name: f ? `Unavailable ${c}` : d.title,
|
|
429
445
|
align: m,
|
|
446
|
+
missing: f,
|
|
430
447
|
isSelected: g,
|
|
431
448
|
isLocked: !!u?.isDialogHidden,
|
|
432
449
|
canReplace: {
|
|
@@ -448,13 +465,13 @@ function ve({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i })
|
|
|
448
465
|
}).run();
|
|
449
466
|
}
|
|
450
467
|
}),
|
|
451
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ I(ve, {
|
|
452
469
|
kind: c,
|
|
453
470
|
id: l,
|
|
454
471
|
item: d,
|
|
455
472
|
missing: f
|
|
456
473
|
}),
|
|
457
|
-
p && /* @__PURE__ */
|
|
474
|
+
p && /* @__PURE__ */ I("div", {
|
|
458
475
|
className: "ds-storyblock__failure",
|
|
459
476
|
children: p
|
|
460
477
|
})
|
|
@@ -463,7 +480,7 @@ function ve({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i })
|
|
|
463
480
|
}
|
|
464
481
|
//#endregion
|
|
465
482
|
//#region src/components/RichTextEditor/use-embeds.tsx
|
|
466
|
-
var
|
|
483
|
+
var be = "ds-rte-embed-commit", xe = ["entry", "asset"], Se = {
|
|
467
484
|
entry: {
|
|
468
485
|
itemLabel: "entry",
|
|
469
486
|
itemsLabel: "entries"
|
|
@@ -472,8 +489,8 @@ var ye = "ds-rte-embed-commit", be = ["entry", "asset"], xe = {
|
|
|
472
489
|
itemLabel: "asset",
|
|
473
490
|
itemsLabel: "assets"
|
|
474
491
|
}
|
|
475
|
-
},
|
|
476
|
-
function
|
|
492
|
+
}, Ce = {}, we = [];
|
|
493
|
+
function Q(e, t, n) {
|
|
477
494
|
return {
|
|
478
495
|
type: e,
|
|
479
496
|
align: t,
|
|
@@ -483,29 +500,29 @@ function we(e, t, n) {
|
|
|
483
500
|
} : { assetId: n.id }
|
|
484
501
|
};
|
|
485
502
|
}
|
|
486
|
-
function
|
|
503
|
+
function Te(e, t) {
|
|
487
504
|
if (t.tone === "removed") return {
|
|
488
505
|
label: t.removedLabel ?? "Removed",
|
|
489
506
|
description: `This ${e} was removed.`
|
|
490
507
|
};
|
|
491
|
-
if (!
|
|
508
|
+
if (!W(Q(e, "full", t))) return {
|
|
492
509
|
label: "Can't embed",
|
|
493
510
|
description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
|
|
494
511
|
};
|
|
495
512
|
}
|
|
496
|
-
var
|
|
497
|
-
entry: (e) =>
|
|
498
|
-
asset: (e) =>
|
|
513
|
+
var Ee = {
|
|
514
|
+
entry: (e) => Te("entry", e),
|
|
515
|
+
asset: (e) => Te("asset", e)
|
|
499
516
|
};
|
|
500
|
-
function
|
|
517
|
+
function De(e, t) {
|
|
501
518
|
return e?.type.name === "storyblock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
|
|
502
519
|
}
|
|
503
|
-
function
|
|
520
|
+
function Oe(e) {
|
|
504
521
|
return e.flatMap((e) => e.mapping.maps);
|
|
505
522
|
}
|
|
506
|
-
function
|
|
523
|
+
function ke(e, t) {
|
|
507
524
|
let n = t;
|
|
508
|
-
for (let t of
|
|
525
|
+
for (let t of Oe(e)) {
|
|
509
526
|
let e = n, r;
|
|
510
527
|
if (t.forEach((t, n, i, a) => {
|
|
511
528
|
r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
|
|
@@ -519,9 +536,9 @@ function Oe(e, t) {
|
|
|
519
536
|
}
|
|
520
537
|
return n;
|
|
521
538
|
}
|
|
522
|
-
function
|
|
539
|
+
function Ae(e, t, n) {
|
|
523
540
|
let r = t, i = n;
|
|
524
|
-
for (let t of
|
|
541
|
+
for (let t of Oe(e)) {
|
|
525
542
|
if (r === i) {
|
|
526
543
|
r = i = t.map(i, -1);
|
|
527
544
|
continue;
|
|
@@ -537,13 +554,13 @@ function ke(e, t, n) {
|
|
|
537
554
|
to: i
|
|
538
555
|
};
|
|
539
556
|
}
|
|
540
|
-
function
|
|
557
|
+
function je(e, t) {
|
|
541
558
|
let n = e.resolve(Math.min(t, e.content.size));
|
|
542
559
|
return n.depth ? n.after(1) : n.pos;
|
|
543
560
|
}
|
|
544
|
-
function
|
|
545
|
-
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l =
|
|
546
|
-
return
|
|
561
|
+
function Me(e, t, n) {
|
|
562
|
+
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = X(e);
|
|
563
|
+
return M(() => r ? {
|
|
547
564
|
resolveItem: i ? t : void 0,
|
|
548
565
|
refreshKey: o,
|
|
549
566
|
items: s,
|
|
@@ -562,8 +579,8 @@ function je(e, t, n) {
|
|
|
562
579
|
n
|
|
563
580
|
]);
|
|
564
581
|
}
|
|
565
|
-
function
|
|
566
|
-
let { itemLabel: s, itemsLabel: c } =
|
|
582
|
+
function Ne({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: o }) {
|
|
583
|
+
let { itemLabel: s, itemsLabel: c } = Se[e.kind], l = M(() => e.replaceId ? [e.replaceId] : [], [e]), u = T(l, t.items ?? we, {
|
|
567
584
|
...t,
|
|
568
585
|
resolveItem: void 0,
|
|
569
586
|
mode: "single"
|
|
@@ -573,9 +590,9 @@ function Me({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
573
590
|
itemLabel: s,
|
|
574
591
|
itemsLabel: c,
|
|
575
592
|
close: i,
|
|
576
|
-
restrict:
|
|
593
|
+
restrict: Ee[e.kind]
|
|
577
594
|
}), d = e.replaceId ? "Replace" : "Embed";
|
|
578
|
-
return /* @__PURE__ */
|
|
595
|
+
return /* @__PURE__ */ I(x, {
|
|
579
596
|
...u.dialog,
|
|
580
597
|
isOpen: !0,
|
|
581
598
|
onClose: i,
|
|
@@ -591,42 +608,42 @@ function Me({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
591
608
|
isDialogHidden: t.isDialogHidden
|
|
592
609
|
});
|
|
593
610
|
}
|
|
594
|
-
function
|
|
595
|
-
let [a,
|
|
611
|
+
function Pe(e, n = Ce, r, i) {
|
|
612
|
+
let [a, o] = P(null), s = N(0), c = N({
|
|
596
613
|
session: null,
|
|
597
614
|
from: 0,
|
|
598
615
|
to: 0,
|
|
599
616
|
alive: !1
|
|
600
|
-
}),
|
|
601
|
-
|
|
602
|
-
}, []), h = a ? n[a.kind] : void 0, g = a &&
|
|
603
|
-
a && !g &&
|
|
604
|
-
let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v =
|
|
617
|
+
}), u = N(/* @__PURE__ */ new Map()), [d, f] = P(0), m = O(() => {
|
|
618
|
+
c.current.alive = !1, o(null);
|
|
619
|
+
}, []), h = a ? n[a.kind] : void 0, g = a && X(h) && (!r || h?.isCreating) ? a : null;
|
|
620
|
+
a && !g && o(null);
|
|
621
|
+
let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = l({
|
|
605
622
|
editor: e,
|
|
606
623
|
sources: n,
|
|
607
624
|
disabled: r,
|
|
608
625
|
busy: _
|
|
609
626
|
});
|
|
610
|
-
|
|
627
|
+
A(() => {
|
|
611
628
|
if (!e || !a) return;
|
|
612
|
-
|
|
629
|
+
c.current.alive = !0;
|
|
613
630
|
let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
|
|
614
631
|
let r = [t, ...n];
|
|
615
|
-
if (!
|
|
616
|
-
let { from: i, to: o } =
|
|
632
|
+
if (!c.current.alive || !r.some((e) => e.docChanged)) return;
|
|
633
|
+
let { from: i, to: o } = c.current;
|
|
617
634
|
if (a.replaceId === void 0) {
|
|
618
|
-
let e =
|
|
619
|
-
e ? Object.assign(
|
|
635
|
+
let e = Ae(r, i, o);
|
|
636
|
+
e ? Object.assign(c.current, e) : m();
|
|
620
637
|
return;
|
|
621
638
|
}
|
|
622
|
-
let s =
|
|
623
|
-
s === null || !
|
|
639
|
+
let s = ke(r, i);
|
|
640
|
+
s === null || !De(e.state.doc.nodeAt(s), a) ? m() : Object.assign(c.current, {
|
|
624
641
|
from: s,
|
|
625
642
|
to: s + 1
|
|
626
643
|
});
|
|
627
644
|
};
|
|
628
645
|
return e.on("transaction", t), () => {
|
|
629
|
-
e.off("transaction", t),
|
|
646
|
+
e.off("transaction", t), c.current.session === a && (c.current.alive = !1);
|
|
630
647
|
};
|
|
631
648
|
}, [
|
|
632
649
|
e,
|
|
@@ -635,41 +652,41 @@ function Ne(e, n = Se, r, i) {
|
|
|
635
652
|
]);
|
|
636
653
|
let y = (e) => {
|
|
637
654
|
let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
|
|
638
|
-
return !(!t || t.isDestroyed ||
|
|
655
|
+
return !(!t || t.isDestroyed || c.current.session !== e || !c.current.alive || !X(i) || r && !i?.isCreating);
|
|
639
656
|
}, b = (e, t, n) => {
|
|
640
657
|
let r = v.current.editor;
|
|
641
658
|
if (!r || !y(e) || t.isDisabled || t.tone === "removed") return !1;
|
|
642
|
-
let { doc: i } = r.state, a = e.replaceId !== void 0, o = a ? i.nodeAt(
|
|
643
|
-
if (a && !
|
|
644
|
-
let s =
|
|
645
|
-
if (!
|
|
646
|
-
let
|
|
647
|
-
|
|
659
|
+
let { doc: i } = r.state, a = e.replaceId !== void 0, o = a ? i.nodeAt(c.current.from) : null;
|
|
660
|
+
if (a && !De(o, e)) return !1;
|
|
661
|
+
let s = Q(e.kind, o?.attrs.align ?? "full", t);
|
|
662
|
+
if (!W(s)) return !1;
|
|
663
|
+
let l = a ? c.current.from : je(i, c.current.to), d = `${e.kind}:${t.id}`;
|
|
664
|
+
c.current.alive = !1, u.current = /* @__PURE__ */ new Map([[d, {
|
|
648
665
|
item: t,
|
|
649
666
|
revision: n
|
|
650
667
|
}]]);
|
|
651
|
-
let
|
|
668
|
+
let p = !1;
|
|
652
669
|
try {
|
|
653
|
-
let e = r.chain().focus().setMeta(
|
|
654
|
-
|
|
670
|
+
let e = r.chain().focus().setMeta(be, !0);
|
|
671
|
+
p = a ? e.setNodeSelection(l).updateAttributes("storyblock", s).run() : e.insertContentAt(l, {
|
|
655
672
|
type: "storyblock",
|
|
656
673
|
attrs: s
|
|
657
|
-
}).setNodeSelection(
|
|
674
|
+
}).setNodeSelection(l).run();
|
|
658
675
|
} catch {
|
|
659
|
-
|
|
676
|
+
p = !1;
|
|
660
677
|
} finally {
|
|
661
678
|
m();
|
|
662
679
|
}
|
|
663
|
-
return
|
|
680
|
+
return p ? f((e) => e + 1) : u.current.delete(d), p;
|
|
664
681
|
}, x = (e, t) => {
|
|
665
682
|
let { editor: n, sources: r, disabled: i, busy: a } = v.current;
|
|
666
|
-
if (!n || i || a || !
|
|
667
|
-
let
|
|
668
|
-
if (t !== void 0 && (
|
|
683
|
+
if (!n || i || a || !X(r[e])) return;
|
|
684
|
+
let l = t === void 0 ? null : n.state.doc.nodeAt(t);
|
|
685
|
+
if (t !== void 0 && (l?.type.name !== "storyblock" || l.attrs.type !== e)) return;
|
|
669
686
|
let { $from: u, from: d, to: f } = n.state.selection, p = {
|
|
670
|
-
id:
|
|
687
|
+
id: s.current += 1,
|
|
671
688
|
kind: e,
|
|
672
|
-
replaceId:
|
|
689
|
+
replaceId: l ? String(e === "entry" ? l.attrs.entryId : l.attrs.assetId) : void 0
|
|
673
690
|
}, m = t === void 0 ? u.depth ? {
|
|
674
691
|
from: u.before(1),
|
|
675
692
|
to: u.after(1)
|
|
@@ -680,16 +697,16 @@ function Ne(e, n = Se, r, i) {
|
|
|
680
697
|
from: t,
|
|
681
698
|
to: t + 1
|
|
682
699
|
};
|
|
683
|
-
|
|
700
|
+
c.current = {
|
|
684
701
|
session: p,
|
|
685
702
|
...m,
|
|
686
703
|
alive: !0
|
|
687
|
-
},
|
|
688
|
-
}, S =
|
|
704
|
+
}, o(p);
|
|
705
|
+
}, S = l({ open: x }), [C] = P(() => ({
|
|
689
706
|
replace: (e, t) => S.current.open(e, t),
|
|
690
|
-
seed: (e, t) =>
|
|
707
|
+
seed: (e, t) => u.current.get(`${e}:${t}`),
|
|
691
708
|
forgetSeed: (e, t, n) => {
|
|
692
|
-
|
|
709
|
+
u.current.get(`${e}:${t}`) === n && u.current.delete(`${e}:${t}`);
|
|
693
710
|
},
|
|
694
711
|
resolve: {
|
|
695
712
|
entry: (e) => v.current.sources.entry?.resolveItem?.(e) ?? null,
|
|
@@ -703,31 +720,31 @@ function Ne(e, n = Se, r, i) {
|
|
|
703
720
|
v.current.sources.asset?.onEditItem?.(e);
|
|
704
721
|
}
|
|
705
722
|
}
|
|
706
|
-
})),
|
|
723
|
+
})), w = Me(n.entry, C.resolve.entry, C.edit.entry), T = Me(n.asset, C.resolve.asset, C.edit.asset), E = M(() => ({
|
|
707
724
|
views: {
|
|
708
|
-
entry:
|
|
709
|
-
asset:
|
|
725
|
+
entry: w,
|
|
726
|
+
asset: T
|
|
710
727
|
},
|
|
711
728
|
disabled: r,
|
|
712
729
|
busy: _,
|
|
713
|
-
pickCount:
|
|
714
|
-
replace:
|
|
715
|
-
seed:
|
|
716
|
-
forgetSeed:
|
|
730
|
+
pickCount: d,
|
|
731
|
+
replace: C.replace,
|
|
732
|
+
seed: C.seed,
|
|
733
|
+
forgetSeed: C.forgetSeed
|
|
717
734
|
}), [
|
|
718
|
-
|
|
719
|
-
|
|
735
|
+
w,
|
|
736
|
+
T,
|
|
720
737
|
r,
|
|
721
738
|
_,
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
]),
|
|
739
|
+
d,
|
|
740
|
+
C
|
|
741
|
+
]), D = xe.filter((e) => X(n[e]));
|
|
725
742
|
return {
|
|
726
|
-
context:
|
|
727
|
-
isCreating:
|
|
728
|
-
toolbar:
|
|
743
|
+
context: E,
|
|
744
|
+
isCreating: xe.some((e) => n[e]?.isCreating),
|
|
745
|
+
toolbar: D.length > 0 && /* @__PURE__ */ I(p, {
|
|
729
746
|
"aria-label": "Embed",
|
|
730
|
-
children:
|
|
747
|
+
children: D.map((n) => /* @__PURE__ */ I(t, {
|
|
731
748
|
size: "sm",
|
|
732
749
|
isIconOnly: !0,
|
|
733
750
|
iconStart: n === "entry" ? "file-text" : "image",
|
|
@@ -739,7 +756,7 @@ function Ne(e, n = Se, r, i) {
|
|
|
739
756
|
onClick: () => x(n)
|
|
740
757
|
}, n))
|
|
741
758
|
}),
|
|
742
|
-
dialog: e && g && h && /* @__PURE__ */
|
|
759
|
+
dialog: e && g && h && /* @__PURE__ */ I(Ne, {
|
|
743
760
|
session: g,
|
|
744
761
|
source: h,
|
|
745
762
|
disabled: r,
|
|
@@ -755,9 +772,9 @@ function Ne(e, n = Se, r, i) {
|
|
|
755
772
|
}
|
|
756
773
|
//#endregion
|
|
757
774
|
//#region src/components/RichTextEditor/index.tsx
|
|
758
|
-
function
|
|
759
|
-
let [i, a] =
|
|
760
|
-
|
|
775
|
+
function Fe({ editor: e, selection: n, onClose: r }) {
|
|
776
|
+
let [i, a] = P(n.href), [o, s] = P(), c = j();
|
|
777
|
+
A(() => {
|
|
761
778
|
let t = () => {
|
|
762
779
|
e.state.doc.eq(n.document) || r();
|
|
763
780
|
};
|
|
@@ -792,13 +809,13 @@ function Pe({ editor: e, selection: n, onClose: r }) {
|
|
|
792
809
|
}]
|
|
793
810
|
}).run() : a.setLink({ href: t }).run(), r();
|
|
794
811
|
};
|
|
795
|
-
return /* @__PURE__ */
|
|
812
|
+
return /* @__PURE__ */ I(g, {
|
|
796
813
|
isOpen: !0,
|
|
797
814
|
title: n.isEditing ? "Edit link" : "Add link",
|
|
798
815
|
size: "dialog",
|
|
799
816
|
onClose: r,
|
|
800
|
-
footer: /* @__PURE__ */
|
|
801
|
-
n.isEditing && /* @__PURE__ */
|
|
817
|
+
footer: /* @__PURE__ */ L(ee, { children: [
|
|
818
|
+
n.isEditing && /* @__PURE__ */ I(t, {
|
|
802
819
|
variant: "danger",
|
|
803
820
|
onClick: () => {
|
|
804
821
|
l() && e.chain().focus().setTextSelection({
|
|
@@ -808,28 +825,28 @@ function Pe({ editor: e, selection: n, onClose: r }) {
|
|
|
808
825
|
},
|
|
809
826
|
children: "Remove link"
|
|
810
827
|
}),
|
|
811
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ I(t, {
|
|
812
829
|
onClick: r,
|
|
813
830
|
children: "Cancel"
|
|
814
831
|
}),
|
|
815
|
-
/* @__PURE__ */
|
|
832
|
+
/* @__PURE__ */ I(t, {
|
|
816
833
|
variant: "primary",
|
|
817
834
|
type: "submit",
|
|
818
835
|
form: c,
|
|
819
836
|
children: "Save"
|
|
820
837
|
})
|
|
821
838
|
] }),
|
|
822
|
-
children: /* @__PURE__ */
|
|
839
|
+
children: /* @__PURE__ */ I("form", {
|
|
823
840
|
id: c,
|
|
824
841
|
noValidate: !0,
|
|
825
842
|
onSubmit: (e) => {
|
|
826
843
|
e.preventDefault(), e.stopPropagation(), u();
|
|
827
844
|
},
|
|
828
|
-
children: /* @__PURE__ */
|
|
845
|
+
children: /* @__PURE__ */ I(h, {
|
|
829
846
|
label: "URL",
|
|
830
847
|
isRequired: !0,
|
|
831
848
|
error: o,
|
|
832
|
-
children: (e) => /* @__PURE__ */
|
|
849
|
+
children: (e) => /* @__PURE__ */ I(_, {
|
|
833
850
|
...e,
|
|
834
851
|
value: i,
|
|
835
852
|
inputMode: "url",
|
|
@@ -922,15 +939,15 @@ var $ = [
|
|
|
922
939
|
run: (e) => e.chain().focus().redo().run()
|
|
923
940
|
}]
|
|
924
941
|
];
|
|
925
|
-
function
|
|
926
|
-
return /* @__PURE__ */
|
|
942
|
+
function Ie({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c }) {
|
|
943
|
+
return /* @__PURE__ */ L("div", {
|
|
927
944
|
className: "ds-rte__toolbar ds-field-surface",
|
|
928
945
|
role: "toolbar",
|
|
929
946
|
"aria-label": `${i} formatting`,
|
|
930
947
|
children: [
|
|
931
|
-
$.map((i, a) => /* @__PURE__ */
|
|
948
|
+
$.map((i, a) => /* @__PURE__ */ I(p, {
|
|
932
949
|
"aria-label": `Formatting ${a + 1}`,
|
|
933
|
-
children: i.map((i) => /* @__PURE__ */
|
|
950
|
+
children: i.map((i) => /* @__PURE__ */ I(t, {
|
|
934
951
|
size: "sm",
|
|
935
952
|
isIconOnly: !0,
|
|
936
953
|
iconStart: i.icon,
|
|
@@ -942,9 +959,9 @@ function Fe({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
|
|
|
942
959
|
onClick: () => e && i.run(e)
|
|
943
960
|
}, i.id))
|
|
944
961
|
}, a)),
|
|
945
|
-
/* @__PURE__ */
|
|
962
|
+
/* @__PURE__ */ I(p, {
|
|
946
963
|
"aria-label": "Link",
|
|
947
|
-
children: /* @__PURE__ */
|
|
964
|
+
children: /* @__PURE__ */ I(t, {
|
|
948
965
|
size: "sm",
|
|
949
966
|
isIconOnly: !0,
|
|
950
967
|
iconStart: "link",
|
|
@@ -961,32 +978,36 @@ function Fe({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
|
|
|
961
978
|
]
|
|
962
979
|
});
|
|
963
980
|
}
|
|
964
|
-
var
|
|
965
|
-
return /* @__PURE__ */
|
|
981
|
+
var Le = D(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: a, contentError: o, errorId: s, surface: l, children: u }, d) {
|
|
982
|
+
return /* @__PURE__ */ I(c.Provider, {
|
|
966
983
|
value: e,
|
|
967
|
-
children: /* @__PURE__ */
|
|
984
|
+
children: /* @__PURE__ */ L("div", {
|
|
968
985
|
ref: d,
|
|
969
986
|
className: ["ds-rte", t].filter(Boolean).join(" "),
|
|
970
987
|
style: n.frameStyle,
|
|
971
988
|
"data-expanded": n.expanded || void 0,
|
|
972
989
|
"data-focused": r && !n.expanded || void 0,
|
|
973
990
|
"data-disabled": i || void 0,
|
|
974
|
-
"
|
|
991
|
+
"data-invalid": a || void 0,
|
|
992
|
+
"aria-invalid": a || void 0,
|
|
975
993
|
children: [
|
|
976
|
-
|
|
977
|
-
id:
|
|
994
|
+
o && /* @__PURE__ */ I("p", {
|
|
995
|
+
id: s,
|
|
978
996
|
role: "alert",
|
|
979
997
|
className: "ds-field__error",
|
|
980
|
-
children:
|
|
998
|
+
children: o
|
|
981
999
|
}),
|
|
982
|
-
n.expanded && /* @__PURE__ */
|
|
1000
|
+
n.expanded && /* @__PURE__ */ I("p", {
|
|
983
1001
|
className: "ds-rte__placeholder",
|
|
984
1002
|
children: "Editing in expanded view. Press Esc to return."
|
|
985
1003
|
}),
|
|
986
|
-
n.surfaceSlot(/* @__PURE__ */
|
|
1004
|
+
n.surfaceSlot(/* @__PURE__ */ I("div", {
|
|
987
1005
|
className: "ds-rte__surface",
|
|
988
|
-
hidden: !!
|
|
989
|
-
"data-
|
|
1006
|
+
hidden: !!o,
|
|
1007
|
+
"data-expanded": n.expanded || void 0,
|
|
1008
|
+
"data-focused": r || void 0,
|
|
1009
|
+
"data-disabled": i || void 0,
|
|
1010
|
+
"data-invalid": a || void 0,
|
|
990
1011
|
children: l
|
|
991
1012
|
})),
|
|
992
1013
|
n.dialog,
|
|
@@ -994,33 +1015,33 @@ var Ie = S(function({ scopeRef: e, className: t, expansion: n, isFocused: r, dis
|
|
|
994
1015
|
]
|
|
995
1016
|
})
|
|
996
1017
|
});
|
|
997
|
-
}),
|
|
998
|
-
return
|
|
1018
|
+
}), Re = K.extend({ addNodeView() {
|
|
1019
|
+
return B(ye, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
|
|
999
1020
|
} });
|
|
1000
|
-
function
|
|
1021
|
+
function ze(e, t) {
|
|
1001
1022
|
return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
|
|
1002
1023
|
}
|
|
1003
|
-
var
|
|
1004
|
-
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, id: d, isRequired: f, required: p, "aria-label": m, "aria-labelledby": h, "aria-describedby": g, "aria-invalid": _ } = e, v =
|
|
1005
|
-
|
|
1006
|
-
let
|
|
1007
|
-
if (
|
|
1024
|
+
var Be = D(function(e, t) {
|
|
1025
|
+
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, id: d, isRequired: f, required: p, "aria-label": m, "aria-labelledby": h, "aria-describedby": g, "aria-invalid": _ } = e, v = N(null), y = M(() => n(v, t), [t]), [b, x] = P(!1), [S, C] = P(null), w = O(() => C(null), []), [T] = P(() => e.defaultValue ?? (e.format === "json" ? q : "")), E = e.value === void 0 ? T : e.value, D = M(() => e.format === "json" ? fe(E) : void 0, [e.format, E]), k = j(), F = s || !!D || _, R = o || !!D;
|
|
1026
|
+
R && S && C(null);
|
|
1027
|
+
let z = O((e, t) => {
|
|
1028
|
+
if (R) return;
|
|
1008
1029
|
let n = t === void 0 ? void 0 : re(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
|
|
1009
|
-
|
|
1030
|
+
C({
|
|
1010
1031
|
from: n?.from ?? e.selection.from,
|
|
1011
1032
|
to: n?.to ?? e.selection.to,
|
|
1012
1033
|
href: r?.attrs.href ?? "",
|
|
1013
1034
|
isEditing: !!r,
|
|
1014
1035
|
document: e.doc
|
|
1015
1036
|
});
|
|
1016
|
-
}, [
|
|
1037
|
+
}, [R]), B = M(() => ({
|
|
1017
1038
|
role: "textbox",
|
|
1018
1039
|
...h ? {} : { "aria-label": m ?? c },
|
|
1019
1040
|
"aria-multiline": "true",
|
|
1020
1041
|
...d ? { id: d } : {},
|
|
1021
1042
|
...h ? { "aria-labelledby": h } : {},
|
|
1022
1043
|
...g ? { "aria-describedby": g } : {},
|
|
1023
|
-
...
|
|
1044
|
+
...F ? { "aria-invalid": String(F) } : {},
|
|
1024
1045
|
...f || p ? { "aria-required": "true" } : {}
|
|
1025
1046
|
}), [
|
|
1026
1047
|
c,
|
|
@@ -1028,96 +1049,96 @@ var ze = S(function(e, t) {
|
|
|
1028
1049
|
d,
|
|
1029
1050
|
h,
|
|
1030
1051
|
g,
|
|
1031
|
-
|
|
1052
|
+
F,
|
|
1032
1053
|
f,
|
|
1033
1054
|
p
|
|
1034
|
-
]),
|
|
1035
|
-
attributes:
|
|
1055
|
+
]), V = M(() => ({
|
|
1056
|
+
attributes: B,
|
|
1036
1057
|
handleDOMEvents: {
|
|
1037
|
-
keydown:
|
|
1058
|
+
keydown: ze,
|
|
1038
1059
|
click: (e, t) => {
|
|
1039
1060
|
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
1040
|
-
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable &&
|
|
1061
|
+
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && z(e.state, e.posAtDOM(n, 0)), !0);
|
|
1041
1062
|
}
|
|
1042
1063
|
}
|
|
1043
|
-
}), [
|
|
1064
|
+
}), [B, z]), H = M(() => [...de(Re), oe.configure({ placeholder: r })], [r]), se = M(() => D ? q : typeof E == "string" ? E : Y(E), [E, D]), U = ie({
|
|
1044
1065
|
immediatelyRender: !1,
|
|
1045
|
-
editable: !
|
|
1046
|
-
content:
|
|
1066
|
+
editable: !R,
|
|
1067
|
+
content: se,
|
|
1047
1068
|
extensions: H,
|
|
1048
|
-
editorProps:
|
|
1069
|
+
editorProps: V,
|
|
1049
1070
|
onFocus: () => x(!0),
|
|
1050
1071
|
onBlur: () => x(!1),
|
|
1051
1072
|
onUpdate: ({ editor: t, transaction: n }) => {
|
|
1052
|
-
(!
|
|
1073
|
+
(!R || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(G(t.getJSON())) : e.onChange?.(t.getHTML()));
|
|
1053
1074
|
}
|
|
1054
1075
|
});
|
|
1055
|
-
|
|
1056
|
-
|
|
1076
|
+
A(() => {
|
|
1077
|
+
U && (U.setEditable(!R, !1), U.setOptions({ editorProps: V }));
|
|
1057
1078
|
}, [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
]),
|
|
1062
|
-
if (!
|
|
1063
|
-
let t = typeof e.value == "string" ? ne(e.value,
|
|
1064
|
-
t.eq(
|
|
1079
|
+
U,
|
|
1080
|
+
R,
|
|
1081
|
+
V
|
|
1082
|
+
]), A(() => {
|
|
1083
|
+
if (!U || e.value === void 0 || D) return;
|
|
1084
|
+
let t = typeof e.value == "string" ? ne(e.value, U.schema) : U.schema.nodeFromJSON(Y(e.value));
|
|
1085
|
+
t.eq(U.state.doc) || U.commands.setContent(t, { emitUpdate: !1 });
|
|
1065
1086
|
}, [
|
|
1066
|
-
|
|
1087
|
+
U,
|
|
1067
1088
|
e.value,
|
|
1068
|
-
|
|
1089
|
+
D
|
|
1069
1090
|
]);
|
|
1070
|
-
let
|
|
1071
|
-
editor:
|
|
1091
|
+
let ce = ae({
|
|
1092
|
+
editor: U,
|
|
1072
1093
|
selector: ({ editor: e }) => e ? {
|
|
1073
1094
|
active: Object.fromEntries($.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
1074
1095
|
linkActive: e.isActive("link")
|
|
1075
1096
|
} : null
|
|
1076
|
-
}),
|
|
1077
|
-
editor:
|
|
1078
|
-
disabled:
|
|
1079
|
-
isHeld:
|
|
1080
|
-
invalid: !!
|
|
1097
|
+
}), W = Pe(U, D ? void 0 : e.embeds, R, c), K = le({
|
|
1098
|
+
editor: U,
|
|
1099
|
+
disabled: R,
|
|
1100
|
+
isHeld: W.isCreating,
|
|
1101
|
+
invalid: !!F,
|
|
1081
1102
|
label: m ?? c,
|
|
1082
1103
|
labelledBy: h,
|
|
1083
1104
|
expandedWidth: a,
|
|
1084
1105
|
frameRef: v
|
|
1085
1106
|
});
|
|
1086
|
-
return /* @__PURE__ */
|
|
1087
|
-
value:
|
|
1088
|
-
children: /* @__PURE__ */
|
|
1107
|
+
return /* @__PURE__ */ I(Z.Provider, {
|
|
1108
|
+
value: W.context,
|
|
1109
|
+
children: /* @__PURE__ */ L(Le, {
|
|
1089
1110
|
ref: y,
|
|
1090
1111
|
scopeRef: v,
|
|
1091
1112
|
className: l,
|
|
1092
|
-
expansion:
|
|
1113
|
+
expansion: K,
|
|
1093
1114
|
isFocused: b,
|
|
1094
|
-
disabled:
|
|
1095
|
-
invalid: !!
|
|
1096
|
-
contentError:
|
|
1097
|
-
errorId:
|
|
1098
|
-
surface: /* @__PURE__ */
|
|
1099
|
-
editor:
|
|
1100
|
-
state:
|
|
1101
|
-
disabled:
|
|
1115
|
+
disabled: R,
|
|
1116
|
+
invalid: !!F,
|
|
1117
|
+
contentError: D,
|
|
1118
|
+
errorId: k,
|
|
1119
|
+
surface: /* @__PURE__ */ L(ee, { children: [/* @__PURE__ */ I(Ie, {
|
|
1120
|
+
editor: U,
|
|
1121
|
+
state: ce,
|
|
1122
|
+
disabled: R,
|
|
1102
1123
|
label: c,
|
|
1103
1124
|
toolbarExtra: u,
|
|
1104
|
-
openLink:
|
|
1105
|
-
expandControl:
|
|
1106
|
-
embedControl:
|
|
1107
|
-
}), /* @__PURE__ */
|
|
1108
|
-
className: "ds-rte__content",
|
|
1125
|
+
openLink: z,
|
|
1126
|
+
expandControl: K.toggle,
|
|
1127
|
+
embedControl: W.toolbar
|
|
1128
|
+
}), /* @__PURE__ */ I("div", {
|
|
1129
|
+
className: "ds-rte__content ds-field-surface",
|
|
1109
1130
|
"data-size": i,
|
|
1110
|
-
children: /* @__PURE__ */
|
|
1131
|
+
children: /* @__PURE__ */ I(te, { editor: U })
|
|
1111
1132
|
})] }),
|
|
1112
|
-
children: [
|
|
1113
|
-
editor:
|
|
1133
|
+
children: [W.dialog, U && S && !R && /* @__PURE__ */ I(Fe, {
|
|
1134
|
+
editor: U,
|
|
1114
1135
|
selection: S,
|
|
1115
|
-
onClose:
|
|
1136
|
+
onClose: w
|
|
1116
1137
|
})]
|
|
1117
1138
|
})
|
|
1118
1139
|
});
|
|
1119
1140
|
});
|
|
1120
1141
|
//#endregion
|
|
1121
|
-
export {
|
|
1142
|
+
export { fe as n, q as r, Be as t };
|
|
1122
1143
|
|
|
1123
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1144
|
+
//# sourceMappingURL=RichTextEditor-D8VQAM5h.js.map
|