@namroodinc/liquid-editorial 0.10.2 → 0.11.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/UPGRADING.md +61 -0
- package/dist/chunks/{ColourField-B03ejnGS.cjs → ColourField--rS9KDpq.cjs} +2 -2
- package/dist/chunks/{ColourField-B03ejnGS.cjs.map → ColourField--rS9KDpq.cjs.map} +1 -1
- package/dist/chunks/{ColourField-D17gkytm.js → ColourField-DkO8tjeB.js} +5 -5
- package/dist/chunks/{ColourField-D17gkytm.js.map → ColourField-DkO8tjeB.js.map} +1 -1
- package/dist/chunks/{DatePicker-0uvnuiye.js → DatePicker-B8tllGYy.js} +20 -20
- package/dist/chunks/{DatePicker-0uvnuiye.js.map → DatePicker-B8tllGYy.js.map} +1 -1
- package/dist/chunks/{DatePicker-CVaefhfS.cjs → DatePicker-OiqjoO-f.cjs} +2 -2
- package/dist/chunks/{DatePicker-CVaefhfS.cjs.map → DatePicker-OiqjoO-f.cjs.map} +1 -1
- package/dist/chunks/{EntryPicker-CiS8zT64.cjs → EntryPicker-BI_7g2Wg.cjs} +2 -2
- package/dist/chunks/{EntryPicker-CiS8zT64.cjs.map → EntryPicker-BI_7g2Wg.cjs.map} +1 -1
- package/dist/chunks/{EntryPicker-LWwX_EzL.js → EntryPicker-KxHZzZsh.js} +2 -2
- package/dist/chunks/{EntryPicker-LWwX_EzL.js.map → EntryPicker-KxHZzZsh.js.map} +1 -1
- package/dist/chunks/{FormEditor-BZ_4nxIG.cjs → FormEditor-BJcAIVcL.cjs} +2 -2
- package/dist/chunks/{FormEditor-BZ_4nxIG.cjs.map → FormEditor-BJcAIVcL.cjs.map} +1 -1
- package/dist/chunks/{FormEditor-IKdPwVPx.js → FormEditor-CdLqPaKK.js} +6 -6
- package/dist/chunks/{FormEditor-IKdPwVPx.js.map → FormEditor-CdLqPaKK.js.map} +1 -1
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs +2 -0
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-CwoHE-AN.js → RichTextEditor-DmNM63Wg.js} +369 -280
- package/dist/chunks/RichTextEditor-DmNM63Wg.js.map +1 -0
- package/dist/chunks/{use-picker-session-BLH1tXk3.js → use-picker-session-BDEWL2jK.js} +8 -8
- package/dist/chunks/use-picker-session-BDEWL2jK.js.map +1 -0
- package/dist/chunks/use-picker-session-C4FGinLN.cjs +2 -0
- package/dist/chunks/use-picker-session-C4FGinLN.cjs.map +1 -0
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/item.d.cts +1 -3
- package/dist/components/EntryPicker/item.d.cts.map +1 -1
- package/dist/components/EntryPicker/item.d.ts +1 -3
- package/dist/components/EntryPicker/item.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +20 -8
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.cts +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.cts.map +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts.map +1 -1
- package/dist/components/RichTextEditor/style.css +84 -29
- package/dist/index.cjs +1 -1
- package/dist/index.js +17 -17
- package/package.json +1 -1
- package/dist/chunks/RichTextEditor-CwoHE-AN.js.map +0 -1
- package/dist/chunks/RichTextEditor-DMrxJhA6.cjs +0 -2
- package/dist/chunks/RichTextEditor-DMrxJhA6.cjs.map +0 -1
- package/dist/chunks/use-picker-session-BLH1tXk3.js.map +0 -1
- package/dist/chunks/use-picker-session-tRDYUd_d.cjs +0 -2
- package/dist/chunks/use-picker-session-tRDYUd_d.cjs.map +0 -1
|
@@ -10,30 +10,29 @@ import { Badge as d } from "../components/Badge/index.js";
|
|
|
10
10
|
import { Field as f } from "../components/Field/index.js";
|
|
11
11
|
import { Modal as p } from "../components/Modal/index.js";
|
|
12
12
|
import { TextField as m } from "../components/TextField/index.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { Link as B } from "@tiptap/extension-link";
|
|
13
|
+
import { a as h, i as g, l as _, o as v, s as y, t as b } from "./use-picker-session-BDEWL2jK.js";
|
|
14
|
+
import { createContext as x, forwardRef as S, useCallback as C, useContext as w, useEffect as T, useId as E, useMemo as D, useRef as O, useState as k } from "react";
|
|
15
|
+
import { createPortal as A } from "react-dom";
|
|
16
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
17
|
+
import { EditorContent as ee, Node as te, NodeViewWrapper as P, ReactNodeViewRenderer as F, createDocument as ne, getMarkRange as re, getSchema as ie, mergeAttributes as I, useEditor as ae, useEditorState as oe } from "@tiptap/react";
|
|
18
|
+
import { Placeholder as se } from "@tiptap/extension-placeholder";
|
|
19
|
+
import { StarterKit as L } from "@tiptap/starter-kit";
|
|
20
|
+
import { Link as R } from "@tiptap/extension-link";
|
|
22
21
|
//#region src/components/RichTextEditor/expansion.tsx
|
|
23
|
-
function
|
|
22
|
+
function z(e, t) {
|
|
24
23
|
let n = t.querySelector(".ds-rte__content");
|
|
25
24
|
if (!n) return;
|
|
26
25
|
let r = e.view.coordsAtPos(e.state.selection.head), i = n.getBoundingClientRect();
|
|
27
26
|
(r.top < i.top || r.bottom > i.bottom) && (n.scrollTop += r.top - i.top - i.height / 2);
|
|
28
27
|
}
|
|
29
|
-
function
|
|
30
|
-
let h = c("ds-rte__host"), [g, _] =
|
|
28
|
+
function ce({ editor: e, disabled: n, isHeld: a = !1, invalid: o, label: u, labelledBy: d, expandedWidth: f, frameRef: m }) {
|
|
29
|
+
let h = c("ds-rte__host"), [g, _] = k(!1), [v, y] = k(0), b = O(null), x = O(null), S = O(null), w = O(!1), T = O(!1), D = E();
|
|
31
30
|
g && n && !a && _(!1);
|
|
32
|
-
let
|
|
33
|
-
|
|
31
|
+
let j = C(() => {
|
|
32
|
+
w.current = document.activeElement === S.current, _(!1);
|
|
34
33
|
}, []);
|
|
35
34
|
l(() => {
|
|
36
|
-
h && (s(h, g ? x.current : b.current), T.current !== g && (T.current = g, n || !e ? r(document.activeElement) && i(m.current, { preventScroll: !0 }) : (
|
|
35
|
+
h && (s(h, g ? x.current : b.current), T.current !== g && (T.current = g, n || !e ? r(document.activeElement) && i(m.current, { preventScroll: !0 }) : (z(e, h), !g && w.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), w.current = !1)));
|
|
37
36
|
}, [
|
|
38
37
|
h,
|
|
39
38
|
g,
|
|
@@ -41,41 +40,41 @@ function se({ editor: e, disabled: n, isHeld: a = !1, invalid: o, label: u, labe
|
|
|
41
40
|
n,
|
|
42
41
|
m
|
|
43
42
|
]);
|
|
44
|
-
let
|
|
43
|
+
let N = g ? "Collapse editor" : "Expand editor";
|
|
45
44
|
return {
|
|
46
45
|
expanded: g,
|
|
47
|
-
toggle: /* @__PURE__ */
|
|
46
|
+
toggle: /* @__PURE__ */ M(t, {
|
|
48
47
|
ref: S,
|
|
49
48
|
size: "sm",
|
|
50
49
|
isIconOnly: !0,
|
|
51
50
|
iconStart: g ? "minimize-2" : "maximize-2",
|
|
52
51
|
className: "ds-rte__expand",
|
|
53
|
-
"aria-label":
|
|
54
|
-
title:
|
|
52
|
+
"aria-label": N,
|
|
53
|
+
title: N,
|
|
55
54
|
"aria-expanded": g,
|
|
56
|
-
"aria-controls": g ?
|
|
55
|
+
"aria-controls": g ? D : void 0,
|
|
57
56
|
isDisabled: n || !e || !h,
|
|
58
57
|
onMouseDown: (e) => e.preventDefault(),
|
|
59
58
|
onClick: () => {
|
|
60
|
-
g ?
|
|
59
|
+
g ? j() : (y(m.current.getBoundingClientRect().height), _(!0));
|
|
61
60
|
}
|
|
62
61
|
}),
|
|
63
|
-
surfaceSlot: (e) => /* @__PURE__ */
|
|
62
|
+
surfaceSlot: (e) => /* @__PURE__ */ M("div", {
|
|
64
63
|
ref: b,
|
|
65
64
|
className: "ds-rte__slot",
|
|
66
|
-
children: h ?
|
|
65
|
+
children: h ? A(e, h) : e
|
|
67
66
|
}),
|
|
68
|
-
dialog: /* @__PURE__ */
|
|
69
|
-
id:
|
|
67
|
+
dialog: /* @__PURE__ */ M(p, {
|
|
68
|
+
id: D,
|
|
70
69
|
isOpen: g,
|
|
71
|
-
onClose:
|
|
70
|
+
onClose: j,
|
|
72
71
|
title: u,
|
|
73
72
|
hasHeader: !1,
|
|
74
73
|
size: f === "full" ? "full" : "wide",
|
|
75
74
|
className: "ds-rte__modal",
|
|
76
75
|
"data-invalid": o || void 0,
|
|
77
76
|
"aria-labelledby": d,
|
|
78
|
-
children: /* @__PURE__ */
|
|
77
|
+
children: /* @__PURE__ */ M("div", {
|
|
79
78
|
ref: x,
|
|
80
79
|
className: "ds-rte__expanded-slot"
|
|
81
80
|
})
|
|
@@ -85,7 +84,7 @@ function se({ editor: e, disabled: n, isHeld: a = !1, invalid: o, label: u, labe
|
|
|
85
84
|
}
|
|
86
85
|
//#endregion
|
|
87
86
|
//#region src/components/RichTextEditor/storyblock.ts
|
|
88
|
-
function
|
|
87
|
+
function B(e) {
|
|
89
88
|
let t = (e) => typeof e == "string" && e.trim().length > 0;
|
|
90
89
|
return [
|
|
91
90
|
"left",
|
|
@@ -93,7 +92,7 @@ function H(e) {
|
|
|
93
92
|
"right"
|
|
94
93
|
].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);
|
|
95
94
|
}
|
|
96
|
-
function
|
|
95
|
+
function V(e) {
|
|
97
96
|
return {
|
|
98
97
|
...e,
|
|
99
98
|
...e.type === "storyblock" && e.attrs ? { attrs: {
|
|
@@ -104,10 +103,10 @@ function U(e) {
|
|
|
104
103
|
} : { assetId: e.attrs.assetId },
|
|
105
104
|
align: e.attrs.align ?? "full"
|
|
106
105
|
} } : {},
|
|
107
|
-
...e.content ? { content: e.content.map(
|
|
106
|
+
...e.content ? { content: e.content.map(V) } : {}
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
|
-
var
|
|
109
|
+
var H = te.create({
|
|
111
110
|
name: "storyblock",
|
|
112
111
|
group: "block",
|
|
113
112
|
atom: !0,
|
|
@@ -130,7 +129,7 @@ var W = F.create({
|
|
|
130
129
|
parseHTML() {
|
|
131
130
|
return [{
|
|
132
131
|
tag: "div[data-storyblock]",
|
|
133
|
-
getAttrs: (e) =>
|
|
132
|
+
getAttrs: (e) => B(Object.fromEntries([
|
|
134
133
|
"type",
|
|
135
134
|
"id",
|
|
136
135
|
"entryId",
|
|
@@ -140,64 +139,64 @@ var W = F.create({
|
|
|
140
139
|
}];
|
|
141
140
|
},
|
|
142
141
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
143
|
-
let n =
|
|
142
|
+
let n = V({
|
|
144
143
|
type: "storyblock",
|
|
145
144
|
attrs: e.attrs
|
|
146
145
|
}).attrs;
|
|
147
|
-
return ["div",
|
|
146
|
+
return ["div", I(t, {
|
|
148
147
|
"data-storyblock": "",
|
|
149
148
|
...Object.fromEntries(Object.entries(n).map(([e, t]) => [`data-storyblock-${e.toLowerCase()}`, t]))
|
|
150
149
|
})];
|
|
151
150
|
}
|
|
152
|
-
}),
|
|
151
|
+
}), U = {
|
|
153
152
|
type: "doc",
|
|
154
153
|
content: [{ type: "paragraph" }]
|
|
155
|
-
},
|
|
154
|
+
}, W = [L.configure({
|
|
156
155
|
link: !1,
|
|
157
156
|
trailingNode: { notAfter: ["paragraph", "storyblock"] }
|
|
158
|
-
}),
|
|
157
|
+
}), R.configure({
|
|
159
158
|
openOnClick: !1,
|
|
160
159
|
autolink: !0
|
|
161
160
|
})];
|
|
162
|
-
function
|
|
163
|
-
return [e, ...
|
|
161
|
+
function G(e = H) {
|
|
162
|
+
return [e, ...W];
|
|
164
163
|
}
|
|
165
|
-
var
|
|
166
|
-
function
|
|
164
|
+
var K = ie(G());
|
|
165
|
+
function q(e) {
|
|
167
166
|
return e.content?.length ? e : {
|
|
168
167
|
...e,
|
|
169
|
-
content:
|
|
168
|
+
content: U.content
|
|
170
169
|
};
|
|
171
170
|
}
|
|
172
|
-
function
|
|
171
|
+
function le(e) {
|
|
173
172
|
try {
|
|
174
173
|
if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
|
|
175
174
|
let t = (e) => {
|
|
176
|
-
let n =
|
|
175
|
+
let n = K.nodes[e.type ?? ""];
|
|
177
176
|
if (!n || Object.keys(e).some((e) => ![
|
|
178
177
|
"type",
|
|
179
178
|
"attrs",
|
|
180
179
|
"content",
|
|
181
180
|
"marks",
|
|
182
181
|
"text"
|
|
183
|
-
].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" && (!
|
|
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" && (!B(e.attrs ?? {}) || e.marks?.length)) throw Error();
|
|
184
183
|
for (let t of e.marks ?? []) {
|
|
185
|
-
let e =
|
|
184
|
+
let e = K.marks[t.type];
|
|
186
185
|
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();
|
|
187
186
|
}
|
|
188
187
|
e.content?.forEach(t);
|
|
189
188
|
}, n = e;
|
|
190
|
-
t(n),
|
|
189
|
+
t(n), K.nodeFromJSON(q(n)).check();
|
|
191
190
|
} catch {
|
|
192
191
|
return "Unsupported or invalid rich-text document.";
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
//#endregion
|
|
196
195
|
//#region src/components/RichTextEditor/embed-context.ts
|
|
197
|
-
function
|
|
196
|
+
function J(e) {
|
|
198
197
|
return !!(e && (e.loadPage || e.items?.length || e.onCreate));
|
|
199
198
|
}
|
|
200
|
-
var
|
|
199
|
+
var Y = x({
|
|
201
200
|
views: {},
|
|
202
201
|
disabled: !1,
|
|
203
202
|
busy: !1,
|
|
@@ -205,7 +204,7 @@ var Z = S({
|
|
|
205
204
|
replace: () => {},
|
|
206
205
|
seed: () => void 0,
|
|
207
206
|
forgetSeed: () => {}
|
|
208
|
-
}),
|
|
207
|
+
}), X = [], Z = [
|
|
209
208
|
{
|
|
210
209
|
align: "left",
|
|
211
210
|
icon: "align-left",
|
|
@@ -221,10 +220,48 @@ var Z = S({
|
|
|
221
220
|
icon: "align-right",
|
|
222
221
|
label: "Align right"
|
|
223
222
|
}
|
|
224
|
-
]
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
], ue = [
|
|
224
|
+
"left",
|
|
225
|
+
"full",
|
|
226
|
+
"right",
|
|
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(() => {
|
|
228
265
|
u && i(e, t, u);
|
|
229
266
|
}, [
|
|
230
267
|
i,
|
|
@@ -232,10 +269,10 @@ function ue(e, t) {
|
|
|
232
269
|
t,
|
|
233
270
|
u
|
|
234
271
|
]);
|
|
235
|
-
let { known: d, failures: f } = l, p = !!a?.resolveItem, m =
|
|
272
|
+
let { known: d, failures: f } = l, p = !!a?.resolveItem, m = D(() => y({
|
|
236
273
|
selected: s,
|
|
237
274
|
items: o,
|
|
238
|
-
pageItems:
|
|
275
|
+
pageItems: X,
|
|
239
276
|
known: d,
|
|
240
277
|
failures: f,
|
|
241
278
|
hasResolver: p,
|
|
@@ -247,134 +284,186 @@ function ue(e, t) {
|
|
|
247
284
|
f,
|
|
248
285
|
p,
|
|
249
286
|
e
|
|
250
|
-
]),
|
|
287
|
+
]), g = h(`Couldn't load ${e}`, l.status, l.error, l.retry), _ = o.some((e) => e.id === t);
|
|
251
288
|
return {
|
|
252
289
|
view: a,
|
|
253
290
|
item: m,
|
|
254
291
|
missing: m.tone === "removed" || !_ && d.has(t) && !d.get(t),
|
|
255
|
-
failure:
|
|
292
|
+
failure: g
|
|
256
293
|
};
|
|
257
294
|
}
|
|
258
|
-
function
|
|
259
|
-
return /* @__PURE__ */ N(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
295
|
+
function he({ kind: t, isMovable: n, onSelect: r }) {
|
|
296
|
+
return /* @__PURE__ */ N("span", {
|
|
297
|
+
className: "ds-storyblock__kind",
|
|
298
|
+
"data-drag-handle": n ? "" : void 0,
|
|
299
|
+
draggable: n || void 0,
|
|
300
|
+
title: n ? "Drag to move" : void 0,
|
|
301
|
+
onClick: n ? r : void 0,
|
|
302
|
+
children: [n && /* @__PURE__ */ M("span", {
|
|
303
|
+
className: "ds-storyblock__grip",
|
|
304
|
+
"aria-hidden": "true",
|
|
305
|
+
children: /* @__PURE__ */ M(e, {
|
|
306
|
+
name: "grip-vertical",
|
|
307
|
+
size: 16
|
|
308
|
+
})
|
|
309
|
+
}), /* @__PURE__ */ M(d, {
|
|
310
|
+
className: "ds-storyblock__kind-label",
|
|
311
|
+
shape: "tag",
|
|
312
|
+
size: "sm",
|
|
313
|
+
children: t
|
|
314
|
+
})]
|
|
263
315
|
});
|
|
264
316
|
}
|
|
265
|
-
function
|
|
266
|
-
let
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
317
|
+
function ge({ kind: e, name: n, align: r, isSelected: i, isLocked: a, canReplace: o, onEdit: s, onSelect: c, onAlign: l, onReplace: d, onRemove: f }) {
|
|
318
|
+
let p = {
|
|
319
|
+
left: !0,
|
|
320
|
+
full: !0,
|
|
321
|
+
right: !0,
|
|
322
|
+
replace: o.isEnabled,
|
|
323
|
+
edit: !!s,
|
|
324
|
+
remove: !0
|
|
325
|
+
}, { control: m, barProps: h } = pe(i, a ? [] : ue.filter((e) => p[e]));
|
|
326
|
+
return /* @__PURE__ */ N("div", {
|
|
327
|
+
className: "ds-storyblock__bar",
|
|
273
328
|
role: "toolbar",
|
|
274
|
-
"aria-label":
|
|
275
|
-
|
|
276
|
-
children:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
variant: i === e.align ? "active" : "neutral",
|
|
288
|
-
onClick: () => c(e.align)
|
|
289
|
-
}, e.align))
|
|
290
|
-
}),
|
|
291
|
-
a && /* @__PURE__ */ N(t, {
|
|
292
|
-
variant: "simple",
|
|
293
|
-
size: "sm",
|
|
294
|
-
onClick: l,
|
|
295
|
-
children: "Replace"
|
|
296
|
-
}),
|
|
297
|
-
s && o && /* @__PURE__ */ N(t, {
|
|
298
|
-
variant: "simple",
|
|
299
|
-
size: "sm",
|
|
300
|
-
isIconOnly: !0,
|
|
301
|
-
iconStart: "pencil",
|
|
302
|
-
"aria-label": `Edit ${r}`,
|
|
303
|
-
onClick: () => o(s)
|
|
304
|
-
}),
|
|
305
|
-
/* @__PURE__ */ N(t, {
|
|
306
|
-
variant: "simple",
|
|
329
|
+
"aria-label": `Block actions for ${n}`,
|
|
330
|
+
...h,
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ M(he, {
|
|
333
|
+
kind: e,
|
|
334
|
+
isMovable: !a,
|
|
335
|
+
onSelect: c
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ M(u, {
|
|
338
|
+
className: "ds-storyblock__alignment",
|
|
339
|
+
"aria-label": "Alignment",
|
|
340
|
+
children: Z.map((e) => /* @__PURE__ */ M(t, {
|
|
341
|
+
...m(e.align),
|
|
307
342
|
size: "sm",
|
|
308
343
|
isIconOnly: !0,
|
|
309
|
-
iconStart:
|
|
310
|
-
"aria-label":
|
|
311
|
-
title:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
344
|
+
iconStart: e.icon,
|
|
345
|
+
"aria-label": `${e.label}: ${n}`,
|
|
346
|
+
title: e.label,
|
|
347
|
+
"aria-pressed": r === e.align,
|
|
348
|
+
variant: r === e.align ? "active" : "neutral",
|
|
349
|
+
onClick: () => l(e.align)
|
|
350
|
+
}, e.align))
|
|
351
|
+
}),
|
|
352
|
+
/* @__PURE__ */ N("div", {
|
|
353
|
+
className: "ds-storyblock__actions",
|
|
354
|
+
children: [
|
|
355
|
+
o.isShown && /* @__PURE__ */ M(t, {
|
|
356
|
+
...m("replace"),
|
|
357
|
+
variant: "simple",
|
|
358
|
+
size: "sm",
|
|
359
|
+
"aria-label": `Replace ${n}`,
|
|
360
|
+
onClick: d,
|
|
361
|
+
children: "Replace"
|
|
362
|
+
}),
|
|
363
|
+
s && /* @__PURE__ */ M(t, {
|
|
364
|
+
...m("edit"),
|
|
365
|
+
variant: "simple",
|
|
366
|
+
size: "sm",
|
|
367
|
+
isIconOnly: !0,
|
|
368
|
+
iconStart: "pencil",
|
|
369
|
+
"aria-label": `Edit ${n}`,
|
|
370
|
+
title: `Edit ${e}`,
|
|
371
|
+
onClick: s
|
|
372
|
+
}),
|
|
373
|
+
/* @__PURE__ */ M(t, {
|
|
374
|
+
...m("remove"),
|
|
375
|
+
variant: "simple",
|
|
376
|
+
size: "sm",
|
|
377
|
+
isIconOnly: !0,
|
|
378
|
+
iconStart: "trash",
|
|
379
|
+
"aria-label": `Remove ${n}`,
|
|
380
|
+
title: "Remove block from this field",
|
|
381
|
+
onClick: f
|
|
382
|
+
})
|
|
383
|
+
]
|
|
384
|
+
})
|
|
385
|
+
]
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function _e({ kind: e, id: t, item: n, missing: r }) {
|
|
389
|
+
return /* @__PURE__ */ M("div", {
|
|
390
|
+
className: "ds-entry ds-storyblock__body",
|
|
391
|
+
children: r ? /* @__PURE__ */ N("span", {
|
|
392
|
+
className: "ds-entry__body",
|
|
393
|
+
children: [/* @__PURE__ */ M("em", {
|
|
394
|
+
className: "ds-entry__title",
|
|
395
|
+
children: `Unavailable ${e}`
|
|
396
|
+
}), /* @__PURE__ */ N("span", {
|
|
397
|
+
className: "ds-entry__meta",
|
|
398
|
+
children: [/* @__PURE__ */ M("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ M("code", { children: t })]
|
|
399
|
+
})]
|
|
400
|
+
}) : /* @__PURE__ */ M(_, { item: n })
|
|
316
401
|
});
|
|
317
402
|
}
|
|
318
|
-
function
|
|
319
|
-
let { disabled:
|
|
320
|
-
|
|
321
|
-
|
|
403
|
+
function ve({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
|
|
404
|
+
let { disabled: a, busy: o, replace: s } = w(Y), c = e.attrs.type, l = String(c === "entry" ? e.attrs.entryId : e.attrs.assetId), { view: u, item: d, missing: f, failure: p } = me(c, l), m = e.attrs.align ?? "full", h = !f && !d.isUnavailable && !d.isDisabled && u?.onEditItem, g = t && !a, _ = () => {
|
|
405
|
+
let e = r();
|
|
406
|
+
e !== void 0 && n.chain().focus().setNodeSelection(e).run();
|
|
407
|
+
};
|
|
408
|
+
return /* @__PURE__ */ N(P, {
|
|
322
409
|
className: "ds-storyblock",
|
|
323
|
-
"data-align":
|
|
324
|
-
"data-selected":
|
|
325
|
-
"data-missing":
|
|
410
|
+
"data-align": m,
|
|
411
|
+
"data-selected": g || void 0,
|
|
412
|
+
"data-missing": f || void 0,
|
|
413
|
+
"data-tone": f ? "removed" : d.tone,
|
|
326
414
|
contentEditable: !1,
|
|
327
415
|
onMouseDown: (e) => {
|
|
328
|
-
|
|
329
|
-
e.preventDefault();
|
|
330
|
-
let t = i();
|
|
331
|
-
t !== void 0 && r.chain().focus().setNodeSelection(t).run();
|
|
416
|
+
let t = e.target instanceof Element ? e.target : null;
|
|
417
|
+
t?.closest("button") ? e.preventDefault() : !a && !t?.closest("[data-drag-handle]") && (e.preventDefault(), _());
|
|
332
418
|
},
|
|
333
419
|
children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
className: "ds-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
children: /* @__PURE__ */ N(e, {
|
|
340
|
-
name: "grip-vertical",
|
|
341
|
-
size: 16
|
|
420
|
+
a ? /* @__PURE__ */ M("div", {
|
|
421
|
+
className: "ds-storyblock__bar",
|
|
422
|
+
children: /* @__PURE__ */ M(he, {
|
|
423
|
+
kind: c,
|
|
424
|
+
isMovable: !1
|
|
342
425
|
})
|
|
343
|
-
}),
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
h,
|
|
357
|
-
/* @__PURE__ */ N(fe, {
|
|
358
|
-
anchorRef: g,
|
|
359
|
-
isOpen: n && !s && !f?.isDialogHidden,
|
|
360
|
-
kind: u,
|
|
361
|
-
align: _,
|
|
362
|
-
canReplace: !!f?.canEmbed && !c,
|
|
363
|
-
onEditItem: f?.onEditItem,
|
|
364
|
-
editable: y ? p : void 0,
|
|
365
|
-
onAlign: (e) => a({ align: e }),
|
|
426
|
+
}) : /* @__PURE__ */ M(ge, {
|
|
427
|
+
kind: c,
|
|
428
|
+
name: f ? `Unavailable ${c}` : d.title,
|
|
429
|
+
align: m,
|
|
430
|
+
isSelected: g,
|
|
431
|
+
isLocked: !!u?.isDialogHidden,
|
|
432
|
+
canReplace: {
|
|
433
|
+
isShown: !!u?.canEmbed,
|
|
434
|
+
isEnabled: !!u?.canEmbed && !o
|
|
435
|
+
},
|
|
436
|
+
onEdit: h ? () => h(d) : void 0,
|
|
437
|
+
onSelect: _,
|
|
438
|
+
onAlign: (e) => i({ align: e }),
|
|
366
439
|
onReplace: () => {
|
|
367
|
-
let e =
|
|
368
|
-
e !== void 0 &&
|
|
440
|
+
let e = r();
|
|
441
|
+
e !== void 0 && s(c, e);
|
|
369
442
|
},
|
|
370
|
-
onRemove:
|
|
443
|
+
onRemove: () => {
|
|
444
|
+
let t = r();
|
|
445
|
+
t !== void 0 && n.chain().focus().setNodeSelection(t).deleteRange({
|
|
446
|
+
from: t,
|
|
447
|
+
to: t + e.nodeSize
|
|
448
|
+
}).run();
|
|
449
|
+
}
|
|
450
|
+
}),
|
|
451
|
+
/* @__PURE__ */ M(_e, {
|
|
452
|
+
kind: c,
|
|
453
|
+
id: l,
|
|
454
|
+
item: d,
|
|
455
|
+
missing: f
|
|
456
|
+
}),
|
|
457
|
+
p && /* @__PURE__ */ M("div", {
|
|
458
|
+
className: "ds-storyblock__failure",
|
|
459
|
+
children: p
|
|
371
460
|
})
|
|
372
461
|
]
|
|
373
462
|
});
|
|
374
463
|
}
|
|
375
464
|
//#endregion
|
|
376
465
|
//#region src/components/RichTextEditor/use-embeds.tsx
|
|
377
|
-
var
|
|
466
|
+
var ye = "ds-rte-embed-commit", be = ["entry", "asset"], xe = {
|
|
378
467
|
entry: {
|
|
379
468
|
itemLabel: "entry",
|
|
380
469
|
itemsLabel: "entries"
|
|
@@ -383,8 +472,8 @@ var me = "ds-rte-embed-commit", he = ["entry", "asset"], ge = {
|
|
|
383
472
|
itemLabel: "asset",
|
|
384
473
|
itemsLabel: "assets"
|
|
385
474
|
}
|
|
386
|
-
},
|
|
387
|
-
function
|
|
475
|
+
}, Se = {}, Ce = [];
|
|
476
|
+
function we(e, t, n) {
|
|
388
477
|
return {
|
|
389
478
|
type: e,
|
|
390
479
|
align: t,
|
|
@@ -394,29 +483,29 @@ function ye(e, t, n) {
|
|
|
394
483
|
} : { assetId: n.id }
|
|
395
484
|
};
|
|
396
485
|
}
|
|
397
|
-
function
|
|
486
|
+
function Q(e, t) {
|
|
398
487
|
if (t.tone === "removed") return {
|
|
399
488
|
label: t.removedLabel ?? "Removed",
|
|
400
489
|
description: `This ${e} was removed.`
|
|
401
490
|
};
|
|
402
|
-
if (!
|
|
491
|
+
if (!B(we(e, "full", t))) return {
|
|
403
492
|
label: "Can't embed",
|
|
404
493
|
description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
|
|
405
494
|
};
|
|
406
495
|
}
|
|
407
|
-
var
|
|
408
|
-
entry: (e) =>
|
|
409
|
-
asset: (e) =>
|
|
496
|
+
var Te = {
|
|
497
|
+
entry: (e) => Q("entry", e),
|
|
498
|
+
asset: (e) => Q("asset", e)
|
|
410
499
|
};
|
|
411
|
-
function
|
|
500
|
+
function Ee(e, t) {
|
|
412
501
|
return e?.type.name === "storyblock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
|
|
413
502
|
}
|
|
414
|
-
function
|
|
503
|
+
function De(e) {
|
|
415
504
|
return e.flatMap((e) => e.mapping.maps);
|
|
416
505
|
}
|
|
417
|
-
function
|
|
506
|
+
function Oe(e, t) {
|
|
418
507
|
let n = t;
|
|
419
|
-
for (let t of
|
|
508
|
+
for (let t of De(e)) {
|
|
420
509
|
let e = n, r;
|
|
421
510
|
if (t.forEach((t, n, i, a) => {
|
|
422
511
|
r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
|
|
@@ -430,9 +519,9 @@ function we(e, t) {
|
|
|
430
519
|
}
|
|
431
520
|
return n;
|
|
432
521
|
}
|
|
433
|
-
function
|
|
522
|
+
function ke(e, t, n) {
|
|
434
523
|
let r = t, i = n;
|
|
435
|
-
for (let t of
|
|
524
|
+
for (let t of De(e)) {
|
|
436
525
|
if (r === i) {
|
|
437
526
|
r = i = t.map(i, -1);
|
|
438
527
|
continue;
|
|
@@ -448,13 +537,13 @@ function Te(e, t, n) {
|
|
|
448
537
|
to: i
|
|
449
538
|
};
|
|
450
539
|
}
|
|
451
|
-
function
|
|
540
|
+
function Ae(e, t) {
|
|
452
541
|
let n = e.resolve(Math.min(t, e.content.size));
|
|
453
542
|
return n.depth ? n.after(1) : n.pos;
|
|
454
543
|
}
|
|
455
|
-
function
|
|
456
|
-
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l =
|
|
457
|
-
return
|
|
544
|
+
function je(e, t, n) {
|
|
545
|
+
let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = J(e);
|
|
546
|
+
return D(() => r ? {
|
|
458
547
|
resolveItem: i ? t : void 0,
|
|
459
548
|
refreshKey: o,
|
|
460
549
|
items: s,
|
|
@@ -473,8 +562,8 @@ function De(e, t, n) {
|
|
|
473
562
|
n
|
|
474
563
|
]);
|
|
475
564
|
}
|
|
476
|
-
function
|
|
477
|
-
let { itemLabel: s, itemsLabel: c } =
|
|
565
|
+
function Me({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: o }) {
|
|
566
|
+
let { itemLabel: s, itemsLabel: c } = xe[e.kind], l = D(() => e.replaceId ? [e.replaceId] : [], [e]), u = b(l, t.items ?? Ce, {
|
|
478
567
|
...t,
|
|
479
568
|
resolveItem: void 0,
|
|
480
569
|
mode: "single"
|
|
@@ -484,9 +573,9 @@ function Oe({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
484
573
|
itemLabel: s,
|
|
485
574
|
itemsLabel: c,
|
|
486
575
|
close: i,
|
|
487
|
-
restrict:
|
|
576
|
+
restrict: Te[e.kind]
|
|
488
577
|
}), d = e.replaceId ? "Replace" : "Embed";
|
|
489
|
-
return /* @__PURE__ */
|
|
578
|
+
return /* @__PURE__ */ M(g, {
|
|
490
579
|
...u.dialog,
|
|
491
580
|
isOpen: !0,
|
|
492
581
|
onClose: i,
|
|
@@ -502,15 +591,15 @@ function Oe({ session: e, source: t, disabled: n, label: r, close: i, target: a,
|
|
|
502
591
|
isDialogHidden: t.isDialogHidden
|
|
503
592
|
});
|
|
504
593
|
}
|
|
505
|
-
function
|
|
506
|
-
let [a, s] =
|
|
594
|
+
function Ne(e, n = Se, r, i) {
|
|
595
|
+
let [a, s] = k(null), c = O(0), l = O({
|
|
507
596
|
session: null,
|
|
508
597
|
from: 0,
|
|
509
598
|
to: 0,
|
|
510
599
|
alive: !1
|
|
511
|
-
}), d =
|
|
600
|
+
}), d = O(/* @__PURE__ */ new Map()), [f, p] = k(0), m = C(() => {
|
|
512
601
|
l.current.alive = !1, s(null);
|
|
513
|
-
}, []), h = a ? n[a.kind] : void 0, g = a &&
|
|
602
|
+
}, []), h = a ? n[a.kind] : void 0, g = a && J(h) && (!r || h?.isCreating) ? a : null;
|
|
514
603
|
a && !g && s(null);
|
|
515
604
|
let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = o({
|
|
516
605
|
editor: e,
|
|
@@ -518,7 +607,7 @@ function ke(e, n = _e, r, i) {
|
|
|
518
607
|
disabled: r,
|
|
519
608
|
busy: _
|
|
520
609
|
});
|
|
521
|
-
|
|
610
|
+
T(() => {
|
|
522
611
|
if (!e || !a) return;
|
|
523
612
|
l.current.alive = !0;
|
|
524
613
|
let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
|
|
@@ -526,12 +615,12 @@ function ke(e, n = _e, r, i) {
|
|
|
526
615
|
if (!l.current.alive || !r.some((e) => e.docChanged)) return;
|
|
527
616
|
let { from: i, to: o } = l.current;
|
|
528
617
|
if (a.replaceId === void 0) {
|
|
529
|
-
let e =
|
|
618
|
+
let e = ke(r, i, o);
|
|
530
619
|
e ? Object.assign(l.current, e) : m();
|
|
531
620
|
return;
|
|
532
621
|
}
|
|
533
|
-
let s =
|
|
534
|
-
s === null || !
|
|
622
|
+
let s = Oe(r, i);
|
|
623
|
+
s === null || !Ee(e.state.doc.nodeAt(s), a) ? m() : Object.assign(l.current, {
|
|
535
624
|
from: s,
|
|
536
625
|
to: s + 1
|
|
537
626
|
});
|
|
@@ -546,22 +635,22 @@ function ke(e, n = _e, r, i) {
|
|
|
546
635
|
]);
|
|
547
636
|
let y = (e) => {
|
|
548
637
|
let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
|
|
549
|
-
return !(!t || t.isDestroyed || l.current.session !== e || !l.current.alive || !
|
|
638
|
+
return !(!t || t.isDestroyed || l.current.session !== e || !l.current.alive || !J(i) || r && !i?.isCreating);
|
|
550
639
|
}, b = (e, t, n) => {
|
|
551
640
|
let r = v.current.editor;
|
|
552
641
|
if (!r || !y(e) || t.isDisabled || t.tone === "removed") return !1;
|
|
553
642
|
let { doc: i } = r.state, a = e.replaceId !== void 0, o = a ? i.nodeAt(l.current.from) : null;
|
|
554
|
-
if (a && !
|
|
555
|
-
let s =
|
|
556
|
-
if (!
|
|
557
|
-
let c = a ? l.current.from :
|
|
643
|
+
if (a && !Ee(o, e)) return !1;
|
|
644
|
+
let s = we(e.kind, o?.attrs.align ?? "full", t);
|
|
645
|
+
if (!B(s)) return !1;
|
|
646
|
+
let c = a ? l.current.from : Ae(i, l.current.to), u = `${e.kind}:${t.id}`;
|
|
558
647
|
l.current.alive = !1, d.current = /* @__PURE__ */ new Map([[u, {
|
|
559
648
|
item: t,
|
|
560
649
|
revision: n
|
|
561
650
|
}]]);
|
|
562
651
|
let f = !1;
|
|
563
652
|
try {
|
|
564
|
-
let e = r.chain().focus().setMeta(
|
|
653
|
+
let e = r.chain().focus().setMeta(ye, !0);
|
|
565
654
|
f = a ? e.setNodeSelection(c).updateAttributes("storyblock", s).run() : e.insertContentAt(c, {
|
|
566
655
|
type: "storyblock",
|
|
567
656
|
attrs: s
|
|
@@ -574,7 +663,7 @@ function ke(e, n = _e, r, i) {
|
|
|
574
663
|
return f ? p((e) => e + 1) : d.current.delete(u), f;
|
|
575
664
|
}, x = (e, t) => {
|
|
576
665
|
let { editor: n, sources: r, disabled: i, busy: a } = v.current;
|
|
577
|
-
if (!n || i || a || !
|
|
666
|
+
if (!n || i || a || !J(r[e])) return;
|
|
578
667
|
let o = t === void 0 ? null : n.state.doc.nodeAt(t);
|
|
579
668
|
if (t !== void 0 && (o?.type.name !== "storyblock" || o.attrs.type !== e)) return;
|
|
580
669
|
let { $from: u, from: d, to: f } = n.state.selection, p = {
|
|
@@ -596,7 +685,7 @@ function ke(e, n = _e, r, i) {
|
|
|
596
685
|
...m,
|
|
597
686
|
alive: !0
|
|
598
687
|
}, s(p);
|
|
599
|
-
}, S = o({ open: x }), [
|
|
688
|
+
}, S = o({ open: x }), [w] = k(() => ({
|
|
600
689
|
replace: (e, t) => S.current.open(e, t),
|
|
601
690
|
seed: (e, t) => d.current.get(`${e}:${t}`),
|
|
602
691
|
forgetSeed: (e, t, n) => {
|
|
@@ -614,31 +703,31 @@ function ke(e, n = _e, r, i) {
|
|
|
614
703
|
v.current.sources.asset?.onEditItem?.(e);
|
|
615
704
|
}
|
|
616
705
|
}
|
|
617
|
-
})),
|
|
706
|
+
})), E = je(n.entry, w.resolve.entry, w.edit.entry), A = je(n.asset, w.resolve.asset, w.edit.asset), j = D(() => ({
|
|
618
707
|
views: {
|
|
619
|
-
entry:
|
|
620
|
-
asset:
|
|
708
|
+
entry: E,
|
|
709
|
+
asset: A
|
|
621
710
|
},
|
|
622
711
|
disabled: r,
|
|
623
712
|
busy: _,
|
|
624
713
|
pickCount: f,
|
|
625
|
-
replace:
|
|
626
|
-
seed:
|
|
627
|
-
forgetSeed:
|
|
714
|
+
replace: w.replace,
|
|
715
|
+
seed: w.seed,
|
|
716
|
+
forgetSeed: w.forgetSeed
|
|
628
717
|
}), [
|
|
629
|
-
|
|
630
|
-
|
|
718
|
+
E,
|
|
719
|
+
A,
|
|
631
720
|
r,
|
|
632
721
|
_,
|
|
633
722
|
f,
|
|
634
|
-
|
|
635
|
-
]),
|
|
723
|
+
w
|
|
724
|
+
]), N = be.filter((e) => J(n[e]));
|
|
636
725
|
return {
|
|
637
726
|
context: j,
|
|
638
|
-
isCreating:
|
|
639
|
-
toolbar:
|
|
727
|
+
isCreating: be.some((e) => n[e]?.isCreating),
|
|
728
|
+
toolbar: N.length > 0 && /* @__PURE__ */ M(u, {
|
|
640
729
|
"aria-label": "Embed",
|
|
641
|
-
children:
|
|
730
|
+
children: N.map((n) => /* @__PURE__ */ M(t, {
|
|
642
731
|
size: "sm",
|
|
643
732
|
isIconOnly: !0,
|
|
644
733
|
iconStart: n === "entry" ? "file-text" : "image",
|
|
@@ -650,7 +739,7 @@ function ke(e, n = _e, r, i) {
|
|
|
650
739
|
onClick: () => x(n)
|
|
651
740
|
}, n))
|
|
652
741
|
}),
|
|
653
|
-
dialog: e && g && h && /* @__PURE__ */
|
|
742
|
+
dialog: e && g && h && /* @__PURE__ */ M(Me, {
|
|
654
743
|
session: g,
|
|
655
744
|
source: h,
|
|
656
745
|
disabled: r,
|
|
@@ -666,9 +755,9 @@ function ke(e, n = _e, r, i) {
|
|
|
666
755
|
}
|
|
667
756
|
//#endregion
|
|
668
757
|
//#region src/components/RichTextEditor/index.tsx
|
|
669
|
-
function
|
|
670
|
-
let [i, a] =
|
|
671
|
-
|
|
758
|
+
function Pe({ editor: e, selection: n, onClose: r }) {
|
|
759
|
+
let [i, a] = k(n.href), [o, s] = k(), c = E();
|
|
760
|
+
T(() => {
|
|
672
761
|
let t = () => {
|
|
673
762
|
e.state.doc.eq(n.document) || r();
|
|
674
763
|
};
|
|
@@ -703,13 +792,13 @@ function Ae({ editor: e, selection: n, onClose: r }) {
|
|
|
703
792
|
}]
|
|
704
793
|
}).run() : a.setLink({ href: t }).run(), r();
|
|
705
794
|
};
|
|
706
|
-
return /* @__PURE__ */
|
|
795
|
+
return /* @__PURE__ */ M(p, {
|
|
707
796
|
isOpen: !0,
|
|
708
797
|
title: n.isEditing ? "Edit link" : "Add link",
|
|
709
798
|
size: "dialog",
|
|
710
799
|
onClose: r,
|
|
711
|
-
footer: /* @__PURE__ */
|
|
712
|
-
n.isEditing && /* @__PURE__ */
|
|
800
|
+
footer: /* @__PURE__ */ N(j, { children: [
|
|
801
|
+
n.isEditing && /* @__PURE__ */ M(t, {
|
|
713
802
|
variant: "danger",
|
|
714
803
|
onClick: () => {
|
|
715
804
|
l() && e.chain().focus().setTextSelection({
|
|
@@ -719,28 +808,28 @@ function Ae({ editor: e, selection: n, onClose: r }) {
|
|
|
719
808
|
},
|
|
720
809
|
children: "Remove link"
|
|
721
810
|
}),
|
|
722
|
-
/* @__PURE__ */
|
|
811
|
+
/* @__PURE__ */ M(t, {
|
|
723
812
|
onClick: r,
|
|
724
813
|
children: "Cancel"
|
|
725
814
|
}),
|
|
726
|
-
/* @__PURE__ */
|
|
815
|
+
/* @__PURE__ */ M(t, {
|
|
727
816
|
variant: "primary",
|
|
728
817
|
type: "submit",
|
|
729
818
|
form: c,
|
|
730
819
|
children: "Save"
|
|
731
820
|
})
|
|
732
821
|
] }),
|
|
733
|
-
children: /* @__PURE__ */
|
|
822
|
+
children: /* @__PURE__ */ M("form", {
|
|
734
823
|
id: c,
|
|
735
824
|
noValidate: !0,
|
|
736
825
|
onSubmit: (e) => {
|
|
737
826
|
e.preventDefault(), e.stopPropagation(), u();
|
|
738
827
|
},
|
|
739
|
-
children: /* @__PURE__ */
|
|
828
|
+
children: /* @__PURE__ */ M(f, {
|
|
740
829
|
label: "URL",
|
|
741
830
|
isRequired: !0,
|
|
742
831
|
error: o,
|
|
743
|
-
children: (e) => /* @__PURE__ */
|
|
832
|
+
children: (e) => /* @__PURE__ */ M(m, {
|
|
744
833
|
...e,
|
|
745
834
|
value: i,
|
|
746
835
|
inputMode: "url",
|
|
@@ -833,15 +922,15 @@ var $ = [
|
|
|
833
922
|
run: (e) => e.chain().focus().redo().run()
|
|
834
923
|
}]
|
|
835
924
|
];
|
|
836
|
-
function
|
|
837
|
-
return /* @__PURE__ */
|
|
925
|
+
function Fe({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c }) {
|
|
926
|
+
return /* @__PURE__ */ N("div", {
|
|
838
927
|
className: "ds-rte__toolbar",
|
|
839
928
|
role: "toolbar",
|
|
840
929
|
"aria-label": `${i} formatting`,
|
|
841
930
|
children: [
|
|
842
|
-
$.map((i, a) => /* @__PURE__ */
|
|
931
|
+
$.map((i, a) => /* @__PURE__ */ M(u, {
|
|
843
932
|
"aria-label": `Formatting ${a + 1}`,
|
|
844
|
-
children: i.map((i) => /* @__PURE__ */
|
|
933
|
+
children: i.map((i) => /* @__PURE__ */ M(t, {
|
|
845
934
|
size: "sm",
|
|
846
935
|
isIconOnly: !0,
|
|
847
936
|
iconStart: i.icon,
|
|
@@ -853,9 +942,9 @@ function je({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
|
|
|
853
942
|
onClick: () => e && i.run(e)
|
|
854
943
|
}, i.id))
|
|
855
944
|
}, a)),
|
|
856
|
-
/* @__PURE__ */
|
|
945
|
+
/* @__PURE__ */ M(u, {
|
|
857
946
|
"aria-label": "Link",
|
|
858
|
-
children: /* @__PURE__ */
|
|
947
|
+
children: /* @__PURE__ */ M(t, {
|
|
859
948
|
size: "sm",
|
|
860
949
|
isIconOnly: !0,
|
|
861
950
|
iconStart: "link",
|
|
@@ -872,10 +961,10 @@ function je({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openL
|
|
|
872
961
|
]
|
|
873
962
|
});
|
|
874
963
|
}
|
|
875
|
-
var
|
|
876
|
-
return /* @__PURE__ */
|
|
964
|
+
var Ie = S(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: o, contentError: s, errorId: c, surface: l, children: u }, d) {
|
|
965
|
+
return /* @__PURE__ */ M(a.Provider, {
|
|
877
966
|
value: e,
|
|
878
|
-
children: /* @__PURE__ */
|
|
967
|
+
children: /* @__PURE__ */ N("div", {
|
|
879
968
|
ref: d,
|
|
880
969
|
className: ["ds-rte", t].filter(Boolean).join(" "),
|
|
881
970
|
style: n.frameStyle,
|
|
@@ -884,17 +973,17 @@ var Me = C(function({ scopeRef: e, className: t, expansion: n, isFocused: r, dis
|
|
|
884
973
|
"data-disabled": i || void 0,
|
|
885
974
|
"aria-invalid": o || void 0,
|
|
886
975
|
children: [
|
|
887
|
-
s && /* @__PURE__ */
|
|
976
|
+
s && /* @__PURE__ */ M("p", {
|
|
888
977
|
id: c,
|
|
889
978
|
role: "alert",
|
|
890
979
|
className: "ds-field__error",
|
|
891
980
|
children: s
|
|
892
981
|
}),
|
|
893
|
-
n.expanded && /* @__PURE__ */
|
|
982
|
+
n.expanded && /* @__PURE__ */ M("p", {
|
|
894
983
|
className: "ds-rte__placeholder",
|
|
895
984
|
children: "Editing in expanded view. Press Esc to return."
|
|
896
985
|
}),
|
|
897
|
-
n.surfaceSlot(/* @__PURE__ */
|
|
986
|
+
n.surfaceSlot(/* @__PURE__ */ M("div", {
|
|
898
987
|
className: "ds-rte__surface",
|
|
899
988
|
hidden: !!s,
|
|
900
989
|
"data-invalid": o || void 0,
|
|
@@ -905,33 +994,33 @@ var Me = C(function({ scopeRef: e, className: t, expansion: n, isFocused: r, dis
|
|
|
905
994
|
]
|
|
906
995
|
})
|
|
907
996
|
});
|
|
908
|
-
}),
|
|
909
|
-
return
|
|
997
|
+
}), Le = H.extend({ addNodeView() {
|
|
998
|
+
return F(ve, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
|
|
910
999
|
} });
|
|
911
|
-
function
|
|
1000
|
+
function Re(e, t) {
|
|
912
1001
|
return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
|
|
913
1002
|
}
|
|
914
|
-
var
|
|
915
|
-
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 =
|
|
916
|
-
|
|
917
|
-
let
|
|
918
|
-
if (
|
|
1003
|
+
var ze = S(function(e, t) {
|
|
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 = O(null), y = D(() => n(v, t), [t]), [b, x] = k(!1), [S, w] = k(null), A = C(() => w(null), []), [te] = k(() => e.defaultValue ?? (e.format === "json" ? U : "")), P = e.value === void 0 ? te : e.value, F = D(() => e.format === "json" ? le(P) : void 0, [e.format, P]), ie = E(), I = s || !!F || _, L = o || !!F;
|
|
1005
|
+
L && S && w(null);
|
|
1006
|
+
let R = C((e, t) => {
|
|
1007
|
+
if (L) return;
|
|
919
1008
|
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);
|
|
920
|
-
|
|
1009
|
+
w({
|
|
921
1010
|
from: n?.from ?? e.selection.from,
|
|
922
1011
|
to: n?.to ?? e.selection.to,
|
|
923
1012
|
href: r?.attrs.href ?? "",
|
|
924
1013
|
isEditing: !!r,
|
|
925
1014
|
document: e.doc
|
|
926
1015
|
});
|
|
927
|
-
}, [
|
|
1016
|
+
}, [L]), z = D(() => ({
|
|
928
1017
|
role: "textbox",
|
|
929
1018
|
...h ? {} : { "aria-label": m ?? c },
|
|
930
1019
|
"aria-multiline": "true",
|
|
931
1020
|
...d ? { id: d } : {},
|
|
932
1021
|
...h ? { "aria-labelledby": h } : {},
|
|
933
1022
|
...g ? { "aria-describedby": g } : {},
|
|
934
|
-
...
|
|
1023
|
+
...I ? { "aria-invalid": String(I) } : {},
|
|
935
1024
|
...f || p ? { "aria-required": "true" } : {}
|
|
936
1025
|
}), [
|
|
937
1026
|
c,
|
|
@@ -939,96 +1028,96 @@ var Fe = C(function(e, t) {
|
|
|
939
1028
|
d,
|
|
940
1029
|
h,
|
|
941
1030
|
g,
|
|
942
|
-
|
|
1031
|
+
I,
|
|
943
1032
|
f,
|
|
944
1033
|
p
|
|
945
|
-
]),
|
|
946
|
-
attributes:
|
|
1034
|
+
]), B = D(() => ({
|
|
1035
|
+
attributes: z,
|
|
947
1036
|
handleDOMEvents: {
|
|
948
|
-
keydown:
|
|
1037
|
+
keydown: Re,
|
|
949
1038
|
click: (e, t) => {
|
|
950
1039
|
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
951
|
-
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable &&
|
|
1040
|
+
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && R(e.state, e.posAtDOM(n, 0)), !0);
|
|
952
1041
|
}
|
|
953
1042
|
}
|
|
954
|
-
}), [
|
|
1043
|
+
}), [z, R]), H = D(() => [...G(Le), se.configure({ placeholder: r })], [r]), W = D(() => F ? U : typeof P == "string" ? P : q(P), [P, F]), K = ae({
|
|
955
1044
|
immediatelyRender: !1,
|
|
956
|
-
editable: !
|
|
1045
|
+
editable: !L,
|
|
957
1046
|
content: W,
|
|
958
1047
|
extensions: H,
|
|
959
|
-
editorProps:
|
|
1048
|
+
editorProps: B,
|
|
960
1049
|
onFocus: () => x(!0),
|
|
961
1050
|
onBlur: () => x(!1),
|
|
962
1051
|
onUpdate: ({ editor: t, transaction: n }) => {
|
|
963
|
-
(!
|
|
1052
|
+
(!L || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(V(t.getJSON())) : e.onChange?.(t.getHTML()));
|
|
964
1053
|
}
|
|
965
1054
|
});
|
|
966
|
-
|
|
967
|
-
K && (K.setEditable(!
|
|
1055
|
+
T(() => {
|
|
1056
|
+
K && (K.setEditable(!L, !1), K.setOptions({ editorProps: B }));
|
|
968
1057
|
}, [
|
|
969
1058
|
K,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
]),
|
|
973
|
-
if (!K || e.value === void 0 ||
|
|
974
|
-
let t = typeof e.value == "string" ? ne(e.value, K.schema) : K.schema.nodeFromJSON(
|
|
1059
|
+
L,
|
|
1060
|
+
B
|
|
1061
|
+
]), T(() => {
|
|
1062
|
+
if (!K || e.value === void 0 || F) return;
|
|
1063
|
+
let t = typeof e.value == "string" ? ne(e.value, K.schema) : K.schema.nodeFromJSON(q(e.value));
|
|
975
1064
|
t.eq(K.state.doc) || K.commands.setContent(t, { emitUpdate: !1 });
|
|
976
1065
|
}, [
|
|
977
1066
|
K,
|
|
978
1067
|
e.value,
|
|
979
|
-
|
|
1068
|
+
F
|
|
980
1069
|
]);
|
|
981
|
-
let J =
|
|
1070
|
+
let J = oe({
|
|
982
1071
|
editor: K,
|
|
983
1072
|
selector: ({ editor: e }) => e ? {
|
|
984
1073
|
active: Object.fromEntries($.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
985
1074
|
linkActive: e.isActive("link")
|
|
986
1075
|
} : null
|
|
987
|
-
}), X =
|
|
1076
|
+
}), X = Ne(K, F ? void 0 : e.embeds, L, c), Z = ce({
|
|
988
1077
|
editor: K,
|
|
989
|
-
disabled:
|
|
1078
|
+
disabled: L,
|
|
990
1079
|
isHeld: X.isCreating,
|
|
991
|
-
invalid: !!
|
|
1080
|
+
invalid: !!I,
|
|
992
1081
|
label: m ?? c,
|
|
993
1082
|
labelledBy: h,
|
|
994
1083
|
expandedWidth: a,
|
|
995
1084
|
frameRef: v
|
|
996
1085
|
});
|
|
997
|
-
return /* @__PURE__ */
|
|
1086
|
+
return /* @__PURE__ */ M(Y.Provider, {
|
|
998
1087
|
value: X.context,
|
|
999
|
-
children: /* @__PURE__ */
|
|
1088
|
+
children: /* @__PURE__ */ N(Ie, {
|
|
1000
1089
|
ref: y,
|
|
1001
1090
|
scopeRef: v,
|
|
1002
1091
|
className: l,
|
|
1003
|
-
expansion:
|
|
1092
|
+
expansion: Z,
|
|
1004
1093
|
isFocused: b,
|
|
1005
|
-
disabled:
|
|
1006
|
-
invalid: !!
|
|
1007
|
-
contentError:
|
|
1008
|
-
errorId:
|
|
1009
|
-
surface: /* @__PURE__ */
|
|
1094
|
+
disabled: L,
|
|
1095
|
+
invalid: !!I,
|
|
1096
|
+
contentError: F,
|
|
1097
|
+
errorId: ie,
|
|
1098
|
+
surface: /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(Fe, {
|
|
1010
1099
|
editor: K,
|
|
1011
1100
|
state: J,
|
|
1012
|
-
disabled:
|
|
1101
|
+
disabled: L,
|
|
1013
1102
|
label: c,
|
|
1014
1103
|
toolbarExtra: u,
|
|
1015
|
-
openLink:
|
|
1016
|
-
expandControl:
|
|
1104
|
+
openLink: R,
|
|
1105
|
+
expandControl: Z.toggle,
|
|
1017
1106
|
embedControl: X.toolbar
|
|
1018
|
-
}), /* @__PURE__ */
|
|
1107
|
+
}), /* @__PURE__ */ M("div", {
|
|
1019
1108
|
className: "ds-rte__content",
|
|
1020
1109
|
"data-size": i,
|
|
1021
|
-
children: /* @__PURE__ */
|
|
1110
|
+
children: /* @__PURE__ */ M(ee, { editor: K })
|
|
1022
1111
|
})] }),
|
|
1023
|
-
children: [X.dialog, K && S && !
|
|
1112
|
+
children: [X.dialog, K && S && !L && /* @__PURE__ */ M(Pe, {
|
|
1024
1113
|
editor: K,
|
|
1025
1114
|
selection: S,
|
|
1026
|
-
onClose:
|
|
1115
|
+
onClose: A
|
|
1027
1116
|
})]
|
|
1028
1117
|
})
|
|
1029
1118
|
});
|
|
1030
1119
|
});
|
|
1031
1120
|
//#endregion
|
|
1032
|
-
export {
|
|
1121
|
+
export { le as n, U as r, ze as t };
|
|
1033
1122
|
|
|
1034
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1123
|
+
//# sourceMappingURL=RichTextEditor-DmNM63Wg.js.map
|