@duffcloudservices/cms 0.13.11 → 0.13.12
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.
|
@@ -1,3 +1,102 @@
|
|
|
1
|
+
// src/editor/bridgeTrust.ts
|
|
2
|
+
var trustedPortalOrigins = [];
|
|
3
|
+
function isTrustedParentOrigin(origin, selfOrigin) {
|
|
4
|
+
if (!origin || origin === "null") return false;
|
|
5
|
+
return origin === selfOrigin || trustedPortalOrigins.includes(origin);
|
|
6
|
+
}
|
|
7
|
+
function resolveParentOrigin(win = globalThis.window) {
|
|
8
|
+
const selfOrigin = win.location.origin;
|
|
9
|
+
let candidate = null;
|
|
10
|
+
try {
|
|
11
|
+
const origin = win.parent.location.origin;
|
|
12
|
+
if (typeof origin === "string" && origin !== "" && origin !== "null") candidate = origin;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
if (!candidate) {
|
|
16
|
+
const ancestors = win.location.ancestorOrigins;
|
|
17
|
+
if (ancestors && ancestors.length > 0) candidate = ancestors[0] ?? null;
|
|
18
|
+
}
|
|
19
|
+
if (!candidate && win.document.referrer) {
|
|
20
|
+
try {
|
|
21
|
+
candidate = new URL(win.document.referrer).origin;
|
|
22
|
+
} catch {
|
|
23
|
+
candidate = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return candidate && isTrustedParentOrigin(candidate, selfOrigin) ? candidate : null;
|
|
27
|
+
}
|
|
28
|
+
var INBOUND_LIMITS = {
|
|
29
|
+
key: 512,
|
|
30
|
+
text: 1e5,
|
|
31
|
+
html: 2e6,
|
|
32
|
+
src: 2e6,
|
|
33
|
+
alt: 1e4,
|
|
34
|
+
reviews: 500
|
|
35
|
+
};
|
|
36
|
+
function isRecord(v) {
|
|
37
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
38
|
+
}
|
|
39
|
+
function key(v) {
|
|
40
|
+
if (typeof v !== "string" || v.length === 0 || v.length > INBOUND_LIMITS.key) return null;
|
|
41
|
+
return /["\\\n\r]/.test(v) ? null : v;
|
|
42
|
+
}
|
|
43
|
+
function bounded(v, max) {
|
|
44
|
+
return typeof v === "string" && v.length <= max ? v : null;
|
|
45
|
+
}
|
|
46
|
+
function imageSrc(v) {
|
|
47
|
+
const s = bounded(v, INBOUND_LIMITS.src);
|
|
48
|
+
if (!s) return null;
|
|
49
|
+
const lower = s.trimStart().toLowerCase();
|
|
50
|
+
if (lower.startsWith("data:")) return lower.startsWith("data:image/") ? s : null;
|
|
51
|
+
if (lower.startsWith("blob:") || lower.startsWith("http://") || lower.startsWith("https://")) return s;
|
|
52
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(lower) ? null : s;
|
|
53
|
+
}
|
|
54
|
+
function parseInboundCommand(raw) {
|
|
55
|
+
if (!isRecord(raw) || typeof raw.type !== "string") return null;
|
|
56
|
+
const d = isRecord(raw.data) ? raw.data : {};
|
|
57
|
+
switch (raw.type) {
|
|
58
|
+
case "dcs:init-editor":
|
|
59
|
+
case "dcs:clear-highlight":
|
|
60
|
+
return { type: raw.type };
|
|
61
|
+
case "dcs:highlight-section": {
|
|
62
|
+
const sectionId = key(d.sectionId);
|
|
63
|
+
return sectionId ? { type: raw.type, sectionId } : null;
|
|
64
|
+
}
|
|
65
|
+
case "dcs:select-text-key": {
|
|
66
|
+
const k = key(d.key);
|
|
67
|
+
return k ? { type: raw.type, key: k } : null;
|
|
68
|
+
}
|
|
69
|
+
case "dcs:update-text": {
|
|
70
|
+
const k = key(d.key);
|
|
71
|
+
const value = bounded(d.value, INBOUND_LIMITS.text);
|
|
72
|
+
return k && value !== null ? { type: raw.type, key: k, value } : null;
|
|
73
|
+
}
|
|
74
|
+
case "dcs:set-mode":
|
|
75
|
+
return d.mode === "edit" || d.mode === "explore" ? { type: raw.type, mode: d.mode } : null;
|
|
76
|
+
case "dcs:set-editing-enabled":
|
|
77
|
+
return typeof d.enabled === "boolean" ? { type: raw.type, enabled: d.enabled } : null;
|
|
78
|
+
case "dcs:update-blog-content": {
|
|
79
|
+
const content = bounded(d.content, INBOUND_LIMITS.html);
|
|
80
|
+
return content !== null ? { type: raw.type, content } : null;
|
|
81
|
+
}
|
|
82
|
+
case "dcs:image-set": {
|
|
83
|
+
const k = key(d.key);
|
|
84
|
+
const src = imageSrc(d.src);
|
|
85
|
+
if (!k || !src) return null;
|
|
86
|
+
if (d.alt !== void 0 && d.alt !== null && bounded(d.alt, INBOUND_LIMITS.alt) === null) return null;
|
|
87
|
+
return { type: raw.type, key: k, src, alt: typeof d.alt === "string" ? d.alt : null };
|
|
88
|
+
}
|
|
89
|
+
case "dcs:update-reviews": {
|
|
90
|
+
const k = key(d.key);
|
|
91
|
+
if (!k) return null;
|
|
92
|
+
if (d.reviews === void 0 || d.reviews === null) return { type: raw.type, key: k, reviews: null };
|
|
93
|
+
return Array.isArray(d.reviews) && d.reviews.length <= INBOUND_LIMITS.reviews ? { type: raw.type, key: k, reviews: d.reviews } : null;
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
1
100
|
// src/editor/editorBridge.ts
|
|
2
101
|
function isInIframe() {
|
|
3
102
|
try {
|
|
@@ -8,7 +107,9 @@ function isInIframe() {
|
|
|
8
107
|
}
|
|
9
108
|
function postToParent(type, data) {
|
|
10
109
|
if (!isInIframe()) return;
|
|
11
|
-
|
|
110
|
+
const targetOrigin = resolveParentOrigin();
|
|
111
|
+
if (!targetOrigin) return;
|
|
112
|
+
globalThis.self.parent.postMessage({ type, data }, targetOrigin);
|
|
12
113
|
}
|
|
13
114
|
var TEXT_KEY_SELECTOR = "[data-text-key], [data-dcs-text]";
|
|
14
115
|
var REVIEW_SELECTOR = "[data-dcs-reviews]";
|
|
@@ -17,8 +118,8 @@ var EVENT_CONTENT_SELECTOR = '[data-event-content], [data-rich-content="event"]'
|
|
|
17
118
|
function getTextKey(el) {
|
|
18
119
|
return el.dataset.dcsText ?? el.dataset.textKey ?? "";
|
|
19
120
|
}
|
|
20
|
-
function textKeySelector(
|
|
21
|
-
return `[data-text-key="${
|
|
121
|
+
function textKeySelector(key2) {
|
|
122
|
+
return `[data-text-key="${key2}"], [data-dcs-text="${key2}"]`;
|
|
22
123
|
}
|
|
23
124
|
var editorActive = false;
|
|
24
125
|
var bridgeInitialized = false;
|
|
@@ -221,8 +322,8 @@ function applyEditorToElements() {
|
|
|
221
322
|
htmlEl.addEventListener("paste", handleTextKeyPaste);
|
|
222
323
|
htmlEl.addEventListener("mouseenter", () => {
|
|
223
324
|
if (activeEditElement) return;
|
|
224
|
-
const
|
|
225
|
-
if (isArrayTextKey(
|
|
325
|
+
const key2 = getTextKey(htmlEl);
|
|
326
|
+
if (isArrayTextKey(key2)) {
|
|
226
327
|
showArrayEditIcon(htmlEl);
|
|
227
328
|
} else {
|
|
228
329
|
showEditIcon(htmlEl);
|
|
@@ -383,11 +484,11 @@ function handleTextKeyDblClick(e) {
|
|
|
383
484
|
e.stopPropagation();
|
|
384
485
|
e.stopImmediatePropagation();
|
|
385
486
|
const el = e.currentTarget;
|
|
386
|
-
const
|
|
487
|
+
const key2 = getTextKey(el);
|
|
387
488
|
const sectionParent = el.closest("[data-section]");
|
|
388
489
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
389
|
-
postToParent("dcs:text-key-dblclick", { key, sectionId });
|
|
390
|
-
startInlineEdit(el,
|
|
490
|
+
postToParent("dcs:text-key-dblclick", { key: key2, sectionId });
|
|
491
|
+
startInlineEdit(el, key2, sectionId);
|
|
391
492
|
}
|
|
392
493
|
function supportsPlaintextOnly() {
|
|
393
494
|
try {
|
|
@@ -398,7 +499,7 @@ function supportsPlaintextOnly() {
|
|
|
398
499
|
return false;
|
|
399
500
|
}
|
|
400
501
|
}
|
|
401
|
-
function startInlineEdit(el,
|
|
502
|
+
function startInlineEdit(el, key2, sectionId) {
|
|
402
503
|
if (activeEditElement && activeEditElement !== el) {
|
|
403
504
|
finishEdit(activeEditElement);
|
|
404
505
|
}
|
|
@@ -412,7 +513,7 @@ function startInlineEdit(el, key, sectionId) {
|
|
|
412
513
|
range.selectNodeContents(el);
|
|
413
514
|
selection?.removeAllRanges();
|
|
414
515
|
selection?.addRange(range);
|
|
415
|
-
postToParent("dcs:text-key-click", { key, sectionId });
|
|
516
|
+
postToParent("dcs:text-key-click", { key: key2, sectionId });
|
|
416
517
|
}
|
|
417
518
|
function handleTextKeyBlur(e) {
|
|
418
519
|
const el = e.currentTarget;
|
|
@@ -467,7 +568,7 @@ function finishEdit(el) {
|
|
|
467
568
|
if (!el.hasAttribute("contenteditable")) return;
|
|
468
569
|
el.removeAttribute("contenteditable");
|
|
469
570
|
el.classList.remove("dcs-editing");
|
|
470
|
-
const
|
|
571
|
+
const key2 = getTextKey(el);
|
|
471
572
|
const sectionParent = el.closest("[data-section]");
|
|
472
573
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
473
574
|
const newValue = el.innerText.trim();
|
|
@@ -476,20 +577,20 @@ function finishEdit(el) {
|
|
|
476
577
|
activeEditElement = null;
|
|
477
578
|
}
|
|
478
579
|
if (newValue !== originalValue) {
|
|
479
|
-
postToParent("dcs:text-key-changed", { key, value: newValue, sectionId });
|
|
580
|
+
postToParent("dcs:text-key-changed", { key: key2, value: newValue, sectionId });
|
|
480
581
|
}
|
|
481
582
|
originalTextValues.delete(el);
|
|
482
583
|
}
|
|
483
|
-
function focusTextKey(
|
|
484
|
-
const el = document.querySelector(textKeySelector(
|
|
584
|
+
function focusTextKey(key2) {
|
|
585
|
+
const el = document.querySelector(textKeySelector(key2));
|
|
485
586
|
if (!el) return;
|
|
486
587
|
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
487
588
|
const sectionParent = el.closest("[data-section]");
|
|
488
589
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
489
|
-
startInlineEdit(el,
|
|
590
|
+
startInlineEdit(el, key2, sectionId);
|
|
490
591
|
}
|
|
491
|
-
function updateTextInPlace(
|
|
492
|
-
const el = document.querySelector(textKeySelector(
|
|
592
|
+
function updateTextInPlace(key2, value) {
|
|
593
|
+
const el = document.querySelector(textKeySelector(key2));
|
|
493
594
|
if (!el) return;
|
|
494
595
|
if (el === activeEditElement) return;
|
|
495
596
|
el.innerText = value;
|
|
@@ -507,11 +608,11 @@ function createEditIcon() {
|
|
|
507
608
|
e.stopImmediatePropagation();
|
|
508
609
|
if (!editIconTarget) return;
|
|
509
610
|
const el = editIconTarget;
|
|
510
|
-
const
|
|
611
|
+
const key2 = getTextKey(el);
|
|
511
612
|
const sectionParent = el.closest("[data-section]");
|
|
512
613
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
513
|
-
postToParent("dcs:text-key-dblclick", { key, sectionId });
|
|
514
|
-
startInlineEdit(el,
|
|
614
|
+
postToParent("dcs:text-key-dblclick", { key: key2, sectionId });
|
|
615
|
+
startInlineEdit(el, key2, sectionId);
|
|
515
616
|
removeEditIcon();
|
|
516
617
|
}, true);
|
|
517
618
|
icon.addEventListener("mouseleave", (e) => {
|
|
@@ -539,13 +640,13 @@ function removeEditIcon() {
|
|
|
539
640
|
}
|
|
540
641
|
editIconTarget = null;
|
|
541
642
|
}
|
|
542
|
-
function isArrayTextKey(
|
|
543
|
-
return /\.\d+\./.test(
|
|
643
|
+
function isArrayTextKey(key2) {
|
|
644
|
+
return /\.\d+\./.test(key2) || /\.\w+-\d+\./.test(key2);
|
|
544
645
|
}
|
|
545
|
-
function getArrayBaseKey(
|
|
546
|
-
const hyphenMatch =
|
|
646
|
+
function getArrayBaseKey(key2) {
|
|
647
|
+
const hyphenMatch = key2.match(/^(.+?)-\d+\./);
|
|
547
648
|
if (hyphenMatch) return hyphenMatch[1];
|
|
548
|
-
const numMatch =
|
|
649
|
+
const numMatch = key2.match(/^(.+?)\.\d+\./);
|
|
549
650
|
return numMatch ? numMatch[1] : null;
|
|
550
651
|
}
|
|
551
652
|
function createArrayEditIcon() {
|
|
@@ -561,8 +662,8 @@ function createArrayEditIcon() {
|
|
|
561
662
|
e.stopImmediatePropagation();
|
|
562
663
|
if (!arrayEditIconTarget) return;
|
|
563
664
|
const el = arrayEditIconTarget;
|
|
564
|
-
const
|
|
565
|
-
const arrayKey = getArrayBaseKey(
|
|
665
|
+
const key2 = getTextKey(el);
|
|
666
|
+
const arrayKey = getArrayBaseKey(key2);
|
|
566
667
|
if (!arrayKey) return;
|
|
567
668
|
const sectionParent = el.closest("[data-section]");
|
|
568
669
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
@@ -607,11 +708,11 @@ function createReviewEditIcon() {
|
|
|
607
708
|
e.stopImmediatePropagation();
|
|
608
709
|
if (!reviewEditIconTarget) return;
|
|
609
710
|
const el = reviewEditIconTarget;
|
|
610
|
-
const
|
|
611
|
-
if (!
|
|
711
|
+
const key2 = el.dataset.dcsReviews ?? "";
|
|
712
|
+
if (!key2) return;
|
|
612
713
|
const sectionParent = el.closest("[data-section]");
|
|
613
714
|
const sectionId = sectionParent?.dataset.section ?? null;
|
|
614
|
-
postToParent("dcs:reviews-click", { key, sectionId });
|
|
715
|
+
postToParent("dcs:reviews-click", { key: key2, sectionId });
|
|
615
716
|
removeReviewEditIcon();
|
|
616
717
|
}, true);
|
|
617
718
|
icon.addEventListener("mouseleave", (e) => {
|
|
@@ -718,9 +819,9 @@ function cssEscapeAttributeValue(value) {
|
|
|
718
819
|
if (typeof cssGlobal?.escape === "function") return cssGlobal.escape(value);
|
|
719
820
|
return value.replace(/[\\"]/g, "\\$&");
|
|
720
821
|
}
|
|
721
|
-
function applyImageOverride(
|
|
722
|
-
if (!
|
|
723
|
-
const escapedKey = cssEscapeAttributeValue(
|
|
822
|
+
function applyImageOverride(key2, src, alt) {
|
|
823
|
+
if (!key2) return 0;
|
|
824
|
+
const escapedKey = cssEscapeAttributeValue(key2);
|
|
724
825
|
const targets = /* @__PURE__ */ new Set();
|
|
725
826
|
document.querySelectorAll(`img[data-dcs-image-key="${escapedKey}"]`).forEach((img) => targets.add(img));
|
|
726
827
|
document.querySelectorAll(`[data-dcs-image-key="${escapedKey}"]`).forEach((el) => {
|
|
@@ -742,31 +843,31 @@ function applyImageOverride(key, src, alt) {
|
|
|
742
843
|
});
|
|
743
844
|
return targets.size;
|
|
744
845
|
}
|
|
745
|
-
function setImageOverride(
|
|
746
|
-
pendingImageOverrides.set(
|
|
747
|
-
applyImageOverride(
|
|
846
|
+
function setImageOverride(key2, src, alt) {
|
|
847
|
+
pendingImageOverrides.set(key2, { src, alt });
|
|
848
|
+
applyImageOverride(key2, src, alt);
|
|
748
849
|
scheduleRediscovery();
|
|
749
850
|
}
|
|
750
851
|
function applyPendingImageOverrides() {
|
|
751
|
-
for (const [
|
|
752
|
-
applyImageOverride(
|
|
852
|
+
for (const [key2, override] of pendingImageOverrides) {
|
|
853
|
+
applyImageOverride(key2, override.src, override.alt);
|
|
753
854
|
}
|
|
754
855
|
}
|
|
755
|
-
function recordPendingImageOverride(
|
|
756
|
-
pendingImageOverrides.set(
|
|
856
|
+
function recordPendingImageOverride(key2, src, alt) {
|
|
857
|
+
pendingImageOverrides.set(key2, { src, alt });
|
|
757
858
|
}
|
|
758
|
-
function revertImageOverrideIfImageKey(
|
|
759
|
-
if (!
|
|
760
|
-
const isPending = pendingImageOverrides.has(
|
|
761
|
-
const isImageElement = !isPending && !!document.querySelector(`[data-dcs-image-key="${cssEscapeAttributeValue(
|
|
859
|
+
function revertImageOverrideIfImageKey(key2, value) {
|
|
860
|
+
if (!key2) return false;
|
|
861
|
+
const isPending = pendingImageOverrides.has(key2);
|
|
862
|
+
const isImageElement = !isPending && !!document.querySelector(`[data-dcs-image-key="${cssEscapeAttributeValue(key2)}"]`);
|
|
762
863
|
if (!isPending && !isImageElement) return false;
|
|
763
|
-
pendingImageOverrides.delete(
|
|
764
|
-
if (value) applyImageOverride(
|
|
864
|
+
pendingImageOverrides.delete(key2);
|
|
865
|
+
if (value) applyImageOverride(key2, value);
|
|
765
866
|
return true;
|
|
766
867
|
}
|
|
767
|
-
function revertImageAltOverrideIfAltKey(
|
|
768
|
-
if (!
|
|
769
|
-
const escapedKey = cssEscapeAttributeValue(
|
|
868
|
+
function revertImageAltOverrideIfAltKey(key2, value) {
|
|
869
|
+
if (!key2) return false;
|
|
870
|
+
const escapedKey = cssEscapeAttributeValue(key2);
|
|
770
871
|
const hosts = document.querySelectorAll(`[data-dcs-image-alt-key="${escapedKey}"]`);
|
|
771
872
|
if (hosts.length === 0) return false;
|
|
772
873
|
hosts.forEach((host) => {
|
|
@@ -1128,89 +1229,67 @@ function injectEditorStyles() {
|
|
|
1128
1229
|
document.head.appendChild(style);
|
|
1129
1230
|
}
|
|
1130
1231
|
function handleMessage(event) {
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
if (!
|
|
1134
|
-
const
|
|
1135
|
-
|
|
1232
|
+
if (event.source !== globalThis.self.parent) return;
|
|
1233
|
+
const parentOrigin = resolveParentOrigin();
|
|
1234
|
+
if (!parentOrigin || event.origin !== parentOrigin) return;
|
|
1235
|
+
const cmd = parseInboundCommand(event.data);
|
|
1236
|
+
if (!cmd) return;
|
|
1237
|
+
switch (cmd.type) {
|
|
1136
1238
|
case "dcs:init-editor":
|
|
1137
1239
|
enableEditorMode();
|
|
1138
1240
|
break;
|
|
1139
1241
|
case "dcs:highlight-section":
|
|
1140
|
-
|
|
1141
|
-
showSectionHighlight(data.sectionId);
|
|
1142
|
-
}
|
|
1242
|
+
showSectionHighlight(cmd.sectionId);
|
|
1143
1243
|
break;
|
|
1144
1244
|
case "dcs:clear-highlight":
|
|
1145
1245
|
break;
|
|
1146
1246
|
case "dcs:select-text-key":
|
|
1147
|
-
|
|
1148
|
-
focusTextKey(data.key);
|
|
1149
|
-
}
|
|
1247
|
+
focusTextKey(cmd.key);
|
|
1150
1248
|
break;
|
|
1151
1249
|
case "dcs:update-text":
|
|
1152
|
-
if (
|
|
1153
|
-
|
|
1154
|
-
if (!revertImageOverrideIfImageKey(d.key, d.value) && !revertImageAltOverrideIfAltKey(d.key, d.value)) {
|
|
1155
|
-
updateTextInPlace(d.key, d.value);
|
|
1156
|
-
}
|
|
1250
|
+
if (!revertImageOverrideIfImageKey(cmd.key, cmd.value) && !revertImageAltOverrideIfAltKey(cmd.key, cmd.value)) {
|
|
1251
|
+
updateTextInPlace(cmd.key, cmd.value);
|
|
1157
1252
|
}
|
|
1158
1253
|
break;
|
|
1159
1254
|
case "dcs:set-mode":
|
|
1160
|
-
|
|
1161
|
-
setMode(data.mode);
|
|
1162
|
-
}
|
|
1255
|
+
setMode(cmd.mode);
|
|
1163
1256
|
break;
|
|
1164
1257
|
case "dcs:set-editing-enabled":
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
finishEdit(activeEditElement);
|
|
1174
|
-
}
|
|
1175
|
-
removeEditIcon();
|
|
1176
|
-
removeArrayEditIcon();
|
|
1177
|
-
removeReviewEditIcon();
|
|
1178
|
-
removeManagedFormEditIcon();
|
|
1179
|
-
removeAllImageEditIcons();
|
|
1180
|
-
document.querySelectorAll(".dcs-editable").forEach((el) => {
|
|
1181
|
-
el.classList.remove("dcs-editable");
|
|
1182
|
-
});
|
|
1258
|
+
editingEnabled = cmd.enabled;
|
|
1259
|
+
if (editingEnabled) {
|
|
1260
|
+
document.querySelectorAll(TEXT_KEY_SELECTOR).forEach((el) => {
|
|
1261
|
+
el.classList.add("dcs-editable");
|
|
1262
|
+
});
|
|
1263
|
+
} else {
|
|
1264
|
+
if (activeEditElement) {
|
|
1265
|
+
finishEdit(activeEditElement);
|
|
1183
1266
|
}
|
|
1267
|
+
removeEditIcon();
|
|
1268
|
+
removeArrayEditIcon();
|
|
1269
|
+
removeReviewEditIcon();
|
|
1270
|
+
removeManagedFormEditIcon();
|
|
1271
|
+
removeAllImageEditIcons();
|
|
1272
|
+
document.querySelectorAll(".dcs-editable").forEach((el) => {
|
|
1273
|
+
el.classList.remove("dcs-editable");
|
|
1274
|
+
});
|
|
1184
1275
|
}
|
|
1185
1276
|
break;
|
|
1186
|
-
case "dcs:update-blog-content":
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
scheduleRediscovery();
|
|
1192
|
-
}
|
|
1277
|
+
case "dcs:update-blog-content": {
|
|
1278
|
+
const contentEl = document.querySelector(BLOG_CONTENT_SELECTOR) ?? document.querySelector(EVENT_CONTENT_SELECTOR);
|
|
1279
|
+
if (contentEl) {
|
|
1280
|
+
contentEl.innerHTML = cmd.content;
|
|
1281
|
+
scheduleRediscovery();
|
|
1193
1282
|
}
|
|
1194
1283
|
break;
|
|
1284
|
+
}
|
|
1195
1285
|
case "dcs:image-set":
|
|
1196
|
-
|
|
1197
|
-
const d = data;
|
|
1198
|
-
if (typeof d.key === "string" && typeof d.src === "string") {
|
|
1199
|
-
setImageOverride(d.key, d.src, d.alt ?? null);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1286
|
+
setImageOverride(cmd.key, cmd.src, cmd.alt);
|
|
1202
1287
|
break;
|
|
1203
1288
|
case "dcs:update-reviews":
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
key: d.key,
|
|
1209
|
-
reviews: Array.isArray(d.reviews) ? d.reviews : null
|
|
1210
|
-
}
|
|
1211
|
-
}));
|
|
1212
|
-
scheduleRediscovery();
|
|
1213
|
-
}
|
|
1289
|
+
globalThis.dispatchEvent(new CustomEvent("dcs:reviews-updated", {
|
|
1290
|
+
detail: { key: cmd.key, reviews: cmd.reviews }
|
|
1291
|
+
}));
|
|
1292
|
+
scheduleRediscovery();
|
|
1214
1293
|
break;
|
|
1215
1294
|
}
|
|
1216
1295
|
}
|