3 * Lightweight frontend runtime for rendered CMS pages (no tree, no editor).
5(function (window, document) {
8 if (!window.dbx || !window.dbx.feature) {
9 console.error("[dbx][content] dbx core missing");
13 const dbx = window.dbx;
14 const LIB = "content";
16 function hasVisibleHeroText(el) {
17 if (!el) return false;
18 if (el.querySelector("img,video,iframe,object,embed,table,ul,ol,li,figure,[data-dbx]")) return true;
19 return String(el.textContent || "").replace(/\u00a0/g, " ").trim() !== "";
22 function cleanupEmptyHeroText(root) {
23 (root || document).querySelectorAll(".c-cms .cms-hero.has-hero .hero-text").forEach(el => {
24 if (!hasVisibleHeroText(el)) el.remove();
28 function init(el, cfg) {
29 if (!el || el.__dbxContentReady) return;
30 el.__dbxContentReady = true;
31 cleanupEmptyHeroText(el);
32 if (window.dbx && typeof dbx.log === "function") {
33 dbx.log("[content] init", cfg && cfg.id ? cfg.id : "");
40 const root = ctx || document;
41 cleanupEmptyHeroText(root);
42 root.querySelectorAll("[data-dbx]").forEach(el => {
43 if (el.__dbxContentReady) return;
44 const cfgList = dbx.parseData(el.getAttribute("data-dbx"));
45 const cfg = cfgList.find(item => item.lib === LIB);
46 if (cfg) init(el, cfg);
51 dbx.feature.register(LIB, {
55 ["css", "design", "c-content-frame.css"],
56 ["css", "design", "c-content.css"]
61 dbx.content.rescan(ctx);