@voltro/cms 0.84.0 → 0.86.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/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +118 -600
- package/dist/ContentForm.js +282 -0
- package/dist/RichDocumentEditor.js +550 -0
- package/dist/RichDocumentView.js +132 -0
- package/dist/RichTextSurface.js +135 -0
- package/dist/aiCandidates.js +199 -0
- package/dist/aiOperations.js +152 -0
- package/dist/audiences.js +31 -0
- package/dist/availability.js +121 -0
- package/dist/blueprint.js +166 -0
- package/dist/bulk.js +281 -0
- package/dist/cacheIdentity.js +152 -0
- package/dist/changes.js +90 -0
- package/dist/cmsContext.js +229 -0
- package/dist/collections.js +224 -0
- package/dist/consent.js +29 -0
- package/dist/contentType.js +191 -0
- package/dist/contentfulImport.js +162 -0
- package/dist/copies.js +89 -0
- package/dist/cutover.js +202 -0
- package/dist/deliveryChecks.js +138 -0
- package/dist/domains.js +145 -0
- package/dist/draftTexts.js +164 -0
- package/dist/duplicates.js +78 -0
- package/dist/edgePurge.js +69 -0
- package/dist/editHistory.js +113 -0
- package/dist/effectForm.js +11 -0
- package/dist/environments.js +109 -0
- package/dist/errors.js +67 -0
- package/dist/experiments.js +528 -0
- package/dist/exposure.js +28 -0
- package/dist/extensionManifest.js +81 -0
- package/dist/extensions.js +314 -0
- package/dist/fieldSchema.js +199 -0
- package/dist/formStrings.js +74 -0
- package/dist/glossary.js +73 -0
- package/dist/history.js +54 -0
- package/dist/htmlImport.js +297 -0
- package/dist/index.d.ts +2266 -170
- package/dist/index.js +73 -3947
- package/dist/media.js +29 -0
- package/dist/metrics.js +46 -0
- package/dist/migration.js +193 -0
- package/dist/migrationStages.js +13 -0
- package/dist/presenceAnchors.js +68 -0
- package/dist/preview.js +31 -0
- package/dist/promotion.js +107 -0
- package/dist/quality.js +188 -0
- package/dist/recurrence.js +78 -0
- package/dist/redirects.js +99 -0
- package/dist/referenceGraph.js +223 -0
- package/dist/references.js +173 -0
- package/dist/release.js +205 -0
- package/dist/rest.js +52 -0
- package/dist/review.js +160 -0
- package/dist/richDocument.js +491 -0
- package/dist/richInline.js +100 -0
- package/dist/schedule.js +80 -0
- package/dist/search.js +148 -0
- package/dist/selectionIntent.js +164 -0
- package/dist/seo.js +31 -0
- package/dist/series.js +105 -0
- package/dist/share.js +112 -0
- package/dist/stewardship.js +146 -0
- package/dist/taxonomy.js +36 -0
- package/dist/team.js +103 -0
- package/dist/templates.js +106 -0
- package/dist/trackChanges.js +197 -0
- package/dist/translation.js +64 -0
- package/dist/tree.js +87 -0
- package/dist/usage.js +50 -0
- package/dist/validation.js +192 -0
- package/dist/visualEditing.js +60 -0
- package/dist/web.d.ts +927 -131
- package/dist/web.js +33 -2
- package/dist/workflow.js +322 -0
- package/dist/write.js +394 -0
- package/dist/xliff.js +325 -0
- package/package.json +6 -6
- package/dist/extensionManifest-BK3ZcL2P.js +0 -2782
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import { blockMarkup as e, inlineMarkupOf as t, listNumberedAt as n, newBlockId as r, normalizeRichDocument as i, withBlockMarkup as a } from "./richDocument.js";
|
|
2
|
+
import { inlineText as o, mergeInline as s } from "./richInline.js";
|
|
3
|
+
import { blockHasChanges as c, pendingChanges as l, resolveChanges as u } from "./trackChanges.js";
|
|
4
|
+
import { contentFormStrings as d } from "./formStrings.js";
|
|
5
|
+
import { RichDocumentView as f } from "./RichDocumentView.js";
|
|
6
|
+
import { RichTextSurface as p } from "./RichTextSurface.js";
|
|
7
|
+
import { useId as m, useMemo as h, useState as g } from "react";
|
|
8
|
+
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
9
|
+
//#region src/RichDocumentEditor.tsx
|
|
10
|
+
var b = (e) => {
|
|
11
|
+
let t = i(e ?? ""), n = t.blocks;
|
|
12
|
+
return Array.isArray(n) ? t : {
|
|
13
|
+
type: "doc",
|
|
14
|
+
blocks: []
|
|
15
|
+
};
|
|
16
|
+
}, x = (e, t) => {
|
|
17
|
+
let n = r();
|
|
18
|
+
switch (e) {
|
|
19
|
+
case "paragraph": return {
|
|
20
|
+
id: n,
|
|
21
|
+
type: e,
|
|
22
|
+
content: []
|
|
23
|
+
};
|
|
24
|
+
case "heading": return {
|
|
25
|
+
id: n,
|
|
26
|
+
type: e,
|
|
27
|
+
level: t.profile?.headings[0] ?? 2,
|
|
28
|
+
content: []
|
|
29
|
+
};
|
|
30
|
+
case "list": return {
|
|
31
|
+
id: n,
|
|
32
|
+
type: e,
|
|
33
|
+
ordered: !1,
|
|
34
|
+
items: []
|
|
35
|
+
};
|
|
36
|
+
case "table": return {
|
|
37
|
+
id: n,
|
|
38
|
+
type: e,
|
|
39
|
+
header: !0,
|
|
40
|
+
rows: []
|
|
41
|
+
};
|
|
42
|
+
case "image": return {
|
|
43
|
+
id: n,
|
|
44
|
+
type: e,
|
|
45
|
+
asset: ""
|
|
46
|
+
};
|
|
47
|
+
case "file": return {
|
|
48
|
+
id: n,
|
|
49
|
+
type: e,
|
|
50
|
+
asset: "",
|
|
51
|
+
label: ""
|
|
52
|
+
};
|
|
53
|
+
case "component": return {
|
|
54
|
+
id: n,
|
|
55
|
+
type: e,
|
|
56
|
+
componentId: t.profile?.components[0]?.id ?? "",
|
|
57
|
+
props: {}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}, S = ({ id: e, options: t, renderPicker: n, onInsert: r, words: i }) => {
|
|
61
|
+
let a = t.profile?.contactPoints !== void 0 && n !== void 0 ? t.profile.contactPoints : void 0, o = t.profile?.contactLiterals === !0, [s, c] = g(a === void 0 ? "email" : "point"), [l, u] = g(""), [d, f] = g("");
|
|
62
|
+
if (a === void 0 && !o) return null;
|
|
63
|
+
let p = s === "point" ? { target: l } : {
|
|
64
|
+
channel: s,
|
|
65
|
+
value: l.trim()
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ y("div", {
|
|
68
|
+
"data-cms-rich-contact": !0,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ v("label", {
|
|
71
|
+
htmlFor: `${e}-contact-kind`,
|
|
72
|
+
children: i.contactKind
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ y("select", {
|
|
75
|
+
id: `${e}-contact-kind`,
|
|
76
|
+
value: s,
|
|
77
|
+
onChange: (e) => {
|
|
78
|
+
c(e.target.value), u("");
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
a === void 0 ? null : /* @__PURE__ */ v("option", {
|
|
82
|
+
value: "point",
|
|
83
|
+
children: i.contactPoint
|
|
84
|
+
}),
|
|
85
|
+
o ? /* @__PURE__ */ v("option", {
|
|
86
|
+
value: "email",
|
|
87
|
+
children: i.contactEmail
|
|
88
|
+
}) : null,
|
|
89
|
+
o ? /* @__PURE__ */ v("option", {
|
|
90
|
+
value: "phone",
|
|
91
|
+
children: i.contactPhone
|
|
92
|
+
}) : null
|
|
93
|
+
]
|
|
94
|
+
}),
|
|
95
|
+
s === "point" && a !== void 0 ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("label", {
|
|
96
|
+
htmlFor: `${e}-contact-value`,
|
|
97
|
+
children: i.contactPoint
|
|
98
|
+
}), n?.({
|
|
99
|
+
id: `${e}-contact-value`,
|
|
100
|
+
type: a,
|
|
101
|
+
value: l,
|
|
102
|
+
onChange: u,
|
|
103
|
+
role: "contact"
|
|
104
|
+
})] }) : /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("label", {
|
|
105
|
+
htmlFor: `${e}-contact-value`,
|
|
106
|
+
children: i.contactValue
|
|
107
|
+
}), /* @__PURE__ */ v("input", {
|
|
108
|
+
id: `${e}-contact-value`,
|
|
109
|
+
type: s === "email" ? "email" : "tel",
|
|
110
|
+
value: l,
|
|
111
|
+
onChange: (e) => u(e.target.value)
|
|
112
|
+
})] }),
|
|
113
|
+
/* @__PURE__ */ v("label", {
|
|
114
|
+
htmlFor: `${e}-contact-text`,
|
|
115
|
+
children: i.contactText
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ v("input", {
|
|
118
|
+
id: `${e}-contact-text`,
|
|
119
|
+
value: d,
|
|
120
|
+
onChange: (e) => f(e.target.value)
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ v("button", {
|
|
123
|
+
type: "button",
|
|
124
|
+
disabled: l.trim() === "" || d.trim() === "",
|
|
125
|
+
onClick: () => {
|
|
126
|
+
r({
|
|
127
|
+
type: "contact",
|
|
128
|
+
text: d.trim(),
|
|
129
|
+
contact: p
|
|
130
|
+
}), u(""), f("");
|
|
131
|
+
},
|
|
132
|
+
children: i.insertContact
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}, C = ({ id: e, type: t, renderPicker: n, onInsert: r, words: i, target: a }) => {
|
|
137
|
+
let [o, s] = g(""), [c, l] = g("");
|
|
138
|
+
return /* @__PURE__ */ y("div", {
|
|
139
|
+
"data-cms-rich-link": !0,
|
|
140
|
+
role: "group",
|
|
141
|
+
"aria-labelledby": `${e}-link-label`,
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ v("span", {
|
|
144
|
+
id: `${e}-link-label`,
|
|
145
|
+
children: i.linkTo
|
|
146
|
+
}),
|
|
147
|
+
n({
|
|
148
|
+
id: `${e}-link-target`,
|
|
149
|
+
type: t,
|
|
150
|
+
value: o,
|
|
151
|
+
onChange: s,
|
|
152
|
+
target: a,
|
|
153
|
+
role: "link",
|
|
154
|
+
labelledBy: `${e}-link-label`
|
|
155
|
+
}),
|
|
156
|
+
o === "" ? null : /* @__PURE__ */ y(_, { children: [
|
|
157
|
+
/* @__PURE__ */ v("label", {
|
|
158
|
+
htmlFor: `${e}-link-text`,
|
|
159
|
+
children: i.linkText
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ v("input", {
|
|
162
|
+
id: `${e}-link-text`,
|
|
163
|
+
value: c,
|
|
164
|
+
onChange: (e) => l(e.target.value)
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ v("button", {
|
|
167
|
+
type: "button",
|
|
168
|
+
disabled: c.trim() === "",
|
|
169
|
+
onClick: () => {
|
|
170
|
+
r({
|
|
171
|
+
type: "link",
|
|
172
|
+
target: o,
|
|
173
|
+
text: c.trim()
|
|
174
|
+
}), s(""), l("");
|
|
175
|
+
},
|
|
176
|
+
children: i.insertLink
|
|
177
|
+
})
|
|
178
|
+
] })
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}, w = (r) => {
|
|
182
|
+
let { id: i, name: w, field: T, value: E, onChange: D, renderPicker: O, renderBlockAside: k, renderComponentProps: A } = r, j = d(r.strings), M = T.richText ?? {}, N = M.profile, P = Object.keys(N?.styles?.tokens ?? {}), F = h(() => b(E), [E]), I = m(), [L, R] = g({}), [z, B] = g("paragraph"), V = Object.keys(j.blockNames).filter((e) => e !== "image" || M.images !== void 0 && O !== void 0).filter((e) => e !== "file" || M.files !== void 0 && O !== void 0).filter((e) => N === void 0 ? e !== "component" : N.blocks.includes(e)).filter((e) => e !== "component" || A !== void 0), H = (e) => D({
|
|
183
|
+
type: "doc",
|
|
184
|
+
blocks: e
|
|
185
|
+
}), U = (e, t) => H(F.blocks.map((n, r) => r === e ? t : n)), W = (e, t) => {
|
|
186
|
+
if (t < 0 || t >= F.blocks.length) return;
|
|
187
|
+
let n = [...F.blocks], [r] = n.splice(e, 1);
|
|
188
|
+
r !== void 0 && n.splice(t, 0, r), H(n);
|
|
189
|
+
}, G = (e, t, n) => {
|
|
190
|
+
R((e) => ({
|
|
191
|
+
...e,
|
|
192
|
+
[t.id]: n
|
|
193
|
+
})), U(e, a(t, n, P));
|
|
194
|
+
}, K = (e, n, r, i) => G(e, n, `${r}${r === "" || r.endsWith(" ") || r.endsWith("\n") ? "" : " "}${t([i])}`), q = F.blocks.map((t, i) => {
|
|
195
|
+
let a = `${j.blockNames[t.type]} ${i + 1}`, d = `${I}-${t.id}`, m = L[t.id] ?? e(t);
|
|
196
|
+
if (c(t)) {
|
|
197
|
+
let e = l({
|
|
198
|
+
type: "doc",
|
|
199
|
+
blocks: [t]
|
|
200
|
+
});
|
|
201
|
+
return /* @__PURE__ */ y("fieldset", {
|
|
202
|
+
"data-cms-rich-block": t.type,
|
|
203
|
+
"data-cms-block-id": t.id,
|
|
204
|
+
"data-cms-rich-suggested": !0,
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ v("legend", { children: a }),
|
|
207
|
+
/* @__PURE__ */ v("p", { children: j.suggestedChanges }),
|
|
208
|
+
/* @__PURE__ */ v("div", {
|
|
209
|
+
"data-cms-rich-preview": !0,
|
|
210
|
+
children: /* @__PURE__ */ v(f, { document: {
|
|
211
|
+
type: "doc",
|
|
212
|
+
blocks: [t]
|
|
213
|
+
} })
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ v("ul", { children: e.map((e) => /* @__PURE__ */ y("li", { children: [
|
|
216
|
+
j.changeBy(e.by, e.inserted, e.deleted),
|
|
217
|
+
" ",
|
|
218
|
+
/* @__PURE__ */ v("button", {
|
|
219
|
+
type: "button",
|
|
220
|
+
"aria-label": j.acceptLabel(e.by),
|
|
221
|
+
onClick: () => D(u(F, (t) => t.id === e.id ? "accept" : "keep")),
|
|
222
|
+
children: j.accept
|
|
223
|
+
}),
|
|
224
|
+
" ",
|
|
225
|
+
/* @__PURE__ */ v("button", {
|
|
226
|
+
type: "button",
|
|
227
|
+
"aria-label": j.rejectLabel(e.by),
|
|
228
|
+
onClick: () => D(u(F, (t) => t.id === e.id ? "reject" : "keep")),
|
|
229
|
+
children: j.reject
|
|
230
|
+
})
|
|
231
|
+
] }, e.id)) }),
|
|
232
|
+
k?.(t.id, a) ?? null
|
|
233
|
+
]
|
|
234
|
+
}, t.id);
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ y("fieldset", {
|
|
237
|
+
"data-cms-rich-block": t.type,
|
|
238
|
+
"data-cms-block-id": t.id,
|
|
239
|
+
children: [
|
|
240
|
+
/* @__PURE__ */ v("legend", { children: a }),
|
|
241
|
+
t.type === "heading" ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("label", {
|
|
242
|
+
htmlFor: `${d}-level`,
|
|
243
|
+
children: j.level
|
|
244
|
+
}), /* @__PURE__ */ v("select", {
|
|
245
|
+
id: `${d}-level`,
|
|
246
|
+
value: t.level,
|
|
247
|
+
onChange: (e) => U(i, {
|
|
248
|
+
...t,
|
|
249
|
+
level: e.target.value === "3" ? 3 : 2
|
|
250
|
+
}),
|
|
251
|
+
children: (N?.headings ?? [2, 3]).map((e) => /* @__PURE__ */ v("option", {
|
|
252
|
+
value: e,
|
|
253
|
+
children: e
|
|
254
|
+
}, e))
|
|
255
|
+
})] }) : null,
|
|
256
|
+
N?.styles !== void 0 && (t.type === "paragraph" || t.type === "heading" || t.type === "list") ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("label", {
|
|
257
|
+
htmlFor: `${d}-style`,
|
|
258
|
+
children: j.style
|
|
259
|
+
}), /* @__PURE__ */ y("select", {
|
|
260
|
+
id: `${d}-style`,
|
|
261
|
+
value: t.style ?? "",
|
|
262
|
+
onChange: (e) => {
|
|
263
|
+
let { style: n, ...r } = t;
|
|
264
|
+
U(i, e.target.value === "" ? r : {
|
|
265
|
+
...r,
|
|
266
|
+
style: e.target.value
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
children: [/* @__PURE__ */ v("option", {
|
|
270
|
+
value: "",
|
|
271
|
+
children: j.noStyle
|
|
272
|
+
}), Object.entries(N.styles.tokens).map(([e, t]) => /* @__PURE__ */ v("option", {
|
|
273
|
+
value: e,
|
|
274
|
+
children: `${e} — ${t}`
|
|
275
|
+
}, e))]
|
|
276
|
+
})] }) : null,
|
|
277
|
+
t.type === "list" ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ y("label", { children: [
|
|
278
|
+
/* @__PURE__ */ v("input", {
|
|
279
|
+
type: "checkbox",
|
|
280
|
+
checked: t.ordered,
|
|
281
|
+
onChange: (e) => U(i, {
|
|
282
|
+
...t,
|
|
283
|
+
ordered: e.target.checked
|
|
284
|
+
})
|
|
285
|
+
}),
|
|
286
|
+
" ",
|
|
287
|
+
j.numbered
|
|
288
|
+
] }), Array.from({ length: Math.max(0, ...t.levels ?? []) }, (e, t) => t + 1).map((e) => /* @__PURE__ */ y("label", { children: [
|
|
289
|
+
/* @__PURE__ */ v("input", {
|
|
290
|
+
type: "checkbox",
|
|
291
|
+
checked: n(t, e),
|
|
292
|
+
onChange: (r) => U(i, {
|
|
293
|
+
...t,
|
|
294
|
+
sublists: Array.from({ length: Math.max(e, t.sublists?.length ?? 0) }, (i, a) => a === e - 1 ? r.target.checked ? "ordered" : "unordered" : n(t, a + 1) ? "ordered" : "unordered")
|
|
295
|
+
})
|
|
296
|
+
}),
|
|
297
|
+
" ",
|
|
298
|
+
j.numberedAt(e + 1)
|
|
299
|
+
] }, e))] }) : null,
|
|
300
|
+
t.type === "table" ? /* @__PURE__ */ y("label", { children: [
|
|
301
|
+
/* @__PURE__ */ v("input", {
|
|
302
|
+
type: "checkbox",
|
|
303
|
+
checked: t.header,
|
|
304
|
+
onChange: (e) => U(i, {
|
|
305
|
+
...t,
|
|
306
|
+
header: e.target.checked
|
|
307
|
+
})
|
|
308
|
+
}),
|
|
309
|
+
" ",
|
|
310
|
+
j.headerRow
|
|
311
|
+
] }) : null,
|
|
312
|
+
t.type === "component" ? /* @__PURE__ */ y(_, { children: [
|
|
313
|
+
/* @__PURE__ */ v("label", {
|
|
314
|
+
htmlFor: `${d}-component`,
|
|
315
|
+
children: j.component
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ v("select", {
|
|
318
|
+
id: `${d}-component`,
|
|
319
|
+
value: t.componentId,
|
|
320
|
+
onChange: (e) => U(i, {
|
|
321
|
+
id: t.id,
|
|
322
|
+
type: "component",
|
|
323
|
+
componentId: e.target.value,
|
|
324
|
+
props: {}
|
|
325
|
+
}),
|
|
326
|
+
children: (N?.components ?? []).map((e) => /* @__PURE__ */ v("option", {
|
|
327
|
+
value: e.id,
|
|
328
|
+
children: e.displayName
|
|
329
|
+
}, e.id))
|
|
330
|
+
}),
|
|
331
|
+
((e) => e === void 0 ? /* @__PURE__ */ v("p", { children: j.unknownComponent(t.componentId) }) : /* @__PURE__ */ v("div", {
|
|
332
|
+
"data-cms-instance": t.id,
|
|
333
|
+
"data-cms-component": t.componentId,
|
|
334
|
+
children: A?.(e, t.props, (e) => U(i, {
|
|
335
|
+
...t,
|
|
336
|
+
props: e
|
|
337
|
+
}))
|
|
338
|
+
}))(N?.components.find((e) => e.id === t.componentId))
|
|
339
|
+
] }) : t.type === "image" ? /* @__PURE__ */ y(_, { children: [
|
|
340
|
+
/* @__PURE__ */ v("label", {
|
|
341
|
+
htmlFor: `${d}-asset`,
|
|
342
|
+
children: j.image
|
|
343
|
+
}),
|
|
344
|
+
O?.({
|
|
345
|
+
id: `${d}-asset`,
|
|
346
|
+
type: M.images ?? "",
|
|
347
|
+
value: t.asset,
|
|
348
|
+
onChange: (e) => U(i, {
|
|
349
|
+
...t,
|
|
350
|
+
asset: e
|
|
351
|
+
}),
|
|
352
|
+
target: {
|
|
353
|
+
field: w,
|
|
354
|
+
blockId: t.id
|
|
355
|
+
},
|
|
356
|
+
role: "image"
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ v("label", {
|
|
359
|
+
htmlFor: `${d}-caption`,
|
|
360
|
+
children: j.caption
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ v("input", {
|
|
363
|
+
id: `${d}-caption`,
|
|
364
|
+
value: t.caption ?? "",
|
|
365
|
+
onChange: (e) => U(i, e.target.value === "" ? {
|
|
366
|
+
id: t.id,
|
|
367
|
+
type: "image",
|
|
368
|
+
asset: t.asset
|
|
369
|
+
} : {
|
|
370
|
+
...t,
|
|
371
|
+
caption: e.target.value
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
] }) : t.type === "file" ? /* @__PURE__ */ y(_, { children: [
|
|
375
|
+
/* @__PURE__ */ v("label", {
|
|
376
|
+
htmlFor: `${d}-asset`,
|
|
377
|
+
children: j.file
|
|
378
|
+
}),
|
|
379
|
+
O?.({
|
|
380
|
+
id: `${d}-asset`,
|
|
381
|
+
type: M.files ?? "",
|
|
382
|
+
value: t.asset,
|
|
383
|
+
onChange: (e) => U(i, {
|
|
384
|
+
...t,
|
|
385
|
+
asset: e
|
|
386
|
+
}),
|
|
387
|
+
target: {
|
|
388
|
+
field: w,
|
|
389
|
+
blockId: t.id
|
|
390
|
+
},
|
|
391
|
+
role: "file"
|
|
392
|
+
}),
|
|
393
|
+
/* @__PURE__ */ v("label", {
|
|
394
|
+
htmlFor: `${d}-label`,
|
|
395
|
+
children: j.fileLabel
|
|
396
|
+
}),
|
|
397
|
+
/* @__PURE__ */ v("input", {
|
|
398
|
+
id: `${d}-label`,
|
|
399
|
+
value: t.label,
|
|
400
|
+
onChange: (e) => U(i, {
|
|
401
|
+
...t,
|
|
402
|
+
label: e.target.value
|
|
403
|
+
})
|
|
404
|
+
})
|
|
405
|
+
] }) : r.surface === "visual" && (t.type === "paragraph" || t.type === "heading") ? /* @__PURE__ */ y(_, { children: [
|
|
406
|
+
/* @__PURE__ */ v("span", {
|
|
407
|
+
id: `${d}-label`,
|
|
408
|
+
"data-cms-rich-label": !0,
|
|
409
|
+
children: j.text
|
|
410
|
+
}),
|
|
411
|
+
/* @__PURE__ */ v(p, {
|
|
412
|
+
id: `${d}-text`,
|
|
413
|
+
labelledBy: `${d}-label`,
|
|
414
|
+
content: t.content,
|
|
415
|
+
onChange: (e) => U(i, {
|
|
416
|
+
...t,
|
|
417
|
+
content: e
|
|
418
|
+
}),
|
|
419
|
+
words: {
|
|
420
|
+
bold: j.bold,
|
|
421
|
+
italic: j.italic,
|
|
422
|
+
underline: j.underline
|
|
423
|
+
}
|
|
424
|
+
}),
|
|
425
|
+
M.links !== void 0 && O !== void 0 && t.type === "paragraph" ? /* @__PURE__ */ v(C, {
|
|
426
|
+
id: d,
|
|
427
|
+
type: M.links,
|
|
428
|
+
renderPicker: O,
|
|
429
|
+
words: j,
|
|
430
|
+
target: {
|
|
431
|
+
field: w,
|
|
432
|
+
blockId: t.id
|
|
433
|
+
},
|
|
434
|
+
onInsert: (e) => U(i, {
|
|
435
|
+
...t,
|
|
436
|
+
content: s([
|
|
437
|
+
...t.content,
|
|
438
|
+
...o(t.content).match(/(^|\s)$/) ? [] : [{
|
|
439
|
+
type: "text",
|
|
440
|
+
text: " "
|
|
441
|
+
}],
|
|
442
|
+
e
|
|
443
|
+
])
|
|
444
|
+
})
|
|
445
|
+
}) : null,
|
|
446
|
+
t.type === "paragraph" ? /* @__PURE__ */ v(S, {
|
|
447
|
+
id: d,
|
|
448
|
+
options: M,
|
|
449
|
+
renderPicker: O,
|
|
450
|
+
words: j,
|
|
451
|
+
onInsert: (e) => U(i, {
|
|
452
|
+
...t,
|
|
453
|
+
content: s([
|
|
454
|
+
...t.content,
|
|
455
|
+
...o(t.content).match(/(^|\s)$/) ? [] : [{
|
|
456
|
+
type: "text",
|
|
457
|
+
text: " "
|
|
458
|
+
}],
|
|
459
|
+
e
|
|
460
|
+
])
|
|
461
|
+
})
|
|
462
|
+
}) : null
|
|
463
|
+
] }) : /* @__PURE__ */ y(_, { children: [
|
|
464
|
+
/* @__PURE__ */ v("label", {
|
|
465
|
+
htmlFor: `${d}-text`,
|
|
466
|
+
children: t.type === "list" ? j.listItems : t.type === "table" ? j.tableRows : j.text
|
|
467
|
+
}),
|
|
468
|
+
/* @__PURE__ */ v("textarea", {
|
|
469
|
+
id: `${d}-text`,
|
|
470
|
+
value: m,
|
|
471
|
+
onChange: (e) => G(i, t, e.target.value)
|
|
472
|
+
}),
|
|
473
|
+
M.links !== void 0 && O !== void 0 && (t.type === "paragraph" || t.type === "list") ? /* @__PURE__ */ v(C, {
|
|
474
|
+
id: d,
|
|
475
|
+
type: M.links,
|
|
476
|
+
renderPicker: O,
|
|
477
|
+
words: j,
|
|
478
|
+
target: {
|
|
479
|
+
field: w,
|
|
480
|
+
blockId: t.id
|
|
481
|
+
},
|
|
482
|
+
onInsert: (e) => K(i, t, m, e)
|
|
483
|
+
}) : null,
|
|
484
|
+
t.type === "paragraph" || t.type === "list" ? /* @__PURE__ */ v(S, {
|
|
485
|
+
id: d,
|
|
486
|
+
options: M,
|
|
487
|
+
renderPicker: O,
|
|
488
|
+
words: j,
|
|
489
|
+
onInsert: (e) => K(i, t, m, e)
|
|
490
|
+
}) : null
|
|
491
|
+
] }),
|
|
492
|
+
/* @__PURE__ */ y("div", {
|
|
493
|
+
"data-cms-rich-actions": !0,
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ v("button", {
|
|
496
|
+
type: "button",
|
|
497
|
+
"aria-label": j.moveUpLabel(a),
|
|
498
|
+
disabled: i === 0,
|
|
499
|
+
onClick: () => W(i, i - 1),
|
|
500
|
+
children: j.moveUp
|
|
501
|
+
}),
|
|
502
|
+
/* @__PURE__ */ v("button", {
|
|
503
|
+
type: "button",
|
|
504
|
+
"aria-label": j.moveDownLabel(a),
|
|
505
|
+
disabled: i === F.blocks.length - 1,
|
|
506
|
+
onClick: () => W(i, i + 1),
|
|
507
|
+
children: j.moveDown
|
|
508
|
+
}),
|
|
509
|
+
/* @__PURE__ */ v("button", {
|
|
510
|
+
type: "button",
|
|
511
|
+
"aria-label": j.removeLabel(a),
|
|
512
|
+
onClick: () => H(F.blocks.filter((e, t) => t !== i)),
|
|
513
|
+
children: j.remove
|
|
514
|
+
})
|
|
515
|
+
]
|
|
516
|
+
}),
|
|
517
|
+
k?.(t.id, a) ?? null
|
|
518
|
+
]
|
|
519
|
+
}, t.id);
|
|
520
|
+
});
|
|
521
|
+
return /* @__PURE__ */ y("div", {
|
|
522
|
+
id: i,
|
|
523
|
+
"data-cms-rich-document": !0,
|
|
524
|
+
children: [q, /* @__PURE__ */ y("div", {
|
|
525
|
+
"data-cms-rich-add": !0,
|
|
526
|
+
children: [
|
|
527
|
+
/* @__PURE__ */ v("label", {
|
|
528
|
+
htmlFor: `${i}-add`,
|
|
529
|
+
children: j.addBlock
|
|
530
|
+
}),
|
|
531
|
+
/* @__PURE__ */ v("select", {
|
|
532
|
+
id: `${i}-add`,
|
|
533
|
+
value: V.includes(z) ? z : V[0] ?? "paragraph",
|
|
534
|
+
onChange: (e) => B(e.target.value),
|
|
535
|
+
children: V.map((e) => /* @__PURE__ */ v("option", {
|
|
536
|
+
value: e,
|
|
537
|
+
children: j.blockNames[e]
|
|
538
|
+
}, e))
|
|
539
|
+
}),
|
|
540
|
+
/* @__PURE__ */ v("button", {
|
|
541
|
+
type: "button",
|
|
542
|
+
onClick: () => H([...F.blocks, x(V.includes(z) ? z : V[0] ?? "paragraph", M)]),
|
|
543
|
+
children: j.add
|
|
544
|
+
})
|
|
545
|
+
]
|
|
546
|
+
})]
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
//#endregion
|
|
550
|
+
export { w as RichDocumentEditor };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { contactLiteralHref as e, listNumberedAt as t, normalizeRichDocument as n, richDocumentProblems as r } from "./richDocument.js";
|
|
2
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
//#region src/RichDocumentView.tsx
|
|
4
|
+
var s = ({ content: t, resolve: n }) => t.map((t, r) => {
|
|
5
|
+
if (t.type === "link" || t.type === "contact") {
|
|
6
|
+
let i = t.type === "link" ? n.hrefOf(t.target) : "target" in t.contact ? n.contactHrefOf(t.contact.target) : e(t.contact.channel, t.contact.value);
|
|
7
|
+
return i === void 0 ? /* @__PURE__ */ a("span", { children: t.text }, r) : /* @__PURE__ */ a("a", {
|
|
8
|
+
href: i,
|
|
9
|
+
children: t.text
|
|
10
|
+
}, r);
|
|
11
|
+
}
|
|
12
|
+
let i = t.marks ?? [], o = t.text;
|
|
13
|
+
return i.includes("underline") && (o = /* @__PURE__ */ a("u", { children: o })), i.includes("italic") && (o = /* @__PURE__ */ a("em", { children: o })), i.includes("bold") && (o = /* @__PURE__ */ a("strong", { children: o })), /* @__PURE__ */ a("span", {
|
|
14
|
+
...t.style === void 0 ? {} : { "data-style": t.style },
|
|
15
|
+
children: o
|
|
16
|
+
}, r);
|
|
17
|
+
}).map((e, n) => {
|
|
18
|
+
let r = t[n]?.change;
|
|
19
|
+
if (r === void 0) return e;
|
|
20
|
+
let i = r.kind === "insert" ? "ins" : "del";
|
|
21
|
+
return /* @__PURE__ */ a(i, {
|
|
22
|
+
"data-change-id": r.id,
|
|
23
|
+
title: r.by,
|
|
24
|
+
children: e
|
|
25
|
+
}, n);
|
|
26
|
+
}), c = (e) => "style" in e && e.style !== void 0 ? { "data-style": e.style } : {}, l = ({ block: e, resolve: n, renderImage: r, renderComponent: i, fileHrefOf: l }) => {
|
|
27
|
+
switch (e.type) {
|
|
28
|
+
case "paragraph": return /* @__PURE__ */ a("p", {
|
|
29
|
+
"data-block-id": e.id,
|
|
30
|
+
...c(e),
|
|
31
|
+
children: /* @__PURE__ */ a(s, {
|
|
32
|
+
content: e.content,
|
|
33
|
+
resolve: n
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
case "heading": return e.level === 2 ? /* @__PURE__ */ a("h2", {
|
|
37
|
+
"data-block-id": e.id,
|
|
38
|
+
...c(e),
|
|
39
|
+
children: /* @__PURE__ */ a(s, {
|
|
40
|
+
content: e.content,
|
|
41
|
+
resolve: n
|
|
42
|
+
})
|
|
43
|
+
}) : /* @__PURE__ */ a("h3", {
|
|
44
|
+
"data-block-id": e.id,
|
|
45
|
+
...c(e),
|
|
46
|
+
children: /* @__PURE__ */ a(s, {
|
|
47
|
+
content: e.content,
|
|
48
|
+
resolve: n
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
case "list": {
|
|
52
|
+
let r = e.levels ?? e.items.map(() => 0), i = (n) => t(e, n) ? "ol" : "ul", l = (t, c) => {
|
|
53
|
+
let u = [], d = t;
|
|
54
|
+
for (; d < e.items.length && r[d] >= c;) {
|
|
55
|
+
let t = d, [r, f] = l(d + 1, c + 1), p = i(c + 1);
|
|
56
|
+
u.push(/* @__PURE__ */ o("li", { children: [/* @__PURE__ */ a(s, {
|
|
57
|
+
content: e.items[t],
|
|
58
|
+
resolve: n
|
|
59
|
+
}), r.length > 0 ? /* @__PURE__ */ a(p, { children: r }) : null] }, t)), d = f;
|
|
60
|
+
}
|
|
61
|
+
return [u, d];
|
|
62
|
+
}, u = i(0);
|
|
63
|
+
return /* @__PURE__ */ a(u, {
|
|
64
|
+
"data-block-id": e.id,
|
|
65
|
+
...c(e),
|
|
66
|
+
children: l(0, 0)[0]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
case "table": {
|
|
70
|
+
let [t, ...r] = e.header ? e.rows : [void 0, ...e.rows];
|
|
71
|
+
return /* @__PURE__ */ o("table", {
|
|
72
|
+
"data-block-id": e.id,
|
|
73
|
+
children: [t === void 0 ? null : /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: t.map((e, t) => /* @__PURE__ */ a("th", {
|
|
74
|
+
scope: "col",
|
|
75
|
+
children: /* @__PURE__ */ a(s, {
|
|
76
|
+
content: e,
|
|
77
|
+
resolve: n
|
|
78
|
+
})
|
|
79
|
+
}, t)) }) }), /* @__PURE__ */ a("tbody", { children: r.map((e, t) => /* @__PURE__ */ a("tr", { children: (e ?? []).map((e, t) => /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a(s, {
|
|
80
|
+
content: e,
|
|
81
|
+
resolve: n
|
|
82
|
+
}) }, t)) }, t)) })]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
case "image": return r === void 0 ? null : /* @__PURE__ */ a("div", {
|
|
86
|
+
"data-block-id": e.id,
|
|
87
|
+
children: r(e)
|
|
88
|
+
});
|
|
89
|
+
case "file": {
|
|
90
|
+
let t = l(e.asset);
|
|
91
|
+
return t === void 0 ? null : /* @__PURE__ */ a("p", {
|
|
92
|
+
"data-block-id": e.id,
|
|
93
|
+
"data-file": !0,
|
|
94
|
+
children: /* @__PURE__ */ a("a", {
|
|
95
|
+
href: t,
|
|
96
|
+
download: !0,
|
|
97
|
+
children: e.label
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
case "component": return i === void 0 ? null : /* @__PURE__ */ a("div", {
|
|
102
|
+
"data-block-id": e.id,
|
|
103
|
+
"data-component": e.componentId,
|
|
104
|
+
children: i(e)
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, u = ({ block: e, children: t }) => e.change === void 0 || t === null ? t : /* @__PURE__ */ a("div", {
|
|
108
|
+
"data-change": e.change.kind,
|
|
109
|
+
"data-change-id": e.change.id,
|
|
110
|
+
title: e.change.by,
|
|
111
|
+
children: t
|
|
112
|
+
}), d = ({ document: e, hrefOf: t = () => void 0, renderImage: o, contactHrefOf: s = () => void 0, renderComponent: c, fileHrefOf: d = () => void 0 }) => {
|
|
113
|
+
let f = {
|
|
114
|
+
hrefOf: t,
|
|
115
|
+
contactHrefOf: s
|
|
116
|
+
}, p = n(e);
|
|
117
|
+
return r("", p, {
|
|
118
|
+
images: "*",
|
|
119
|
+
links: "*"
|
|
120
|
+
}).some((e) => e.rule === "type" || e.rule === "unknown") ? null : /* @__PURE__ */ a(i, { children: p.blocks.map((e) => /* @__PURE__ */ a(u, {
|
|
121
|
+
block: e,
|
|
122
|
+
children: /* @__PURE__ */ a(l, {
|
|
123
|
+
block: e,
|
|
124
|
+
resolve: f,
|
|
125
|
+
renderImage: o,
|
|
126
|
+
renderComponent: c,
|
|
127
|
+
fileHrefOf: d
|
|
128
|
+
})
|
|
129
|
+
}, e.id)) });
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { d as RichDocumentView };
|