article-content-renderer-vue2 0.1.0 → 0.2.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/README.md +49 -56
- package/dist/article-content-renderer-vue2.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +462 -796
- package/dist/types/components/ArticleContentRenderer.vue.d.ts +4 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/types/protocols/types.d.ts +4 -8
- package/dist/types/types.d.ts +4 -9
- package/package.json +1 -1
- package/dist/types/components/AdManagerAd.d.ts +0 -39
- package/dist/types/components/AdSenseAd.d.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -1,294 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var t in
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
import
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
if (typeof
|
|
18
|
-
const t =
|
|
1
|
+
var v = Object.defineProperty, x = Object.defineProperties;
|
|
2
|
+
var j = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var _ = Object.getOwnPropertySymbols;
|
|
4
|
+
var z = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var L = (n, r, t) => r in n ? v(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t, m = (n, r) => {
|
|
6
|
+
for (var t in r || (r = {}))
|
|
7
|
+
z.call(r, t) && L(n, t, r[t]);
|
|
8
|
+
if (_)
|
|
9
|
+
for (var t of _(r))
|
|
10
|
+
M.call(r, t) && L(n, t, r[t]);
|
|
11
|
+
return n;
|
|
12
|
+
}, A = (n, r) => x(n, j(r));
|
|
13
|
+
var P = (n, r, t) => L(n, typeof r != "symbol" ? r + "" : r, t);
|
|
14
|
+
import Y from "vue";
|
|
15
|
+
const F = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), K = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), G = "https://article-content-renderer.invalid/", I = "https://www.doitme.link/";
|
|
16
|
+
function W(n, r) {
|
|
17
|
+
if (typeof n != "string") return n;
|
|
18
|
+
const t = n.trim();
|
|
19
19
|
if (!t.startsWith(I)) return t;
|
|
20
|
-
const
|
|
21
|
-
return `${
|
|
20
|
+
const i = (r.trim() || I).replace(/\/+$/u, ""), s = t.slice(I.length).replace(/^\/+/, "");
|
|
21
|
+
return `${i}/${s}`;
|
|
22
22
|
}
|
|
23
|
-
function E(
|
|
24
|
-
if (typeof
|
|
25
|
-
const t =
|
|
23
|
+
function E(n, r) {
|
|
24
|
+
if (typeof n != "string") return null;
|
|
25
|
+
const t = n.trim();
|
|
26
26
|
if (!t || /[\u0000-\u001F\u007F]/u.test(t)) return null;
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
return (
|
|
30
|
-
} catch (
|
|
28
|
+
const e = new URL(t, G);
|
|
29
|
+
return (r === "link" ? F : K).has(e.protocol) ? t : null;
|
|
30
|
+
} catch (e) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function V(
|
|
34
|
+
function V(n, r) {
|
|
35
35
|
const t = new Set(
|
|
36
|
-
typeof
|
|
36
|
+
typeof n == "string" ? n.trim().split(/\s+/u).filter(Boolean) : []
|
|
37
37
|
);
|
|
38
|
-
return
|
|
38
|
+
return r === "_blank" && (t.add("noopener"), t.add("noreferrer")), t.size > 0 ? [...t].join(" ") : void 0;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
const e = i.trim();
|
|
42
|
-
return e ? e.startsWith("ca-pub-") ? e : `ca-pub-${e}` : "";
|
|
43
|
-
}
|
|
44
|
-
const U = N.extend({
|
|
45
|
-
name: "ArticleAdSenseAd",
|
|
46
|
-
props: {
|
|
47
|
-
publisherId: {
|
|
48
|
-
type: String,
|
|
49
|
-
required: !0
|
|
50
|
-
},
|
|
51
|
-
slotId: {
|
|
52
|
-
type: [String, Number],
|
|
53
|
-
required: !0
|
|
54
|
-
},
|
|
55
|
-
title: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: "Advertisement"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
data() {
|
|
61
|
-
return {
|
|
62
|
-
observer: null,
|
|
63
|
-
requestedKey: null
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
computed: {
|
|
67
|
-
adClient() {
|
|
68
|
-
return Z(this.publisherId);
|
|
69
|
-
},
|
|
70
|
-
adSlot() {
|
|
71
|
-
return String(this.slotId).trim();
|
|
72
|
-
},
|
|
73
|
-
requestKey() {
|
|
74
|
-
return `${this.adClient}:${this.adSlot}`;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
watch: {
|
|
78
|
-
requestKey() {
|
|
79
|
-
this.requestedKey = null, this.stopObserver(), this.$nextTick(() => this.startObserver());
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
mounted() {
|
|
83
|
-
this.startObserver();
|
|
84
|
-
},
|
|
85
|
-
beforeDestroy() {
|
|
86
|
-
this.stopObserver();
|
|
87
|
-
},
|
|
88
|
-
methods: {
|
|
89
|
-
requestAd() {
|
|
90
|
-
var i;
|
|
91
|
-
if (!(!this.adClient || !this.adSlot || this.requestedKey === this.requestKey))
|
|
92
|
-
try {
|
|
93
|
-
const e = window;
|
|
94
|
-
((i = e.adsbygoogle) != null ? i : e.adsbygoogle = []).push({}), this.requestedKey = this.requestKey;
|
|
95
|
-
} catch (e) {
|
|
96
|
-
console.error("[ArticleContentRenderer] Failed to request AdSense ad:", e);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
startObserver() {
|
|
100
|
-
const i = this.$refs.root;
|
|
101
|
-
if (!(!i || !this.adClient || !this.adSlot)) {
|
|
102
|
-
if (typeof IntersectionObserver == "undefined") {
|
|
103
|
-
this.requestAd();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.observer = new IntersectionObserver(
|
|
107
|
-
(e) => {
|
|
108
|
-
e.some((t) => t.isIntersecting) && (this.requestAd(), this.stopObserver());
|
|
109
|
-
},
|
|
110
|
-
{ rootMargin: "200px 0px" }
|
|
111
|
-
), this.observer.observe(i);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
stopObserver() {
|
|
115
|
-
var i;
|
|
116
|
-
(i = this.observer) == null || i.disconnect(), this.observer = null;
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
render(i) {
|
|
120
|
-
return !this.adClient || !this.adSlot ? i() : i(
|
|
121
|
-
"div",
|
|
122
|
-
{
|
|
123
|
-
ref: "root",
|
|
124
|
-
staticClass: "article-ad-wrapper",
|
|
125
|
-
attrs: { "data-google-ad": "true" }
|
|
126
|
-
},
|
|
127
|
-
[
|
|
128
|
-
i("div", { staticClass: "article-ad-title" }, this.title),
|
|
129
|
-
i("ins", {
|
|
130
|
-
key: this.requestKey,
|
|
131
|
-
staticClass: "adsbygoogle article-ad-unit",
|
|
132
|
-
style: { display: "block", width: "100%" },
|
|
133
|
-
attrs: {
|
|
134
|
-
"data-ad-client": this.adClient,
|
|
135
|
-
"data-ad-slot": this.adSlot
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
]
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
function _() {
|
|
143
|
-
var e;
|
|
144
|
-
const i = window;
|
|
145
|
-
return (e = i.googletag) != null || (i.googletag = { cmd: [] }), i.googletag;
|
|
146
|
-
}
|
|
147
|
-
function tt(i, e) {
|
|
148
|
-
const t = i.trim().replace(/\/+$/u, ""), r = e.replace(/^\/+|\/+$/gu, "");
|
|
149
|
-
return t && r ? `${t}/${r}` : "";
|
|
150
|
-
}
|
|
151
|
-
const et = N.extend({
|
|
152
|
-
name: "ArticleAdManagerAd",
|
|
153
|
-
props: {
|
|
154
|
-
publisherId: {
|
|
155
|
-
type: String,
|
|
156
|
-
required: !0
|
|
157
|
-
},
|
|
158
|
-
slotId: {
|
|
159
|
-
type: [String, Number],
|
|
160
|
-
required: !0
|
|
161
|
-
},
|
|
162
|
-
title: {
|
|
163
|
-
type: String,
|
|
164
|
-
default: "Advertisement"
|
|
165
|
-
},
|
|
166
|
-
fallbackPublisherId: {
|
|
167
|
-
type: String,
|
|
168
|
-
default: ""
|
|
169
|
-
},
|
|
170
|
-
fallbackSlotId: {
|
|
171
|
-
type: [String, Number],
|
|
172
|
-
default: void 0
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
data() {
|
|
176
|
-
return {
|
|
177
|
-
observer: null,
|
|
178
|
-
definedSlot: null,
|
|
179
|
-
pubAdsService: null,
|
|
180
|
-
slotRenderEnded: null,
|
|
181
|
-
emptyAdmKey: null,
|
|
182
|
-
cancelled: !1
|
|
183
|
-
};
|
|
184
|
-
},
|
|
185
|
-
computed: {
|
|
186
|
-
admSlotId() {
|
|
187
|
-
return String(this.slotId).trim();
|
|
188
|
-
},
|
|
189
|
-
adsSlotId() {
|
|
190
|
-
return this.fallbackSlotId === void 0 ? "" : String(this.fallbackSlotId).trim();
|
|
191
|
-
},
|
|
192
|
-
adUnitPath() {
|
|
193
|
-
return tt(this.publisherId, this.admSlotId);
|
|
194
|
-
},
|
|
195
|
-
fallbackKey() {
|
|
196
|
-
return `${this.adUnitPath}:${this.admSlotId}:${this.fallbackPublisherId}:${this.adsSlotId}`;
|
|
197
|
-
},
|
|
198
|
-
hasAdSenseFallback() {
|
|
199
|
-
return !!(this.fallbackPublisherId.trim() && this.adsSlotId);
|
|
200
|
-
},
|
|
201
|
-
shouldUseAdSense() {
|
|
202
|
-
return this.hasAdSenseFallback && this.emptyAdmKey === this.fallbackKey;
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
watch: {
|
|
206
|
-
fallbackKey() {
|
|
207
|
-
this.restartAdManager();
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
mounted() {
|
|
211
|
-
this.startObserver();
|
|
212
|
-
},
|
|
213
|
-
beforeDestroy() {
|
|
214
|
-
this.cleanupAdManager();
|
|
215
|
-
},
|
|
216
|
-
methods: {
|
|
217
|
-
restartAdManager() {
|
|
218
|
-
this.cleanupAdManager(), this.emptyAdmKey = null, this.$nextTick(() => this.startObserver());
|
|
219
|
-
},
|
|
220
|
-
startObserver() {
|
|
221
|
-
const i = this.$refs.root;
|
|
222
|
-
if (!(!i || !this.adUnitPath || !this.admSlotId || this.shouldUseAdSense)) {
|
|
223
|
-
if (this.cancelled = !1, typeof IntersectionObserver == "undefined") {
|
|
224
|
-
this.requestAd();
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this.observer = new IntersectionObserver(
|
|
228
|
-
(e) => {
|
|
229
|
-
var t;
|
|
230
|
-
e.some((r) => r.isIntersecting) && (this.requestAd(), (t = this.observer) == null || t.disconnect(), this.observer = null);
|
|
231
|
-
},
|
|
232
|
-
{ rootMargin: "200px 0px" }
|
|
233
|
-
), this.observer.observe(i);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
requestAd() {
|
|
237
|
-
const i = this.$refs.unit;
|
|
238
|
-
if (!i) return;
|
|
239
|
-
const e = _();
|
|
240
|
-
e.cmd.push(() => {
|
|
241
|
-
if (this.cancelled) return;
|
|
242
|
-
const t = i.clientWidth, r = i.clientHeight, n = t > 0 && r > 0 ? ["fluid", [t, r]] : "fluid", s = e.defineSlot(this.adUnitPath, n, this.admSlotId);
|
|
243
|
-
if (!s) return;
|
|
244
|
-
const a = e.pubads(), o = (c) => {
|
|
245
|
-
if (this.cancelled || c.slot !== s || !c.isEmpty || !this.hasAdSenseFallback) return;
|
|
246
|
-
const d = this.fallbackKey;
|
|
247
|
-
this.cleanupAdManager(), this.emptyAdmKey = d;
|
|
248
|
-
};
|
|
249
|
-
this.definedSlot = s, this.pubAdsService = a, this.slotRenderEnded = o, a.addEventListener("slotRenderEnded", o), s.addService(a), e.enableServices(), e.display(this.admSlotId);
|
|
250
|
-
});
|
|
251
|
-
},
|
|
252
|
-
cleanupAdManager() {
|
|
253
|
-
var n;
|
|
254
|
-
this.cancelled = !0, (n = this.observer) == null || n.disconnect(), this.observer = null;
|
|
255
|
-
const i = this.definedSlot, e = this.pubAdsService, t = this.slotRenderEnded;
|
|
256
|
-
if (this.definedSlot = null, this.pubAdsService = null, this.slotRenderEnded = null, !i && !t) return;
|
|
257
|
-
const r = _();
|
|
258
|
-
r.cmd.push(() => {
|
|
259
|
-
var s, a;
|
|
260
|
-
e && t && ((s = e.removeEventListener) == null || s.call(e, "slotRenderEnded", t)), i && ((a = r.destroySlots) == null || a.call(r, [i]));
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
render(i) {
|
|
265
|
-
return this.shouldUseAdSense ? i(U, {
|
|
266
|
-
props: {
|
|
267
|
-
publisherId: this.fallbackPublisherId,
|
|
268
|
-
slotId: this.adsSlotId,
|
|
269
|
-
title: this.title
|
|
270
|
-
}
|
|
271
|
-
}) : !this.adUnitPath || !this.admSlotId ? i() : i(
|
|
272
|
-
"div",
|
|
273
|
-
{
|
|
274
|
-
ref: "root",
|
|
275
|
-
staticClass: "article-ad-wrapper article-adm-wrapper",
|
|
276
|
-
attrs: {
|
|
277
|
-
"data-google-ad-manager": "true",
|
|
278
|
-
"data-ad-unit-path": this.adUnitPath
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
[
|
|
282
|
-
i("div", { staticClass: "article-ad-title" }, this.title),
|
|
283
|
-
i("div", {
|
|
284
|
-
ref: "unit",
|
|
285
|
-
staticClass: "article-ad-unit article-adm-unit",
|
|
286
|
-
attrs: { id: this.admSlotId }
|
|
287
|
-
})
|
|
288
|
-
]
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
}), rt = /* @__PURE__ */ new Set([
|
|
40
|
+
const H = /* @__PURE__ */ new Set([
|
|
292
41
|
"paragraph",
|
|
293
42
|
"heading",
|
|
294
43
|
"blockquote",
|
|
@@ -300,280 +49,280 @@ const et = N.extend({
|
|
|
300
49
|
"articleButton",
|
|
301
50
|
"table"
|
|
302
51
|
]);
|
|
303
|
-
function
|
|
304
|
-
return typeof
|
|
305
|
-
}
|
|
306
|
-
function R(
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
function
|
|
310
|
-
var
|
|
311
|
-
const
|
|
312
|
-
for (const [
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
else if (
|
|
316
|
-
|
|
317
|
-
else if (
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
} else
|
|
321
|
-
return Object.keys(
|
|
322
|
-
}
|
|
323
|
-
function y(
|
|
324
|
-
return Array.isArray(
|
|
325
|
-
}
|
|
326
|
-
function
|
|
327
|
-
return `${
|
|
328
|
-
}
|
|
329
|
-
function
|
|
330
|
-
return
|
|
331
|
-
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
function
|
|
336
|
-
return
|
|
337
|
-
}
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
function
|
|
342
|
-
if (!
|
|
52
|
+
function p(n) {
|
|
53
|
+
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
54
|
+
}
|
|
55
|
+
function R(n) {
|
|
56
|
+
return p(n) ? n : {};
|
|
57
|
+
}
|
|
58
|
+
function u(n, r, t, e) {
|
|
59
|
+
var f;
|
|
60
|
+
const i = p(t) ? t : {}, s = p(t) ? e : t, o = {}, a = {};
|
|
61
|
+
for (const [l, h] of Object.entries(i))
|
|
62
|
+
if (l === "class")
|
|
63
|
+
o.class = h;
|
|
64
|
+
else if (l === "style")
|
|
65
|
+
o.style = h;
|
|
66
|
+
else if (l.startsWith("on") && typeof h == "function") {
|
|
67
|
+
const $ = l.slice(2).toLowerCase();
|
|
68
|
+
o.on = A(m({}, (f = o.on) != null ? f : {}), { [$]: h });
|
|
69
|
+
} else h !== void 0 && h !== !1 && (a[l] = h);
|
|
70
|
+
return Object.keys(a).length > 0 && (o.attrs = a), n.createElement(r, o, s);
|
|
71
|
+
}
|
|
72
|
+
function y(n) {
|
|
73
|
+
return Array.isArray(n) ? n : [];
|
|
74
|
+
}
|
|
75
|
+
function g(n, ...r) {
|
|
76
|
+
return `${n}/${r.map(String).join("/")}`;
|
|
77
|
+
}
|
|
78
|
+
function S(n) {
|
|
79
|
+
return n === "left" || n === "center" || n === "right" || n === "justify";
|
|
80
|
+
}
|
|
81
|
+
function X(n) {
|
|
82
|
+
return n === "left" || n === "center" || n === "right";
|
|
83
|
+
}
|
|
84
|
+
function N(n) {
|
|
85
|
+
return n === "_blank" || n === "_self";
|
|
86
|
+
}
|
|
87
|
+
function b(n, r) {
|
|
88
|
+
n.reportIssue(r);
|
|
89
|
+
}
|
|
90
|
+
function J(n, r, t) {
|
|
91
|
+
if (!p(n) || n.type !== "text" || typeof n.text != "string" || !n.text)
|
|
343
92
|
return null;
|
|
344
|
-
let
|
|
345
|
-
const
|
|
346
|
-
for (let s = 0; s <
|
|
347
|
-
const
|
|
348
|
-
if (!
|
|
349
|
-
const
|
|
350
|
-
switch (
|
|
93
|
+
let e = n.text;
|
|
94
|
+
const i = y(n.marks);
|
|
95
|
+
for (let s = 0; s < i.length; s += 1) {
|
|
96
|
+
const o = i[s];
|
|
97
|
+
if (!p(o) || typeof o.type != "string") continue;
|
|
98
|
+
const a = g(r, "marks", s);
|
|
99
|
+
switch (o.type) {
|
|
351
100
|
case "bold":
|
|
352
|
-
|
|
101
|
+
e = u(t, "strong", { class: "acp-mark acp-mark--bold" }, [e]);
|
|
353
102
|
break;
|
|
354
103
|
case "italic":
|
|
355
|
-
|
|
104
|
+
e = u(t, "em", { class: "acp-mark acp-mark--italic" }, [e]);
|
|
356
105
|
break;
|
|
357
106
|
case "strike":
|
|
358
|
-
|
|
107
|
+
e = u(t, "s", { class: "acp-mark acp-mark--strike" }, [e]);
|
|
359
108
|
break;
|
|
360
109
|
case "underline":
|
|
361
|
-
|
|
110
|
+
e = u(t, "u", { class: "acp-mark acp-mark--underline" }, [e]);
|
|
362
111
|
break;
|
|
363
112
|
case "code":
|
|
364
|
-
|
|
113
|
+
e = u(t, "code", { class: "acp-mark acp-mark--code" }, [e]);
|
|
365
114
|
break;
|
|
366
115
|
case "link": {
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
369
|
-
|
|
116
|
+
const f = R(o.attrs), l = E(f.href, "link");
|
|
117
|
+
if (!l) {
|
|
118
|
+
b(t, {
|
|
370
119
|
code: "UNSAFE_URL",
|
|
371
|
-
path:
|
|
120
|
+
path: g(a, "attrs", "href"),
|
|
372
121
|
message: "The link URL is empty, malformed, or uses a disallowed protocol.",
|
|
373
122
|
nodeType: "link"
|
|
374
123
|
});
|
|
375
124
|
break;
|
|
376
125
|
}
|
|
377
|
-
const
|
|
378
|
-
|
|
126
|
+
const h = N(f.target) ? f.target : "_blank";
|
|
127
|
+
e = u(
|
|
379
128
|
t,
|
|
380
129
|
"a",
|
|
381
130
|
{
|
|
382
131
|
class: "acp-link",
|
|
383
|
-
href:
|
|
384
|
-
target:
|
|
385
|
-
rel: V(void 0,
|
|
132
|
+
href: l,
|
|
133
|
+
target: h,
|
|
134
|
+
rel: V(void 0, h)
|
|
386
135
|
},
|
|
387
|
-
[
|
|
136
|
+
[e]
|
|
388
137
|
);
|
|
389
138
|
break;
|
|
390
139
|
}
|
|
391
140
|
}
|
|
392
141
|
}
|
|
393
|
-
return
|
|
142
|
+
return e;
|
|
394
143
|
}
|
|
395
|
-
function
|
|
396
|
-
return y(
|
|
144
|
+
function B(n, r, t) {
|
|
145
|
+
return y(n).map((e, i) => J(e, g(r, i), t)).filter((e) => e !== null);
|
|
397
146
|
}
|
|
398
|
-
function
|
|
399
|
-
return !
|
|
147
|
+
function w(n, r, t) {
|
|
148
|
+
return !p(n) || n.type !== "listItem" ? null : u(
|
|
400
149
|
t,
|
|
401
150
|
"li",
|
|
402
151
|
{ class: "acp-list-item", "data-node-type": "listItem" },
|
|
403
|
-
|
|
152
|
+
T(n.content, g(r, "content"), t)
|
|
404
153
|
);
|
|
405
154
|
}
|
|
406
|
-
function
|
|
407
|
-
return !
|
|
155
|
+
function Q(n, r, t) {
|
|
156
|
+
return !p(n) || n.type !== "tableCell" ? null : u(
|
|
408
157
|
t,
|
|
409
158
|
"td",
|
|
410
159
|
{ class: "acp-table-cell", "data-node-type": "tableCell" },
|
|
411
|
-
|
|
160
|
+
T(n.content, g(r, "content"), t)
|
|
412
161
|
);
|
|
413
162
|
}
|
|
414
|
-
function
|
|
415
|
-
if (!
|
|
416
|
-
const
|
|
417
|
-
return
|
|
418
|
-
}
|
|
419
|
-
function
|
|
420
|
-
var
|
|
421
|
-
if (
|
|
422
|
-
const
|
|
423
|
-
href:
|
|
424
|
-
},
|
|
425
|
-
if (!
|
|
426
|
-
const t = E(
|
|
163
|
+
function Z(n, r, t) {
|
|
164
|
+
if (!p(n) || n.type !== "tableRow") return null;
|
|
165
|
+
const e = y(n.content).map((i, s) => Q(i, g(r, "content", s), t)).filter((i) => i !== null);
|
|
166
|
+
return u(t, "tr", { class: "acp-table-row", "data-node-type": "tableRow" }, e);
|
|
167
|
+
}
|
|
168
|
+
function tt(n) {
|
|
169
|
+
var i;
|
|
170
|
+
if (p(n) && n.target !== void 0 && !N(n.target) || p(n) && n.rel !== void 0 && typeof n.rel != "string") return null;
|
|
171
|
+
const r = typeof n == "string" ? { href: n } : p(n) && typeof n.href == "string" ? m(m({
|
|
172
|
+
href: n.href
|
|
173
|
+
}, N(n.target) ? { target: n.target } : {}), typeof n.rel == "string" ? { rel: n.rel } : {}) : null;
|
|
174
|
+
if (!r) return null;
|
|
175
|
+
const t = E(r.href, "link");
|
|
427
176
|
if (!t) return null;
|
|
428
|
-
const
|
|
177
|
+
const e = (i = r.target) != null ? i : "_self";
|
|
429
178
|
return {
|
|
430
179
|
href: t,
|
|
431
|
-
target:
|
|
432
|
-
rel: V(
|
|
180
|
+
target: e,
|
|
181
|
+
rel: V(r.rel, e)
|
|
433
182
|
};
|
|
434
183
|
}
|
|
435
|
-
function
|
|
436
|
-
var
|
|
437
|
-
const
|
|
438
|
-
if (typeof
|
|
184
|
+
function et(n, r, t) {
|
|
185
|
+
var f;
|
|
186
|
+
const e = R(n.attrs);
|
|
187
|
+
if (typeof e.id != "string" || !e.id || typeof e.text != "string" || !e.text || e.style !== "text" && e.style !== "button")
|
|
439
188
|
return null;
|
|
440
|
-
const
|
|
441
|
-
id:
|
|
442
|
-
}, typeof
|
|
443
|
-
text:
|
|
444
|
-
style:
|
|
445
|
-
})), s = Object.freeze({ type: "articleButton", attrs:
|
|
446
|
-
let
|
|
189
|
+
const i = Object.freeze(A(m({
|
|
190
|
+
id: e.id
|
|
191
|
+
}, typeof e.title == "string" ? { title: e.title } : {}), {
|
|
192
|
+
text: e.text,
|
|
193
|
+
style: e.style
|
|
194
|
+
})), s = Object.freeze({ type: "articleButton", attrs: i });
|
|
195
|
+
let o = null;
|
|
447
196
|
if (!t.resolveArticleButtonLink)
|
|
448
|
-
|
|
197
|
+
b(t, {
|
|
449
198
|
code: "LINK_RESOLUTION_FAILED",
|
|
450
|
-
path:
|
|
199
|
+
path: r,
|
|
451
200
|
message: "No resolveArticleButtonLink callback was provided for an articleButton node.",
|
|
452
201
|
nodeType: "articleButton"
|
|
453
202
|
});
|
|
454
203
|
else
|
|
455
204
|
try {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
code: typeof
|
|
459
|
-
path:
|
|
205
|
+
const l = t.resolveArticleButtonLink(i, s);
|
|
206
|
+
o = tt(l), o || b(t, {
|
|
207
|
+
code: typeof l == "string" || p(l) && typeof l.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
|
|
208
|
+
path: r,
|
|
460
209
|
message: "The articleButton link resolver returned no usable safe URL.",
|
|
461
210
|
nodeType: "articleButton"
|
|
462
211
|
});
|
|
463
|
-
} catch (
|
|
464
|
-
|
|
212
|
+
} catch (l) {
|
|
213
|
+
b(t, {
|
|
465
214
|
code: "LINK_RESOLUTION_FAILED",
|
|
466
|
-
path:
|
|
467
|
-
message: `The articleButton link resolver threw an error: ${
|
|
215
|
+
path: r,
|
|
216
|
+
message: `The articleButton link resolver threw an error: ${l instanceof Error ? l.message : String(l)}`,
|
|
468
217
|
nodeType: "articleButton"
|
|
469
218
|
});
|
|
470
219
|
}
|
|
471
|
-
const
|
|
472
|
-
return
|
|
220
|
+
const a = (f = o == null ? void 0 : o.href) != null ? f : null;
|
|
221
|
+
return u(
|
|
473
222
|
t,
|
|
474
223
|
"a",
|
|
475
224
|
{
|
|
476
225
|
class: [
|
|
477
226
|
"acp-article-button",
|
|
478
|
-
`acp-article-button--${
|
|
479
|
-
!
|
|
227
|
+
`acp-article-button--${i.style}`,
|
|
228
|
+
!a && "acp-article-button--disabled"
|
|
480
229
|
],
|
|
481
|
-
href:
|
|
482
|
-
target:
|
|
483
|
-
rel:
|
|
484
|
-
title:
|
|
230
|
+
href: a != null ? a : void 0,
|
|
231
|
+
target: o == null ? void 0 : o.target,
|
|
232
|
+
rel: o == null ? void 0 : o.rel,
|
|
233
|
+
title: i.title,
|
|
485
234
|
"data-node-type": "articleButton",
|
|
486
|
-
"data-article-button-id":
|
|
487
|
-
"data-article-button-style":
|
|
488
|
-
"aria-disabled":
|
|
489
|
-
onClick: (
|
|
490
|
-
|
|
235
|
+
"data-article-button-id": i.id,
|
|
236
|
+
"data-article-button-style": i.style,
|
|
237
|
+
"aria-disabled": a ? void 0 : "true",
|
|
238
|
+
onClick: (l) => {
|
|
239
|
+
a || l.preventDefault(), t.emitArticleButtonClick({ attrs: i, node: s, href: a, event: l });
|
|
491
240
|
}
|
|
492
241
|
},
|
|
493
|
-
|
|
242
|
+
i.text
|
|
494
243
|
);
|
|
495
244
|
}
|
|
496
|
-
function
|
|
497
|
-
if (!
|
|
245
|
+
function q(n, r, t) {
|
|
246
|
+
if (!p(n) || typeof n.type != "string" || !H.has(n.type))
|
|
498
247
|
return null;
|
|
499
|
-
const
|
|
500
|
-
switch (
|
|
248
|
+
const e = R(n.attrs);
|
|
249
|
+
switch (n.type) {
|
|
501
250
|
case "paragraph": {
|
|
502
|
-
const
|
|
503
|
-
return
|
|
251
|
+
const i = S(e.textAlign) ? e.textAlign : void 0;
|
|
252
|
+
return u(
|
|
504
253
|
t,
|
|
505
254
|
"p",
|
|
506
255
|
{
|
|
507
256
|
class: "acp-paragraph",
|
|
508
257
|
"data-node-type": "paragraph",
|
|
509
|
-
style:
|
|
258
|
+
style: i ? { textAlign: i } : void 0
|
|
510
259
|
},
|
|
511
|
-
|
|
260
|
+
B(n.content, g(r, "content"), t)
|
|
512
261
|
);
|
|
513
262
|
}
|
|
514
263
|
case "heading": {
|
|
515
|
-
const
|
|
516
|
-
return
|
|
264
|
+
const i = Number.isInteger(e.level) && Number(e.level) >= 1 && Number(e.level) <= 6 ? Number(e.level) : 1, s = S(e.textAlign) ? e.textAlign : void 0;
|
|
265
|
+
return u(
|
|
517
266
|
t,
|
|
518
|
-
`h${
|
|
267
|
+
`h${i}`,
|
|
519
268
|
{
|
|
520
|
-
class: ["acp-heading", `acp-heading--${
|
|
269
|
+
class: ["acp-heading", `acp-heading--${i}`],
|
|
521
270
|
"data-node-type": "heading",
|
|
522
271
|
style: s ? { textAlign: s } : void 0
|
|
523
272
|
},
|
|
524
|
-
|
|
273
|
+
B(n.content, g(r, "content"), t)
|
|
525
274
|
);
|
|
526
275
|
}
|
|
527
276
|
case "blockquote":
|
|
528
|
-
return
|
|
277
|
+
return u(
|
|
529
278
|
t,
|
|
530
279
|
"blockquote",
|
|
531
280
|
{ class: "acp-blockquote", "data-node-type": "blockquote" },
|
|
532
|
-
|
|
281
|
+
T(n.content, g(r, "content"), t)
|
|
533
282
|
);
|
|
534
283
|
case "bulletList": {
|
|
535
|
-
const
|
|
536
|
-
return
|
|
284
|
+
const i = y(n.content).map((s, o) => w(s, g(r, "content", o), t)).filter((s) => s !== null);
|
|
285
|
+
return u(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, i);
|
|
537
286
|
}
|
|
538
287
|
case "orderedList": {
|
|
539
|
-
const
|
|
540
|
-
return
|
|
288
|
+
const i = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = y(n.content).map((o, a) => w(o, g(r, "content", a), t)).filter((o) => o !== null);
|
|
289
|
+
return u(
|
|
541
290
|
t,
|
|
542
291
|
"ol",
|
|
543
292
|
{
|
|
544
293
|
class: "acp-list acp-list--ordered",
|
|
545
294
|
"data-node-type": "orderedList",
|
|
546
|
-
start:
|
|
295
|
+
start: i
|
|
547
296
|
},
|
|
548
297
|
s
|
|
549
298
|
);
|
|
550
299
|
}
|
|
551
300
|
case "codeBlock": {
|
|
552
|
-
const
|
|
553
|
-
return
|
|
301
|
+
const i = typeof e.language == "string" && e.language ? e.language : void 0, s = y(n.content).filter((o) => p(o) && o.type === "text" && typeof o.text == "string").map((o) => o.text).join("");
|
|
302
|
+
return u(
|
|
554
303
|
t,
|
|
555
304
|
"pre",
|
|
556
305
|
{
|
|
557
306
|
class: "acp-code-block",
|
|
558
307
|
"data-node-type": "codeBlock",
|
|
559
|
-
"data-language":
|
|
308
|
+
"data-language": i
|
|
560
309
|
},
|
|
561
|
-
[
|
|
310
|
+
[u(t, "code", { class: i ? `language-${i}` : void 0 }, s)]
|
|
562
311
|
);
|
|
563
312
|
}
|
|
564
313
|
case "horizontalRule":
|
|
565
|
-
return
|
|
314
|
+
return u(t, "hr", { class: "acp-horizontal-rule", "data-node-type": "horizontalRule" });
|
|
566
315
|
case "image": {
|
|
567
|
-
const
|
|
568
|
-
if (!
|
|
569
|
-
return
|
|
316
|
+
const i = E(W(e.src, t.imageBaseUrl), "image");
|
|
317
|
+
if (!i)
|
|
318
|
+
return b(t, {
|
|
570
319
|
code: "UNSAFE_URL",
|
|
571
|
-
path:
|
|
320
|
+
path: g(r, "attrs", "src"),
|
|
572
321
|
message: "The image URL is empty, malformed, or uses a disallowed protocol.",
|
|
573
322
|
nodeType: "image"
|
|
574
323
|
}), null;
|
|
575
|
-
const s =
|
|
576
|
-
return
|
|
324
|
+
const s = X(e.imageAlign) ? e.imageAlign : "center", o = Number.isInteger(e.width) && Number(e.width) >= 1 && Number(e.width) <= 1e4 ? Number(e.width) : void 0, a = Number.isInteger(e.height) && Number(e.height) >= 1 && Number(e.height) <= 1e4 ? Number(e.height) : void 0;
|
|
325
|
+
return u(
|
|
577
326
|
t,
|
|
578
327
|
"div",
|
|
579
328
|
{
|
|
@@ -582,94 +331,57 @@ function D(i, e, t) {
|
|
|
582
331
|
"data-image-align": s
|
|
583
332
|
},
|
|
584
333
|
[
|
|
585
|
-
|
|
334
|
+
u(t, "img", {
|
|
586
335
|
class: "acp-image__element",
|
|
587
|
-
src:
|
|
588
|
-
alt: typeof
|
|
589
|
-
title: typeof
|
|
590
|
-
width:
|
|
591
|
-
height:
|
|
336
|
+
src: i,
|
|
337
|
+
alt: typeof e.alt == "string" ? e.alt : "",
|
|
338
|
+
title: typeof e.title == "string" ? e.title : void 0,
|
|
339
|
+
width: o,
|
|
340
|
+
height: a,
|
|
592
341
|
"data-image-align": s
|
|
593
342
|
})
|
|
594
343
|
]
|
|
595
344
|
);
|
|
596
345
|
}
|
|
597
346
|
case "articleButton":
|
|
598
|
-
return
|
|
347
|
+
return et(n, r, t);
|
|
599
348
|
case "table": {
|
|
600
|
-
const
|
|
601
|
-
return
|
|
349
|
+
const i = y(n.content).map((s, o) => Z(s, g(r, "content", o), t)).filter((s) => s !== null);
|
|
350
|
+
return u(
|
|
602
351
|
t,
|
|
603
352
|
"div",
|
|
604
353
|
{ class: "acp-table-wrapper", "data-node-type": "table" },
|
|
605
|
-
[
|
|
354
|
+
[u(t, "table", { class: "acp-table" }, [u(t, "tbody", i)])]
|
|
606
355
|
);
|
|
607
356
|
}
|
|
608
357
|
}
|
|
609
358
|
return null;
|
|
610
359
|
}
|
|
611
|
-
function
|
|
612
|
-
return y(
|
|
360
|
+
function T(n, r, t) {
|
|
361
|
+
return y(n).map((e, i) => q(e, g(r, i), t)).filter((e) => e !== null);
|
|
613
362
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
slotId: t,
|
|
623
|
-
title: e.adTitle,
|
|
624
|
-
fallbackPublisherId: r !== void 0 ? e.adsPublisherId : void 0,
|
|
625
|
-
fallbackSlotId: r
|
|
626
|
-
}
|
|
627
|
-
}) : r !== void 0 && e.adsPublisherId ? e.createElement(U, {
|
|
628
|
-
key: `ads:${i.index}:${String(r)}`,
|
|
629
|
-
props: {
|
|
630
|
-
publisherId: e.adsPublisherId,
|
|
631
|
-
slotId: r,
|
|
632
|
-
title: e.adTitle
|
|
633
|
-
}
|
|
634
|
-
}) : null;
|
|
635
|
-
return e.createElement(
|
|
636
|
-
"div",
|
|
637
|
-
{
|
|
638
|
-
key: `/adConf/${i.index}`,
|
|
639
|
-
staticClass: "acp-ad-slot",
|
|
640
|
-
attrs: {
|
|
641
|
-
"data-node-type": "adSlot",
|
|
642
|
-
"data-ad-slot": "true",
|
|
643
|
-
"data-ad-index": i.index,
|
|
644
|
-
"data-ad-location": i.location,
|
|
645
|
-
"data-adm": t,
|
|
646
|
-
"data-ads": r
|
|
647
|
-
}
|
|
648
|
-
},
|
|
649
|
-
n ? [n] : []
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
function ct(i, e) {
|
|
653
|
-
const t = y(i.content), r = /* @__PURE__ */ new Map();
|
|
654
|
-
e.adSlots.forEach((s) => {
|
|
655
|
-
var o;
|
|
656
|
-
if (s.location > t.length) return;
|
|
657
|
-
const a = (o = r.get(s.location)) != null ? o : [];
|
|
658
|
-
a.push(s), r.set(s.location, a);
|
|
363
|
+
function rt(n, r) {
|
|
364
|
+
const t = y(n.content), e = /* @__PURE__ */ new Map();
|
|
365
|
+
r.customSlots.forEach((s) => {
|
|
366
|
+
var a;
|
|
367
|
+
if (!Number.isInteger(s.location) || s.location < 1 || s.location > t.length)
|
|
368
|
+
return;
|
|
369
|
+
const o = (a = e.get(s.location)) != null ? a : [];
|
|
370
|
+
o.push(s), e.set(s.location, o);
|
|
659
371
|
});
|
|
660
|
-
const
|
|
661
|
-
return t.forEach((s,
|
|
662
|
-
var
|
|
663
|
-
const
|
|
664
|
-
(
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
}),
|
|
668
|
-
}
|
|
669
|
-
function
|
|
670
|
-
return !
|
|
671
|
-
}
|
|
672
|
-
const
|
|
372
|
+
const i = [];
|
|
373
|
+
return t.forEach((s, o) => {
|
|
374
|
+
var l;
|
|
375
|
+
const a = o + 1;
|
|
376
|
+
(l = e.get(a)) == null || l.forEach((h) => i.push(...h.content));
|
|
377
|
+
const f = q(s, g("/content", o), r);
|
|
378
|
+
f && typeof f != "string" && i.push(f);
|
|
379
|
+
}), i;
|
|
380
|
+
}
|
|
381
|
+
function nt(n, r) {
|
|
382
|
+
return !p(n) || n.type !== "doc" ? [] : rt(n, r);
|
|
383
|
+
}
|
|
384
|
+
const it = /* @__PURE__ */ new Set([
|
|
673
385
|
"paragraph",
|
|
674
386
|
"heading",
|
|
675
387
|
"blockquote",
|
|
@@ -680,28 +392,28 @@ const ht = /* @__PURE__ */ new Set([
|
|
|
680
392
|
"image",
|
|
681
393
|
"articleButton",
|
|
682
394
|
"table"
|
|
683
|
-
]),
|
|
684
|
-
function
|
|
685
|
-
return typeof
|
|
395
|
+
]), st = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), ot = /* @__PURE__ */ new Set(["left", "center", "right"]), at = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
|
|
396
|
+
function k(n) {
|
|
397
|
+
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
686
398
|
}
|
|
687
|
-
function
|
|
688
|
-
return `${
|
|
399
|
+
function c(n, r) {
|
|
400
|
+
return `${n}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
|
|
689
401
|
}
|
|
690
|
-
function
|
|
691
|
-
let t =
|
|
692
|
-
for (const
|
|
402
|
+
function d(n, ...r) {
|
|
403
|
+
let t = n;
|
|
404
|
+
for (const e of r) t = c(t, e);
|
|
693
405
|
return t;
|
|
694
406
|
}
|
|
695
|
-
class
|
|
407
|
+
class ct {
|
|
696
408
|
constructor() {
|
|
697
|
-
|
|
409
|
+
P(this, "issues", []);
|
|
698
410
|
}
|
|
699
|
-
validate(
|
|
700
|
-
if (!
|
|
411
|
+
validate(r) {
|
|
412
|
+
if (!k(r))
|
|
701
413
|
return this.add("INVALID_ROOT", "", "The document must be an object."), this.result();
|
|
702
|
-
this.checkProperties(
|
|
703
|
-
const t = this.requireArray(
|
|
704
|
-
return t == null || t.forEach((
|
|
414
|
+
this.checkProperties(r, "", ["type", "content"], ["type", "content"]), r.type !== "doc" && this.add("INVALID_ROOT", "/type", 'The root node type must be "doc".');
|
|
415
|
+
const t = this.requireArray(r.content, "/content");
|
|
416
|
+
return t == null || t.forEach((e, i) => this.validateBlock(e, c("/content", i))), this.result();
|
|
705
417
|
}
|
|
706
418
|
result() {
|
|
707
419
|
return {
|
|
@@ -709,328 +421,304 @@ class yt {
|
|
|
709
421
|
issues: this.issues
|
|
710
422
|
};
|
|
711
423
|
}
|
|
712
|
-
add(
|
|
713
|
-
this.issues.push(m({ code:
|
|
424
|
+
add(r, t, e, i) {
|
|
425
|
+
this.issues.push(m({ code: r, path: t, message: e }, i ? { nodeType: i } : {}));
|
|
714
426
|
}
|
|
715
|
-
checkProperties(
|
|
716
|
-
const
|
|
717
|
-
for (const
|
|
718
|
-
|
|
427
|
+
checkProperties(r, t, e, i = [], s) {
|
|
428
|
+
const o = new Set(e);
|
|
429
|
+
for (const a of Object.keys(r))
|
|
430
|
+
o.has(a) || this.add(
|
|
719
431
|
"UNKNOWN_PROPERTY",
|
|
720
|
-
|
|
721
|
-
`Property "${
|
|
432
|
+
c(t, a),
|
|
433
|
+
`Property "${a}" is not allowed.`,
|
|
722
434
|
s
|
|
723
435
|
);
|
|
724
|
-
for (const
|
|
725
|
-
|
|
436
|
+
for (const a of i)
|
|
437
|
+
a in r || this.add(
|
|
726
438
|
"MISSING_PROPERTY",
|
|
727
|
-
|
|
728
|
-
`Required property "${
|
|
439
|
+
c(t, a),
|
|
440
|
+
`Required property "${a}" is missing.`,
|
|
729
441
|
s
|
|
730
442
|
);
|
|
731
443
|
}
|
|
732
|
-
requireArray(
|
|
733
|
-
return Array.isArray(
|
|
444
|
+
requireArray(r, t, e) {
|
|
445
|
+
return Array.isArray(r) ? r : (this.add("INVALID_TYPE", t, "Expected an array.", e), null);
|
|
734
446
|
}
|
|
735
|
-
optionalArray(
|
|
736
|
-
return
|
|
447
|
+
optionalArray(r, t, e) {
|
|
448
|
+
return r === void 0 ? [] : this.requireArray(r, t, e);
|
|
737
449
|
}
|
|
738
|
-
requireNonEmptyArray(
|
|
739
|
-
const
|
|
740
|
-
return
|
|
450
|
+
requireNonEmptyArray(r, t, e) {
|
|
451
|
+
const i = this.requireArray(r, t, e);
|
|
452
|
+
return i && i.length === 0 && this.add(
|
|
741
453
|
"INVALID_CONTENT",
|
|
742
454
|
t,
|
|
743
|
-
`Node "${
|
|
744
|
-
|
|
745
|
-
),
|
|
455
|
+
`Node "${e}" must contain at least one child.`,
|
|
456
|
+
e
|
|
457
|
+
), i;
|
|
746
458
|
}
|
|
747
|
-
requireRecord(
|
|
748
|
-
return
|
|
459
|
+
requireRecord(r, t, e) {
|
|
460
|
+
return k(r) ? r : (this.add("INVALID_TYPE", t, "Expected an object.", e), null);
|
|
749
461
|
}
|
|
750
|
-
optionalRecord(
|
|
751
|
-
return
|
|
462
|
+
optionalRecord(r, t, e) {
|
|
463
|
+
return r === void 0 ? {} : this.requireRecord(r, t, e);
|
|
752
464
|
}
|
|
753
|
-
requireString(
|
|
754
|
-
return typeof
|
|
465
|
+
requireString(r, t, e, i = {}) {
|
|
466
|
+
return typeof r != "string" ? (this.add("INVALID_TYPE", t, "Expected a string.", e), !1) : !i.allowEmpty && r.length === 0 ? (this.add("INVALID_VALUE", t, "The string must not be empty.", e), !1) : i.maxLength !== void 0 && r.length > i.maxLength ? (this.add(
|
|
755
467
|
"INVALID_VALUE",
|
|
756
468
|
t,
|
|
757
|
-
`The string must contain at most ${
|
|
758
|
-
|
|
469
|
+
`The string must contain at most ${i.maxLength} characters.`,
|
|
470
|
+
e
|
|
759
471
|
), !1) : !0;
|
|
760
472
|
}
|
|
761
|
-
optionalString(
|
|
762
|
-
|
|
473
|
+
optionalString(r, t, e, i = {}) {
|
|
474
|
+
r !== void 0 && this.requireString(r, t, e, i);
|
|
763
475
|
}
|
|
764
|
-
requireInteger(
|
|
765
|
-
if (!Number.isInteger(
|
|
766
|
-
return this.add("INVALID_TYPE", t, "Expected an integer.",
|
|
767
|
-
const
|
|
768
|
-
return
|
|
476
|
+
requireInteger(r, t, e, i, s) {
|
|
477
|
+
if (!Number.isInteger(r))
|
|
478
|
+
return this.add("INVALID_TYPE", t, "Expected an integer.", e), !1;
|
|
479
|
+
const o = r;
|
|
480
|
+
return i !== void 0 && o < i ? (this.add("INVALID_VALUE", t, `Value must be at least ${i}.`, e), !1) : s !== void 0 && o > s ? (this.add("INVALID_VALUE", t, `Value must be at most ${s}.`, e), !1) : !0;
|
|
769
481
|
}
|
|
770
|
-
validateBlock(
|
|
771
|
-
if (!
|
|
482
|
+
validateBlock(r, t) {
|
|
483
|
+
if (!k(r)) {
|
|
772
484
|
this.add("INVALID_TYPE", t, "A block node must be an object.");
|
|
773
485
|
return;
|
|
774
486
|
}
|
|
775
|
-
const
|
|
776
|
-
if (typeof
|
|
777
|
-
this.add("MISSING_PROPERTY",
|
|
487
|
+
const e = r.type;
|
|
488
|
+
if (typeof e != "string") {
|
|
489
|
+
this.add("MISSING_PROPERTY", c(t, "type"), "A block node requires a type.");
|
|
778
490
|
return;
|
|
779
491
|
}
|
|
780
|
-
if (!
|
|
781
|
-
this.add("UNKNOWN_NODE",
|
|
492
|
+
if (!it.has(e)) {
|
|
493
|
+
this.add("UNKNOWN_NODE", c(t, "type"), `Unknown block node "${e}".`, e);
|
|
782
494
|
return;
|
|
783
495
|
}
|
|
784
|
-
switch (
|
|
496
|
+
switch (e) {
|
|
785
497
|
case "paragraph":
|
|
786
|
-
this.validateParagraph(
|
|
498
|
+
this.validateParagraph(r, t);
|
|
787
499
|
break;
|
|
788
500
|
case "heading":
|
|
789
|
-
this.validateHeading(
|
|
501
|
+
this.validateHeading(r, t);
|
|
790
502
|
break;
|
|
791
503
|
case "blockquote":
|
|
792
|
-
this.validateBlockquote(
|
|
504
|
+
this.validateBlockquote(r, t);
|
|
793
505
|
break;
|
|
794
506
|
case "bulletList":
|
|
795
|
-
this.validateBulletList(
|
|
507
|
+
this.validateBulletList(r, t);
|
|
796
508
|
break;
|
|
797
509
|
case "orderedList":
|
|
798
|
-
this.validateOrderedList(
|
|
510
|
+
this.validateOrderedList(r, t);
|
|
799
511
|
break;
|
|
800
512
|
case "codeBlock":
|
|
801
|
-
this.validateCodeBlock(
|
|
513
|
+
this.validateCodeBlock(r, t);
|
|
802
514
|
break;
|
|
803
515
|
case "horizontalRule":
|
|
804
|
-
this.checkProperties(
|
|
516
|
+
this.checkProperties(r, t, ["type"], ["type"], e);
|
|
805
517
|
break;
|
|
806
518
|
case "image":
|
|
807
|
-
this.validateImage(
|
|
519
|
+
this.validateImage(r, t);
|
|
808
520
|
break;
|
|
809
521
|
case "articleButton":
|
|
810
|
-
this.validateArticleButton(
|
|
522
|
+
this.validateArticleButton(r, t);
|
|
811
523
|
break;
|
|
812
524
|
case "table":
|
|
813
|
-
this.validateTable(
|
|
525
|
+
this.validateTable(r, t);
|
|
814
526
|
break;
|
|
815
527
|
}
|
|
816
528
|
}
|
|
817
|
-
validateParagraph(
|
|
818
|
-
const
|
|
819
|
-
this.checkProperties(
|
|
529
|
+
validateParagraph(r, t) {
|
|
530
|
+
const e = "paragraph";
|
|
531
|
+
this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e), this.validateTextAlignAttrs(r.attrs, c(t, "attrs"), e, !1), this.validateInlineContent(r.content, c(t, "content"), e);
|
|
820
532
|
}
|
|
821
|
-
validateHeading(
|
|
822
|
-
const
|
|
823
|
-
this.checkProperties(
|
|
824
|
-
const
|
|
825
|
-
|
|
533
|
+
validateHeading(r, t) {
|
|
534
|
+
const e = "heading";
|
|
535
|
+
this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "attrs"], e);
|
|
536
|
+
const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
|
|
537
|
+
i && (this.checkProperties(i, c(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(i.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(i.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, c(t, "content"), e);
|
|
826
538
|
}
|
|
827
|
-
validateTextAlignAttrs(
|
|
828
|
-
const s =
|
|
829
|
-
s && (this.checkProperties(s, t, ["textAlign"], [],
|
|
539
|
+
validateTextAlignAttrs(r, t, e, i) {
|
|
540
|
+
const s = i ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, e);
|
|
541
|
+
s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, c(t, "textAlign"), e));
|
|
830
542
|
}
|
|
831
|
-
validateTextAlign(
|
|
832
|
-
|
|
543
|
+
validateTextAlign(r, t, e) {
|
|
544
|
+
r !== void 0 && (typeof r != "string" ? this.add("INVALID_TYPE", t, "Text alignment must be a string.", e) : st.has(r) || this.add("INVALID_VALUE", t, `Unsupported text alignment "${r}".`, e));
|
|
833
545
|
}
|
|
834
|
-
validateInlineContent(
|
|
835
|
-
const
|
|
836
|
-
|
|
546
|
+
validateInlineContent(r, t, e) {
|
|
547
|
+
const i = this.optionalArray(r, t, e);
|
|
548
|
+
i == null || i.forEach((s, o) => this.validateText(s, c(t, o), !0));
|
|
837
549
|
}
|
|
838
|
-
validateText(
|
|
839
|
-
if (!
|
|
550
|
+
validateText(r, t, e) {
|
|
551
|
+
if (!k(r)) {
|
|
840
552
|
this.add("INVALID_TYPE", t, "A text node must be an object.", "text");
|
|
841
553
|
return;
|
|
842
554
|
}
|
|
843
|
-
const
|
|
844
|
-
if (this.checkProperties(
|
|
845
|
-
const s = this.requireArray(
|
|
846
|
-
s == null || s.forEach((
|
|
555
|
+
const i = e ? ["type", "text", "marks"] : ["type", "text"];
|
|
556
|
+
if (this.checkProperties(r, t, i, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", c(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, c(t, "text"), "text"), e && r.marks !== void 0) {
|
|
557
|
+
const s = this.requireArray(r.marks, c(t, "marks"), "text");
|
|
558
|
+
s == null || s.forEach((o, a) => this.validateMark(o, d(t, "marks", a)));
|
|
847
559
|
}
|
|
848
560
|
}
|
|
849
|
-
validateMark(
|
|
850
|
-
if (!
|
|
561
|
+
validateMark(r, t) {
|
|
562
|
+
if (!k(r)) {
|
|
851
563
|
this.add("INVALID_TYPE", t, "A mark must be an object.");
|
|
852
564
|
return;
|
|
853
565
|
}
|
|
854
|
-
if (typeof
|
|
855
|
-
this.add("MISSING_PROPERTY",
|
|
566
|
+
if (typeof r.type != "string") {
|
|
567
|
+
this.add("MISSING_PROPERTY", c(t, "type"), "A mark requires a type.");
|
|
856
568
|
return;
|
|
857
569
|
}
|
|
858
|
-
if (
|
|
859
|
-
this.checkProperties(
|
|
570
|
+
if (at.has(r.type)) {
|
|
571
|
+
this.checkProperties(r, t, ["type"], ["type"], r.type);
|
|
860
572
|
return;
|
|
861
573
|
}
|
|
862
|
-
if (
|
|
863
|
-
this.add("UNKNOWN_MARK",
|
|
574
|
+
if (r.type !== "link") {
|
|
575
|
+
this.add("UNKNOWN_MARK", c(t, "type"), `Unknown mark "${r.type}".`, r.type);
|
|
864
576
|
return;
|
|
865
577
|
}
|
|
866
|
-
this.checkProperties(
|
|
867
|
-
const
|
|
868
|
-
|
|
578
|
+
this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], "link");
|
|
579
|
+
const e = this.requireRecord(r.attrs, c(t, "attrs"), "link");
|
|
580
|
+
e && (this.checkProperties(e, c(t, "attrs"), ["href", "target"], ["href"], "link"), this.requireString(e.href, d(t, "attrs", "href"), "link"), e.target !== void 0 && e.target !== "_blank" && e.target !== "_self" && this.add(
|
|
869
581
|
"INVALID_VALUE",
|
|
870
|
-
|
|
582
|
+
d(t, "attrs", "target"),
|
|
871
583
|
'Link target must be "_blank" or "_self".',
|
|
872
584
|
"link"
|
|
873
585
|
));
|
|
874
586
|
}
|
|
875
|
-
validateBlockquote(
|
|
876
|
-
const
|
|
877
|
-
this.checkProperties(
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
validateBulletList(
|
|
882
|
-
const
|
|
883
|
-
this.checkProperties(
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
validateOrderedList(
|
|
888
|
-
const
|
|
889
|
-
this.checkProperties(
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
const s = this.requireNonEmptyArray(
|
|
893
|
-
s == null || s.forEach((
|
|
894
|
-
}
|
|
895
|
-
validateListItem(
|
|
896
|
-
const
|
|
897
|
-
if (!
|
|
898
|
-
this.checkProperties(
|
|
899
|
-
const s = this.requireNonEmptyArray(
|
|
900
|
-
s == null || s.forEach((
|
|
901
|
-
}
|
|
902
|
-
validateCodeBlock(
|
|
903
|
-
const
|
|
904
|
-
this.checkProperties(
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
const s = this.optionalArray(
|
|
587
|
+
validateBlockquote(r, t) {
|
|
588
|
+
const e = "blockquote";
|
|
589
|
+
this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
|
|
590
|
+
const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
|
|
591
|
+
i == null || i.forEach((s, o) => this.validateBlock(s, d(t, "content", o)));
|
|
592
|
+
}
|
|
593
|
+
validateBulletList(r, t) {
|
|
594
|
+
const e = "bulletList";
|
|
595
|
+
this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
|
|
596
|
+
const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
|
|
597
|
+
i == null || i.forEach((s, o) => this.validateListItem(s, d(t, "content", o)));
|
|
598
|
+
}
|
|
599
|
+
validateOrderedList(r, t) {
|
|
600
|
+
const e = "orderedList";
|
|
601
|
+
this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "content"], e);
|
|
602
|
+
const i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
|
|
603
|
+
i && (this.checkProperties(i, c(t, "attrs"), ["start"], [], e), i.start !== void 0 && this.requireInteger(i.start, d(t, "attrs", "start"), e, 1));
|
|
604
|
+
const s = this.requireNonEmptyArray(r.content, c(t, "content"), e);
|
|
605
|
+
s == null || s.forEach((o, a) => this.validateListItem(o, d(t, "content", a)));
|
|
606
|
+
}
|
|
607
|
+
validateListItem(r, t) {
|
|
608
|
+
const e = "listItem", i = this.requireRecord(r, t, e);
|
|
609
|
+
if (!i) return;
|
|
610
|
+
this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a listItem node.", e);
|
|
611
|
+
const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
|
|
612
|
+
s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
|
|
613
|
+
}
|
|
614
|
+
validateCodeBlock(r, t) {
|
|
615
|
+
const e = "codeBlock";
|
|
616
|
+
this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e);
|
|
617
|
+
const i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
|
|
618
|
+
i && (this.checkProperties(i, c(t, "attrs"), ["language"], [], e), this.optionalString(i.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
|
|
619
|
+
const s = this.optionalArray(r.content, c(t, "content"), e);
|
|
908
620
|
s && (s.length > 1 && this.add(
|
|
909
621
|
"INVALID_CONTENT",
|
|
910
|
-
|
|
622
|
+
c(t, "content"),
|
|
911
623
|
"A codeBlock may contain at most one text node.",
|
|
912
|
-
|
|
624
|
+
e
|
|
913
625
|
), s.forEach(
|
|
914
|
-
(
|
|
626
|
+
(o, a) => this.validateText(o, d(t, "content", a), !1)
|
|
915
627
|
));
|
|
916
628
|
}
|
|
917
|
-
validateImage(
|
|
918
|
-
const
|
|
919
|
-
this.checkProperties(
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
629
|
+
validateImage(r, t) {
|
|
630
|
+
const e = "image";
|
|
631
|
+
this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
|
|
632
|
+
const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
|
|
633
|
+
i && (this.checkProperties(
|
|
634
|
+
i,
|
|
635
|
+
c(t, "attrs"),
|
|
924
636
|
["src", "alt", "title", "width", "height", "imageAlign"],
|
|
925
637
|
["src"],
|
|
926
|
-
|
|
927
|
-
), this.requireString(
|
|
638
|
+
e
|
|
639
|
+
), this.requireString(i.src, d(t, "attrs", "src"), e), this.optionalString(i.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(i.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), i.width !== void 0 && this.requireInteger(i.width, d(t, "attrs", "width"), e, 1, 1e4), i.height !== void 0 && this.requireInteger(i.height, d(t, "attrs", "height"), e, 1, 1e4), i.imageAlign !== void 0 && (typeof i.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : ot.has(i.imageAlign) || this.add(
|
|
928
640
|
"INVALID_VALUE",
|
|
929
|
-
|
|
930
|
-
`Unsupported image alignment "${
|
|
931
|
-
|
|
641
|
+
d(t, "attrs", "imageAlign"),
|
|
642
|
+
`Unsupported image alignment "${i.imageAlign}".`,
|
|
643
|
+
e
|
|
932
644
|
)));
|
|
933
645
|
}
|
|
934
|
-
validateArticleButton(
|
|
935
|
-
const
|
|
936
|
-
this.checkProperties(
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
646
|
+
validateArticleButton(r, t) {
|
|
647
|
+
const e = "articleButton";
|
|
648
|
+
this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
|
|
649
|
+
const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
|
|
650
|
+
i && (this.checkProperties(
|
|
651
|
+
i,
|
|
652
|
+
c(t, "attrs"),
|
|
941
653
|
["id", "title", "text", "style"],
|
|
942
654
|
["id", "text", "style"],
|
|
943
|
-
|
|
944
|
-
), this.requireString(
|
|
655
|
+
e
|
|
656
|
+
), this.requireString(i.id, d(t, "attrs", "id"), e), this.optionalString(i.title, d(t, "attrs", "title"), e), this.requireString(i.text, d(t, "attrs", "text"), e), i.style !== "text" && i.style !== "button" && this.add(
|
|
945
657
|
"INVALID_VALUE",
|
|
946
|
-
|
|
658
|
+
d(t, "attrs", "style"),
|
|
947
659
|
'Article button style must be "text" or "button".',
|
|
948
|
-
|
|
660
|
+
e
|
|
949
661
|
));
|
|
950
662
|
}
|
|
951
|
-
validateTable(
|
|
952
|
-
const
|
|
953
|
-
this.checkProperties(
|
|
954
|
-
const
|
|
955
|
-
if (!
|
|
663
|
+
validateTable(r, t) {
|
|
664
|
+
const e = "table";
|
|
665
|
+
this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
|
|
666
|
+
const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
|
|
667
|
+
if (!i) return;
|
|
956
668
|
let s = null;
|
|
957
|
-
|
|
958
|
-
const
|
|
959
|
-
|
|
669
|
+
i.forEach((o, a) => {
|
|
670
|
+
const f = d(t, "content", a), l = this.validateTableRow(o, f);
|
|
671
|
+
l !== null && (s === null ? s = l : l !== s && this.add(
|
|
960
672
|
"TABLE_COLUMN_MISMATCH",
|
|
961
|
-
|
|
962
|
-
`Expected ${s} table cells but received ${
|
|
673
|
+
c(f, "content"),
|
|
674
|
+
`Expected ${s} table cells but received ${l}.`,
|
|
963
675
|
"tableRow"
|
|
964
676
|
));
|
|
965
677
|
});
|
|
966
678
|
}
|
|
967
|
-
validateTableRow(
|
|
968
|
-
var
|
|
969
|
-
const
|
|
970
|
-
if (!
|
|
971
|
-
this.checkProperties(
|
|
972
|
-
const s = this.requireNonEmptyArray(
|
|
973
|
-
return s == null || s.forEach((
|
|
679
|
+
validateTableRow(r, t) {
|
|
680
|
+
var o;
|
|
681
|
+
const e = "tableRow", i = this.requireRecord(r, t, e);
|
|
682
|
+
if (!i) return null;
|
|
683
|
+
this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableRow node.", e);
|
|
684
|
+
const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
|
|
685
|
+
return s == null || s.forEach((a, f) => this.validateTableCell(a, d(t, "content", f))), (o = s == null ? void 0 : s.length) != null ? o : null;
|
|
974
686
|
}
|
|
975
|
-
validateTableCell(
|
|
976
|
-
const
|
|
977
|
-
if (!
|
|
978
|
-
this.checkProperties(
|
|
979
|
-
const s = this.requireNonEmptyArray(
|
|
980
|
-
s == null || s.forEach((
|
|
687
|
+
validateTableCell(r, t) {
|
|
688
|
+
const e = "tableCell", i = this.requireRecord(r, t, e);
|
|
689
|
+
if (!i) return;
|
|
690
|
+
this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableCell node.", e);
|
|
691
|
+
const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
|
|
692
|
+
s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
|
|
981
693
|
}
|
|
982
694
|
}
|
|
983
|
-
function
|
|
984
|
-
return new
|
|
695
|
+
function lt(n) {
|
|
696
|
+
return new ct().validate(n);
|
|
985
697
|
}
|
|
986
|
-
const
|
|
698
|
+
const O = Object.freeze({
|
|
987
699
|
version: 1,
|
|
988
|
-
validate:
|
|
989
|
-
render:
|
|
990
|
-
}),
|
|
991
|
-
function
|
|
992
|
-
return
|
|
700
|
+
validate: lt,
|
|
701
|
+
render: nt
|
|
702
|
+
}), C = /* @__PURE__ */ new Map([[O.version, O]]), bt = Object.freeze([...C.keys()]), U = 1;
|
|
703
|
+
function D(n) {
|
|
704
|
+
return C.get(n);
|
|
993
705
|
}
|
|
994
|
-
function
|
|
706
|
+
function dt(n, r = {}) {
|
|
995
707
|
var s;
|
|
996
|
-
const t = (s =
|
|
997
|
-
return
|
|
708
|
+
const t = (s = r.protocolVersion) != null ? s : U, e = D(t);
|
|
709
|
+
return e ? e.validate(n) : { valid: !1, issues: [{
|
|
998
710
|
code: "UNSUPPORTED_PROTOCOL",
|
|
999
711
|
path: "",
|
|
1000
712
|
message: `Article Content Protocol version ${t} is not supported.`
|
|
1001
713
|
}] };
|
|
1002
714
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
return { adm: [], ads: [], loc: [] };
|
|
715
|
+
function ut() {
|
|
716
|
+
return [];
|
|
1006
717
|
}
|
|
1007
|
-
function
|
|
1008
|
-
return {
|
|
718
|
+
function ft(n) {
|
|
719
|
+
return `${n.code}:${n.path}:${n.message}`;
|
|
1009
720
|
}
|
|
1010
|
-
|
|
1011
|
-
return `${i.code}:${i.path}:${i.message}`;
|
|
1012
|
-
}
|
|
1013
|
-
function St(i) {
|
|
1014
|
-
var o, c, d, f;
|
|
1015
|
-
const e = (c = (o = i.adm) == null ? void 0 : o.length) != null ? c : 0, t = (f = (d = i.ads) == null ? void 0 : d.length) != null ? f : 0, r = i.loc.length, n = e === 0 || e === r, s = t === 0 || t === r, a = e > 0 || t > 0;
|
|
1016
|
-
return r === 0 && !a || a && n && s ? null : {
|
|
1017
|
-
code: "AD_CONFIG_LENGTH_MISMATCH",
|
|
1018
|
-
path: "/adConf",
|
|
1019
|
-
message: `Each non-empty adConf.adm or adConf.ads array must have the same length as adConf.loc, and at least one ad array must contain values when loc is non-empty. Received adm length ${e}, ads length ${t}, and loc length ${r}.`
|
|
1020
|
-
};
|
|
1021
|
-
}
|
|
1022
|
-
function Lt(i, e) {
|
|
1023
|
-
return e ? [] : i.loc.map((t, r) => {
|
|
1024
|
-
var n, s;
|
|
1025
|
-
return {
|
|
1026
|
-
index: r + 1,
|
|
1027
|
-
location: t,
|
|
1028
|
-
adm: (n = i.adm) == null ? void 0 : n[r],
|
|
1029
|
-
ads: (s = i.ads) == null ? void 0 : s[r]
|
|
1030
|
-
};
|
|
1031
|
-
}).filter((t) => Number.isInteger(t.location) && t.location >= 1);
|
|
1032
|
-
}
|
|
1033
|
-
const Nt = N.extend({
|
|
721
|
+
const gt = Y.extend({
|
|
1034
722
|
name: "ArticleContentRenderer",
|
|
1035
723
|
props: {
|
|
1036
724
|
document: {
|
|
@@ -1039,23 +727,15 @@ const Nt = N.extend({
|
|
|
1039
727
|
},
|
|
1040
728
|
protocolVersion: {
|
|
1041
729
|
type: Number,
|
|
1042
|
-
default:
|
|
730
|
+
default: U
|
|
1043
731
|
},
|
|
1044
732
|
strict: {
|
|
1045
733
|
type: Boolean,
|
|
1046
734
|
default: !1
|
|
1047
735
|
},
|
|
1048
|
-
|
|
1049
|
-
type:
|
|
1050
|
-
default:
|
|
1051
|
-
},
|
|
1052
|
-
pubid: {
|
|
1053
|
-
type: Object,
|
|
1054
|
-
default: kt
|
|
1055
|
-
},
|
|
1056
|
-
adTitle: {
|
|
1057
|
-
type: String,
|
|
1058
|
-
default: At
|
|
736
|
+
customSlots: {
|
|
737
|
+
type: Array,
|
|
738
|
+
default: ut
|
|
1059
739
|
},
|
|
1060
740
|
imageBaseUrl: {
|
|
1061
741
|
type: String,
|
|
@@ -1068,27 +748,20 @@ const Nt = N.extend({
|
|
|
1068
748
|
},
|
|
1069
749
|
data() {
|
|
1070
750
|
return {
|
|
1071
|
-
reportedRuntimeIssues: /* @__PURE__ */ new Set()
|
|
1072
|
-
reportedAdConfigIssue: null
|
|
751
|
+
reportedRuntimeIssues: /* @__PURE__ */ new Set()
|
|
1073
752
|
};
|
|
1074
753
|
},
|
|
1075
754
|
computed: {
|
|
1076
755
|
validation() {
|
|
1077
|
-
return
|
|
1078
|
-
},
|
|
1079
|
-
adConfigIssue() {
|
|
1080
|
-
return St(this.adConf);
|
|
1081
|
-
},
|
|
1082
|
-
adSlots() {
|
|
1083
|
-
return Lt(this.adConf, this.adConfigIssue);
|
|
756
|
+
return dt(this.document, { protocolVersion: this.protocolVersion });
|
|
1084
757
|
}
|
|
1085
758
|
},
|
|
1086
759
|
watch: {
|
|
1087
760
|
validation: {
|
|
1088
761
|
immediate: !0,
|
|
1089
762
|
deep: !0,
|
|
1090
|
-
handler(
|
|
1091
|
-
|
|
763
|
+
handler(n) {
|
|
764
|
+
n.issues.forEach((r) => this.$emit("render-error", r));
|
|
1092
765
|
}
|
|
1093
766
|
},
|
|
1094
767
|
document: {
|
|
@@ -1105,29 +778,25 @@ const Nt = N.extend({
|
|
|
1105
778
|
},
|
|
1106
779
|
imageBaseUrl() {
|
|
1107
780
|
this.reportedRuntimeIssues.clear();
|
|
1108
|
-
},
|
|
1109
|
-
adConfigIssue: {
|
|
1110
|
-
immediate: !0,
|
|
1111
|
-
handler(i) {
|
|
1112
|
-
if (!i) {
|
|
1113
|
-
this.reportedAdConfigIssue = null;
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
const e = $(i);
|
|
1117
|
-
this.reportedAdConfigIssue !== e && (this.reportedAdConfigIssue = e, console.error("[ArticleContentRenderer] Invalid adConf:", i), this.$emit("render-error", i));
|
|
1118
|
-
}
|
|
1119
781
|
}
|
|
1120
782
|
},
|
|
1121
783
|
methods: {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
784
|
+
resolveCustomSlots() {
|
|
785
|
+
return this.customSlots.map((n) => {
|
|
786
|
+
var e, i, s, o;
|
|
787
|
+
const r = { id: n.id, location: n.location }, t = (o = (s = (i = (e = this.$scopedSlots)[n.id]) == null ? void 0 : i.call(e, r)) != null ? s : this.$slots[n.id]) != null ? o : [];
|
|
788
|
+
return A(m({}, n), { content: t });
|
|
789
|
+
});
|
|
790
|
+
},
|
|
791
|
+
reportRuntimeIssue(n) {
|
|
792
|
+
const r = ft(n);
|
|
793
|
+
this.reportedRuntimeIssues.has(r) || (this.reportedRuntimeIssues.add(r), this.$nextTick(() => this.$emit("render-error", n)));
|
|
1125
794
|
}
|
|
1126
795
|
},
|
|
1127
|
-
render(
|
|
1128
|
-
const
|
|
1129
|
-
if (!
|
|
1130
|
-
return
|
|
796
|
+
render(n) {
|
|
797
|
+
const r = D(this.protocolVersion);
|
|
798
|
+
if (!r || this.strict && !this.validation.valid)
|
|
799
|
+
return n(
|
|
1131
800
|
"div",
|
|
1132
801
|
{
|
|
1133
802
|
class: "acp-render-error",
|
|
@@ -1138,18 +807,15 @@ const Nt = N.extend({
|
|
|
1138
807
|
},
|
|
1139
808
|
"Invalid article content"
|
|
1140
809
|
);
|
|
1141
|
-
const t =
|
|
1142
|
-
createElement:
|
|
1143
|
-
|
|
1144
|
-
admPublisherId: this.pubid.adm,
|
|
1145
|
-
adsPublisherId: this.pubid.ads,
|
|
1146
|
-
adTitle: this.adTitle,
|
|
810
|
+
const t = r.render(this.document, {
|
|
811
|
+
createElement: n,
|
|
812
|
+
customSlots: this.resolveCustomSlots(),
|
|
1147
813
|
imageBaseUrl: this.imageBaseUrl,
|
|
1148
814
|
resolveArticleButtonLink: this.resolveArticleButtonLink,
|
|
1149
|
-
emitArticleButtonClick: (
|
|
815
|
+
emitArticleButtonClick: (e) => this.$emit("article-button-click", e),
|
|
1150
816
|
reportIssue: this.reportRuntimeIssue
|
|
1151
817
|
});
|
|
1152
|
-
return
|
|
818
|
+
return n(
|
|
1153
819
|
"div",
|
|
1154
820
|
{
|
|
1155
821
|
class: "acp-document",
|
|
@@ -1162,17 +828,17 @@ const Nt = N.extend({
|
|
|
1162
828
|
);
|
|
1163
829
|
}
|
|
1164
830
|
});
|
|
1165
|
-
function
|
|
1166
|
-
var
|
|
831
|
+
function pt(n, r, t, e, i, s, o, a) {
|
|
832
|
+
var f = typeof n == "function" ? n.options : n;
|
|
1167
833
|
return {
|
|
1168
|
-
exports:
|
|
1169
|
-
options:
|
|
834
|
+
exports: n,
|
|
835
|
+
options: f
|
|
1170
836
|
};
|
|
1171
837
|
}
|
|
1172
|
-
var
|
|
1173
|
-
|
|
838
|
+
var ht = /* @__PURE__ */ pt(
|
|
839
|
+
gt
|
|
1174
840
|
);
|
|
1175
|
-
const
|
|
841
|
+
const yt = ht.exports, At = Object.freeze({
|
|
1176
842
|
fileFormat: "article-content-protocol",
|
|
1177
843
|
fileFormatVersion: 1,
|
|
1178
844
|
mediaType: "application/vnd.article-content-protocol+json",
|
|
@@ -1199,17 +865,17 @@ const Pt = Rt.exports, Ct = Object.freeze({
|
|
|
1199
865
|
"text"
|
|
1200
866
|
]),
|
|
1201
867
|
markTypes: Object.freeze(["bold", "italic", "strike", "underline", "code", "link"])
|
|
1202
|
-
}),
|
|
1203
|
-
install(
|
|
1204
|
-
|
|
868
|
+
}), It = {
|
|
869
|
+
install(n) {
|
|
870
|
+
n.component("ArticleContentRenderer", yt);
|
|
1205
871
|
}
|
|
1206
872
|
};
|
|
1207
873
|
export {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
874
|
+
At as ARTICLE_CONTENT_PROTOCOL_V1,
|
|
875
|
+
yt as ArticleContentRenderer,
|
|
876
|
+
It as ArticleContentRendererPlugin,
|
|
877
|
+
U as CURRENT_PROTOCOL_VERSION,
|
|
878
|
+
bt as SUPPORTED_PROTOCOL_VERSIONS,
|
|
879
|
+
yt as default,
|
|
880
|
+
dt as validateArticleDocument
|
|
1215
881
|
};
|