@nubisco/cms-vue 1.2.0 → 1.4.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/cms-vue.css +1 -1
- package/dist/index.d.ts +350 -267
- package/dist/index.js +490 -331
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,336 +1,328 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
type: "date",
|
|
45
|
-
label: "To"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
resolveAt: "build"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
id: "auth",
|
|
52
|
-
label: "Signed in",
|
|
53
|
-
valueType: "boolean",
|
|
54
|
-
resolveAt: "request"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "region",
|
|
58
|
-
label: "Region",
|
|
59
|
-
valueType: "enum",
|
|
60
|
-
enumValues: [
|
|
61
|
-
"EU",
|
|
62
|
-
"NA",
|
|
63
|
-
"SA",
|
|
64
|
-
"AS",
|
|
65
|
-
"AF",
|
|
66
|
-
"OC"
|
|
67
|
-
],
|
|
68
|
-
resolveAt: "request"
|
|
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, text as l } from "@nubisco/cms-core";
|
|
2
|
+
import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createTextVNode as g, defineComponent as _, getCurrentInstance as v, inject as y, mergeProps as b, normalizeClass as x, openBlock as S, provide as C, ref as w, renderList as T, renderSlot as E, resolveDynamicComponent as D, toDisplayString as O, unref as k, withCtx as A, withKeys as ee, withModifiers as j } from "vue";
|
|
3
|
+
export * from "@nubisco/cms-core";
|
|
4
|
+
//#region src/context.ts
|
|
5
|
+
var M = Symbol("cms-context");
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/useField.ts
|
|
8
|
+
function N() {
|
|
9
|
+
let e = y(M, {
|
|
10
|
+
messages: {},
|
|
11
|
+
editing: !1,
|
|
12
|
+
setText: () => {}
|
|
13
|
+
});
|
|
14
|
+
return { t: (t) => l(t, e.messages) };
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/client.ts
|
|
18
|
+
var P = Symbol("cms-client");
|
|
19
|
+
function F() {
|
|
20
|
+
return typeof window > "u";
|
|
21
|
+
}
|
|
22
|
+
function te() {
|
|
23
|
+
return typeof window < "u" ? new URLSearchParams(window.location.search) : null;
|
|
24
|
+
}
|
|
25
|
+
function I() {
|
|
26
|
+
let e = te();
|
|
27
|
+
return e?.has("cms-edit") ? {
|
|
28
|
+
active: !0,
|
|
29
|
+
environment: e.get("cms-env")?.trim() || void 0,
|
|
30
|
+
token: e.get("cms-preview-token")?.trim() || void 0
|
|
31
|
+
} : { active: !1 };
|
|
32
|
+
}
|
|
33
|
+
var L = { active: !1 };
|
|
34
|
+
function R(e) {
|
|
35
|
+
if (!e.apiBase) throw Error("createCms: apiBase is required, for example https://cms.example.com");
|
|
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 ?? I;
|
|
38
|
+
function o() {
|
|
39
|
+
try {
|
|
40
|
+
return a() ?? L;
|
|
41
|
+
} catch {
|
|
42
|
+
return L;
|
|
43
|
+
}
|
|
69
44
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
label: "Environment",
|
|
84
|
-
color: "#b9781e",
|
|
85
|
-
category: "input",
|
|
86
|
-
ports: [{
|
|
87
|
-
id: "out",
|
|
88
|
-
label: "is",
|
|
89
|
-
type: "output"
|
|
90
|
-
}],
|
|
91
|
-
param: "environment"
|
|
92
|
-
},
|
|
93
|
-
auth: {
|
|
94
|
-
label: "Signed in",
|
|
95
|
-
color: "#2c9560",
|
|
96
|
-
category: "input",
|
|
97
|
-
ports: [{
|
|
98
|
-
id: "out",
|
|
99
|
-
label: "yes",
|
|
100
|
-
type: "output"
|
|
101
|
-
}]
|
|
102
|
-
},
|
|
103
|
-
region: {
|
|
104
|
-
label: "Region",
|
|
105
|
-
color: "#3a86c8",
|
|
106
|
-
category: "input",
|
|
107
|
-
ports: [{
|
|
108
|
-
id: "out",
|
|
109
|
-
label: "in",
|
|
110
|
-
type: "output"
|
|
111
|
-
}],
|
|
112
|
-
param: "region"
|
|
113
|
-
},
|
|
114
|
-
and: {
|
|
115
|
-
label: "AND",
|
|
116
|
-
color: "#5a5a6a",
|
|
117
|
-
category: "gate",
|
|
118
|
-
ports: [
|
|
119
|
-
{
|
|
120
|
-
id: "a",
|
|
121
|
-
label: "a",
|
|
122
|
-
type: "input"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: "b",
|
|
126
|
-
label: "b",
|
|
127
|
-
type: "input"
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: "out",
|
|
131
|
-
label: "out",
|
|
132
|
-
type: "output"
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
or: {
|
|
137
|
-
label: "OR",
|
|
138
|
-
color: "#5a5a6a",
|
|
139
|
-
category: "gate",
|
|
140
|
-
ports: [
|
|
141
|
-
{
|
|
142
|
-
id: "a",
|
|
143
|
-
label: "a",
|
|
144
|
-
type: "input"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: "b",
|
|
148
|
-
label: "b",
|
|
149
|
-
type: "input"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: "out",
|
|
153
|
-
label: "out",
|
|
154
|
-
type: "output"
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
not: {
|
|
159
|
-
label: "NOT",
|
|
160
|
-
color: "#5a5a6a",
|
|
161
|
-
category: "gate",
|
|
162
|
-
ports: [{
|
|
163
|
-
id: "in",
|
|
164
|
-
label: "in",
|
|
165
|
-
type: "input"
|
|
166
|
-
}, {
|
|
167
|
-
id: "out",
|
|
168
|
-
label: "out",
|
|
169
|
-
type: "output"
|
|
170
|
-
}]
|
|
171
|
-
},
|
|
172
|
-
visible: {
|
|
173
|
-
label: "Visible",
|
|
174
|
-
color: "#c0392b",
|
|
175
|
-
category: "output",
|
|
176
|
-
ports: [{
|
|
177
|
-
id: "in",
|
|
178
|
-
label: "show",
|
|
179
|
-
type: "input"
|
|
180
|
-
}]
|
|
45
|
+
function s(e) {
|
|
46
|
+
let i = o(), a = i.active && i.environment || n, s = i.active ? i.token ? `?previewToken=${encodeURIComponent(i.token)}` : "?preview=1" : "";
|
|
47
|
+
return `${t}/api/v1/${r}/${a}/${e.replace(/^\/+/, "")}${s}`;
|
|
48
|
+
}
|
|
49
|
+
async function c(e) {
|
|
50
|
+
let t = o().active || F() ? "no-store" : "default", n = await i(s(e), { cache: t });
|
|
51
|
+
return n.ok ? {
|
|
52
|
+
status: n.status,
|
|
53
|
+
body: await n.json()
|
|
54
|
+
} : {
|
|
55
|
+
status: n.status,
|
|
56
|
+
body: null
|
|
57
|
+
};
|
|
181
58
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
59
|
+
async function l(e) {
|
|
60
|
+
try {
|
|
61
|
+
let t = await c(e);
|
|
62
|
+
if (!t) return {
|
|
63
|
+
doc: null,
|
|
64
|
+
error: "CMS delivery unreachable",
|
|
65
|
+
outcome: "unavailable"
|
|
66
|
+
};
|
|
67
|
+
if (t.body === null) {
|
|
68
|
+
let e = t.status === 404 || t.status === 410;
|
|
69
|
+
return {
|
|
70
|
+
doc: null,
|
|
71
|
+
error: `CMS delivery ${t.status}`,
|
|
72
|
+
outcome: e ? "missing" : "unavailable"
|
|
73
|
+
};
|
|
197
74
|
}
|
|
75
|
+
let n = t.body;
|
|
76
|
+
return {
|
|
77
|
+
doc: n,
|
|
78
|
+
error: null,
|
|
79
|
+
outcome: n?.zones?.main ? "ok" : "missing"
|
|
80
|
+
};
|
|
81
|
+
} catch {
|
|
82
|
+
return {
|
|
83
|
+
doc: null,
|
|
84
|
+
error: "CMS delivery unreachable",
|
|
85
|
+
outcome: "unavailable"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function u(t) {
|
|
90
|
+
if (e.partials === !1) return {
|
|
91
|
+
doc: null,
|
|
92
|
+
error: "CMS partials are off"
|
|
198
93
|
};
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
case "region":
|
|
223
|
-
o = t.region?.(void 0, "in", [a.param ?? ""]) ?? !1;
|
|
224
|
-
break;
|
|
225
|
-
case "and":
|
|
226
|
-
o = i(r, "a") && i(r, "b");
|
|
227
|
-
break;
|
|
228
|
-
case "or":
|
|
229
|
-
o = i(r, "a") || i(r, "b");
|
|
230
|
-
break;
|
|
231
|
-
case "not":
|
|
232
|
-
o = !i(r, "in");
|
|
233
|
-
break;
|
|
234
|
-
case "visible": o = i(r, "in");
|
|
94
|
+
try {
|
|
95
|
+
let e = await c(`_partials/${encodeURIComponent(t)}`);
|
|
96
|
+
if (!e) return {
|
|
97
|
+
doc: null,
|
|
98
|
+
error: "CMS delivery unreachable"
|
|
99
|
+
};
|
|
100
|
+
if (e.body === null) return {
|
|
101
|
+
doc: null,
|
|
102
|
+
error: `CMS delivery ${e.status}`
|
|
103
|
+
};
|
|
104
|
+
let n = e.body;
|
|
105
|
+
return n?.zones?.main?.blocks?.length ? {
|
|
106
|
+
doc: n,
|
|
107
|
+
error: ""
|
|
108
|
+
} : {
|
|
109
|
+
doc: null,
|
|
110
|
+
error: "CMS partial is empty"
|
|
111
|
+
};
|
|
112
|
+
} catch {
|
|
113
|
+
return {
|
|
114
|
+
doc: null,
|
|
115
|
+
error: "CMS delivery unreachable"
|
|
116
|
+
};
|
|
235
117
|
}
|
|
236
|
-
return n[r] = o, o;
|
|
237
118
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
119
|
+
function d(t) {
|
|
120
|
+
return e.navigate ? (e.navigate(t), !0) : e.router ? (e.router.push(t), !0) : !1;
|
|
121
|
+
}
|
|
122
|
+
let f = {
|
|
123
|
+
siteId: r,
|
|
124
|
+
environment: n,
|
|
125
|
+
apiBase: t,
|
|
126
|
+
patchMessageType: e.patchMessageType ?? "nubisco-cms:patch",
|
|
127
|
+
options: e,
|
|
128
|
+
preview: o,
|
|
129
|
+
documentUrl: s,
|
|
130
|
+
navigate: d,
|
|
131
|
+
fetchPage: l,
|
|
132
|
+
fetchPartial: u,
|
|
133
|
+
install(e) {
|
|
134
|
+
e.provide(P, f);
|
|
135
|
+
}
|
|
243
136
|
};
|
|
137
|
+
return f;
|
|
138
|
+
}
|
|
139
|
+
function z() {
|
|
140
|
+
return y(P, null);
|
|
141
|
+
}
|
|
142
|
+
function ne() {
|
|
143
|
+
let e = z();
|
|
144
|
+
if (!e) throw Error("[cms-vue] No CMS client provided. Call app.use(createCms({ siteId }))");
|
|
145
|
+
return e;
|
|
244
146
|
}
|
|
245
147
|
//#endregion
|
|
246
|
-
//#region src/
|
|
247
|
-
function
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return
|
|
148
|
+
//#region src/usePage.ts
|
|
149
|
+
function re(e, t) {
|
|
150
|
+
let n = t ?? z(), r = w(null), i = w(null), a = w("unavailable"), o = w(!1);
|
|
151
|
+
async function s() {
|
|
152
|
+
if (!n) {
|
|
153
|
+
i.value = "CMS client is not configured", a.value = "unavailable";
|
|
154
|
+
return;
|
|
253
155
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
156
|
+
o.value = !0;
|
|
157
|
+
try {
|
|
158
|
+
let t = await n.fetchPage(e);
|
|
159
|
+
r.value = t.doc, i.value = t.error, a.value = t.outcome;
|
|
160
|
+
} finally {
|
|
161
|
+
o.value = !1;
|
|
260
162
|
}
|
|
261
163
|
}
|
|
164
|
+
return {
|
|
165
|
+
doc: r,
|
|
166
|
+
error: i,
|
|
167
|
+
outcome: a,
|
|
168
|
+
loading: o,
|
|
169
|
+
load: s
|
|
170
|
+
};
|
|
262
171
|
}
|
|
263
172
|
//#endregion
|
|
264
|
-
//#region src/
|
|
265
|
-
|
|
266
|
-
|
|
173
|
+
//#region src/usePartial.ts
|
|
174
|
+
var B = /* @__PURE__ */ new Map();
|
|
175
|
+
function V(e) {
|
|
176
|
+
if (!F()) return B;
|
|
177
|
+
let t = e ?? v()?.appContext.app;
|
|
178
|
+
return t ? t.__cmsPartialStates ??= /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map();
|
|
267
179
|
}
|
|
268
|
-
function
|
|
269
|
-
return
|
|
180
|
+
function H(e, t) {
|
|
181
|
+
return e ? `${e.siteId}:${e.environment}:${t}` : `:${t}`;
|
|
270
182
|
}
|
|
271
|
-
function
|
|
272
|
-
return
|
|
183
|
+
function U() {
|
|
184
|
+
return {
|
|
185
|
+
doc: w(null),
|
|
186
|
+
messages: w({}),
|
|
187
|
+
error: w(null),
|
|
188
|
+
loading: w(!0),
|
|
189
|
+
started: !1,
|
|
190
|
+
ready: null
|
|
191
|
+
};
|
|
273
192
|
}
|
|
274
|
-
function
|
|
275
|
-
|
|
193
|
+
function W(e, t) {
|
|
194
|
+
let n = V(t), r = n.get(e);
|
|
195
|
+
return r || (r = U(), n.set(e, r)), r;
|
|
276
196
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
function
|
|
283
|
-
let
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
197
|
+
function G(e, t) {
|
|
198
|
+
if (!e || typeof e != "object") return !1;
|
|
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
|
+
return !r && !i ? !1 : !t || i === t || r && i === "";
|
|
201
|
+
}
|
|
202
|
+
function K(e) {
|
|
203
|
+
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
204
|
+
if (e) try {
|
|
205
|
+
t.add(new URL(e).origin);
|
|
206
|
+
} catch {}
|
|
207
|
+
};
|
|
208
|
+
n(e?.apiBase);
|
|
209
|
+
for (let t of e?.options.consoleOrigins ?? []) n(t);
|
|
210
|
+
return n(typeof document < "u" ? document.referrer : void 0), Array.from(t);
|
|
211
|
+
}
|
|
212
|
+
function q(e, t, n) {
|
|
213
|
+
typeof window > "u" || window.addEventListener("message", (r) => {
|
|
214
|
+
if (!e?.preview().active) return;
|
|
215
|
+
if (window.parent !== window) {
|
|
216
|
+
if (r.source !== window.parent || !K(e).includes(r.origin)) return;
|
|
217
|
+
} else if (r.origin !== window.location.origin) return;
|
|
218
|
+
let i = r.data, a = e?.patchMessageType ?? "nubisco-cms:patch";
|
|
219
|
+
!i || i.type !== a || !i.document?.zones?.main || G(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
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function J(e, t) {
|
|
223
|
+
let n = t ?? z(), r = W(H(n, e));
|
|
224
|
+
return r.started || (r.started = !0, n ? (n.options.livePreview !== !1 && n.preview().active && q(n, e, r), r.ready = n.fetchPartial(e).then((e) => {
|
|
225
|
+
r.doc.value || (r.doc.value = e.doc, r.error.value = e.error, r.loading.value = !1);
|
|
226
|
+
}), r.ready) : (r.error.value = "CMS client is not configured", r.loading.value = !1)), {
|
|
227
|
+
doc: r.doc,
|
|
228
|
+
messages: r.messages,
|
|
229
|
+
error: r.error,
|
|
230
|
+
loading: r.loading,
|
|
231
|
+
whenReady: () => r.ready ?? Promise.resolve()
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function Y() {
|
|
235
|
+
B.clear();
|
|
236
|
+
}
|
|
237
|
+
var X = "cmsPartials";
|
|
238
|
+
function ie(e) {
|
|
239
|
+
let t = {};
|
|
240
|
+
for (let [n, r] of V(e)) r.loading.value || (t[n] = {
|
|
241
|
+
doc: r.doc.value,
|
|
242
|
+
error: r.error.value
|
|
287
243
|
});
|
|
288
|
-
return
|
|
244
|
+
return t;
|
|
245
|
+
}
|
|
246
|
+
function ae(e, t) {
|
|
247
|
+
if (!(!e || typeof e != "object") && !t?.preview().active) for (let [t, n] of Object.entries(e)) {
|
|
248
|
+
let e = n;
|
|
249
|
+
if (!e || typeof e != "object") continue;
|
|
250
|
+
let r = W(t);
|
|
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
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/props.ts
|
|
256
|
+
function Z() {
|
|
257
|
+
return {
|
|
258
|
+
block: {
|
|
259
|
+
type: Object,
|
|
260
|
+
required: !0
|
|
261
|
+
},
|
|
262
|
+
index: {
|
|
263
|
+
type: Number,
|
|
264
|
+
required: !1,
|
|
265
|
+
default: 0
|
|
266
|
+
},
|
|
267
|
+
blocks: {
|
|
268
|
+
type: Array,
|
|
269
|
+
required: !1,
|
|
270
|
+
default: () => []
|
|
271
|
+
},
|
|
272
|
+
context: {
|
|
273
|
+
type: null,
|
|
274
|
+
required: !1,
|
|
275
|
+
default: void 0
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function oe() {
|
|
280
|
+
return Z();
|
|
289
281
|
}
|
|
290
282
|
//#endregion
|
|
291
283
|
//#region src/CmsText.vue?vue&type=script&setup=true&lang.ts
|
|
292
|
-
var
|
|
284
|
+
var se = [
|
|
293
285
|
"data-cms-block",
|
|
294
286
|
"data-cms-field",
|
|
295
287
|
"onKeydown"
|
|
296
|
-
],
|
|
288
|
+
], ce = { key: 1 }, le = /*@__PURE__*/ _({
|
|
297
289
|
__name: "CmsText",
|
|
298
290
|
props: {
|
|
299
291
|
block: {},
|
|
300
292
|
field: {}
|
|
301
293
|
},
|
|
302
294
|
setup(e) {
|
|
303
|
-
let
|
|
295
|
+
let t = e, n = y(M, {
|
|
304
296
|
messages: {},
|
|
305
297
|
editing: !1,
|
|
306
298
|
setText: () => {}
|
|
307
|
-
}),
|
|
308
|
-
function
|
|
309
|
-
let e =
|
|
310
|
-
e !==
|
|
299
|
+
}), r = d(() => t.block.fields[t.field]), i = d(() => l(r.value, n.messages)), a = w(null);
|
|
300
|
+
function o() {
|
|
301
|
+
let e = a.value?.innerText.trim() ?? "";
|
|
302
|
+
e !== i.value && n.setText(t.block, t.field, r.value, e), a.value?.blur();
|
|
311
303
|
}
|
|
312
|
-
return (t,
|
|
304
|
+
return (t, r) => k(n).editing ? (S(), m("span", {
|
|
313
305
|
key: 0,
|
|
314
306
|
ref_key: "el",
|
|
315
|
-
ref:
|
|
307
|
+
ref: a,
|
|
316
308
|
class: "cms-text cms-text--editing",
|
|
317
309
|
"data-cms-block": e.block.id,
|
|
318
310
|
"data-cms-field": e.field,
|
|
319
311
|
contenteditable: "plaintext-only",
|
|
320
312
|
role: "textbox",
|
|
321
313
|
tabindex: "0",
|
|
322
|
-
onBlur:
|
|
323
|
-
onKeydown:
|
|
324
|
-
},
|
|
314
|
+
onBlur: o,
|
|
315
|
+
onKeydown: ee(j(o, ["prevent"]), ["enter"])
|
|
316
|
+
}, O(i.value), 41, se)) : (S(), m("span", ce, O(i.value), 1));
|
|
325
317
|
}
|
|
326
|
-
}),
|
|
318
|
+
}), Q = (e, t) => {
|
|
327
319
|
let n = e.__vccOpts || e;
|
|
328
320
|
for (let [e, r] of t) n[e] = r;
|
|
329
321
|
return n;
|
|
330
|
-
},
|
|
322
|
+
}, ue = /*#__PURE__*/ Q(le, [["__scopeId", "data-v-67fffd3d"]]), de = { class: "bf__type" }, fe = {
|
|
331
323
|
key: 0,
|
|
332
324
|
class: "bf__badge"
|
|
333
|
-
},
|
|
325
|
+
}, pe = ["disabled"], $ = ["disabled"], me = { class: "bf__body" }, he = /*#__PURE__*/ Q(/* @__PURE__ */ _({
|
|
334
326
|
__name: "BlockFrame",
|
|
335
327
|
props: {
|
|
336
328
|
label: {},
|
|
@@ -345,43 +337,43 @@ var j = [
|
|
|
345
337
|
"select"
|
|
346
338
|
],
|
|
347
339
|
setup(e) {
|
|
348
|
-
return (t, n) => (
|
|
340
|
+
return (t, n) => (S(), m("div", { class: x(["bf", {
|
|
349
341
|
"bf--dim": e.hidden,
|
|
350
342
|
"bf--selected": e.selected
|
|
351
|
-
}]) }, [
|
|
343
|
+
}]) }, [h("div", {
|
|
352
344
|
class: "bf__bar",
|
|
353
345
|
onClick: n[2] ||= (e) => t.$emit("select")
|
|
354
346
|
}, [
|
|
355
|
-
n[3] ||=
|
|
347
|
+
n[3] ||= h("span", {
|
|
356
348
|
class: "bf__grip",
|
|
357
349
|
"aria-hidden": "true"
|
|
358
350
|
}, "⠿", -1),
|
|
359
|
-
|
|
360
|
-
e.hidden ? (
|
|
361
|
-
n[4] ||=
|
|
362
|
-
|
|
351
|
+
h("span", de, O(e.label), 1),
|
|
352
|
+
e.hidden ? (S(), m("span", fe, "hidden by condition")) : p("", !0),
|
|
353
|
+
n[4] ||= h("span", { class: "bf__spacer" }, null, -1),
|
|
354
|
+
h("button", {
|
|
363
355
|
class: "bf__btn",
|
|
364
356
|
type: "button",
|
|
365
357
|
disabled: e.isFirst,
|
|
366
358
|
title: "Move up",
|
|
367
|
-
onClick: n[0] ||=
|
|
368
|
-
}, " ↑ ", 8,
|
|
369
|
-
|
|
359
|
+
onClick: n[0] ||= j((e) => t.$emit("up"), ["stop"])
|
|
360
|
+
}, " ↑ ", 8, pe),
|
|
361
|
+
h("button", {
|
|
370
362
|
class: "bf__btn",
|
|
371
363
|
type: "button",
|
|
372
364
|
disabled: e.isLast,
|
|
373
365
|
title: "Move down",
|
|
374
|
-
onClick: n[1] ||=
|
|
375
|
-
}, " ↓ ", 8,
|
|
376
|
-
]),
|
|
366
|
+
onClick: n[1] ||= j((e) => t.$emit("down"), ["stop"])
|
|
367
|
+
}, " ↓ ", 8, $)
|
|
368
|
+
]), h("div", me, [E(t.$slots, "default", {}, void 0, !0)])], 2));
|
|
377
369
|
}
|
|
378
|
-
}), [["__scopeId", "data-v-22d52899"]]),
|
|
370
|
+
}), [["__scopeId", "data-v-22d52899"]]), ge = { class: "cms-zone" }, _e = {
|
|
379
371
|
key: 1,
|
|
380
372
|
class: "cms-zone__missing"
|
|
381
|
-
},
|
|
373
|
+
}, ve = {
|
|
382
374
|
key: 1,
|
|
383
375
|
class: "cms-zone__missing"
|
|
384
|
-
},
|
|
376
|
+
}, ye = /*#__PURE__*/ Q(/* @__PURE__ */ _({
|
|
385
377
|
__name: "CmsZone",
|
|
386
378
|
props: {
|
|
387
379
|
zone: {},
|
|
@@ -391,48 +383,57 @@ var j = [
|
|
|
391
383
|
editing: { type: Boolean },
|
|
392
384
|
selectedId: {},
|
|
393
385
|
graphs: {},
|
|
386
|
+
provideBlockProps: { type: Boolean },
|
|
387
|
+
context: {},
|
|
394
388
|
setText: { type: Function }
|
|
395
389
|
},
|
|
396
390
|
emits: ["select"],
|
|
397
|
-
setup(
|
|
398
|
-
let
|
|
399
|
-
|
|
391
|
+
setup(e, { emit: t }) {
|
|
392
|
+
let r = e, i = t;
|
|
393
|
+
C(M, {
|
|
400
394
|
get messages() {
|
|
401
|
-
return
|
|
395
|
+
return r.messages;
|
|
402
396
|
},
|
|
403
397
|
get editing() {
|
|
404
|
-
return
|
|
398
|
+
return r.editing ?? !1;
|
|
405
399
|
},
|
|
406
|
-
setText: (e, t, n,
|
|
400
|
+
setText: (e, t, n, i) => r.setText?.(e, t, n, i)
|
|
407
401
|
});
|
|
408
|
-
function
|
|
409
|
-
return
|
|
402
|
+
function a(e) {
|
|
403
|
+
return n(e.when, r.env, r.graphs);
|
|
410
404
|
}
|
|
411
|
-
let
|
|
412
|
-
function
|
|
405
|
+
let o = d(() => r.zone.blocks.filter(a));
|
|
406
|
+
function s(e) {
|
|
407
|
+
if (r.provideBlockProps) return {
|
|
408
|
+
index: e,
|
|
409
|
+
blocks: r.zone.blocks,
|
|
410
|
+
context: r.context
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function c(e) {
|
|
413
414
|
return e.type + (e.variation ? ` · ${e.variation}` : "");
|
|
414
415
|
}
|
|
415
|
-
function
|
|
416
|
-
let n =
|
|
416
|
+
function l(e, t) {
|
|
417
|
+
let n = r.zone.blocks;
|
|
417
418
|
if (t < 0 || t >= n.length) return;
|
|
418
|
-
let [
|
|
419
|
-
n.splice(t, 0,
|
|
419
|
+
let [i] = n.splice(e, 1);
|
|
420
|
+
n.splice(t, 0, i);
|
|
420
421
|
}
|
|
421
|
-
return (t,
|
|
422
|
-
key:
|
|
423
|
-
label:
|
|
424
|
-
hidden: !
|
|
425
|
-
"is-first":
|
|
426
|
-
"is-last":
|
|
427
|
-
selected:
|
|
428
|
-
onUp: (e) =>
|
|
429
|
-
onDown: (e) =>
|
|
430
|
-
onSelect: (
|
|
422
|
+
return (t, n) => (S(), m("div", ge, [e.editing ? (S(!0), m(u, { key: 0 }, T(e.zone.blocks, (t, n) => (S(), f(he, {
|
|
423
|
+
key: t.id,
|
|
424
|
+
label: c(t),
|
|
425
|
+
hidden: !a(t),
|
|
426
|
+
"is-first": n === 0,
|
|
427
|
+
"is-last": n === e.zone.blocks.length - 1,
|
|
428
|
+
selected: t.id === e.selectedId,
|
|
429
|
+
onUp: (e) => l(n, n - 1),
|
|
430
|
+
onDown: (e) => l(n, n + 1),
|
|
431
|
+
onSelect: (e) => i("select", t.id)
|
|
431
432
|
}, {
|
|
432
|
-
default:
|
|
433
|
+
default: A(() => [e.registry[t.type] ? (S(), f(D(e.registry[t.type]), b({
|
|
433
434
|
key: 0,
|
|
434
|
-
block:
|
|
435
|
-
}, null,
|
|
435
|
+
block: t
|
|
436
|
+
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (S(), m("div", _e, "Unknown block type: " + O(t.type), 1))]),
|
|
436
437
|
_: 2
|
|
437
438
|
}, 1032, [
|
|
438
439
|
"label",
|
|
@@ -443,11 +444,169 @@ var j = [
|
|
|
443
444
|
"onUp",
|
|
444
445
|
"onDown",
|
|
445
446
|
"onSelect"
|
|
446
|
-
]))), 128)) : (
|
|
447
|
+
]))), 128)) : (S(!0), m(u, { key: 1 }, T(o.value, (t, n) => (S(), m(u, { key: t.id }, [e.registry[t.type] ? (S(), f(D(e.registry[t.type]), b({
|
|
447
448
|
key: 0,
|
|
448
449
|
block: t
|
|
449
|
-
}, null,
|
|
450
|
+
}, { ref_for: !0 }, s(n)), null, 16, ["block"])) : (S(), m("div", ve, "Unknown block type: " + O(t.type), 1))], 64))), 128))]));
|
|
451
|
+
}
|
|
452
|
+
}), [["__scopeId", "data-v-6a544d0b"]]), be = /* @__PURE__ */ _({
|
|
453
|
+
__name: "CmsRichText",
|
|
454
|
+
props: {
|
|
455
|
+
block: {},
|
|
456
|
+
field: {},
|
|
457
|
+
value: {},
|
|
458
|
+
serializers: {},
|
|
459
|
+
as: { default: "div" },
|
|
460
|
+
plainAs: { default: "p" },
|
|
461
|
+
transform: {}
|
|
462
|
+
},
|
|
463
|
+
setup(n, { expose: i }) {
|
|
464
|
+
let a = n, o = y(M, {
|
|
465
|
+
messages: {},
|
|
466
|
+
editing: !1,
|
|
467
|
+
setText: () => {}
|
|
468
|
+
}), s = z(), u = d(() => a.block?.fields);
|
|
469
|
+
function m(e) {
|
|
470
|
+
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
471
|
+
}
|
|
472
|
+
let h = d(() => {
|
|
473
|
+
if (!a.block) return;
|
|
474
|
+
let e = u.value;
|
|
475
|
+
return m(a.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
476
|
+
}), _ = d(() => a.block?.id), v = d(() => a.value === void 0 ? c(u.value, m(a.field)) : a.value), b = d(() => l(v.value, o.messages)), x = d(() => r(b.value)), C = d(() => x.value ? "" : b.value), w = d(() => {
|
|
477
|
+
let n = e(t(b.value), a.serializers);
|
|
478
|
+
return a.transform && (n = a.transform(n)), n;
|
|
479
|
+
});
|
|
480
|
+
function T(e) {
|
|
481
|
+
if (!s || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
482
|
+
let t = e.target?.closest?.("a");
|
|
483
|
+
if (!t || t.hasAttribute("download")) return;
|
|
484
|
+
let n = t.getAttribute("target");
|
|
485
|
+
if (n && n !== "_self") return;
|
|
486
|
+
let r = t.getAttribute("href") ?? "";
|
|
487
|
+
!r.startsWith("/") || r.startsWith("//") || s.navigate(r) && e.preventDefault();
|
|
488
|
+
}
|
|
489
|
+
return i({
|
|
490
|
+
html: w,
|
|
491
|
+
plain: C
|
|
492
|
+
}), (e, t) => x.value ? (S(), f(D(n.as), {
|
|
493
|
+
key: 0,
|
|
494
|
+
class: "cms-richtext-body",
|
|
495
|
+
"data-cms-block": _.value,
|
|
496
|
+
"data-cms-field": h.value,
|
|
497
|
+
"data-cms-field-kind": "richtext",
|
|
498
|
+
onClick: T,
|
|
499
|
+
innerHTML: w.value
|
|
500
|
+
}, null, 8, [
|
|
501
|
+
"data-cms-block",
|
|
502
|
+
"data-cms-field",
|
|
503
|
+
"innerHTML"
|
|
504
|
+
])) : C.value ? (S(), f(D(n.plainAs), {
|
|
505
|
+
key: 1,
|
|
506
|
+
class: "cms-richtext-body",
|
|
507
|
+
"data-cms-block": _.value,
|
|
508
|
+
"data-cms-field": h.value,
|
|
509
|
+
"data-cms-field-kind": "richtext"
|
|
510
|
+
}, {
|
|
511
|
+
default: A(() => [g(O(C.value), 1)]),
|
|
512
|
+
_: 1
|
|
513
|
+
}, 8, ["data-cms-block", "data-cms-field"])) : p("", !0);
|
|
514
|
+
}
|
|
515
|
+
}), xe = /*#__PURE__*/ Q(/* @__PURE__ */ _({
|
|
516
|
+
__name: "CmsLink",
|
|
517
|
+
props: {
|
|
518
|
+
block: {},
|
|
519
|
+
field: {},
|
|
520
|
+
value: {},
|
|
521
|
+
fallback: {},
|
|
522
|
+
label: {},
|
|
523
|
+
labelField: {}
|
|
524
|
+
},
|
|
525
|
+
setup(e, { expose: t }) {
|
|
526
|
+
let n = e, r = y(M, {
|
|
527
|
+
messages: {},
|
|
528
|
+
editing: !1,
|
|
529
|
+
setText: () => {}
|
|
530
|
+
}), o = z(), u = d(() => n.block?.fields);
|
|
531
|
+
function p(e) {
|
|
532
|
+
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
533
|
+
}
|
|
534
|
+
let m = d(() => {
|
|
535
|
+
if (!n.block) return;
|
|
536
|
+
let e = u.value;
|
|
537
|
+
return p(n.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
538
|
+
}), h = d(() => n.block?.id), _ = d(() => n.value === void 0 ? c(u.value, p(n.field)) : n.value), v = d(() => s(_.value, n.fallback ?? "")), x = d(() => a(v.value)), C = d(() => i(v.value)), w = d(() => {
|
|
539
|
+
if (n.label !== void 0) return l(n.label, r.messages);
|
|
540
|
+
let e = c(u.value, p(n.labelField));
|
|
541
|
+
return e === void 0 ? "" : l(e, r.messages);
|
|
542
|
+
});
|
|
543
|
+
t({ link: v });
|
|
544
|
+
function T(e) {
|
|
545
|
+
let t = v.value;
|
|
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
|
+
}
|
|
548
|
+
return (e, t) => (S(), f(D(x.value), b(C.value, {
|
|
549
|
+
class: ["cms-link", v.value.ok && v.value.href ? "" : "cms-link--inert"],
|
|
550
|
+
"data-cms-block": h.value,
|
|
551
|
+
"data-cms-field": m.value,
|
|
552
|
+
"data-cms-link-status": v.value.status,
|
|
553
|
+
onClick: T
|
|
554
|
+
}), {
|
|
555
|
+
default: A(() => [E(e.$slots, "default", { link: v.value }, () => [g(O(w.value), 1)], !0)]),
|
|
556
|
+
_: 3
|
|
557
|
+
}, 16, [
|
|
558
|
+
"class",
|
|
559
|
+
"data-cms-block",
|
|
560
|
+
"data-cms-field",
|
|
561
|
+
"data-cms-link-status"
|
|
562
|
+
]));
|
|
563
|
+
}
|
|
564
|
+
}), [["__scopeId", "data-v-87a57473"]]), Se = [
|
|
565
|
+
"src",
|
|
566
|
+
"alt",
|
|
567
|
+
"width",
|
|
568
|
+
"height",
|
|
569
|
+
"data-cms-block",
|
|
570
|
+
"data-cms-field"
|
|
571
|
+
], Ce = /* @__PURE__ */ _({
|
|
572
|
+
__name: "CmsImage",
|
|
573
|
+
props: {
|
|
574
|
+
block: {},
|
|
575
|
+
field: {},
|
|
576
|
+
value: {},
|
|
577
|
+
fallback: {},
|
|
578
|
+
alt: {}
|
|
579
|
+
},
|
|
580
|
+
setup(e, { expose: t }) {
|
|
581
|
+
let n = e, r = y(M, {
|
|
582
|
+
messages: {},
|
|
583
|
+
editing: !1,
|
|
584
|
+
setText: () => {}
|
|
585
|
+
}), i = d(() => n.block?.fields);
|
|
586
|
+
function a(e) {
|
|
587
|
+
return e === void 0 ? [] : typeof e == "string" ? [e] : e;
|
|
588
|
+
}
|
|
589
|
+
let s = d(() => {
|
|
590
|
+
if (!n.block) return;
|
|
591
|
+
let e = i.value;
|
|
592
|
+
return a(n.field).find((t) => e && e[t] !== void 0 && e[t] !== null);
|
|
593
|
+
}), l = d(() => n.block?.id), u = d(() => n.value === void 0 ? c(i.value, a(n.field)) : n.value), f = d(() => {
|
|
594
|
+
let e = o(u.value, r.messages, n.fallback ?? "");
|
|
595
|
+
return n.alt === void 0 ? e : {
|
|
596
|
+
...e,
|
|
597
|
+
alt: n.alt
|
|
598
|
+
};
|
|
599
|
+
});
|
|
600
|
+
return t({ image: f }), (e, t) => f.value.src ? (S(), m("img", {
|
|
601
|
+
key: 0,
|
|
602
|
+
src: f.value.src,
|
|
603
|
+
alt: f.value.alt,
|
|
604
|
+
width: f.value.width,
|
|
605
|
+
height: f.value.height,
|
|
606
|
+
"data-cms-block": l.value,
|
|
607
|
+
"data-cms-field": s.value
|
|
608
|
+
}, null, 8, Se)) : p("", !0);
|
|
450
609
|
}
|
|
451
|
-
})
|
|
610
|
+
});
|
|
452
611
|
//#endregion
|
|
453
|
-
export {
|
|
612
|
+
export { P as CMS_CLIENT, M as CMS_CONTEXT, X as CMS_PARTIAL_STATE_KEY, Ce as CmsImage, xe as CmsLink, be as CmsRichText, ue as CmsText, ye as CmsZone, R as createCms, oe as defineBlock, Z as getBlockComponentProps, ae as hydrateCmsPartials, G as isPartialDocument, F as isServerRender, I as readPreviewFromLocation, Y as resetCmsPartials, ie as snapshotCmsPartials, z as useCms, ne as useCmsOrThrow, re as useCmsPage, J as useCmsPartial, N as useField };
|