@dotcms/vue 1.5.5

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.
Files changed (45) hide show
  1. package/README.md +571 -0
  2. package/index.d.ts +12 -0
  3. package/index.js +842 -0
  4. package/lib/__test__/mocks.d.ts +6 -0
  5. package/lib/components/Column/Column.vue.d.ts +12 -0
  6. package/lib/components/Container/Container.vue.d.ts +11 -0
  7. package/lib/components/Container/ContainerNotFound.vue.d.ts +6 -0
  8. package/lib/components/Container/EmptyContainer.vue.d.ts +2 -0
  9. package/lib/components/Contentlet/Contentlet.vue.d.ts +14 -0
  10. package/lib/components/Contentlet/constants.d.ts +2 -0
  11. package/lib/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.vue.d.ts +5 -0
  12. package/lib/components/DotCMSBlockEditorRenderer/components/BlockEditorBlock.vue.d.ts +13 -0
  13. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/BulletList.vue.d.ts +17 -0
  14. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/CodeBlock.vue.d.ts +22 -0
  15. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotContent.vue.d.ts +10 -0
  16. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotImage.vue.d.ts +7 -0
  17. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotVideo.vue.d.ts +7 -0
  18. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/GridBlock.vue.d.ts +10 -0
  19. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Heading.vue.d.ts +22 -0
  20. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/ListItem.vue.d.ts +17 -0
  21. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/NoComponentProvided.vue.d.ts +6 -0
  22. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/OrderedList.vue.d.ts +17 -0
  23. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Paragraph.vue.d.ts +22 -0
  24. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Quote.vue.d.ts +17 -0
  25. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/TableRenderer.vue.d.ts +15 -0
  26. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/TextBlock.vue.d.ts +13 -0
  27. package/lib/components/DotCMSBlockEditorRenderer/components/blocks/UnknownBlock.vue.d.ts +10 -0
  28. package/lib/components/DotCMSBlockEditorRenderer/types.d.ts +44 -0
  29. package/lib/components/DotCMSEditableText/DotCMSEditableText.vue.d.ts +15 -0
  30. package/lib/components/DotCMSEditableText/utils.d.ts +22 -0
  31. package/lib/components/DotCMSLayoutBody/DotCMSLayoutBody.vue.d.ts +5 -0
  32. package/lib/components/DotCMSLayoutBody/components/ErrorMessage.vue.d.ts +2 -0
  33. package/lib/components/DotCMSLayoutBody/types.d.ts +17 -0
  34. package/lib/components/DotCMSShow/DotCMSShow.vue.d.ts +35 -0
  35. package/lib/components/FallbackComponent/FallbackComponent.vue.d.ts +13 -0
  36. package/lib/components/Row/Row.vue.d.ts +13 -0
  37. package/lib/composables/useCheckVisibleContent.d.ts +16 -0
  38. package/lib/composables/useDotCMSShowWhen.d.ts +18 -0
  39. package/lib/composables/useEditableDotCMSPage.d.ts +34 -0
  40. package/lib/composables/useIsAnalyticsActive.d.ts +14 -0
  41. package/lib/composables/useIsDevMode.d.ts +23 -0
  42. package/lib/contexts/dotcms-page.context.d.ts +61 -0
  43. package/lib/utils/toPlain.d.ts +12 -0
  44. package/package.json +47 -0
  45. package/test-setup.d.ts +0 -0
