@nubisco/cms-vue 1.5.0 → 1.6.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/dist/index.js +129 -129
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { applySerializers as e, compileLinks as t, evaluate as n, isHtml as r, linkAttrs as i, linkTag as a, normalizeImage as o, normalizeLink as s, pickField as c, sanitizeRichText as l,
|
|
2
|
-
import { Fragment as
|
|
1
|
+
import { applySerializers as e, compileLinks as t, evaluate as n, isHtml as r, linkAttrs as i, linkTag as a, normalizeImage as o, normalizeLink as s, pickField as c, sanitizeRichText as l, slugHeadings as u, text as d } from "@nubisco/cms-core";
|
|
2
|
+
import { Fragment as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createTextVNode as v, defineComponent as y, getCurrentInstance as b, inject as x, mergeProps as S, normalizeClass as C, openBlock as w, provide as T, ref as E, renderList as D, renderSlot as O, resolveDynamicComponent as k, toDisplayString as A, unref as j, withCtx as M, withKeys as ee, withModifiers as N } from "vue";
|
|
3
3
|
export * from "@nubisco/cms-core";
|
|
4
4
|
//#region src/context.ts
|
|
5
|
-
var
|
|
5
|
+
var P = Symbol("cms-context");
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/useField.ts
|
|
8
8
|
function te() {
|
|
9
|
-
let e =
|
|
9
|
+
let e = x(P, {
|
|
10
10
|
messages: {},
|
|
11
11
|
editing: !1,
|
|
12
12
|
setText: () => {}
|
|
13
13
|
});
|
|
14
|
-
return { t: (t) =>
|
|
14
|
+
return { t: (t) => d(t, e.messages) };
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/client.ts
|
|
18
|
-
var
|
|
19
|
-
function
|
|
18
|
+
var F = Symbol("cms-client");
|
|
19
|
+
function I() {
|
|
20
20
|
return typeof window > "u";
|
|
21
21
|
}
|
|
22
22
|
function ne() {
|
|
23
23
|
return typeof window < "u" ? new URLSearchParams(window.location.search) : null;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function L() {
|
|
26
26
|
let e = ne();
|
|
27
27
|
return e?.has("cms-edit") ? {
|
|
28
28
|
active: !0,
|
|
@@ -30,16 +30,16 @@ function I() {
|
|
|
30
30
|
token: e.get("cms-preview-token")?.trim() || void 0
|
|
31
31
|
} : { active: !1 };
|
|
32
32
|
}
|
|
33
|
-
var
|
|
34
|
-
function
|
|
33
|
+
var R = { active: !1 };
|
|
34
|
+
function z(e) {
|
|
35
35
|
if (!e.apiBase) throw Error("createCms: apiBase is required, for example https://cms.example.com");
|
|
36
36
|
if (!e.siteId) throw Error("createCms: siteId is required");
|
|
37
|
-
let t = e.apiBase.replace(/\/$/, ""), n = e.environment || "production", r = e.siteId, i = e.fetch ?? ((e, t) => fetch(e, t)), a = e.preview ??
|
|
37
|
+
let t = e.apiBase.replace(/\/$/, ""), n = e.environment || "production", r = e.siteId, i = e.fetch ?? ((e, t) => fetch(e, t)), a = e.preview ?? L;
|
|
38
38
|
function o() {
|
|
39
39
|
try {
|
|
40
|
-
return a() ??
|
|
40
|
+
return a() ?? R;
|
|
41
41
|
} catch {
|
|
42
|
-
return
|
|
42
|
+
return R;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
function s(e) {
|
|
@@ -47,7 +47,7 @@ function R(e) {
|
|
|
47
47
|
return `${t}/api/v1/${r}/${a}/${e.replace(/^\/+/, "")}${s}`;
|
|
48
48
|
}
|
|
49
49
|
async function c(e) {
|
|
50
|
-
let t = o().active ||
|
|
50
|
+
let t = o().active || I() ? "no-store" : "default", n = await i(s(e), { cache: t });
|
|
51
51
|
return n.ok ? {
|
|
52
52
|
status: n.status,
|
|
53
53
|
body: await n.json()
|
|
@@ -131,23 +131,23 @@ function R(e) {
|
|
|
131
131
|
fetchPage: l,
|
|
132
132
|
fetchPartial: u,
|
|
133
133
|
install(e) {
|
|
134
|
-
e.provide(
|
|
134
|
+
e.provide(F, f);
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
return f;
|
|
138
138
|
}
|
|
139
|
-
function z() {
|
|
140
|
-
return b(P, null);
|
|
141
|
-
}
|
|
142
139
|
function B() {
|
|
143
|
-
|
|
140
|
+
return x(F, null);
|
|
141
|
+
}
|
|
142
|
+
function V() {
|
|
143
|
+
let e = B();
|
|
144
144
|
if (!e) throw Error("[cms-vue] No CMS client provided. Call app.use(createCms({ siteId }))");
|
|
145
145
|
return e;
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
148
|
//#region src/usePage.ts
|
|
149
149
|
function re(e, t) {
|
|
150
|
-
let n = t ??
|
|
150
|
+
let n = t ?? B(), r = E(null), i = E(null), a = E("unavailable"), o = E(!1);
|
|
151
151
|
async function s() {
|
|
152
152
|
if (!n) {
|
|
153
153
|
i.value = "CMS client is not configured", a.value = "unavailable";
|
|
@@ -171,35 +171,35 @@ function re(e, t) {
|
|
|
171
171
|
}
|
|
172
172
|
//#endregion
|
|
173
173
|
//#region src/usePartial.ts
|
|
174
|
-
var
|
|
175
|
-
function
|
|
176
|
-
if (!
|
|
177
|
-
let t = e ??
|
|
174
|
+
var H = /* @__PURE__ */ new Map();
|
|
175
|
+
function U(e) {
|
|
176
|
+
if (!I()) return H;
|
|
177
|
+
let t = e ?? b()?.appContext.app;
|
|
178
178
|
return t ? t.__cmsPartialStates ??= /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map();
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function W(e, t) {
|
|
181
181
|
return e ? `${e.siteId}:${e.environment}:${t}` : `:${t}`;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function G() {
|
|
184
184
|
return {
|
|
185
|
-
doc:
|
|
186
|
-
messages:
|
|
187
|
-
error:
|
|
188
|
-
loading:
|
|
185
|
+
doc: E(null),
|
|
186
|
+
messages: E({}),
|
|
187
|
+
error: E(null),
|
|
188
|
+
loading: E(!0),
|
|
189
189
|
started: !1,
|
|
190
190
|
ready: null
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
function G(e, t) {
|
|
194
|
-
let n = H(t), r = n.get(e);
|
|
195
|
-
return r || (r = W(), n.set(e, r)), r;
|
|
196
|
-
}
|
|
197
193
|
function K(e, t) {
|
|
194
|
+
let n = U(t), r = n.get(e);
|
|
195
|
+
return r || (r = G(), n.set(e, r)), r;
|
|
196
|
+
}
|
|
197
|
+
function q(e, t) {
|
|
198
198
|
if (!e || typeof e != "object") return !1;
|
|
199
199
|
let n = e, r = (typeof n.contentType == "string" ? n.contentType : typeof n.content_type == "string" ? n.content_type : "") === "partial" || n.kind === "partial", i = typeof n.key == "string" ? n.key : typeof n.route == "string" && !n.route.startsWith("/") ? n.route : "";
|
|
200
200
|
return !r && !i ? !1 : !t || i === t || r && i === "";
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function J(e) {
|
|
203
203
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
204
204
|
if (e) try {
|
|
205
205
|
t.add(new URL(e).origin);
|
|
@@ -209,19 +209,19 @@ function q(e) {
|
|
|
209
209
|
for (let t of e?.options.consoleOrigins ?? []) n(t);
|
|
210
210
|
return n(typeof document < "u" ? document.referrer : void 0), Array.from(t);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function Y(e, t, n) {
|
|
213
213
|
typeof window > "u" || window.addEventListener("message", (r) => {
|
|
214
214
|
if (!e?.preview().active) return;
|
|
215
215
|
if (window.parent !== window) {
|
|
216
|
-
if (r.source !== window.parent || !
|
|
216
|
+
if (r.source !== window.parent || !J(e).includes(r.origin)) return;
|
|
217
217
|
} else if (r.origin !== window.location.origin) return;
|
|
218
218
|
let i = r.data, a = e?.patchMessageType ?? "nubisco-cms:patch";
|
|
219
|
-
!i || i.type !== a || !i.document?.zones?.main ||
|
|
219
|
+
!i || i.type !== a || !i.document?.zones?.main || q(i.document, t) && (i.messages && typeof i.messages == "object" && (n.messages.value = i.messages), n.doc.value = i.document, n.error.value = "", n.loading.value = !1);
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
let n = t ??
|
|
224
|
-
return r.started || (r.started = !0, n ? (n.options.livePreview !== !1 && n.preview().active &&
|
|
222
|
+
function X(e, t) {
|
|
223
|
+
let n = t ?? B(), r = K(W(n, e));
|
|
224
|
+
return r.started || (r.started = !0, n ? (n.options.livePreview !== !1 && n.preview().active && Y(n, e, r), r.ready = n.fetchPartial(e).then((e) => {
|
|
225
225
|
r.doc.value || (r.doc.value = e.doc, r.error.value = e.error, r.loading.value = !1);
|
|
226
226
|
}), r.ready) : (r.error.value = "CMS client is not configured", r.loading.value = !1)), {
|
|
227
227
|
doc: r.doc,
|
|
@@ -231,23 +231,23 @@ function Y(e, t) {
|
|
|
231
231
|
whenReady: () => r.ready ?? Promise.resolve()
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
234
|
+
function ie() {
|
|
235
|
+
H.clear();
|
|
236
236
|
}
|
|
237
|
-
var
|
|
238
|
-
function
|
|
237
|
+
var ae = "cmsPartials";
|
|
238
|
+
function oe(e) {
|
|
239
239
|
let t = {};
|
|
240
|
-
for (let [n, r] of
|
|
240
|
+
for (let [n, r] of U(e)) r.loading.value || (t[n] = {
|
|
241
241
|
doc: r.doc.value,
|
|
242
242
|
error: r.error.value
|
|
243
243
|
});
|
|
244
244
|
return t;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function se(e, t) {
|
|
247
247
|
if (!(!e || typeof e != "object") && !t?.preview().active) for (let [t, n] of Object.entries(e)) {
|
|
248
248
|
let e = n;
|
|
249
249
|
if (!e || typeof e != "object") continue;
|
|
250
|
-
let r =
|
|
250
|
+
let r = K(t);
|
|
251
251
|
r.started || (r.started = !0, r.doc.value = e.doc ?? null, r.error.value = typeof e.error == "string" ? e.error : e.doc ? "" : "CMS partial unavailable", r.loading.value = !1, r.ready = Promise.resolve());
|
|
252
252
|
}
|
|
253
253
|
}
|
|
@@ -276,32 +276,32 @@ function Z() {
|
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function ce() {
|
|
280
280
|
return Z();
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/CmsText.vue?vue&type=script&setup=true&lang.ts
|
|
284
|
-
var
|
|
284
|
+
var le = [
|
|
285
285
|
"data-cms-block",
|
|
286
286
|
"data-cms-field",
|
|
287
287
|
"onKeydown"
|
|
288
|
-
],
|
|
288
|
+
], ue = { key: 1 }, de = /*@__PURE__*/ y({
|
|
289
289
|
__name: "CmsText",
|
|
290
290
|
props: {
|
|
291
291
|
block: {},
|
|
292
292
|
field: {}
|
|
293
293
|
},
|
|
294
294
|
setup(e) {
|
|
295
|
-
let t = e, n =
|
|
295
|
+
let t = e, n = x(P, {
|
|
296
296
|
messages: {},
|
|
297
297
|
editing: !1,
|
|
298
298
|
setText: () => {}
|
|
299
|
-
}), r =
|
|
299
|
+
}), r = p(() => t.block.fields[t.field]), i = p(() => d(r.value, n.messages)), a = E(null);
|
|
300
300
|
function o() {
|
|
301
301
|
let e = a.value?.innerText.trim() ?? "";
|
|
302
302
|
e !== i.value && n.setText(t.block, t.field, r.value, e), a.value?.blur();
|
|
303
303
|
}
|
|
304
|
-
return (t, r) =>
|
|
304
|
+
return (t, r) => j(n).editing ? (w(), g("span", {
|
|
305
305
|
key: 0,
|
|
306
306
|
ref_key: "el",
|
|
307
307
|
ref: a,
|
|
@@ -312,17 +312,17 @@ var ce = [
|
|
|
312
312
|
role: "textbox",
|
|
313
313
|
tabindex: "0",
|
|
314
314
|
onBlur: o,
|
|
315
|
-
onKeydown: ee(
|
|
316
|
-
},
|
|
315
|
+
onKeydown: ee(N(o, ["prevent"]), ["enter"])
|
|
316
|
+
}, A(i.value), 41, le)) : (w(), g("span", ue, A(i.value), 1));
|
|
317
317
|
}
|
|
318
318
|
}), Q = (e, t) => {
|
|
319
319
|
let n = e.__vccOpts || e;
|
|
320
320
|
for (let [e, r] of t) n[e] = r;
|
|
321
321
|
return n;
|
|
322
|
-
},
|
|
322
|
+
}, fe = /*#__PURE__*/ Q(de, [["__scopeId", "data-v-67fffd3d"]]), pe = { class: "bf__type" }, me = {
|
|
323
323
|
key: 0,
|
|
324
324
|
class: "bf__badge"
|
|
325
|
-
},
|
|
325
|
+
}, he = ["disabled"], ge = ["disabled"], _e = { class: "bf__body" }, ve = /*#__PURE__*/ Q(/* @__PURE__ */ y({
|
|
326
326
|
__name: "BlockFrame",
|
|
327
327
|
props: {
|
|
328
328
|
label: {},
|
|
@@ -337,43 +337,43 @@ var ce = [
|
|
|
337
337
|
"select"
|
|
338
338
|
],
|
|
339
339
|
setup(e) {
|
|
340
|
-
return (t, n) => (
|
|
340
|
+
return (t, n) => (w(), g("div", { class: C(["bf", {
|
|
341
341
|
"bf--dim": e.hidden,
|
|
342
342
|
"bf--selected": e.selected
|
|
343
|
-
}]) }, [
|
|
343
|
+
}]) }, [_("div", {
|
|
344
344
|
class: "bf__bar",
|
|
345
345
|
onClick: n[2] ||= (e) => t.$emit("select")
|
|
346
346
|
}, [
|
|
347
|
-
n[3] ||=
|
|
347
|
+
n[3] ||= _("span", {
|
|
348
348
|
class: "bf__grip",
|
|
349
349
|
"aria-hidden": "true"
|
|
350
350
|
}, "⠿", -1),
|
|
351
|
-
|
|
352
|
-
e.hidden ? (
|
|
353
|
-
n[4] ||=
|
|
354
|
-
|
|
351
|
+
_("span", pe, A(e.label), 1),
|
|
352
|
+
e.hidden ? (w(), g("span", me, "hidden by condition")) : h("", !0),
|
|
353
|
+
n[4] ||= _("span", { class: "bf__spacer" }, null, -1),
|
|
354
|
+
_("button", {
|
|
355
355
|
class: "bf__btn",
|
|
356
356
|
type: "button",
|
|
357
357
|
disabled: e.isFirst,
|
|
358
358
|
title: "Move up",
|
|
359
|
-
onClick: n[0] ||=
|
|
360
|
-
}, " ↑ ", 8,
|
|
361
|
-
|
|
359
|
+
onClick: n[0] ||= N((e) => t.$emit("up"), ["stop"])
|
|
360
|
+
}, " ↑ ", 8, he),
|
|
361
|
+
_("button", {
|
|
362
362
|
class: "bf__btn",
|
|
363
363
|
type: "button",
|
|
364
364
|
disabled: e.isLast,
|
|
365
365
|
title: "Move down",
|
|
366
|
-
onClick: n[1] ||=
|
|
367
|
-
}, " ↓ ", 8,
|
|
368
|
-
]),
|
|
366
|
+
onClick: n[1] ||= N((e) => t.$emit("down"), ["stop"])
|
|
367
|
+
}, " ↓ ", 8, ge)
|
|
368
|
+
]), _("div", _e, [O(t.$slots, "default", {}, void 0, !0)])], 2));
|
|
369
369
|
}
|
|
370
|
-
}), [["__scopeId", "data-v-22d52899"]]), $ = { class: "cms-zone" },
|
|
370
|
+
}), [["__scopeId", "data-v-22d52899"]]), $ = { class: "cms-zone" }, ye = {
|
|
371
371
|
key: 1,
|
|
372
372
|
class: "cms-zone__missing"
|
|
373
|
-
},
|
|
373
|
+
}, be = {
|
|
374
374
|
key: 1,
|
|
375
375
|
class: "cms-zone__missing"
|
|
376
|
-
},
|
|
376
|
+
}, xe = /*#__PURE__*/ Q(/* @__PURE__ */ y({
|
|
377
377
|
__name: "CmsZone",
|
|
378
378
|
props: {
|
|
379
379
|
zone: {},
|
|
@@ -390,7 +390,7 @@ var ce = [
|
|
|
390
390
|
emits: ["select"],
|
|
391
391
|
setup(e, { emit: t }) {
|
|
392
392
|
let r = e, i = t;
|
|
393
|
-
|
|
393
|
+
T(P, {
|
|
394
394
|
get messages() {
|
|
395
395
|
return r.messages;
|
|
396
396
|
},
|
|
@@ -402,7 +402,7 @@ var ce = [
|
|
|
402
402
|
function a(e) {
|
|
403
403
|
return n(e.when, r.env, r.graphs);
|
|
404
404
|
}
|
|
405
|
-
let o =
|
|
405
|
+
let o = p(() => r.zone.blocks.filter(a));
|
|
406
406
|
function s(e) {
|
|
407
407
|
if (r.provideBlockProps) return {
|
|
408
408
|
index: e,
|
|
@@ -419,7 +419,7 @@ var ce = [
|
|
|
419
419
|
let [i] = n.splice(e, 1);
|
|
420
420
|
n.splice(t, 0, i);
|
|
421
421
|
}
|
|
422
|
-
return (t, n) => (
|
|
422
|
+
return (t, n) => (w(), g("div", $, [e.editing ? (w(!0), g(f, { key: 0 }, D(e.zone.blocks, (t, n) => (w(), m(ve, {
|
|
423
423
|
key: t.id,
|
|
424
424
|
label: c(t),
|
|
425
425
|
hidden: !a(t),
|
|
@@ -430,10 +430,10 @@ var ce = [
|
|
|
430
430
|
onDown: (e) => l(n, n + 1),
|
|
431
431
|
onSelect: (e) => i("select", t.id)
|
|
432
432
|
}, {
|
|
433
|
-
default:
|
|
433
|
+
default: M(() => [e.registry[t.type] ? (w(), m(k(e.registry[t.type]), S({
|
|
434
434
|
key: 0,
|
|
435
435
|
block: t
|
|
436
|
-
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (
|
|
436
|
+
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (w(), g("div", ye, "Unknown block type: " + A(t.type), 1))]),
|
|
437
437
|
_: 2
|
|
438
438
|
}, 1032, [
|
|
439
439
|
"label",
|
|
@@ -444,12 +444,12 @@ var ce = [
|
|
|
444
444
|
"onUp",
|
|
445
445
|
"onDown",
|
|
446
446
|
"onSelect"
|
|
447
|
-
]))), 128)) : (
|
|
447
|
+
]))), 128)) : (w(!0), g(f, { key: 1 }, D(o.value, (t, n) => (w(), g(f, { key: t.id }, [e.registry[t.type] ? (w(), m(k(e.registry[t.type]), S({
|
|
448
448
|
key: 0,
|
|
449
449
|
block: t
|
|
450
|
-
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (
|
|
450
|
+
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (w(), g("div", be, "Unknown block type: " + A(t.type), 1))], 64))), 128))]));
|
|
451
451
|
}
|
|
452
|
-
}), [["__scopeId", "data-v-6a544d0b"]]),
|
|
452
|
+
}), [["__scopeId", "data-v-6a544d0b"]]), Se = /* @__PURE__ */ y({
|
|
453
453
|
__name: "CmsRichText",
|
|
454
454
|
props: {
|
|
455
455
|
block: {},
|
|
@@ -461,23 +461,23 @@ var ce = [
|
|
|
461
461
|
transform: {}
|
|
462
462
|
},
|
|
463
463
|
setup(n, { expose: i }) {
|
|
464
|
-
let a = n, o =
|
|
464
|
+
let a = n, o = x(P, {
|
|
465
465
|
messages: {},
|
|
466
466
|
editing: !1,
|
|
467
467
|
setText: () => {}
|
|
468
|
-
}), s =
|
|
469
|
-
function
|
|
468
|
+
}), s = B(), f = p(() => a.block?.fields);
|
|
469
|
+
function g(e) {
|
|
470
470
|
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
471
471
|
}
|
|
472
|
-
let
|
|
472
|
+
let _ = p(() => {
|
|
473
473
|
if (!a.block) return;
|
|
474
|
-
let e =
|
|
475
|
-
return
|
|
476
|
-
}),
|
|
477
|
-
let n = e(l(t(
|
|
474
|
+
let e = f.value;
|
|
475
|
+
return g(a.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
476
|
+
}), y = p(() => a.block?.id), b = p(() => a.value === void 0 ? c(f.value, g(a.field)) : a.value), S = p(() => d(b.value, o.messages)), C = p(() => r(S.value)), T = p(() => C.value ? "" : S.value), E = p(() => {
|
|
477
|
+
let n = e(u(l(t(S.value))), a.serializers);
|
|
478
478
|
return a.transform && (n = a.transform(n)), n;
|
|
479
479
|
});
|
|
480
|
-
function
|
|
480
|
+
function D(e) {
|
|
481
481
|
if (!s || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
482
482
|
let t = e.target?.closest?.("a");
|
|
483
483
|
if (!t || t.hasAttribute("download")) return;
|
|
@@ -487,32 +487,32 @@ var ce = [
|
|
|
487
487
|
!r.startsWith("/") || r.startsWith("//") || s.navigate(r) && e.preventDefault();
|
|
488
488
|
}
|
|
489
489
|
return i({
|
|
490
|
-
html:
|
|
491
|
-
plain:
|
|
492
|
-
}), (e, t) =>
|
|
490
|
+
html: E,
|
|
491
|
+
plain: T
|
|
492
|
+
}), (e, t) => C.value ? (w(), m(k(n.as), {
|
|
493
493
|
key: 0,
|
|
494
494
|
class: "cms-richtext-body",
|
|
495
|
-
"data-cms-block":
|
|
496
|
-
"data-cms-field":
|
|
495
|
+
"data-cms-block": y.value,
|
|
496
|
+
"data-cms-field": _.value,
|
|
497
497
|
"data-cms-field-kind": "richtext",
|
|
498
|
-
onClick:
|
|
499
|
-
innerHTML:
|
|
498
|
+
onClick: D,
|
|
499
|
+
innerHTML: E.value
|
|
500
500
|
}, null, 8, [
|
|
501
501
|
"data-cms-block",
|
|
502
502
|
"data-cms-field",
|
|
503
503
|
"innerHTML"
|
|
504
|
-
])) :
|
|
504
|
+
])) : T.value ? (w(), m(k(n.plainAs), {
|
|
505
505
|
key: 1,
|
|
506
506
|
class: "cms-richtext-body",
|
|
507
|
-
"data-cms-block":
|
|
508
|
-
"data-cms-field":
|
|
507
|
+
"data-cms-block": y.value,
|
|
508
|
+
"data-cms-field": _.value,
|
|
509
509
|
"data-cms-field-kind": "richtext"
|
|
510
510
|
}, {
|
|
511
|
-
default:
|
|
511
|
+
default: M(() => [v(A(T.value), 1)]),
|
|
512
512
|
_: 1
|
|
513
|
-
}, 8, ["data-cms-block", "data-cms-field"])) :
|
|
513
|
+
}, 8, ["data-cms-block", "data-cms-field"])) : h("", !0);
|
|
514
514
|
}
|
|
515
|
-
}),
|
|
515
|
+
}), Ce = /*#__PURE__*/ Q(/* @__PURE__ */ y({
|
|
516
516
|
__name: "CmsLink",
|
|
517
517
|
props: {
|
|
518
518
|
block: {},
|
|
@@ -523,36 +523,36 @@ var ce = [
|
|
|
523
523
|
labelField: {}
|
|
524
524
|
},
|
|
525
525
|
setup(e, { expose: t }) {
|
|
526
|
-
let n = e, r =
|
|
526
|
+
let n = e, r = x(P, {
|
|
527
527
|
messages: {},
|
|
528
528
|
editing: !1,
|
|
529
529
|
setText: () => {}
|
|
530
|
-
}), o =
|
|
531
|
-
function
|
|
530
|
+
}), o = B(), l = p(() => n.block?.fields);
|
|
531
|
+
function u(e) {
|
|
532
532
|
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
533
533
|
}
|
|
534
|
-
let
|
|
534
|
+
let f = p(() => {
|
|
535
535
|
if (!n.block) return;
|
|
536
536
|
let e = l.value;
|
|
537
|
-
return
|
|
538
|
-
}), h =
|
|
539
|
-
if (n.label !== void 0) return
|
|
540
|
-
let e = c(l.value,
|
|
541
|
-
return e === void 0 ? "" :
|
|
537
|
+
return u(n.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
538
|
+
}), h = p(() => n.block?.id), g = p(() => n.value === void 0 ? c(l.value, u(n.field)) : n.value), _ = p(() => s(g.value, n.fallback ?? "")), y = p(() => a(_.value)), b = p(() => i(_.value)), C = p(() => {
|
|
539
|
+
if (n.label !== void 0) return d(n.label, r.messages);
|
|
540
|
+
let e = c(l.value, u(n.labelField));
|
|
541
|
+
return e === void 0 ? "" : d(e, r.messages);
|
|
542
542
|
});
|
|
543
|
-
t({ link:
|
|
543
|
+
t({ link: _ });
|
|
544
544
|
function T(e) {
|
|
545
|
-
let t =
|
|
545
|
+
let t = _.value;
|
|
546
546
|
!t.ok || !t.internal || !t.href || t.newTab || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || o && o.navigate(t.href) && e.preventDefault();
|
|
547
547
|
}
|
|
548
|
-
return (e, t) => (
|
|
549
|
-
class: ["cms-link",
|
|
548
|
+
return (e, t) => (w(), m(k(y.value), S(b.value, {
|
|
549
|
+
class: ["cms-link", _.value.ok && _.value.href ? "" : "cms-link--inert"],
|
|
550
550
|
"data-cms-block": h.value,
|
|
551
|
-
"data-cms-field":
|
|
552
|
-
"data-cms-link-status":
|
|
551
|
+
"data-cms-field": f.value,
|
|
552
|
+
"data-cms-link-status": _.value.status,
|
|
553
553
|
onClick: T
|
|
554
554
|
}), {
|
|
555
|
-
default:
|
|
555
|
+
default: M(() => [O(e.$slots, "default", { link: _.value }, () => [v(A(C.value), 1)], !0)]),
|
|
556
556
|
_: 3
|
|
557
557
|
}, 16, [
|
|
558
558
|
"class",
|
|
@@ -561,14 +561,14 @@ var ce = [
|
|
|
561
561
|
"data-cms-link-status"
|
|
562
562
|
]));
|
|
563
563
|
}
|
|
564
|
-
}), [["__scopeId", "data-v-87a57473"]]),
|
|
564
|
+
}), [["__scopeId", "data-v-87a57473"]]), we = [
|
|
565
565
|
"src",
|
|
566
566
|
"alt",
|
|
567
567
|
"width",
|
|
568
568
|
"height",
|
|
569
569
|
"data-cms-block",
|
|
570
570
|
"data-cms-field"
|
|
571
|
-
],
|
|
571
|
+
], Te = /* @__PURE__ */ y({
|
|
572
572
|
__name: "CmsImage",
|
|
573
573
|
props: {
|
|
574
574
|
block: {},
|
|
@@ -578,26 +578,26 @@ var ce = [
|
|
|
578
578
|
alt: {}
|
|
579
579
|
},
|
|
580
580
|
setup(e, { expose: t }) {
|
|
581
|
-
let n = e, r =
|
|
581
|
+
let n = e, r = x(P, {
|
|
582
582
|
messages: {},
|
|
583
583
|
editing: !1,
|
|
584
584
|
setText: () => {}
|
|
585
|
-
}), i =
|
|
585
|
+
}), i = p(() => n.block?.fields);
|
|
586
586
|
function a(e) {
|
|
587
587
|
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
588
588
|
}
|
|
589
|
-
let s =
|
|
589
|
+
let s = p(() => {
|
|
590
590
|
if (!n.block) return;
|
|
591
591
|
let e = i.value;
|
|
592
592
|
return a(n.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
593
|
-
}), l =
|
|
593
|
+
}), l = p(() => n.block?.id), u = p(() => n.value === void 0 ? c(i.value, a(n.field)) : n.value), d = p(() => {
|
|
594
594
|
let e = o(u.value, r.messages, n.fallback ?? "");
|
|
595
595
|
return n.alt === void 0 ? e : {
|
|
596
596
|
...e,
|
|
597
597
|
alt: n.alt
|
|
598
598
|
};
|
|
599
599
|
});
|
|
600
|
-
return t({ image: d }), (e, t) => d.value.src ? (
|
|
600
|
+
return t({ image: d }), (e, t) => d.value.src ? (w(), g("img", {
|
|
601
601
|
key: 0,
|
|
602
602
|
src: d.value.src,
|
|
603
603
|
alt: d.value.alt,
|
|
@@ -605,8 +605,8 @@ var ce = [
|
|
|
605
605
|
height: d.value.height,
|
|
606
606
|
"data-cms-block": l.value,
|
|
607
607
|
"data-cms-field": s.value
|
|
608
|
-
}, null, 8,
|
|
608
|
+
}, null, 8, we)) : h("", !0);
|
|
609
609
|
}
|
|
610
610
|
});
|
|
611
611
|
//#endregion
|
|
612
|
-
export {
|
|
612
|
+
export { F as CMS_CLIENT, P as CMS_CONTEXT, ae as CMS_PARTIAL_STATE_KEY, Te as CmsImage, Ce as CmsLink, Se as CmsRichText, fe as CmsText, xe as CmsZone, z as createCms, ce as defineBlock, Z as getBlockComponentProps, se as hydrateCmsPartials, q as isPartialDocument, I as isServerRender, L as readPreviewFromLocation, ie as resetCmsPartials, oe as snapshotCmsPartials, B as useCms, V as useCmsOrThrow, re as useCmsPage, X as useCmsPartial, te as useField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubisco/cms-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Nubisco CMS content contract, evaluator, and Vue render kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@nubisco/cms-core": "^1.
|
|
73
|
+
"@nubisco/cms-core": "^1.3.0"
|
|
74
74
|
},
|
|
75
75
|
"author": "José Silva <jose@nubisco.io>",
|
|
76
76
|
"homepage": "https://github.com/nubisco/cms-vue#readme",
|