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