package/index.js ADDED
@@ -0,0 +1,842 @@
1
+ import { isRef as te, isReactive as ne, toRaw as oe, shallowRef as re, onMounted as D, onBeforeUnmount as H, ref as S, readonly as se, defineComponent as p, unref as C, renderSlot as N, createCommentVNode as T, provide as ae, inject as ce, computed as c, openBlock as r, createElementBlock as l, createElementVNode as f, createTextVNode as _, toValue as le, normalizeStyle as w, toDisplayString as x, mergeProps as $, Fragment as E, createBlock as v, resolveDynamicComponent as M, normalizeProps as R, getCurrentInstance as ie, renderList as h, normalizeClass as Y, watch as ue, createVNode as b, withCtx as B, resolveComponent as X } from "vue";
2
+ import { UVEEventType as de, UVE_MODE as L, DotCMSUVEAction as K } from "@dotcms/types";
3
+ import { getUVEState as A, initUVE as me, updateNavigation as pe, createUVESubscription as ve, sendMessageToUVE as W } from "@dotcms/uve";
4
+ import { registerStyleEditorSchemas as fe, isDotAnalyticsActive as q, ANALYTICS_READY_EVENT as z, DEVELOPMENT_MODE as ye, EMPTY_CONTAINER_STYLE_REACT as Q, getDotContentletAttributes as _e, getAnalyticsContentletAttributes as ge, CUSTOM_NO_COMPONENT as Ce, getContainersData as Ee, getContentletsInContainer as ke, getDotContainerAttributes as De, combineClasses as Te, DOT_SECTION_ID_PREFIX as Me, __DEFAULT_TINYMCE_CONFIG__ as he, __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ as F, __TINYMCE_PATH_ON_DOTCMS__ as be, isValidBlocks as Ne } from "@dotcms/uve/internal";
5
+ import Se from "@tinymce/tinymce-vue";
6
+ import { __DOTCMS_UVE_EVENT__ as we, BlockEditorDefaultBlocks as $e } from "@dotcms/types/internal";
7
+ function xe(e) {
8
+ const t = /* @__PURE__ */ new WeakMap(), o = (s) => {
9
+ const n = te(s) ? s.value : ne(s) ? oe(s) : s;
10
+ if (n === null || typeof n != "object")
11
+ return n;
12
+ if (t.has(n))
13
+ return t.get(n);
14
+ if (Array.isArray(n)) {
15
+ const d = [];
16
+ return t.set(n, d), n.forEach((y) => d.push(o(y))), d;
17
+ }
18
+ const a = Object.getPrototypeOf(n);
19
+ if (a !== Object.prototype && a !== null)
20
+ return n;
21
+ const i = {};
22
+ t.set(n, i);
23
+ for (const d of Object.keys(n))
24
+ i[d] = o(n[d]);
25
+ return i;
26
+ };
27
+ return o(e);
28
+ }
29
+ function Gt(e) {
30
+ const t = re(e);
31
+ let o, s;
32
+ return D(() => {
33
+ if (!A())
34
+ return;
35
+ if (!e) {
36
+ console.warn("[useEditableDotCMSPage]: No page response provided");
37
+ return;
38
+ }
39
+ const n = xe(e), a = n?.pageAsset?.page?.pageURI;
40
+ ({ destroyUVESubscriptions: o } = me(n)), a && pe(a), n.styleEditorSchemas?.length && fe(n.styleEditorSchemas);
41
+ }), D(() => {
42
+ ({ unsubscribe: s } = ve(
43
+ de.CONTENT_CHANGES,
44
+ (n) => {
45
+ t.value = n;
46
+ }
47
+ ));
48
+ }), H(() => {
49
+ o?.(), s?.();
50
+ }), t;
51
+ }
52
+ function Ae(e) {
53
+ const t = S(!1);
54
+ return D(() => {
55
+ t.value = A()?.mode === e;
56
+ }), se(t);
57
+ }
58
+ const Ht = /* @__PURE__ */ p({
59
+ __name: "DotCMSShow",
60
+ props: {
61
+ when: { default: L.EDIT }
62
+ },
63
+ setup(e) {
64
+ const o = Ae(e.when);
65
+ return (s, n) => C(o) ? N(s.$slots, "default", { key: 0 }) : T("", !0);
66
+ }
67
+ }), J = /* @__PURE__ */ Symbol("DotCMSPageContext");
68
+ function Ie(e) {
69
+ ae(J, e);
70
+ }
71
+ const Oe = {
72
+ pageAsset: {},
73
+ mode: "production",
74
+ userComponents: {},
75
+ isDevMode: !1,
76
+ isAnalyticsActive: !1
77
+ };
78
+ function I() {
79
+ return ce(
80
+ J,
81
+ c(() => Oe)
82
+ );
83
+ }
84
+ const Re = {
85
+ key: 0,
86
+ "data-testid": "error-message",
87
+ style: { padding: "1rem", border: "1px solid #e0e0e0", borderRadius: "4px" }
88
+ }, Be = /* @__PURE__ */ p({
89
+ __name: "ErrorMessage",
90
+ setup(e) {
91
+ const t = I(), o = c(() => t.value.isDevMode);
92
+ return D(() => {
93
+ console.warn("Missing required layout.body property in page");
94
+ }), (s, n) => o.value ? (r(), l("div", Re, [...n[0] || (n[0] = [
95
+ f("p", { style: { margin: "0 0 0.5rem", color: "#666" } }, [
96
+ _(" The "),
97
+ f("code", null, "page"),
98
+ _(" is missing the required "),
99
+ f("code", null, "layout.body"),
100
+ _(" property. ")
101
+ ], -1),
102
+ f("p", { style: { margin: 0, color: "#666" } }, " Make sure the page asset is properly loaded and includes a layout configuration. ", -1)
103
+ ])])) : T("", !0);
104
+ }
105
+ });
106
+ function Le() {
107
+ const e = S(!1), t = () => {
108
+ e.value = q();
109
+ };
110
+ return D(() => {
111
+ e.value = q(), window.addEventListener(z, t);
112
+ }), H(() => {
113
+ window.removeEventListener(z, t);
114
+ }), e;
115
+ }
116
+ function Pe(e) {
117
+ const t = A()?.mode;
118
+ return t ? t === L.EDIT : e === ye;
119
+ }
120
+ function Ue(e) {
121
+ return c(() => Pe(le(e)));
122
+ }
123
+ const Ve = /* @__PURE__ */ p({
124
+ __name: "ContainerNotFound",
125
+ props: {
126
+ identifier: {}
127
+ },
128
+ setup(e) {
129
+ const t = e, o = I(), s = c(() => o.value.isDevMode);
130
+ return D(() => {
131
+ s.value && console.error(`Container with identifier ${t.identifier} not found`);
132
+ }), (n, a) => s.value ? (r(), l("div", {
133
+ key: 0,
134
+ "data-testid": "container-not-found",
135
+ style: w(C(Q))
136
+ }, " This container with identifier " + x(e.identifier) + " was not found. ", 5)) : T("", !0);
137
+ }
138
+ }), Fe = /* @__PURE__ */ p({
139
+ inheritAttrs: !1,
140
+ __name: "EmptyContainer",
141
+ setup(e) {
142
+ const t = I(), o = c(() => t.value.isDevMode);
143
+ return (s, n) => o.value ? (r(), l("div", $({ key: 0 }, s.$attrs, { style: C(Q) }), [...n[0] || (n[0] = [
144
+ f("span", {
145
+ "data-testid": "empty-container-message",
146
+ "data-dot-object": "empty-content"
147
+ }, " This container is empty. ", -1)
148
+ ])], 16)) : T("", !0);
149
+ }
150
+ });
151
+ function Ge(e) {
152
+ const t = S(!1);
153
+ return D(() => {
154
+ const o = e()?.getBoundingClientRect().height ?? 0;
155
+ t.value = o > 0;
156
+ }), t;
157
+ }
158
+ const He = "dotcms-contentlet", Ye = {
159
+ key: 1,
160
+ "data-testid": "no-component"
161
+ }, je = /* @__PURE__ */ p({
162
+ __name: "FallbackComponent",
163
+ props: {
164
+ contentlet: {},
165
+ userNoComponent: {}
166
+ },
167
+ setup(e) {
168
+ const t = e, o = I(), s = c(() => o.value.isDevMode), n = c(() => !!t.userNoComponent);
169
+ return (a, i) => s.value ? (r(), l(E, { key: 0 }, [
170
+ n.value ? (r(), v(M(e.userNoComponent), R($({ key: 0 }, e.contentlet)), null, 16)) : (r(), l("div", Ye, [
171
+ i[0] || (i[0] = _(" No Component for ", -1)),
172
+ f("strong", null, x(e.contentlet.contentType), 1),
173
+ i[1] || (i[1] = _(". ", -1))
174
+ ]))
175
+ ], 64)) : T("", !0);
176
+ }
177
+ }), Ke = /* @__PURE__ */ p({
178
+ __name: "Contentlet",
179
+ props: {
180
+ contentlet: {},
181
+ container: {}
182
+ },
183
+ setup(e) {
184
+ const t = e, o = I(), s = c(() => o.value.isDevMode), n = ie(), a = Ge(
185
+ () => n?.proxy?.$el
186
+ ), i = c(() => o.value.isDevMode ? {
187
+ ..._e(t.contentlet, t.container),
188
+ "data-dot-object": "contentlet"
189
+ } : o.value.isAnalyticsActive ? ge(t.contentlet) : {}), d = c(
190
+ () => s.value ? { minHeight: a.value ? void 0 : "4rem" } : {}
191
+ ), y = c(
192
+ () => o.value.userComponents[t.contentlet?.contentType]
193
+ ), u = c(
194
+ () => o.value.userComponents[Ce]
195
+ );
196
+ return (g, m) => (r(), l("div", $(i.value, {
197
+ class: C(He),
198
+ style: d.value
199
+ }), [
200
+ y.value ? (r(), v(M(y.value), R($({ key: 0 }, e.contentlet)), null, 16)) : (r(), v(je, {
201
+ key: 1,
202
+ "user-no-component": u.value,
203
+ contentlet: e.contentlet
204
+ }, null, 8, ["user-no-component", "contentlet"]))
205
+ ], 16));
206
+ }
207
+ }), We = /* @__PURE__ */ p({
208
+ __name: "Container",
209
+ props: {
210
+ container: {}
211
+ },
212
+ setup(e) {
213
+ const t = e, o = I(), s = c(() => Ee(o.value.pageAsset, t.container)), n = c(
214
+ () => ke(o.value.pageAsset, t.container)
215
+ ), a = c(() => n.value.length === 0), i = c(
216
+ () => o.value.isDevMode && s.value ? De(s.value) : {}
217
+ ), d = c(
218
+ () => o.value.isDevMode ? JSON.stringify(s.value) : ""
219
+ );
220
+ return (y, u) => s.value ? a.value ? (r(), v(Fe, R($({ key: 1 }, i.value)), null, 16)) : (r(), l("div", R($({ key: 2 }, i.value)), [
221
+ (r(!0), l(E, null, h(n.value, (g) => (r(), v(Ke, {
222
+ key: g.identifier,
223
+ contentlet: g,
224
+ container: d.value
225
+ }, null, 8, ["contentlet", "container"]))), 128))
226
+ ], 16)) : (r(), v(Ve, {
227
+ key: 0,
228
+ identifier: e.container.identifier
229
+ }, null, 8, ["identifier"]));
230
+ }
231
+ }), qe = /* @__PURE__ */ p({
232
+ __name: "Column",
233
+ props: {
234
+ column: {}
235
+ },
236
+ setup(e) {
237
+ const t = e, o = c(() => ({
238
+ gridColumnStart: t.column.leftOffset,
239
+ gridColumnEnd: t.column.leftOffset + t.column.width
240
+ }));
241
+ return (s, n) => (r(), l("div", {
242
+ "data-dot": "column",
243
+ style: w(o.value)
244
+ }, [
245
+ f("div", {
246
+ class: Y(e.column.styleClass)
247
+ }, [
248
+ (r(!0), l(E, null, h(e.column.containers, (a) => (r(), v(We, {
249
+ key: `${a.identifier}-${a.uuid}`,
250
+ container: a
251
+ }, null, 8, ["container"]))), 128))
252
+ ], 2)
253
+ ], 4));
254
+ }
255
+ }), ze = ["id"], Xe = /* @__PURE__ */ p({
256
+ __name: "Row",
257
+ props: {
258
+ row: {},
259
+ index: {}
260
+ },
261
+ setup(e) {
262
+ const t = e, o = c(() => Te(["dot-row-container", t.row.styleClass || ""])), s = c(() => `${Me}${t.index}`), n = {
263
+ display: "grid",
264
+ gridTemplateColumns: "repeat(12, 1fr)",
265
+ gap: "1rem"
266
+ };
267
+ return (a, i) => (r(), l("div", {
268
+ id: s.value,
269
+ class: Y(o.value)
270
+ }, [
271
+ f("div", {
272
+ class: "dotcms-row",
273
+ "data-dot-object": "row",
274
+ style: n
275
+ }, [
276
+ (r(!0), l(E, null, h(e.row.columns, (d, y) => (r(), v(qe, {
277
+ key: y,
278
+ column: d
279
+ }, null, 8, ["column"]))), 128))
280
+ ])
281
+ ], 10, ze));
282
+ }
283
+ }), Yt = /* @__PURE__ */ p({
284
+ __name: "DotCMSLayoutBody",
285
+ props: {
286
+ page: {},
287
+ components: {},
288
+ mode: { default: "production" }
289
+ },
290
+ setup(e) {
291
+ const t = e, o = Ue(() => t.mode), s = Le();
292
+ Ie(
293
+ c(() => ({
294
+ pageAsset: t.page,
295
+ mode: t.mode,
296
+ userComponents: t.components,
297
+ isDevMode: o.value,
298
+ isAnalyticsActive: s.value
299
+ }))
300
+ );
301
+ const n = c(() => t.page?.layout?.body?.rows);
302
+ return (a, i) => n.value ? (r(!0), l(E, { key: 0 }, h(n.value, (d, y) => (r(), v(Xe, {
303
+ key: y,
304
+ row: d,
305
+ index: y + 1
306
+ }, null, 8, ["row", "index"]))), 128)) : (r(), v(Be, { key: 1 }));
307
+ }
308
+ }), G = {
309
+ ...he,
310
+ licenseKey: "gpl"
311
+ // Self-hosted GPL license.
312
+ }, Qe = {
313
+ full: {
314
+ ...G,
315
+ ...F.full
316
+ },
317
+ plain: {
318
+ ...G,
319
+ ...F.plain
320
+ },
321
+ minimal: {
322
+ ...G,
323
+ ...F.minimal
324
+ }
325
+ }, Je = ["innerHTML"], Ze = {
326
+ key: 1,
327
+ style: { outline: "2px solid #006ce7", borderRadius: "4px" }
328
+ }, jt = /* @__PURE__ */ p({
329
+ __name: "DotCMSEditableText",
330
+ props: {
331
+ contentlet: {},
332
+ fieldName: {},
333
+ format: { default: "text" },
334
+ mode: { default: "plain" }
335
+ },
336
+ setup(e) {
337
+ const t = e, o = S(null), s = S(""), n = S(!1), a = S(t.contentlet?.[t.fieldName] || ""), i = c(() => Qe[t.mode]);
338
+ ue(
339
+ () => [t.fieldName, t.contentlet],
340
+ () => {
341
+ a.value = t.contentlet?.[t.fieldName] || "", o.value?.setContent(a.value, { format: t.format });
342
+ }
343
+ );
344
+ const d = (m, k) => {
345
+ o.value = k;
346
+ }, y = (m) => {
347
+ if (Number(
348
+ t.contentlet.onNumberOfPages ?? 1
349
+ ) <= 1 || o.value?.hasFocus())
350
+ return;
351
+ m.stopPropagation(), m.preventDefault();
352
+ const { inode: O, languageId: V } = t.contentlet;
353
+ W({
354
+ action: K.COPY_CONTENTLET_INLINE_EDITING,
355
+ payload: {
356
+ dataset: { inode: O, language: V, fieldName: t.fieldName }
357
+ }
358
+ });
359
+ }, u = () => {
360
+ const m = o.value?.getContent({ format: t.format }) || "";
361
+ if (!o.value?.isDirty() || m === a.value)
362
+ return;
363
+ const { inode: k, languageId: O } = t.contentlet;
364
+ W({
365
+ action: K.UPDATE_CONTENTLET_INLINE_EDITING,
366
+ payload: {
367
+ content: m,
368
+ dataset: { inode: k, langId: O, fieldName: t.fieldName }
369
+ }
370
+ });
371
+ }, g = ({ data: m }) => {
372
+ const { name: k, payload: O } = m ?? {};
373
+ if (k !== we.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS)
374
+ return;
375
+ const { oldInode: V, inode: Z, fieldName: ee } = O ?? {}, j = t.contentlet.inode;
376
+ (j === V || j === Z) && ee === t.fieldName && o.value?.focus();
377
+ };
378
+ return D(() => {
379
+ const m = A();
380
+ if (n.value = m?.mode === L.EDIT && !!m?.dotCMSHost?.length, !t.contentlet || !t.fieldName) {
381
+ console.error(
382
+ "[DotCMSEditableText]: contentlet or fieldName is missing. Ensure all needed props are passed to view and edit the content."
383
+ );
384
+ return;
385
+ }
386
+ if (m && m.mode !== L.EDIT) {
387
+ console.warn("[DotCMSEditableText]: TinyMCE is not available in the current mode");
388
+ return;
389
+ }
390
+ m?.dotCMSHost && (s.value = new URL(be, m.dotCMSHost).toString(), window.addEventListener("message", g));
391
+ }), H(() => {
392
+ window.removeEventListener("message", g);
393
+ }), (m, k) => n.value ? (r(), l("div", Ze, [
394
+ b(C(Se), {
395
+ "tinymce-script-src": s.value,
396
+ inline: !0,
397
+ init: i.value,
398
+ "initial-value": a.value,
399
+ onInit: d,
400
+ onMousedown: y,
401
+ onFocusout: u
402
+ }, null, 8, ["tinymce-script-src", "init", "initial-value"])
403
+ ])) : (r(), l("span", {
404
+ key: 0,
405
+ innerHTML: a.value
406
+ }, null, 8, Je));
407
+ }
408
+ }), U = (e, t) => {
409
+ const o = e.__vccOpts || e;
410
+ for (const [s, n] of t)
411
+ o[s] = n;
412
+ return o;
413
+ }, et = {};
414
+ function tt(e, t) {
415
+ return r(), l("ul", null, [
416
+ N(e.$slots, "default")
417
+ ]);
418
+ }
419
+ const nt = /* @__PURE__ */ U(et, [["render", tt]]), ot = ["data-language"], rt = /* @__PURE__ */ p({
420
+ __name: "CodeBlock",
421
+ props: {
422
+ node: {}
423
+ },
424
+ setup(e) {
425
+ const t = e, o = c(() => t.node?.attrs?.language || "");
426
+ return (s, n) => (r(), l("pre", { "data-language": o.value }, [
427
+ f("code", null, [
428
+ N(s.$slots, "default")
429
+ ])
430
+ ], 8, ot));
431
+ }
432
+ }), st = /* @__PURE__ */ p({
433
+ __name: "NoComponentProvided",
434
+ props: {
435
+ contentType: {}
436
+ },
437
+ setup(e) {
438
+ const t = {
439
+ backgroundColor: "#fffaf0",
440
+ color: "#333",
441
+ padding: "1rem",
442
+ borderRadius: "0.5rem",
443
+ marginBottom: "1rem",
444
+ marginTop: "1rem",
445
+ border: "1px solid #ed8936"
446
+ }, o = { color: "#c05621" };
447
+ return (s, n) => (r(), l("div", {
448
+ "data-testid": "no-component-provided",
449
+ style: t
450
+ }, [
451
+ f("strong", { style: o }, "Dev Warning"),
452
+ n[0] || (n[0] = _(": No component or custom renderer provided for content type ", -1)),
453
+ f("strong", { style: o }, x(e.contentType || "Unknown"), 1),
454
+ n[1] || (n[1] = _(". ", -1)),
455
+ n[2] || (n[2] = f("br", null, null, -1)),
456
+ n[3] || (n[3] = _(" Please refer to the ", -1)),
457
+ f("a", {
458
+ href: "https://dev.dotcms.com/docs/block-editor",
459
+ target: "_blank",
460
+ rel: "noopener noreferrer",
461
+ style: o
462
+ }, "Block Editor Custom Renderers Documentation"),
463
+ n[4] || (n[4] = _(" for guidance. ", -1))
464
+ ]));
465
+ }
466
+ }), at = "[DotCMSBlockEditorRenderer]: No data provided for Contentlet Block. Try to add a contentlet to the block editor. If the error persists, please contact the DotCMS support team.", ct = /* @__PURE__ */ p({
467
+ __name: "DotContent",
468
+ props: {
469
+ node: {},
470
+ customRenderers: {},
471
+ isDevMode: { type: Boolean }
472
+ },
473
+ setup(e) {
474
+ const t = (d) => `[DotCMSBlockEditorRenderer]: No matching component found for content type: ${d}. Provide a custom renderer for this content type to fix this error.`, o = e, s = c(() => o.node.attrs?.data), n = c(() => s.value?.contentType ?? "Unknown Content Type"), a = c(() => o.customRenderers?.[n.value]), i = c(() => s.value ? o.isDevMode && !a.value ? "dev-warning" : a.value ? "render" : (console.warn(t(n.value)), "no-component") : (console.error(at), "no-data"));
475
+ return (d, y) => i.value === "dev-warning" ? (r(), v(st, {
476
+ key: 0,
477
+ "content-type": n.value
478
+ }, null, 8, ["content-type"])) : i.value === "render" ? (r(), v(M(a.value), {
479
+ key: 1,
480
+ node: e.node
481
+ }, null, 8, ["node"])) : T("", !0);
482
+ }
483
+ }), lt = ["alt", "src"], it = /* @__PURE__ */ p({
484
+ __name: "DotImage",
485
+ props: {
486
+ node: {}
487
+ },
488
+ setup(e) {
489
+ const t = e, o = c(() => t.node.attrs ?? {}), s = c(() => {
490
+ const { textWrap: a, textAlign: i } = o.value;
491
+ return a === "left" ? { float: "left", width: "50%", margin: "0 1rem 1rem 0" } : a === "right" ? { float: "right", width: "50%", margin: "0 0 1rem 1rem" } : i ? { textAlign: i } : {};
492
+ }), n = c(
493
+ () => o.value.textWrap ? { maxWidth: "100%", height: "auto" } : void 0
494
+ );
495
+ return (a, i) => (r(), l("figure", {
496
+ style: w(s.value)
497
+ }, [
498
+ f("img", {
499
+ alt: o.value.alt,
500
+ src: o.value.src,
501
+ style: w(n.value)
502
+ }, null, 12, lt)
503
+ ], 4));
504
+ }
505
+ }), ut = ["width", "height", "poster"], dt = ["src", "type"], mt = /* @__PURE__ */ p({
506
+ __name: "DotVideo",
507
+ props: {
508
+ node: {}
509
+ },
510
+ setup(e) {
511
+ const t = e, o = c(() => t.node.attrs ?? {}), s = c(() => o.value.data?.thumbnail);
512
+ return (n, a) => (r(), l("video", {
513
+ controls: "",
514
+ preload: "metadata",
515
+ width: o.value.width,
516
+ height: o.value.height,
517
+ poster: s.value
518
+ }, [
519
+ a[0] || (a[0] = f("track", {
520
+ default: "",
521
+ kind: "captions",
522
+ srclang: "en"
523
+ }, null, -1)),
524
+ f("source", {
525
+ src: o.value.src,
526
+ type: o.value.mimeType
527
+ }, null, 8, dt),
528
+ a[1] || (a[1] = _(" Your browser does not support the ", -1)),
529
+ a[2] || (a[2] = f("code", null, "video", -1)),
530
+ a[3] || (a[3] = _(" element. ", -1))
531
+ ], 8, ut));
532
+ }
533
+ }), pt = /* @__PURE__ */ p({
534
+ __name: "GridBlock",
535
+ props: {
536
+ node: {},
537
+ customRenderers: {},
538
+ isDevMode: { type: Boolean }
539
+ },
540
+ setup(e) {
541
+ const t = e, o = c(() => {
542
+ const n = t.node.attrs?.columns;
543
+ return Array.isArray(n) && n.length === 2 && n.every((a) => typeof a == "number" && Number.isFinite(a)) ? n : [6, 6];
544
+ }), s = {
545
+ display: "grid",
546
+ gridTemplateColumns: "repeat(12, 1fr)",
547
+ gap: "1rem"
548
+ };
549
+ return (n, a) => (r(), l("div", {
550
+ "data-type": "gridBlock",
551
+ class: "grid-block",
552
+ style: s
553
+ }, [
554
+ (r(!0), l(E, null, h(e.node.content ?? [], (i, d) => (r(), l("div", {
555
+ key: `gridColumn-${d}`,
556
+ "data-type": "gridColumn",
557
+ class: "grid-block__column",
558
+ style: w({ gridColumn: `span ${o.value[d] ?? 6}` })
559
+ }, [
560
+ b(P, {
561
+ content: i.content,
562
+ "custom-renderers": e.customRenderers,
563
+ "is-dev-mode": e.isDevMode
564
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
565
+ ], 4))), 128))
566
+ ]));
567
+ }
568
+ }), vt = /* @__PURE__ */ p({
569
+ __name: "Heading",
570
+ props: {
571
+ node: {}
572
+ },
573
+ setup(e) {
574
+ const t = e, o = c(() => `h${t.node?.attrs?.level || 1}`);
575
+ return (s, n) => (r(), v(M(o.value), null, {
576
+ default: B(() => [
577
+ N(s.$slots, "default")
578
+ ]),
579
+ _: 3
580
+ }));
581
+ }
582
+ }), ft = {};
583
+ function yt(e, t) {
584
+ return r(), l("li", null, [
585
+ N(e.$slots, "default")
586
+ ]);
587
+ }
588
+ const _t = /* @__PURE__ */ U(ft, [["render", yt]]), gt = {};
589
+ function Ct(e, t) {
590
+ return r(), l("ol", null, [
591
+ N(e.$slots, "default")
592
+ ]);
593
+ }
594
+ const Et = /* @__PURE__ */ U(gt, [["render", Ct]]), kt = /* @__PURE__ */ p({
595
+ __name: "Paragraph",
596
+ props: {
597
+ node: {}
598
+ },
599
+ setup(e) {
600
+ const t = e, o = c(() => t.node?.attrs ?? {});
601
+ return (s, n) => (r(), l("p", {
602
+ style: w(o.value)
603
+ }, [
604
+ N(s.$slots, "default")
605
+ ], 4));
606
+ }
607
+ }), Dt = {};
608
+ function Tt(e, t) {
609
+ return r(), l("blockquote", null, [
610
+ N(e.$slots, "default")
611
+ ]);
612
+ }
613
+ const Mt = /* @__PURE__ */ U(Dt, [["render", Tt]]), ht = ["aria-label", "aria-labelledby"], bt = { key: 0 }, Nt = ["colspan", "rowspan", "scope"], St = ["colspan", "rowspan"], wt = /* @__PURE__ */ p({
614
+ __name: "TableRenderer",
615
+ props: {
616
+ content: {},
617
+ attrs: {},
618
+ customRenderers: {},
619
+ isDevMode: { type: Boolean }
620
+ },
621
+ setup(e) {
622
+ const t = e, o = c(() => t.attrs?.caption || void 0), s = c(() => t.attrs?.ariaLabel || void 0), n = c(() => t.attrs?.ariaLabelledby || void 0), a = (d) => Number(d.attrs?.colspan || 1), i = (d) => Number(d.attrs?.rowspan || 1);
623
+ return (d, y) => (r(), l("table", {
624
+ "aria-label": s.value,
625
+ "aria-labelledby": n.value
626
+ }, [
627
+ o.value ? (r(), l("caption", bt, x(o.value), 1)) : T("", !0),
628
+ f("tbody", null, [
629
+ (r(!0), l(E, null, h(e.content, (u, g) => (r(), l("tr", {
630
+ key: `row-${g}`
631
+ }, [
632
+ (r(!0), l(E, null, h(u.content ?? [], (m, k) => (r(), l(E, {
633
+ key: `cell-${k}`
634
+ }, [
635
+ m.type === "tableHeader" ? (r(), l("th", {
636
+ key: 0,
637
+ colspan: a(m),
638
+ rowspan: i(m),
639
+ scope: m.attrs?.scope || void 0
640
+ }, [
641
+ b(P, {
642
+ content: m.content ?? [],
643
+ "custom-renderers": e.customRenderers,
644
+ "is-dev-mode": e.isDevMode
645
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
646
+ ], 8, Nt)) : (r(), l("td", {
647
+ key: 1,
648
+ colspan: a(m),
649
+ rowspan: i(m)
650
+ }, [
651
+ b(P, {
652
+ content: m.content ?? [],
653
+ "custom-renderers": e.customRenderers,
654
+ "is-dev-mode": e.isDevMode
655
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
656
+ ], 8, St))
657
+ ], 64))), 128))
658
+ ]))), 128))
659
+ ])
660
+ ], 8, ht));
661
+ }
662
+ }), $t = /* @__PURE__ */ p({
663
+ __name: "TextBlock",
664
+ props: {
665
+ text: {},
666
+ marks: {}
667
+ },
668
+ setup(e) {
669
+ const t = e, o = {
670
+ bold: "strong",
671
+ italic: "em",
672
+ strike: "s",
673
+ underline: "u",
674
+ superscript: "sup",
675
+ subscript: "sub",
676
+ link: "a"
677
+ }, s = c(() => t.marks ?? []), n = c(() => s.value[0]), a = c(() => s.value.slice(1)), i = c(() => n.value ? o[n.value.type] : void 0), d = c(() => n.value?.attrs ?? {});
678
+ return (y, u) => {
679
+ const g = X("TextBlock", !0);
680
+ return i.value ? (r(), v(M(i.value), R($({ key: 0 }, d.value)), {
681
+ default: B(() => [
682
+ b(g, {
683
+ text: e.text,
684
+ marks: a.value
685
+ }, null, 8, ["text", "marks"])
686
+ ]),
687
+ _: 1
688
+ }, 16)) : (r(), l(E, { key: 1 }, [
689
+ _(x(e.text), 1)
690
+ ], 64));
691
+ };
692
+ }
693
+ }), xt = /* @__PURE__ */ p({
694
+ __name: "UnknownBlock",
695
+ props: {
696
+ node: {}
697
+ },
698
+ setup(e) {
699
+ const t = e, o = {
700
+ backgroundColor: "#fff5f5",
701
+ color: "#333",
702
+ padding: "1rem",
703
+ borderRadius: "0.5rem",
704
+ marginBottom: "1rem",
705
+ marginTop: "1rem",
706
+ border: "1px solid #fc8181"
707
+ };
708
+ return D(() => {
709
+ A() || console.warn(
710
+ `[DotCMSBlockEditorRenderer]: Unknown block type "${t.node?.type}". No renderer was found for it.`
711
+ );
712
+ }), (s, n) => C(A)() ? (r(), l("div", {
713
+ key: 0,
714
+ "data-testid": "unknown-block",
715
+ style: o
716
+ }, [
717
+ n[0] || (n[0] = _(" Unknown block type: ", -1)),
718
+ f("strong", null, x(e.node?.type), 1)
719
+ ])) : T("", !0);
720
+ }
721
+ }), At = { key: 4 }, It = { key: 5 }, P = /* @__PURE__ */ p({
722
+ __name: "BlockEditorBlock",
723
+ props: {
724
+ content: {},
725
+ customRenderers: {},
726
+ isDevMode: { type: Boolean }
727
+ },
728
+ setup(e) {
729
+ const t = $e, o = {
730
+ [t.PARAGRAPH]: kt,
731
+ [t.HEADING]: vt,
732
+ [t.BULLET_LIST]: nt,
733
+ [t.ORDERED_LIST]: Et,
734
+ [t.LIST_ITEM]: _t,
735
+ [t.BLOCK_QUOTE]: Mt,
736
+ [t.CODE_BLOCK]: rt
737
+ }, s = {
738
+ [t.DOT_IMAGE]: it,
739
+ [t.DOT_VIDEO]: mt
740
+ }, n = (i) => o[i], a = (i) => s[i];
741
+ return (i, d) => {
742
+ const y = X("BlockEditorBlock", !0);
743
+ return r(!0), l(E, null, h(e.content ?? [], (u, g) => (r(), l(E, {
744
+ key: `${u.type}-${g}`
745
+ }, [
746
+ e.customRenderers && e.customRenderers[u.type] ? (r(), v(M(e.customRenderers[u.type]), {
747
+ key: 0,
748
+ node: u
749
+ }, {
750
+ default: B(() => [
751
+ b(y, {
752
+ content: u.content,
753
+ "custom-renderers": e.customRenderers,
754
+ "is-dev-mode": e.isDevMode
755
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
756
+ ]),
757
+ _: 2
758
+ }, 1032, ["node"])) : n(u.type) ? (r(), v(M(n(u.type)), {
759
+ key: 1,
760
+ node: u
761
+ }, {
762
+ default: B(() => [
763
+ b(y, {
764
+ content: u.content,
765
+ "custom-renderers": e.customRenderers,
766
+ "is-dev-mode": e.isDevMode
767
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
768
+ ]),
769
+ _: 2
770
+ }, 1032, ["node"])) : u.type === C(t).TEXT ? (r(), v($t, {
771
+ key: 2,
772
+ text: u.text,
773
+ marks: u.marks
774
+ }, null, 8, ["text", "marks"])) : a(u.type) ? (r(), v(M(a(u.type)), {
775
+ key: 3,
776
+ node: u
777
+ }, null, 8, ["node"])) : u.type === C(t).HARDBREAK ? (r(), l("br", At)) : u.type === C(t).HORIZONTAL_RULE ? (r(), l("hr", It)) : u.type === C(t).TABLE ? (r(), v(wt, {
778
+ key: 6,
779
+ content: u.content ?? [],
780
+ attrs: u.attrs,
781
+ "custom-renderers": e.customRenderers,
782
+ "is-dev-mode": e.isDevMode
783
+ }, null, 8, ["content", "attrs", "custom-renderers", "is-dev-mode"])) : u.type === C(t).GRID_BLOCK ? (r(), v(pt, {
784
+ key: 7,
785
+ node: u,
786
+ "custom-renderers": e.customRenderers,
787
+ "is-dev-mode": e.isDevMode
788
+ }, null, 8, ["node", "custom-renderers", "is-dev-mode"])) : u.type === C(t).DOT_CONTENT ? (r(), v(ct, {
789
+ key: 8,
790
+ node: u,
791
+ "custom-renderers": e.customRenderers,
792
+ "is-dev-mode": e.isDevMode
793
+ }, null, 8, ["node", "custom-renderers", "is-dev-mode"])) : (r(), v(xt, {
794
+ key: 9,
795
+ node: u
796
+ }, null, 8, ["node"]))
797
+ ], 64))), 128);
798
+ };
799
+ }
800
+ }), Ot = {
801
+ key: 0,
802
+ "data-testid": "invalid-blocks-message"
803
+ }, Kt = /* @__PURE__ */ p({
804
+ __name: "DotCMSBlockEditorRenderer",
805
+ props: {
806
+ blocks: {},
807
+ style: {},
808
+ className: {},
809
+ customRenderers: {},
810
+ isDevMode: { type: Boolean, default: !1 }
811
+ },
812
+ setup(e) {
813
+ const t = e, o = c(() => Ne(t.blocks)), s = c(() => {
814
+ const n = o.value.error;
815
+ return n && console.error(n), n;
816
+ });
817
+ return (n, a) => s.value && e.isDevMode ? (r(), l("div", Ot, x(s.value), 1)) : s.value ? T("", !0) : (r(), l("div", {
818
+ key: 1,
819
+ class: Y(e.className),
820
+ style: w(e.style),
821
+ "data-testid": "dot-block-editor-container"
822
+ }, [
823
+ b(P, {
824
+ content: e.blocks?.content,
825
+ "custom-renderers": e.customRenderers,
826
+ "is-dev-mode": e.isDevMode
827
+ }, null, 8, ["content", "custom-renderers", "is-dev-mode"])
828
+ ], 6));
829
+ }
830
+ });
831
+ export {
832
+ J as DOTCMS_PAGE_CONTEXT,
833
+ Kt as DotCMSBlockEditorRenderer,
834
+ jt as DotCMSEditableText,
835
+ Yt as DotCMSLayoutBody,
836
+ Ht as DotCMSShow,
837
+ Ie as provideDotCMSPageContext,
838
+ xe as toPlain,
839
+ I as useDotCMSPageContext,
840
+ Ae as useDotCMSShowWhen,
841
+ Gt as useEditableDotCMSPage
842
+ };