@namroodinc/liquid-editorial 0.11.0 → 0.13.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 +44 -20
- package/UPGRADING.md +322 -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-Cnyqrc-R.js → Board-BCS7sDXg.js} +13 -5
- package/dist/chunks/{Board-Cnyqrc-R.js.map → Board-BCS7sDXg.js.map} +1 -1
- package/dist/chunks/{Board-DFuJt2Oh.cjs → Board-CNVy8gHI.cjs} +2 -2
- package/dist/chunks/Board-CNVy8gHI.cjs.map +1 -0
- package/dist/chunks/CollectionView-CIJdNwcq.cjs +2 -0
- package/dist/chunks/CollectionView-CIJdNwcq.cjs.map +1 -0
- package/dist/chunks/{CollectionView-Vj84E26b.js → CollectionView-JRNdXHti.js} +5 -5
- package/dist/chunks/CollectionView-JRNdXHti.js.map +1 -0
- package/dist/chunks/{ColourField-DkO8tjeB.js → ColourField-BTj9NHgI.js} +147 -153
- package/dist/chunks/ColourField-BTj9NHgI.js.map +1 -0
- package/dist/chunks/ColourField-DuoVeXjG.cjs +2 -0
- package/dist/chunks/ColourField-DuoVeXjG.cjs.map +1 -0
- package/dist/chunks/DatePicker-BYpGsfL4.cjs +2 -0
- package/dist/chunks/DatePicker-BYpGsfL4.cjs.map +1 -0
- package/dist/chunks/{DatePicker-B8tllGYy.js → DatePicker-Cb5WspIC.js} +22 -22
- package/dist/chunks/DatePicker-Cb5WspIC.js.map +1 -0
- package/dist/chunks/{Drawer-DTtgAZO2.js → Drawer-Ck5XKT_V.js} +4 -4
- package/dist/chunks/Drawer-Ck5XKT_V.js.map +1 -0
- package/dist/chunks/Drawer-DdIH9jpe.cjs +2 -0
- package/dist/chunks/Drawer-DdIH9jpe.cjs.map +1 -0
- package/dist/chunks/EntryPicker-CCCoJxbd.cjs +2 -0
- package/dist/chunks/EntryPicker-CCCoJxbd.cjs.map +1 -0
- package/dist/chunks/{EntryPicker-KxHZzZsh.js → EntryPicker-DLCP4S-q.js} +4 -4
- package/dist/chunks/EntryPicker-DLCP4S-q.js.map +1 -0
- package/dist/chunks/{FormEditor-BJcAIVcL.cjs → FormEditor-ArvjKtJJ.cjs} +2 -2
- package/dist/chunks/{FormEditor-BJcAIVcL.cjs.map → FormEditor-ArvjKtJJ.cjs.map} +1 -1
- package/dist/chunks/{FormEditor-CdLqPaKK.js → FormEditor-DnNBv9Xf.js} +16 -16
- package/dist/chunks/{FormEditor-CdLqPaKK.js.map → FormEditor-DnNBv9Xf.js.map} +1 -1
- package/dist/chunks/{Message-CyLq9ef-.js → Message-C73sJfdo.js} +4 -8
- package/dist/chunks/{Message-CyLq9ef-.js.map → Message-C73sJfdo.js.map} +1 -1
- package/dist/chunks/{Message-D3b8HDhm.cjs → Message-CIKSTXp8.cjs} +2 -2
- package/dist/chunks/{Message-D3b8HDhm.cjs.map → Message-CIKSTXp8.cjs.map} +1 -1
- package/dist/chunks/RichTextEditor--kMao88d.cjs +2 -0
- package/dist/chunks/RichTextEditor--kMao88d.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-DmNM63Wg.js → RichTextEditor-CvbboqJY.js} +397 -380
- package/dist/chunks/RichTextEditor-CvbboqJY.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-Bue5MJHQ.cjs +2 -0
- package/dist/chunks/use-picker-session-Bue5MJHQ.cjs.map +1 -0
- package/dist/chunks/{use-picker-session-BDEWL2jK.js → use-picker-session-DUO4G8Cs.js} +4 -4
- package/dist/chunks/use-picker-session-DUO4G8Cs.js.map +1 -0
- 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.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +16 -16
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetCard/style.css +47 -46
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.cjs.map +1 -1
- package/dist/components/AssetGrid/index.d.cts +0 -2
- package/dist/components/AssetGrid/index.d.cts.map +1 -1
- package/dist/components/AssetGrid/index.d.ts +0 -2
- package/dist/components/AssetGrid/index.d.ts.map +1 -1
- package/dist/components/AssetGrid/index.js +15 -15
- package/dist/components/AssetGrid/index.js.map +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Avatar/style.css +26 -5
- package/dist/components/Badge/index.cjs +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts +2 -3
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts +2 -3
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/style.css +29 -35
- 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 +37 -16
- package/dist/components/Button/style.css +17 -12
- package/dist/components/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/ButtonGroup/index.d.cts +1 -1
- package/dist/components/ButtonGroup/index.d.ts +1 -1
- package/dist/components/ButtonGroup/index.js.map +1 -1
- package/dist/components/ButtonGroup/style.css +4 -20
- 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 +34 -22
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/CollectionView/style.css +8 -11
- 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 +31 -20
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DatePicker/style.css +10 -3
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/style.css +10 -23
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.js +4 -4
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EditLayout/style.css +5 -6
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/style.css +46 -20
- package/dist/components/Field/style.css +6 -5
- package/dist/components/FormEditor/README.md +28 -19
- 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/ImageCropper/style.css +20 -20
- 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 -3
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.js +3 -3
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +6 -6
- 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/Popover/style.css +2 -2
- 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 +123 -75
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- 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 +7 -3
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SelectionCard/style.css +30 -48
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts +3 -3
- package/dist/components/SideNav/index.d.ts +3 -3
- package/dist/components/SideNav/index.js +15 -3
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/SideNav/style.css +19 -13
- package/dist/components/Skeleton/style.css +1 -1
- package/dist/components/Slider/style.css +19 -32
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.js +6 -2
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +20 -5
- package/dist/components/Stepper/style.css +8 -9
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts +2 -2
- package/dist/components/SubNav/index.d.ts +2 -2
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +3 -8
- 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 +3 -2
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +26 -6
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.cjs.map +1 -1
- package/dist/components/Table/index.js +2 -2
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/style.css +34 -22
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.js +1 -1
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/TagsInput/style.css +12 -5
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/components/Time/style.css +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toast/style.css +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.cjs.map +1 -1
- package/dist/components/TopNav/index.d.cts +4 -4
- package/dist/components/TopNav/index.d.ts +4 -4
- package/dist/components/TopNav/index.js +5 -1
- package/dist/components/TopNav/index.js.map +1 -1
- package/dist/components/TopNav/style.css +6 -9
- package/dist/elements.css +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -44
- 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 +13 -17
- package/dist/tokens.css +112 -280
- package/package.json +1 -1
- package/dist/chunks/Board-DFuJt2Oh.cjs.map +0 -1
- package/dist/chunks/CollectionView-BNYx29b1.cjs +0 -2
- package/dist/chunks/CollectionView-BNYx29b1.cjs.map +0 -1
- package/dist/chunks/CollectionView-Vj84E26b.js.map +0 -1
- package/dist/chunks/ColourField--rS9KDpq.cjs +0 -2
- package/dist/chunks/ColourField--rS9KDpq.cjs.map +0 -1
- package/dist/chunks/ColourField-DkO8tjeB.js.map +0 -1
- package/dist/chunks/DatePicker-B8tllGYy.js.map +0 -1
- package/dist/chunks/DatePicker-OiqjoO-f.cjs +0 -2
- package/dist/chunks/DatePicker-OiqjoO-f.cjs.map +0 -1
- package/dist/chunks/Drawer-BDX9_qHA.cjs +0 -2
- package/dist/chunks/Drawer-BDX9_qHA.cjs.map +0 -1
- package/dist/chunks/Drawer-DTtgAZO2.js.map +0 -1
- package/dist/chunks/EntryPicker-BI_7g2Wg.cjs +0 -2
- package/dist/chunks/EntryPicker-BI_7g2Wg.cjs.map +0 -1
- package/dist/chunks/EntryPicker-KxHZzZsh.js.map +0 -1
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs +0 -2
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DmNM63Wg.js.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/chunks/use-picker-session-BDEWL2jK.js.map +0 -1
- package/dist/chunks/use-picker-session-C4FGinLN.cjs +0 -2
- package/dist/chunks/use-picker-session-C4FGinLN.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
1
|
import { t as e } from "./Icon-CYXOo0Kt.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-DUO4G8Cs.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,168 @@ 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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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", {
|
|
296
|
+
className: "ds-storyblock__bar ds-field-surface",
|
|
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__ */ I("div", {
|
|
347
|
+
className: "ds-storyblock__popover-label",
|
|
348
|
+
children: "Alignment"
|
|
349
|
+
}),
|
|
350
|
+
/* @__PURE__ */ I(p, {
|
|
351
|
+
className: "ds-storyblock__alignment",
|
|
352
|
+
"aria-label": "Alignment",
|
|
353
|
+
children: me.map((e) => /* @__PURE__ */ I(t, {
|
|
354
|
+
size: "sm",
|
|
355
|
+
iconStart: e.icon,
|
|
356
|
+
"aria-pressed": r === e.align,
|
|
357
|
+
variant: r === e.align ? "primary" : "neutral",
|
|
358
|
+
onClick: () => m(e.align),
|
|
359
|
+
children: e.label
|
|
360
|
+
}, e.align))
|
|
361
|
+
}),
|
|
362
|
+
d && /* @__PURE__ */ L(t, {
|
|
363
|
+
className: "ds-storyblock__action",
|
|
364
|
+
variant: "simple",
|
|
365
|
+
size: "sm",
|
|
366
|
+
iconStart: "pencil",
|
|
367
|
+
onClick: () => {
|
|
368
|
+
O(), d();
|
|
369
|
+
},
|
|
370
|
+
children: ["Edit ", e]
|
|
371
|
+
}),
|
|
372
|
+
u.isShown && /* @__PURE__ */ I(t, {
|
|
373
|
+
className: "ds-storyblock__action",
|
|
374
|
+
variant: "simple",
|
|
375
|
+
size: "sm",
|
|
376
|
+
iconStart: "rotate-cw",
|
|
377
|
+
isDisabled: !u.isEnabled,
|
|
378
|
+
onClick: () => {
|
|
379
|
+
O(), h();
|
|
380
|
+
},
|
|
381
|
+
children: l ? `Choose another ${e}…` : "Replace…"
|
|
382
|
+
}),
|
|
383
|
+
/* @__PURE__ */ I(y, {}),
|
|
384
|
+
/* @__PURE__ */ I(t, {
|
|
385
|
+
className: "ds-storyblock__action",
|
|
386
|
+
variant: "danger",
|
|
387
|
+
size: "sm",
|
|
388
|
+
iconStart: "trash",
|
|
389
|
+
onClick: () => {
|
|
390
|
+
b(!1), g();
|
|
391
|
+
},
|
|
392
|
+
children: "Remove from field"
|
|
393
|
+
})
|
|
394
|
+
]
|
|
395
|
+
})
|
|
384
396
|
})
|
|
385
397
|
]
|
|
386
398
|
});
|
|
387
399
|
}
|
|
388
|
-
function
|
|
389
|
-
return /* @__PURE__ */
|
|
400
|
+
function ve({ kind: e, id: t, item: n, missing: r }) {
|
|
401
|
+
return /* @__PURE__ */ I("div", {
|
|
390
402
|
className: "ds-entry ds-storyblock__body",
|
|
391
|
-
children: r ? /* @__PURE__ */
|
|
403
|
+
children: r ? /* @__PURE__ */ L("span", {
|
|
392
404
|
className: "ds-entry__body",
|
|
393
|
-
children: [/* @__PURE__ */
|
|
405
|
+
children: [/* @__PURE__ */ I("em", {
|
|
394
406
|
className: "ds-entry__title",
|
|
395
407
|
children: `Unavailable ${e}`
|
|
396
|
-
}), /* @__PURE__ */
|
|
408
|
+
}), /* @__PURE__ */ L("span", {
|
|
397
409
|
className: "ds-entry__meta",
|
|
398
|
-
children: [/* @__PURE__ */
|
|
410
|
+
children: [/* @__PURE__ */ I("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ I("code", { children: t })]
|
|
399
411
|
})]
|
|
400
|
-
}) : /* @__PURE__ */
|
|
412
|
+
}) : /* @__PURE__ */ I(S, { item: n })
|
|
401
413
|
});
|
|
402
414
|
}
|
|
403
|
-
function
|
|
404
|
-
let { disabled: a, busy: o, replace: s } =
|
|
415
|
+
function ye({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
|
|
416
|
+
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
417
|
let e = r();
|
|
406
418
|
e !== void 0 && n.chain().focus().setNodeSelection(e).run();
|
|
407
419
|
};
|
|
408
|
-
return /* @__PURE__ */
|
|
409
|
-
className: "ds-storyblock",
|
|
420
|
+
return /* @__PURE__ */ L(z, {
|
|
421
|
+
className: "ds-storyblock ds-field-surface",
|
|
410
422
|
"data-align": m,
|
|
411
423
|
"data-selected": g || void 0,
|
|
412
424
|
"data-missing": f || void 0,
|
|
413
425
|
"data-tone": f ? "removed" : d.tone,
|
|
414
426
|
contentEditable: !1,
|
|
415
427
|
onMouseDown: (e) => {
|
|
416
|
-
let t = e.target
|
|
417
|
-
t
|
|
428
|
+
let t = e.target;
|
|
429
|
+
t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), _()));
|
|
418
430
|
},
|
|
419
431
|
children: [
|
|
420
|
-
a ? /* @__PURE__ */
|
|
421
|
-
className: "ds-storyblock__bar",
|
|
422
|
-
children: /* @__PURE__ */
|
|
432
|
+
a ? /* @__PURE__ */ I("div", {
|
|
433
|
+
className: "ds-storyblock__bar ds-field-surface",
|
|
434
|
+
children: /* @__PURE__ */ I(ge, {
|
|
423
435
|
kind: c,
|
|
424
436
|
isMovable: !1
|
|
425
437
|
})
|
|
426
|
-
}) : /* @__PURE__ */
|
|
438
|
+
}) : /* @__PURE__ */ I(_e, {
|
|
427
439
|
kind: c,
|
|
428
440
|
name: f ? `Unavailable ${c}` : d.title,
|
|
429
441
|
align: m,
|
|
442
|
+
missing: f,
|
|
430
443
|
isSelected: g,
|
|
431
444
|
isLocked: !!u?.isDialogHidden,
|
|
432
445
|
canReplace: {
|
|
@@ -448,13 +461,13 @@ function ve({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i })
|
|
|
448
461
|
}).run();
|
|
449
462
|
}
|
|
450
463
|
}),
|
|
451
|
-
/* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ I(ve, {
|
|
452
465
|
kind: c,
|
|
453
466
|
id: l,
|
|
454
467
|
item: d,
|
|
455
468
|
missing: f
|
|
456
469
|
}),
|
|
457
|
-
p && /* @__PURE__ */
|
|
470
|
+
p && /* @__PURE__ */ I("div", {
|
|
458
471
|
className: "ds-storyblock__failure",
|
|
459
472
|
children: p
|
|
460
473
|
})
|
|
@@ -463,7 +476,7 @@ function ve({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i })
|
|
|
463
476
|
}
|
|
464
477
|
//#endregion
|
|
465
478
|
//#region src/components/RichTextEditor/use-embeds.tsx
|
|
466
|
-
var
|
|
479
|
+
var be = "ds-rte-embed-commit", xe = ["entry", "asset"], Se = {
|
|
467
480
|
entry: {
|
|
468
481
|
itemLabel: "entry",
|
|
469
482
|
itemsLabel: "entries"
|
|
@@ -472,8 +485,8 @@ var ye = "ds-rte-embed-commit", be = ["entry", "asset"], xe = {
|
|
|
472
485
|
itemLabel: "asset",
|
|
473
486
|
itemsLabel: "assets"
|
|
474
487
|
}
|
|
475
|
-
},
|
|
476
|
-
function
|
|
488
|
+
}, Ce = {}, we = [];
|
|
489
|
+
function Q(e, t, n) {
|
|
477
490
|
return {
|
|
478
491
|
type: e,
|
|
479
492
|
align: t,
|
|
@@ -483,29 +496,29 @@ function we(e, t, n) {
|
|
|
483
496
|
} : { assetId: n.id }
|
|
484
497
|
};
|
|
485
498
|
}
|
|
486
|
-
function
|
|
499
|
+
function Te(e, t) {
|
|
487
500
|
if (t.tone === "removed") return {
|
|
488
501
|
label: t.removedLabel ?? "Removed",
|
|
489
502
|
description: `This ${e} was removed.`
|
|
490
503
|
};
|
|
491
|
-
if (!
|
|
504
|
+
if (!W(Q(e, "full", t))) return {
|
|
492
505
|
label: "Can't embed",
|
|
493
506
|
description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
|
|
494
507
|
};
|
|
495
508
|
}
|
|
496
|
-
var
|
|
497
|
-
entry: (e) =>
|
|
498
|
-
asset: (e) =>
|
|
509
|
+
var Ee = {
|
|
510
|
+
entry: (e) => Te("entry", e),
|
|
511
|
+
asset: (e) => Te("asset", e)
|
|
499
512
|
};
|
|
500
|
-
function
|
|
513
|
+
function De(e, t) {
|
|
501
514
|
return e?.type.name === "storyblock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
|
|
502
515
|
}
|
|
503
|
-
function
|
|
516
|
+
function Oe(e) {
|
|
504
517
|
return e.flatMap((e) => e.mapping.maps);
|
|
505
518
|
}
|
|
506
|
-
function
|
|
519
|
+
function ke(e, t) {
|
|
507
520
|
let n = t;
|
|
508
|
-
for (let t of
|
|
521
|
+
for (let t of Oe(e)) {
|
|
509
522
|
let e = n, r;
|
|
510
523
|
if (t.forEach((t, n, i, a) => {
|
|
511
524
|
r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
|
|
@@ -519,9 +532,9 @@ function Oe(e, t) {
|
|
|
519
532
|
}
|
|
520
533
|
return n;
|
|
521
534
|
}
|
|
522
|
-
function
|
|
535
|
+
function Ae(e, t, n) {
|
|
523
536
|
let r = t, i = n;
|
|
524
|
-
for (let t of
|
|
537
|
+
for (let t of Oe(e)) {
|
|
525
538
|
if (r === i) {
|
|
526
539
|
r = i = t.map(i, -1);
|
|
527
540
|
continue;
|
|
@@ -537,13 +550,13 @@ function ke(e, t, n) {
|
|
|
537
550
|
to: i
|
|
538
551
|
};
|
|
539
552
|
}
|
|
540
|
-
function
|
|
553
|
+
function je(e, t) {
|
|
541
554
|
let n = e.resolve(Math.min(t, e.content.size));
|
|
542
555
|
return n.depth ? n.after(1) : n.pos;
|
|
543
556
|
}
|
|
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
|
|
557
|
+
function Me(e, t, n) {
|
|
558
|
+
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = X(e);
|
|
559
|
+
return M(() => r ? {
|
|
547
560
|
resolveItem: i ? t : void 0,
|
|
548
561
|
refreshKey: o,
|
|
549
562
|
items: s,
|
|
@@ -562,8 +575,8 @@ function je(e, t, n) {
|
|
|
562
575
|
n
|
|
563
576
|
]);
|
|
564
577
|
}
|
|
565
|
-
function
|
|
566
|
-
let { itemLabel: s, itemsLabel: c } =
|
|
578
|
+
function Ne({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: o }) {
|
|
579
|
+
let { itemLabel: s, itemsLabel: c } = Se[e.kind], l = M(() => e.replaceId ? [e.replaceId] : [], [e]), u = T(l, t.items ?? we, {
|
|
567
580
|
...t,
|
|
568
581
|
resolveItem: void 0,
|
|
569
582
|
mode: "single"
|
|
@@ -573,9 +586,9 @@ function Me({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
573
586
|
itemLabel: s,
|
|
574
587
|
itemsLabel: c,
|
|
575
588
|
close: i,
|
|
576
|
-
restrict:
|
|
589
|
+
restrict: Ee[e.kind]
|
|
577
590
|
}), d = e.replaceId ? "Replace" : "Embed";
|
|
578
|
-
return /* @__PURE__ */
|
|
591
|
+
return /* @__PURE__ */ I(x, {
|
|
579
592
|
...u.dialog,
|
|
580
593
|
isOpen: !0,
|
|
581
594
|
onClose: i,
|
|
@@ -591,42 +604,42 @@ function Me({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
591
604
|
isDialogHidden: t.isDialogHidden
|
|
592
605
|
});
|
|
593
606
|
}
|
|
594
|
-
function
|
|
595
|
-
let [a,
|
|
607
|
+
function Pe(e, n = Ce, r, i) {
|
|
608
|
+
let [a, o] = P(null), s = N(0), c = N({
|
|
596
609
|
session: null,
|
|
597
610
|
from: 0,
|
|
598
611
|
to: 0,
|
|
599
612
|
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 =
|
|
613
|
+
}), u = N(/* @__PURE__ */ new Map()), [d, f] = P(0), m = O(() => {
|
|
614
|
+
c.current.alive = !1, o(null);
|
|
615
|
+
}, []), h = a ? n[a.kind] : void 0, g = a && X(h) && (!r || h?.isCreating) ? a : null;
|
|
616
|
+
a && !g && o(null);
|
|
617
|
+
let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = l({
|
|
605
618
|
editor: e,
|
|
606
619
|
sources: n,
|
|
607
620
|
disabled: r,
|
|
608
621
|
busy: _
|
|
609
622
|
});
|
|
610
|
-
|
|
623
|
+
A(() => {
|
|
611
624
|
if (!e || !a) return;
|
|
612
|
-
|
|
625
|
+
c.current.alive = !0;
|
|
613
626
|
let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
|
|
614
627
|
let r = [t, ...n];
|
|
615
|
-
if (!
|
|
616
|
-
let { from: i, to: o } =
|
|
628
|
+
if (!c.current.alive || !r.some((e) => e.docChanged)) return;
|
|
629
|
+
let { from: i, to: o } = c.current;
|
|
617
630
|
if (a.replaceId === void 0) {
|
|
618
|
-
let e =
|
|
619
|
-
e ? Object.assign(
|
|
631
|
+
let e = Ae(r, i, o);
|
|
632
|
+
e ? Object.assign(c.current, e) : m();
|
|
620
633
|
return;
|
|
621
634
|
}
|
|
622
|
-
let s =
|
|
623
|
-
s === null || !
|
|
635
|
+
let s = ke(r, i);
|
|
636
|
+
s === null || !De(e.state.doc.nodeAt(s), a) ? m() : Object.assign(c.current, {
|
|
624
637
|
from: s,
|
|
625
638
|
to: s + 1
|
|
626
639
|
});
|
|
627
640
|
};
|
|
628
641
|
return e.on("transaction", t), () => {
|
|
629
|
-
e.off("transaction", t),
|
|
642
|
+
e.off("transaction", t), c.current.session === a && (c.current.alive = !1);
|
|
630
643
|
};
|
|
631
644
|
}, [
|
|
632
645
|
e,
|
|
@@ -635,41 +648,41 @@ function Ne(e, n = Se, r, i) {
|
|
|
635
648
|
]);
|
|
636
649
|
let y = (e) => {
|
|
637
650
|
let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
|
|
638
|
-
return !(!t || t.isDestroyed ||
|
|
651
|
+
return !(!t || t.isDestroyed || c.current.session !== e || !c.current.alive || !X(i) || r && !i?.isCreating);
|
|
639
652
|
}, b = (e, t, n) => {
|
|
640
653
|
let r = v.current.editor;
|
|
641
654
|
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
|
-
|
|
655
|
+
let { doc: i } = r.state, a = e.replaceId !== void 0, o = a ? i.nodeAt(c.current.from) : null;
|
|
656
|
+
if (a && !De(o, e)) return !1;
|
|
657
|
+
let s = Q(e.kind, o?.attrs.align ?? "full", t);
|
|
658
|
+
if (!W(s)) return !1;
|
|
659
|
+
let l = a ? c.current.from : je(i, c.current.to), d = `${e.kind}:${t.id}`;
|
|
660
|
+
c.current.alive = !1, u.current = /* @__PURE__ */ new Map([[d, {
|
|
648
661
|
item: t,
|
|
649
662
|
revision: n
|
|
650
663
|
}]]);
|
|
651
|
-
let
|
|
664
|
+
let p = !1;
|
|
652
665
|
try {
|
|
653
|
-
let e = r.chain().focus().setMeta(
|
|
654
|
-
|
|
666
|
+
let e = r.chain().focus().setMeta(be, !0);
|
|
667
|
+
p = a ? e.setNodeSelection(l).updateAttributes("storyblock", s).run() : e.insertContentAt(l, {
|
|
655
668
|
type: "storyblock",
|
|
656
669
|
attrs: s
|
|
657
|
-
}).setNodeSelection(
|
|
670
|
+
}).setNodeSelection(l).run();
|
|
658
671
|
} catch {
|
|
659
|
-
|
|
672
|
+
p = !1;
|
|
660
673
|
} finally {
|
|
661
674
|
m();
|
|
662
675
|
}
|
|
663
|
-
return
|
|
676
|
+
return p ? f((e) => e + 1) : u.current.delete(d), p;
|
|
664
677
|
}, x = (e, t) => {
|
|
665
678
|
let { editor: n, sources: r, disabled: i, busy: a } = v.current;
|
|
666
|
-
if (!n || i || a || !
|
|
667
|
-
let
|
|
668
|
-
if (t !== void 0 && (
|
|
679
|
+
if (!n || i || a || !X(r[e])) return;
|
|
680
|
+
let l = t === void 0 ? null : n.state.doc.nodeAt(t);
|
|
681
|
+
if (t !== void 0 && (l?.type.name !== "storyblock" || l.attrs.type !== e)) return;
|
|
669
682
|
let { $from: u, from: d, to: f } = n.state.selection, p = {
|
|
670
|
-
id:
|
|
683
|
+
id: s.current += 1,
|
|
671
684
|
kind: e,
|
|
672
|
-
replaceId:
|
|
685
|
+
replaceId: l ? String(e === "entry" ? l.attrs.entryId : l.attrs.assetId) : void 0
|
|
673
686
|
}, m = t === void 0 ? u.depth ? {
|
|
674
687
|
from: u.before(1),
|
|
675
688
|
to: u.after(1)
|
|
@@ -680,16 +693,16 @@ function Ne(e, n = Se, r, i) {
|
|
|
680
693
|
from: t,
|
|
681
694
|
to: t + 1
|
|
682
695
|
};
|
|
683
|
-
|
|
696
|
+
c.current = {
|
|
684
697
|
session: p,
|
|
685
698
|
...m,
|
|
686
699
|
alive: !0
|
|
687
|
-
},
|
|
688
|
-
}, S =
|
|
700
|
+
}, o(p);
|
|
701
|
+
}, S = l({ open: x }), [C] = P(() => ({
|
|
689
702
|
replace: (e, t) => S.current.open(e, t),
|
|
690
|
-
seed: (e, t) =>
|
|
703
|
+
seed: (e, t) => u.current.get(`${e}:${t}`),
|
|
691
704
|
forgetSeed: (e, t, n) => {
|
|
692
|
-
|
|
705
|
+
u.current.get(`${e}:${t}`) === n && u.current.delete(`${e}:${t}`);
|
|
693
706
|
},
|
|
694
707
|
resolve: {
|
|
695
708
|
entry: (e) => v.current.sources.entry?.resolveItem?.(e) ?? null,
|
|
@@ -703,43 +716,43 @@ function Ne(e, n = Se, r, i) {
|
|
|
703
716
|
v.current.sources.asset?.onEditItem?.(e);
|
|
704
717
|
}
|
|
705
718
|
}
|
|
706
|
-
})),
|
|
719
|
+
})), w = Me(n.entry, C.resolve.entry, C.edit.entry), T = Me(n.asset, C.resolve.asset, C.edit.asset), E = M(() => ({
|
|
707
720
|
views: {
|
|
708
|
-
entry:
|
|
709
|
-
asset:
|
|
721
|
+
entry: w,
|
|
722
|
+
asset: T
|
|
710
723
|
},
|
|
711
724
|
disabled: r,
|
|
712
725
|
busy: _,
|
|
713
|
-
pickCount:
|
|
714
|
-
replace:
|
|
715
|
-
seed:
|
|
716
|
-
forgetSeed:
|
|
726
|
+
pickCount: d,
|
|
727
|
+
replace: C.replace,
|
|
728
|
+
seed: C.seed,
|
|
729
|
+
forgetSeed: C.forgetSeed
|
|
717
730
|
}), [
|
|
718
|
-
|
|
719
|
-
|
|
731
|
+
w,
|
|
732
|
+
T,
|
|
720
733
|
r,
|
|
721
734
|
_,
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
]),
|
|
735
|
+
d,
|
|
736
|
+
C
|
|
737
|
+
]), D = xe.filter((e) => X(n[e]));
|
|
725
738
|
return {
|
|
726
|
-
context:
|
|
727
|
-
isCreating:
|
|
728
|
-
toolbar:
|
|
739
|
+
context: E,
|
|
740
|
+
isCreating: xe.some((e) => n[e]?.isCreating),
|
|
741
|
+
toolbar: D.length > 0 && /* @__PURE__ */ I(p, {
|
|
729
742
|
"aria-label": "Embed",
|
|
730
|
-
children:
|
|
743
|
+
children: D.map((n) => /* @__PURE__ */ I(t, {
|
|
731
744
|
size: "sm",
|
|
732
745
|
isIconOnly: !0,
|
|
733
746
|
iconStart: n === "entry" ? "file-text" : "image",
|
|
734
747
|
"aria-label": `Embed ${n}`,
|
|
735
748
|
title: `Embed ${n}`,
|
|
736
749
|
"aria-pressed": g?.kind === n,
|
|
737
|
-
variant: g?.kind === n ? "
|
|
750
|
+
variant: g?.kind === n ? "primary" : "neutral",
|
|
738
751
|
isDisabled: r || _ || !e,
|
|
739
752
|
onClick: () => x(n)
|
|
740
753
|
}, n))
|
|
741
754
|
}),
|
|
742
|
-
dialog: e && g && h && /* @__PURE__ */
|
|
755
|
+
dialog: e && g && h && /* @__PURE__ */ I(Ne, {
|
|
743
756
|
session: g,
|
|
744
757
|
source: h,
|
|
745
758
|
disabled: r,
|
|
@@ -755,9 +768,9 @@ function Ne(e, n = Se, r, i) {
|
|
|
755
768
|
}
|
|
756
769
|
//#endregion
|
|
757
770
|
//#region src/components/RichTextEditor/index.tsx
|
|
758
|
-
function
|
|
759
|
-
let [i, a] =
|
|
760
|
-
|
|
771
|
+
function Fe({ editor: e, selection: n, onClose: r }) {
|
|
772
|
+
let [i, a] = P(n.href), [o, s] = P(), c = j();
|
|
773
|
+
A(() => {
|
|
761
774
|
let t = () => {
|
|
762
775
|
e.state.doc.eq(n.document) || r();
|
|
763
776
|
};
|
|
@@ -792,13 +805,13 @@ function Pe({ editor: e, selection: n, onClose: r }) {
|
|
|
792
805
|
}]
|
|
793
806
|
}).run() : a.setLink({ href: t }).run(), r();
|
|
794
807
|
};
|
|
795
|
-
return /* @__PURE__ */
|
|
808
|
+
return /* @__PURE__ */ I(g, {
|
|
796
809
|
isOpen: !0,
|
|
797
810
|
title: n.isEditing ? "Edit link" : "Add link",
|
|
798
811
|
size: "dialog",
|
|
799
812
|
onClose: r,
|
|
800
|
-
footer: /* @__PURE__ */
|
|
801
|
-
n.isEditing && /* @__PURE__ */
|
|
813
|
+
footer: /* @__PURE__ */ L(ee, { children: [
|
|
814
|
+
n.isEditing && /* @__PURE__ */ I(t, {
|
|
802
815
|
variant: "danger",
|
|
803
816
|
onClick: () => {
|
|
804
817
|
l() && e.chain().focus().setTextSelection({
|
|
@@ -808,28 +821,28 @@ function Pe({ editor: e, selection: n, onClose: r }) {
|
|
|
808
821
|
},
|
|
809
822
|
children: "Remove link"
|
|
810
823
|
}),
|
|
811
|
-
/* @__PURE__ */
|
|
824
|
+
/* @__PURE__ */ I(t, {
|
|
812
825
|
onClick: r,
|
|
813
826
|
children: "Cancel"
|
|
814
827
|
}),
|
|
815
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ I(t, {
|
|
816
829
|
variant: "primary",
|
|
817
830
|
type: "submit",
|
|
818
831
|
form: c,
|
|
819
832
|
children: "Save"
|
|
820
833
|
})
|
|
821
834
|
] }),
|
|
822
|
-
children: /* @__PURE__ */
|
|
835
|
+
children: /* @__PURE__ */ I("form", {
|
|
823
836
|
id: c,
|
|
824
837
|
noValidate: !0,
|
|
825
838
|
onSubmit: (e) => {
|
|
826
839
|
e.preventDefault(), e.stopPropagation(), u();
|
|
827
840
|
},
|
|
828
|
-
children: /* @__PURE__ */
|
|
841
|
+
children: /* @__PURE__ */ I(h, {
|
|
829
842
|
label: "URL",
|
|
830
843
|
isRequired: !0,
|
|
831
844
|
error: o,
|
|
832
|
-
children: (e) => /* @__PURE__ */
|
|
845
|
+
children: (e) => /* @__PURE__ */ I(_, {
|
|
833
846
|
...e,
|
|
834
847
|
value: i,
|
|
835
848
|
inputMode: "url",
|
|
@@ -922,35 +935,35 @@ var $ = [
|
|
|
922
935
|
run: (e) => e.chain().focus().redo().run()
|
|
923
936
|
}]
|
|
924
937
|
];
|
|
925
|
-
function
|
|
926
|
-
return /* @__PURE__ */
|
|
927
|
-
className: "ds-rte__toolbar",
|
|
938
|
+
function Ie({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c }) {
|
|
939
|
+
return /* @__PURE__ */ L("div", {
|
|
940
|
+
className: "ds-rte__toolbar ds-field-surface",
|
|
928
941
|
role: "toolbar",
|
|
929
942
|
"aria-label": `${i} formatting`,
|
|
930
943
|
children: [
|
|
931
|
-
$.map((i, a) => /* @__PURE__ */
|
|
944
|
+
$.map((i, a) => /* @__PURE__ */ I(p, {
|
|
932
945
|
"aria-label": `Formatting ${a + 1}`,
|
|
933
|
-
children: i.map((i) => /* @__PURE__ */
|
|
946
|
+
children: i.map((i) => /* @__PURE__ */ I(t, {
|
|
934
947
|
size: "sm",
|
|
935
948
|
isIconOnly: !0,
|
|
936
949
|
iconStart: i.icon,
|
|
937
950
|
"aria-label": i.label,
|
|
938
951
|
title: i.label,
|
|
939
952
|
"aria-pressed": i.active ? n?.active[i.id] : void 0,
|
|
940
|
-
variant: n?.active[i.id] ? "
|
|
953
|
+
variant: n?.active[i.id] ? "primary" : "neutral",
|
|
941
954
|
isDisabled: r || !e,
|
|
942
955
|
onClick: () => e && i.run(e)
|
|
943
956
|
}, i.id))
|
|
944
957
|
}, a)),
|
|
945
|
-
/* @__PURE__ */
|
|
958
|
+
/* @__PURE__ */ I(p, {
|
|
946
959
|
"aria-label": "Link",
|
|
947
|
-
children: /* @__PURE__ */
|
|
960
|
+
children: /* @__PURE__ */ I(t, {
|
|
948
961
|
size: "sm",
|
|
949
962
|
isIconOnly: !0,
|
|
950
963
|
iconStart: "link",
|
|
951
964
|
"aria-label": n?.linkActive ? "Edit link" : "Add link",
|
|
952
965
|
title: n?.linkActive ? "Edit link" : "Add link",
|
|
953
|
-
variant: n?.linkActive ? "
|
|
966
|
+
variant: n?.linkActive ? "primary" : "neutral",
|
|
954
967
|
isDisabled: r || !e,
|
|
955
968
|
onClick: () => e && o(e.state, e.isActive("link") ? e.state.selection.from : void 0)
|
|
956
969
|
})
|
|
@@ -961,32 +974,36 @@ function Fe({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
|
|
|
961
974
|
]
|
|
962
975
|
});
|
|
963
976
|
}
|
|
964
|
-
var
|
|
965
|
-
return /* @__PURE__ */
|
|
977
|
+
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) {
|
|
978
|
+
return /* @__PURE__ */ I(c.Provider, {
|
|
966
979
|
value: e,
|
|
967
|
-
children: /* @__PURE__ */
|
|
980
|
+
children: /* @__PURE__ */ L("div", {
|
|
968
981
|
ref: d,
|
|
969
982
|
className: ["ds-rte", t].filter(Boolean).join(" "),
|
|
970
983
|
style: n.frameStyle,
|
|
971
984
|
"data-expanded": n.expanded || void 0,
|
|
972
985
|
"data-focused": r && !n.expanded || void 0,
|
|
973
986
|
"data-disabled": i || void 0,
|
|
974
|
-
"
|
|
987
|
+
"data-invalid": a || void 0,
|
|
988
|
+
"aria-invalid": a || void 0,
|
|
975
989
|
children: [
|
|
976
|
-
|
|
977
|
-
id:
|
|
990
|
+
o && /* @__PURE__ */ I("p", {
|
|
991
|
+
id: s,
|
|
978
992
|
role: "alert",
|
|
979
993
|
className: "ds-field__error",
|
|
980
|
-
children:
|
|
994
|
+
children: o
|
|
981
995
|
}),
|
|
982
|
-
n.expanded && /* @__PURE__ */
|
|
996
|
+
n.expanded && /* @__PURE__ */ I("p", {
|
|
983
997
|
className: "ds-rte__placeholder",
|
|
984
998
|
children: "Editing in expanded view. Press Esc to return."
|
|
985
999
|
}),
|
|
986
|
-
n.surfaceSlot(/* @__PURE__ */
|
|
1000
|
+
n.surfaceSlot(/* @__PURE__ */ I("div", {
|
|
987
1001
|
className: "ds-rte__surface",
|
|
988
|
-
hidden: !!
|
|
989
|
-
"data-
|
|
1002
|
+
hidden: !!o,
|
|
1003
|
+
"data-expanded": n.expanded || void 0,
|
|
1004
|
+
"data-focused": r || void 0,
|
|
1005
|
+
"data-disabled": i || void 0,
|
|
1006
|
+
"data-invalid": a || void 0,
|
|
990
1007
|
children: l
|
|
991
1008
|
})),
|
|
992
1009
|
n.dialog,
|
|
@@ -994,33 +1011,33 @@ var Ie = S(function({ scopeRef: e, className: t, expansion: n, isFocused: r, dis
|
|
|
994
1011
|
]
|
|
995
1012
|
})
|
|
996
1013
|
});
|
|
997
|
-
}),
|
|
998
|
-
return
|
|
1014
|
+
}), Re = K.extend({ addNodeView() {
|
|
1015
|
+
return B(ye, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
|
|
999
1016
|
} });
|
|
1000
|
-
function
|
|
1017
|
+
function ze(e, t) {
|
|
1001
1018
|
return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
|
|
1002
1019
|
}
|
|
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 (
|
|
1020
|
+
var Be = D(function(e, t) {
|
|
1021
|
+
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;
|
|
1022
|
+
R && S && C(null);
|
|
1023
|
+
let z = O((e, t) => {
|
|
1024
|
+
if (R) return;
|
|
1008
1025
|
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
|
-
|
|
1026
|
+
C({
|
|
1010
1027
|
from: n?.from ?? e.selection.from,
|
|
1011
1028
|
to: n?.to ?? e.selection.to,
|
|
1012
1029
|
href: r?.attrs.href ?? "",
|
|
1013
1030
|
isEditing: !!r,
|
|
1014
1031
|
document: e.doc
|
|
1015
1032
|
});
|
|
1016
|
-
}, [
|
|
1033
|
+
}, [R]), B = M(() => ({
|
|
1017
1034
|
role: "textbox",
|
|
1018
1035
|
...h ? {} : { "aria-label": m ?? c },
|
|
1019
1036
|
"aria-multiline": "true",
|
|
1020
1037
|
...d ? { id: d } : {},
|
|
1021
1038
|
...h ? { "aria-labelledby": h } : {},
|
|
1022
1039
|
...g ? { "aria-describedby": g } : {},
|
|
1023
|
-
...
|
|
1040
|
+
...F ? { "aria-invalid": String(F) } : {},
|
|
1024
1041
|
...f || p ? { "aria-required": "true" } : {}
|
|
1025
1042
|
}), [
|
|
1026
1043
|
c,
|
|
@@ -1028,96 +1045,96 @@ var ze = S(function(e, t) {
|
|
|
1028
1045
|
d,
|
|
1029
1046
|
h,
|
|
1030
1047
|
g,
|
|
1031
|
-
|
|
1048
|
+
F,
|
|
1032
1049
|
f,
|
|
1033
1050
|
p
|
|
1034
|
-
]),
|
|
1035
|
-
attributes:
|
|
1051
|
+
]), V = M(() => ({
|
|
1052
|
+
attributes: B,
|
|
1036
1053
|
handleDOMEvents: {
|
|
1037
|
-
keydown:
|
|
1054
|
+
keydown: ze,
|
|
1038
1055
|
click: (e, t) => {
|
|
1039
1056
|
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
1040
|
-
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable &&
|
|
1057
|
+
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && z(e.state, e.posAtDOM(n, 0)), !0);
|
|
1041
1058
|
}
|
|
1042
1059
|
}
|
|
1043
|
-
}), [
|
|
1060
|
+
}), [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
1061
|
immediatelyRender: !1,
|
|
1045
|
-
editable: !
|
|
1046
|
-
content:
|
|
1062
|
+
editable: !R,
|
|
1063
|
+
content: se,
|
|
1047
1064
|
extensions: H,
|
|
1048
|
-
editorProps:
|
|
1065
|
+
editorProps: V,
|
|
1049
1066
|
onFocus: () => x(!0),
|
|
1050
1067
|
onBlur: () => x(!1),
|
|
1051
1068
|
onUpdate: ({ editor: t, transaction: n }) => {
|
|
1052
|
-
(!
|
|
1069
|
+
(!R || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(G(t.getJSON())) : e.onChange?.(t.getHTML()));
|
|
1053
1070
|
}
|
|
1054
1071
|
});
|
|
1055
|
-
|
|
1056
|
-
|
|
1072
|
+
A(() => {
|
|
1073
|
+
U && (U.setEditable(!R, !1), U.setOptions({ editorProps: V }));
|
|
1057
1074
|
}, [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
]),
|
|
1062
|
-
if (!
|
|
1063
|
-
let t = typeof e.value == "string" ? ne(e.value,
|
|
1064
|
-
t.eq(
|
|
1075
|
+
U,
|
|
1076
|
+
R,
|
|
1077
|
+
V
|
|
1078
|
+
]), A(() => {
|
|
1079
|
+
if (!U || e.value === void 0 || D) return;
|
|
1080
|
+
let t = typeof e.value == "string" ? ne(e.value, U.schema) : U.schema.nodeFromJSON(Y(e.value));
|
|
1081
|
+
t.eq(U.state.doc) || U.commands.setContent(t, { emitUpdate: !1 });
|
|
1065
1082
|
}, [
|
|
1066
|
-
|
|
1083
|
+
U,
|
|
1067
1084
|
e.value,
|
|
1068
|
-
|
|
1085
|
+
D
|
|
1069
1086
|
]);
|
|
1070
|
-
let
|
|
1071
|
-
editor:
|
|
1087
|
+
let ce = ae({
|
|
1088
|
+
editor: U,
|
|
1072
1089
|
selector: ({ editor: e }) => e ? {
|
|
1073
1090
|
active: Object.fromEntries($.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
1074
1091
|
linkActive: e.isActive("link")
|
|
1075
1092
|
} : null
|
|
1076
|
-
}),
|
|
1077
|
-
editor:
|
|
1078
|
-
disabled:
|
|
1079
|
-
isHeld:
|
|
1080
|
-
invalid: !!
|
|
1093
|
+
}), W = Pe(U, D ? void 0 : e.embeds, R, c), K = le({
|
|
1094
|
+
editor: U,
|
|
1095
|
+
disabled: R,
|
|
1096
|
+
isHeld: W.isCreating,
|
|
1097
|
+
invalid: !!F,
|
|
1081
1098
|
label: m ?? c,
|
|
1082
1099
|
labelledBy: h,
|
|
1083
1100
|
expandedWidth: a,
|
|
1084
1101
|
frameRef: v
|
|
1085
1102
|
});
|
|
1086
|
-
return /* @__PURE__ */
|
|
1087
|
-
value:
|
|
1088
|
-
children: /* @__PURE__ */
|
|
1103
|
+
return /* @__PURE__ */ I(Z.Provider, {
|
|
1104
|
+
value: W.context,
|
|
1105
|
+
children: /* @__PURE__ */ L(Le, {
|
|
1089
1106
|
ref: y,
|
|
1090
1107
|
scopeRef: v,
|
|
1091
1108
|
className: l,
|
|
1092
|
-
expansion:
|
|
1109
|
+
expansion: K,
|
|
1093
1110
|
isFocused: b,
|
|
1094
|
-
disabled:
|
|
1095
|
-
invalid: !!
|
|
1096
|
-
contentError:
|
|
1097
|
-
errorId:
|
|
1098
|
-
surface: /* @__PURE__ */
|
|
1099
|
-
editor:
|
|
1100
|
-
state:
|
|
1101
|
-
disabled:
|
|
1111
|
+
disabled: R,
|
|
1112
|
+
invalid: !!F,
|
|
1113
|
+
contentError: D,
|
|
1114
|
+
errorId: k,
|
|
1115
|
+
surface: /* @__PURE__ */ L(ee, { children: [/* @__PURE__ */ I(Ie, {
|
|
1116
|
+
editor: U,
|
|
1117
|
+
state: ce,
|
|
1118
|
+
disabled: R,
|
|
1102
1119
|
label: c,
|
|
1103
1120
|
toolbarExtra: u,
|
|
1104
|
-
openLink:
|
|
1105
|
-
expandControl:
|
|
1106
|
-
embedControl:
|
|
1107
|
-
}), /* @__PURE__ */
|
|
1108
|
-
className: "ds-rte__content",
|
|
1121
|
+
openLink: z,
|
|
1122
|
+
expandControl: K.toggle,
|
|
1123
|
+
embedControl: W.toolbar
|
|
1124
|
+
}), /* @__PURE__ */ I("div", {
|
|
1125
|
+
className: "ds-rte__content ds-field-surface",
|
|
1109
1126
|
"data-size": i,
|
|
1110
|
-
children: /* @__PURE__ */
|
|
1127
|
+
children: /* @__PURE__ */ I(te, { editor: U })
|
|
1111
1128
|
})] }),
|
|
1112
|
-
children: [
|
|
1113
|
-
editor:
|
|
1129
|
+
children: [W.dialog, U && S && !R && /* @__PURE__ */ I(Fe, {
|
|
1130
|
+
editor: U,
|
|
1114
1131
|
selection: S,
|
|
1115
|
-
onClose:
|
|
1132
|
+
onClose: w
|
|
1116
1133
|
})]
|
|
1117
1134
|
})
|
|
1118
1135
|
});
|
|
1119
1136
|
});
|
|
1120
1137
|
//#endregion
|
|
1121
|
-
export {
|
|
1138
|
+
export { fe as n, q as r, Be as t };
|
|
1122
1139
|
|
|
1123
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1140
|
+
//# sourceMappingURL=RichTextEditor-CvbboqJY.js.map
|