${t.innerHTML}
${e.innerHTML}
${a.innerHTML}
`)}- ${n==null?void 0:n.map(a=>h`
- ${a.innerHTML} `)}
diff --git a/dist/banner/banner.js b/dist/banner/banner.js index 7069175a..5d5ea5d0 100644 --- a/dist/banner/banner.js +++ b/dist/banner/banner.js @@ -1,2 +1,2 @@ -import{T as p,j as L,x as h}from"../__chunks__/lit-element.CH8ciVnL.js";import{e as b,i as S,o as $}from"../__chunks__/unsafe-html.C_rT9aKG.js";import{i as y}from"../__chunks__/isSidekickLibraryActive.U-fJCMMj.js";const d=r=>{const t={dataLibraryId:void 0,innerHTML:"",href:""};if(!r)return t;t.innerHTML=r.innerHTML,r instanceof HTMLAnchorElement&&r.href!==""&&(t.href=r.href);const e=r.getAttribute("data-library-id");return y()&&e!==null&&(t.dataLibraryId=e),t};class A extends S{update(t,e){this.part=t;const i=e[0];return this.render(i)}render(t){var c;if(y()===!1)return p;const e=(c=this.part)==null?void 0:c.element,{dataLibraryId:i,href:n}=t;return i&&(e==null||e.setAttribute("data-library-id",i)),i&&(e==null||e.setAttribute("contenteditable","true")),n&&e instanceof HTMLAnchorElement&&(e==null||e.setAttribute("href",n)),p}}const o=b(A),T=r=>{const{headline:t,subline:e,texts:i,buttons:n,picture:c}=r;return h`
`};function M(r){const t=r.querySelector("img");t&&t.setAttribute("loading","eager");const e=r.querySelector("div"),i=r.children[1],n=d(e==null?void 0:e.querySelector("h1")),c=d(e==null?void 0:e.querySelector("h3")),a=e?[...e.querySelectorAll("p")].map(l=>d(l)):[],f=i?[...i.querySelectorAll("a")].map(l=>d(l)):[],s=(e==null?void 0:e.querySelector("picture"))||void 0,u=s==null?void 0:s.querySelector("img");u==null||u.setAttribute("loading","eager"),r.innerHTML="",r.style.removeProperty("display"),L(T({headline:n,subline:c,texts:a,buttons:f,picture:s}),r)}export{M as default}; +import{T as p,j as b,x as h}from"../__chunks__/lit-element.CH8ciVnL.js";import{e as S,i as m,o as $}from"../__chunks__/unsafe-html.C_rT9aKG.js";import{i as y}from"../__chunks__/isSidekickLibraryActive.U-fJCMMj.js";const d=t=>{const r={dataLibraryId:void 0,content:new DocumentFragment,href:""};if(!t)return r;r.content.append(...t.cloneNode(!0).childNodes),t instanceof HTMLAnchorElement&&t.href!==""&&(r.href=t.href);const e=t.getAttribute("data-library-id");return y()&&e!==null&&(r.dataLibraryId=e),r};class g extends m{update(r,e){this.part=r;const i=e[0];return this.render(i)}render(r){var c;if(y()===!1)return p;const e=(c=this.part)==null?void 0:c.element,{dataLibraryId:i,href:n}=r;return i&&(e==null||e.setAttribute("data-library-id",i)),i&&(e==null||e.setAttribute("contenteditable","true")),n&&e instanceof HTMLAnchorElement&&(e==null||e.setAttribute("href",n)),p}}const s=S(g),v=t=>{const{headline:r,subline:e,texts:i,buttons:n,picture:c}=t;return h` `};function k(t){const r=t.querySelector("img");r&&r.setAttribute("loading","eager");const e=t.querySelector("div"),i=t.children[1],n=d(e==null?void 0:e.querySelector("h1")),c=d(e==null?void 0:e.querySelector("h3")),a=e?[...e.querySelectorAll("p")].map(l=>d(l)):[],f=i?[...i.querySelectorAll("a")].map(l=>d(l)):[],o=(e==null?void 0:e.querySelector("picture"))||void 0,u=o==null?void 0:o.querySelector("img");u==null||u.setAttribute("loading","eager"),t.innerHTML="",t.style.removeProperty("display"),b(v({headline:n,subline:c,texts:a,buttons:f,picture:o}),t)}export{k as default}; //# sourceMappingURL=banner.js.map diff --git a/dist/banner/banner.js.map b/dist/banner/banner.js.map index 8ddfc094..27fa878e 100644 --- a/dist/banner/banner.js.map +++ b/dist/banner/banner.js.map @@ -1 +1 @@ -{"version":3,"file":"banner.js","sources":["../../src/helpers/sidekick/extractSidekickLibraryId.ts","../../src/directives/sidekickLibraryId.ts","../../src/blocks/banner/banner.ts"],"sourcesContent":["import { isSidekickLibraryActive } from './isSidekickLibraryActive.ts';\n\n/**\n * Represents the constructed Element.\n *\n * @interface ConstructedElement\n * @property {string} dataLibraryId - The data library id generated by the Sidekick Library Plugin.\n * @property {string} innerHTML - The innerHTML of a provided element.\n * @property {string} href - The href of a provided anchor element.\n */\nexport type SidekickElement = {\n dataLibraryId?: string;\n innerHTML: string;\n href?: string;\n};\n\n/**\n * Extracts the innerHTML, the href attribute (if defined) and\n * the data-library-id attribute (if the Sidekick Library Plugin is active) of a given HTML element.\n *\n * @param {HTMLElement | HTMLAnchorElement | null} element - The original HTMLElement or HTMLAnchorElement.\n * @returns {SidekickElement} - A constructed element object.\n *\n * @example\n * const button = extractSidekickLibraryId(document.querySelector('a'));\n * \n * ${button.text}\n * \n *\n * @remarks\n * The data-library-id is generated by the Sidekick Library Plugin\n * and is necessary to copy edited block content from the Sidekick Library.\n */\nexport const extractSidekickLibraryId = (element?: HTMLElement | HTMLAnchorElement | null): SidekickElement => {\n const constructedElement: SidekickElement = {\n dataLibraryId: undefined,\n innerHTML: '',\n href: '',\n };\n if (!element) return constructedElement;\n\n constructedElement.innerHTML = element.innerHTML;\n if (element instanceof HTMLAnchorElement && element.href !== '') {\n constructedElement.href = element.href;\n }\n\n const sidekickLibraryId: string | null = element.getAttribute('data-library-id');\n if (isSidekickLibraryActive() && sidekickLibraryId !== null) {\n constructedElement.dataLibraryId = sidekickLibraryId;\n }\n\n return constructedElement;\n};\n","import { Directive, directive } from 'lit/directive.js';\nimport { AttributePart, nothing } from 'lit';\nimport { SidekickElement } from 'Helpers/sidekick/extractSidekickLibraryId';\nimport { isSidekickLibraryActive } from 'Helpers/sidekick//isSidekickLibraryActive';\n\n/**\n * Represents a directive for managing a sidekick library id.\n * @extends Directive\n *\n * @example\n *${subline.innerHTML}
\n *${subline.innerHTML}
\n *