payload-live-preview 2.2.2 → 2.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 +20 -17
- package/dist/adapters/astro/PreviewBoundary.astro +17 -4
- package/dist/adapters/astro/RichText.astro +13 -2
- package/dist/adapters/astro/index.d.ts +7 -7
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.d.ts +3 -3
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +2 -2
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +4 -4
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/nuxt/module.d.ts +1 -1
- package/dist/adapters/react/index.d.ts +2 -2
- package/dist/adapters/react/index.js +1 -1
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +5 -5
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +2 -2
- package/dist/adapters/vue/index.js +1 -1
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +15 -3
- package/dist/client.d.ts +15 -3
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.js.map +1 -1
- package/dist/codegen-cli.js +1 -1
- package/dist/codegen-cli.js.map +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.js +1 -1
- package/dist/codegen.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +139 -4
- package/dist/core.d.ts +139 -4
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +1 -1
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +2 -2
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/{document-session-Bkd181PV.d.ts → document-session-BuYuO3ae.d.ts} +27 -2
- package/dist/{fragment-endpoint-CLRpNQ3n.d.ts → fragment-endpoint-CQE_7MKi.d.ts} +1 -1
- package/dist/fragment.cjs +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.d.cts +6 -2
- package/dist/fragment.d.ts +6 -2
- package/dist/fragment.js +1 -1
- package/dist/fragment.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -12
- package/dist/index.d.ts +73 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.d.cts +16 -4
- package/dist/lexical.d.ts +16 -4
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/{locals-zz2gi9dj.d.ts → locals-CyzDKfKU.d.ts} +7 -1
- package/dist/{middleware-CI-UTf6R.d.ts → middleware-Dnt6u4nF.d.ts} +2 -2
- package/dist/{options-CnYybG51.d.ts → options-DTzhFVJ4.d.ts} +13 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +15 -9
- package/dist/plugin.d.ts +15 -9
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +8 -2
- package/dist/plugins.d.ts +8 -2
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{probe-D-IHg9dF.d.ts → probe-afwdYebU.d.ts} +6 -2
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +19 -1
- package/dist/server.d.ts +19 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/structural.d.cts +2 -0
- package/dist/structural.d.ts +2 -0
- package/package.json +2 -1
package/dist/lexical.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}var t=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function n(e){const n=function(){const e=function(){const e=globalThis,n=e[t];if(void 0!==n)return n;const r={};return e[t]=r,r}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;const n=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===n?null:n.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===n?e:n.createHTML(e)}var r=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),o=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,i=/^[\\/]{2}/,a=/[\t\n\r]/g,s=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,l=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(a,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(i.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return r.has(e.protocol)}catch{return o.test(t)&&!function(e){const t=l.exec(e.replace(s,""))?.[1];return void 0!==t&&!r.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(a,"");return/^https?:\/\//i.test(t)||i.test(t)}var c=/* @__PURE__ */new Set;function u(e){c.has(e)||(c.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var d=/* @__PURE__ */new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),p=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),f=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),m=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),h="aria-",g="data-",b={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},y=/* @__PURE__ */new Set(["href","src","cite","poster","action","formaction"]),$=class extends Error{name="SanitizerEnvironmentError"},v=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),w=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function setSanitizerDocument(t){e("set-sanitizer-document","`setSanitizerDocument()` is removed in 3.0: pass the document per call, `sanitizeHtml(html, { document })` or `lexicalToHtml(content, { document })` (ADR 0026)."),globalThis[w]=t??void 0}function sanitizeHtml(t,r){return function(t,r,o){const i=o?.document??H();if(!i)throw S();if(""===t)return"";const a=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(b))e.set(t,n);return{allowedTags:d,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(d);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of p)r.add(e);const o=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(b))o.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(o.get(t));for(const t of n)e.add(t);o.set(t,e)}return{allowedTags:r,attrByTag:o,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(o,void 0);let s=t;for(let e=0;e<6;e+=1){const e=i.createElement("template");e.innerHTML=n(s);const t=e.content;T(t,a);const r=k(t);if(r===s)return r;s=r}return e("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}(t,0,r)}function S(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new $("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function k(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw S();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw S();return t.innerHTML}function H(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[w];if(e)return e}if("undefined"!=typeof document)return document}function T(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?A(n,t):8===n.nodeType&&n.remove()}function A(e,t){const n=e.tagName.toLowerCase();if(!f.has(n)||t.allowFormControls&&p.has(n)){if(!t.allowedTags.has(n))return T(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const o=t.name.toLowerCase();if(o.startsWith("on")||"style"===o)e.removeAttribute(t.name);else if("is"!==o){if("strict"===n.mode){if(n.templateMode&&v.has(o))continue;if("id"===o||"name"===o||o.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===o&&!0!==r?.has(o)||u(o);continue}if(o.startsWith(g)){n.allowedData.has(o)||(e.removeAttribute(t.name),u(o));continue}if(m.has(o)||o.startsWith(h))continue}else if(m.has(o)||o.startsWith(h)||o.startsWith(g))continue;r?.has(o)?y.has(o)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):("srcset"!==o||C(t.value))&&("ping"!==o||t.value.trim().split(/\s+/u).every(isSafeUrl))||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),T(e,t)}else e.remove()}function C(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n)||!isSafeUrl(e))return!1}return!0}var _=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),L=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(L,e=>_[e])}var x=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),U=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(U,e=>x[e])}var z={BOLD:1,ITALIC:2,STRIKETHROUGH:4,UNDERLINE:8,CODE:16,SUBSCRIPT:32,SUPERSCRIPT:64,HIGHLIGHT:128},I={1:"left",2:"center",3:"right",4:"justify"},D=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function E(e){const t=e.format;return"string"==typeof t&&D.has(t)?t:"number"==typeof t?I[t]:void 0}function B(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function M(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function N(e){const t=E(e),n=B(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var j=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function R(e){return"object"==typeof e&&null!==e?e:void 0}function O(e){return R(e)}function W(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function P(e){return"string"==typeof e&&e.length>0?e:void 0}var q=' target="_blank" rel="noopener noreferrer"',F=(e,t)=>{const n=t.renderChildren(e.children??[]),r=R(e.fields),o=function(e,t){if("internal"===t?.linkType)return function(e){const t=R(R(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const r=t?.slug;return"string"==typeof r&&r.length>0?`/${r}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,r);if(void 0===o||!isSafeUrl(o))return n;const i="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(o)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return q;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?q:` target="${escapeHtml(r)}"`}(e,r,o)}${i}>${n}</a>`};function G(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=G(n);return t}function K(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Z(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var V=/* @__PURE__ */new Map;function J(e,t){V.set(e,t)}function Q(e){return V.get(e)}function X(){return[...V.keys()]}function Y(e,t,n,r){const o=R(e.fields)??{},i="string"==typeof o.blockType?o.blockType:"",a=W(i),s=""===a?r:`${r} ${r}--${a}`;if(""!==i){const e=Q(i)??Q(a);if(e)return e(o,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(i,s)}return`<${n} class="${s}"></${n}>`}function ee(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var te={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const n="number"==typeof e.format?e.format:0;return 0!==(n&z.CODE)&&(t=`<code>${t}</code>`),0!==(n&z.BOLD)&&(t=`<strong>${t}</strong>`),0!==(n&z.ITALIC)&&(t=`<em>${t}</em>`),0!==(n&z.UNDERLINE)&&(t=`<u>${t}</u>`),0!==(n&z.STRIKETHROUGH)&&(t=`<s>${t}</s>`),0!==(n&z.SUBSCRIPT)&&(t=`<sub>${t}</sub>`),0!==(n&z.SUPERSCRIPT)&&(t=`<sup>${t}</sup>`),0!==(n&z.HIGHLIGHT)&&(t=`<mark>${t}</mark>`),t},paragraph:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<p${M(e)}${N(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=j.has(n)?n:"h2",o=t.renderChildren(e.children??[]);return`<${r}${M(e)}${N(e)}>${o}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",o="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",i="check"===n?' role="list"':"",a=t.renderChildren(e.children??[]);return`<${r}${M(e)}${N(e)}${o}${i}>${a}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${N(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${M(e)}${N(e)}${r}>${n}</li>`},link:F,autolink:F,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${M(e)}${N(e)}>${n}</blockquote>`},code:e=>{const t=W("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(G(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${W(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=O(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${K(e)}><source src="${escapeHtmlAttribute(t)}"${Z(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Z(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${K(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=R(e.value),r=escapeHtml((n&&function(e){const t=P(e.title)??P(e.name)??P(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}(n))??`#${t}`),o=W(t),i=""===o?' class="lp-relation"':` class="lp-relation lp-relation--${o}"`,a=n?.url;return"string"==typeof a&&isSafeUrl(a)?`<a href="${escapeHtmlAttribute(a)}"${i}>${r}</a>`:`<span${i}>${r}</span>`},block:(e,t)=>Y(e,t,"div","lp-block"),inlineBlock:(e,t)=>Y(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${M(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${ee("colspan",e.colSpan)}${ee("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},ne=/* @__PURE__ */new Map;function re(e,t){ne.set(e,t)}function oe(e){return ne.get(e)??te[e]}var ie=!1;function ae(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function se(e,t={}){if(!ae(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ce(r,t);return n},resolveAlignment:E,resolveIndent:B,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==H()?sanitizeHtml(n):(function(){if(!ie){ie=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}function le(e){return ae(e)?e.root.children.map(ue).join("\n").trim():""}function ce(e,t){const n=oe(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function ue(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=ue(n);return t}function de(e,t){const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function pe(e,t){const n=de(e,t);return void 0!==n&&isSafeUrl(n)?n:void 0}function fe(e){const t=de(e,"caption");return void 0!==t?`<figcaption>${escapeHtml(t)}</figcaption>`:""}var me=(e,t)=>{const n=W(de(e,"importance")??"info"),r=de(e,"title"),o=de(e,"text"),i=function(e){const t=e.body??e.content;if("object"!=typeof t||null===t)return;const n=t.root;return n&&Array.isArray(n.children)?n.children:void 0}(e);return`<aside class="lp-block-callout lp-block-callout--${n}">${void 0!==r?`<strong>${escapeHtml(r)}</strong>`:""}${void 0!==i?t.renderChildren(i):void 0!==o?`<p>${escapeHtml(o)}</p>`:""}</aside>`},he=e=>{const t=O(e.image),n=t?.url??pe(e,"imageUrl");if(void 0===n||!isSafeUrl(n))return"";const r=t?.alt??de(e,"alt")??"";return`<figure class="lp-block-image"><img src="${escapeHtmlAttribute(n)}" alt="${escapeHtmlAttribute(r)}"${function(e){return`${"number"==typeof e?.width?` width="${String(e.width)}"`:""}${"number"==typeof e?.height?` height="${String(e.height)}"`:""}`}(t)} loading="lazy" decoding="async">${fe(e)}</figure>`},ge=e=>{const t=O(e.video),n=t?.url??pe(e,"videoUrl");if(void 0===n||!isSafeUrl(n))return"";const r=t?.mimeType??de(e,"mimeType"),o=void 0!==r?` type="${escapeHtmlAttribute(r)}"`:"",i=pe(e,"poster");return`<figure class="lp-block-video"><video controls${void 0!==i?` poster="${escapeHtmlAttribute(i)}"`:""}><source src="${escapeHtmlAttribute(n)}"${o}></video>${fe(e)}</figure>`},be=e=>{const t=de(e,"code")??de(e,"content");if(void 0===t)return"";const n=W(de(e,"language")??""),r=""===n?"":` class="language-${n}"`;return`<figure class="lp-block-code">${fe(e)}<pre><code${r}>${escapeHtml(t)}</code></pre></figure>`},ye=e=>{const t=de(e,"label")??de(e,"text"),n=pe(e,"href")??pe(e,"url");if(void 0===t||void 0===n)return"";const r=de(e,"lead"),o=void 0!==r?`<p class="lp-block-cta__lead">${escapeHtml(r)}</p>`:"",i=[$e(t,n,!0)],a=de(e,"secondaryLabel"),s=pe(e,"secondaryHref");return void 0!==a&&void 0!==s&&i.push($e(a,s,!1)),`<div class="lp-block-cta">${o}<div class="lp-block-cta__actions">${i.join("")}</div></div>`};function $e(e,t,n){const r=isExternalHttpUrl(t)?' target="_blank" rel="noopener noreferrer"':"";return`<a class="lp-block-cta__button lp-block-cta__button--${n?"primary":"secondary"}" href="${escapeHtmlAttribute(t)}"${r}>${escapeHtml(e)}</a>`}function ve(){J("callout",me),J("image-block",he),J("imageBlock",he),J("image",he),J("video-block",ge),J("videoBlock",ge),J("video",ge),J("code-block",be),J("codeBlock",be),J("code",be),J("cta-block",ye),J("ctaBlock",ye),J("cta",ye)}export{z as TextFormat,ae as isLexicalContent,se as lexicalToHtml,le as lexicalToPlainText,Q as lookupBlockRenderer,oe as lookupLexicalNode,J as registerBlockRenderer,ve as registerDefaultBlocks,re as registerLexicalNode,X as registeredBlockTypes,setSanitizerDocument};
|
|
1
|
+
function e(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}var t=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function n(e){const n=function(){const e=function(){const e=globalThis,n=e[t];if(void 0!==n)return n;const r={};return e[t]=r,r}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;const n=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===n?null:n.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===n?e:n.createHTML(e)}var r=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),o=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,i=/^[\\/]{2}/,a=/[\t\n\r]/g,l=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,s=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(a,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(i.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return r.has(e.protocol)}catch{return o.test(t)&&!function(e){const t=s.exec(e.replace(l,""))?.[1];return void 0!==t&&!r.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(a,"");return/^https?:\/\//i.test(t)||i.test(t)}var c=/* @__PURE__ */new Set;function u(e){c.has(e)||(c.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var d=/* @__PURE__ */new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),f=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),p=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),m=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),h="aria-",g="data-",y={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},b=/* @__PURE__ */new Set(["href","src","cite","poster","action","formaction"]),v=class extends Error{name="SanitizerEnvironmentError"},$=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),w=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function setSanitizerDocument(t){e("set-sanitizer-document","`setSanitizerDocument()` is removed in 3.0: pass the document per call, `sanitizeHtml(html, { document })` or `lexicalToHtml(content, { document })` (ADR 0026)."),globalThis[w]=t??void 0}function sanitizeHtml(t,r){return function(t,r,o){const i=o?.document??H();if(!i)throw S();if(""===t)return"";const a=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(y))e.set(t,n);return{allowedTags:d,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(d);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of f)r.add(e);const o=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(y))o.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(o.get(t));for(const t of n)e.add(t);o.set(t,e)}return{allowedTags:r,attrByTag:o,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(o,void 0);let l=t;for(let e=0;e<6;e+=1){const e=i.createElement("template");e.innerHTML=n(l);const t=e.content;T(t,a);const r=k(t);if(r===l)return r;l=r}return e("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}(t,0,r)}function S(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new v("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function k(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw S();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw S();return t.innerHTML}function H(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[w];if(e)return e}if("undefined"!=typeof document)return document}function T(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?A(n,t):8===n.nodeType&&n.remove()}function A(e,t){const n=e.tagName.toLowerCase();if(!p.has(n)||t.allowFormControls&&f.has(n)){if(!t.allowedTags.has(n))return T(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const o=t.name.toLowerCase();if(o.startsWith("on")||"style"===o)e.removeAttribute(t.name);else if("is"!==o){if("strict"===n.mode){if(n.templateMode&&$.has(o))continue;if("id"===o||"name"===o||o.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===o&&!0!==r?.has(o)||u(o);continue}if(o.startsWith(g)){n.allowedData.has(o)||(e.removeAttribute(t.name),u(o));continue}if(m.has(o)||o.startsWith(h))continue}else if(m.has(o)||o.startsWith(h)||o.startsWith(g))continue;r?.has(o)?b.has(o)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):("srcset"!==o||C(t.value))&&("ping"!==o||t.value.trim().split(/\s+/u).every(isSafeUrl))||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),T(e,t)}else e.remove()}function C(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n)||!isSafeUrl(e))return!1}return!0}var L=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),_=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(_,e=>L[e])}var U=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),x=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(x,e=>U[e])}var z={BOLD:1,ITALIC:2,STRIKETHROUGH:4,UNDERLINE:8,CODE:16,SUBSCRIPT:32,SUPERSCRIPT:64,HIGHLIGHT:128},I={1:"left",2:"center",3:"right",4:"justify"},D=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function E(e){const t=e.format;return"string"==typeof t&&D.has(t)?t:"number"==typeof t?I[t]:void 0}function B(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function M(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function N(e){const t=E(e),n=B(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var j=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function P(e){return"object"==typeof e&&null!==e?e:void 0}function R(e){return P(e)}function O(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function W(e){return"string"==typeof e&&e.length>0?e:void 0}var q=/\{(slug|id|collection|locale)\}/gu,F=' target="_blank" rel="noopener noreferrer"',G=(e,t)=>{const n=t.renderChildren(e.children??[]),r=P(e.fields),o=function(e,t,n){if("internal"===t?.linkType)return function(e,t){const n=P(e),r=P(n?.value),o=r?.url;if("string"==typeof o&&o.length>0)return o;const i=void 0===t.internalLinkPattern?void 0:function(e,t){const n=e=>{const n=t[e];return"string"==typeof n&&n.length>0||"number"==typeof n?encodeURIComponent(n):void 0};for(const[,t=""]of e.matchAll(q))if(void 0===n(t))return;return e.replace(q,(e,t)=>n(t)??"")}(t.internalLinkPattern,{slug:r?.slug,id:void 0===r?n?.value:r.id,collection:n?.relationTo,locale:t.locale});if(void 0!==i)return i;const a=r?.slug;return"string"==typeof a&&a.length>0?`/${a}`:void 0}(t.doc,n);const r=t?.url??e.url;return"string"==typeof r&&r.length>0?r:void 0}(e,r,t);if(void 0===o||!isSafeUrl(o))return n;const i="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(o)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return F;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?F:` target="${escapeHtml(r)}"`}(e,r,o)}${i}>${n}</a>`};function K(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=K(n);return t}function Z(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function V(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var J=/* @__PURE__ */new Map;function Q(e,t){J.set(e,t)}function X(e){return J.get(e)}function Y(){return[...J.keys()]}function ee(e,t,n,r){const o=P(e.fields)??{},i="string"==typeof o.blockType?o.blockType:"",a=O(i),l=""===a?r:`${r} ${r}--${a}`;if(""!==i){const e=X(i)??X(a);if(e)return e(o,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(i,l,o)}return`<${n} class="${l}"></${n}>`}function te(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var ne={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const n="number"==typeof e.format?e.format:0;return 0!==(n&z.CODE)&&(t=`<code>${t}</code>`),0!==(n&z.BOLD)&&(t=`<strong>${t}</strong>`),0!==(n&z.ITALIC)&&(t=`<em>${t}</em>`),0!==(n&z.UNDERLINE)&&(t=`<u>${t}</u>`),0!==(n&z.STRIKETHROUGH)&&(t=`<s>${t}</s>`),0!==(n&z.SUBSCRIPT)&&(t=`<sub>${t}</sub>`),0!==(n&z.SUPERSCRIPT)&&(t=`<sup>${t}</sup>`),0!==(n&z.HIGHLIGHT)&&(t=`<mark>${t}</mark>`),t},paragraph:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<p${M(e)}${N(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=j.has(n)?n:"h2",o=t.renderChildren(e.children??[]);return`<${r}${M(e)}${N(e)}>${o}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",o="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",i="check"===n?' role="list"':"",a=t.renderChildren(e.children??[]);return`<${r}${M(e)}${N(e)}${o}${i}>${a}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${N(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${M(e)}${N(e)}${r}>${n}</li>`},link:G,autolink:G,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${M(e)}${N(e)}>${n}</blockquote>`},code:e=>{const t=O("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(K(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${O(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=R(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${Z(e)}><source src="${escapeHtmlAttribute(t)}"${V(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${V(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${Z(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=P(e.value),r=escapeHtml((n&&function(e){const t=W(e.title)??W(e.name)??W(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}(n))??`#${t}`),o=O(t),i=""===o?' class="lp-relation"':` class="lp-relation lp-relation--${o}"`,a=n?.url;return"string"==typeof a&&isSafeUrl(a)?`<a href="${escapeHtmlAttribute(a)}"${i}>${r}</a>`:`<span${i}>${r}</span>`},block:(e,t)=>ee(e,t,"div","lp-block"),inlineBlock:(e,t)=>ee(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${M(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${te("colspan",e.colSpan)}${te("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},re=/* @__PURE__ */new Map;function oe(e,t){re.set(e,t)}function ie(e){return re.get(e)??ne[e]}var ae=!1;function le(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function se(e,t={}){if(!le(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ue(r,t);return n},resolveAlignment:E,resolveIndent:B,onUnrenderedBlock:e.onUnrenderedBlock,internalLinkPattern:e.internalLinkPattern,locale:e.locale};return t}(t).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==H()?sanitizeHtml(n):(function(){if(!ae){ae=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}function ce(e){return le(e)?e.root.children.map(de).join("\n").trim():""}function ue(e,t){const n=ie(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function de(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=de(n);return t}function fe(e,t){const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function pe(e,t){const n=fe(e,t);return void 0!==n&&isSafeUrl(n)?n:void 0}function me(e){const t=fe(e,"caption");return void 0!==t?`<figcaption>${escapeHtml(t)}</figcaption>`:""}var he=(e,t)=>{const n=O(fe(e,"importance")??"info"),r=fe(e,"title"),o=fe(e,"text"),i=function(e){const t=e.body??e.content;if("object"!=typeof t||null===t)return;const n=t.root;return n&&Array.isArray(n.children)?n.children:void 0}(e);return`<aside class="lp-block-callout lp-block-callout--${n}">${void 0!==r?`<strong>${escapeHtml(r)}</strong>`:""}${void 0!==i?t.renderChildren(i):void 0!==o?`<p>${escapeHtml(o)}</p>`:""}</aside>`},ge=e=>{const t=R(e.image),n=t?.url??pe(e,"imageUrl");if(void 0===n||!isSafeUrl(n))return"";const r=t?.alt??fe(e,"alt")??"";return`<figure class="lp-block-image"><img src="${escapeHtmlAttribute(n)}" alt="${escapeHtmlAttribute(r)}"${function(e){return`${"number"==typeof e?.width?` width="${String(e.width)}"`:""}${"number"==typeof e?.height?` height="${String(e.height)}"`:""}`}(t)} loading="lazy" decoding="async">${me(e)}</figure>`},ye=e=>{const t=R(e.video),n=t?.url??pe(e,"videoUrl");if(void 0===n||!isSafeUrl(n))return"";const r=t?.mimeType??fe(e,"mimeType"),o=void 0!==r?` type="${escapeHtmlAttribute(r)}"`:"",i=pe(e,"poster");return`<figure class="lp-block-video"><video controls${void 0!==i?` poster="${escapeHtmlAttribute(i)}"`:""}><source src="${escapeHtmlAttribute(n)}"${o}></video>${me(e)}</figure>`},be=e=>{const t=fe(e,"code")??fe(e,"content");if(void 0===t)return"";const n=O(fe(e,"language")??""),r=""===n?"":` class="language-${n}"`;return`<figure class="lp-block-code">${me(e)}<pre><code${r}>${escapeHtml(t)}</code></pre></figure>`},ve=e=>{const t=fe(e,"label")??fe(e,"text"),n=pe(e,"href")??pe(e,"url");if(void 0===t||void 0===n)return"";const r=fe(e,"lead"),o=void 0!==r?`<p class="lp-block-cta__lead">${escapeHtml(r)}</p>`:"",i=[$e(t,n,!0)],a=fe(e,"secondaryLabel"),l=pe(e,"secondaryHref");return void 0!==a&&void 0!==l&&i.push($e(a,l,!1)),`<div class="lp-block-cta">${o}<div class="lp-block-cta__actions">${i.join("")}</div></div>`};function $e(e,t,n){const r=isExternalHttpUrl(t)?' target="_blank" rel="noopener noreferrer"':"";return`<a class="lp-block-cta__button lp-block-cta__button--${n?"primary":"secondary"}" href="${escapeHtmlAttribute(t)}"${r}>${escapeHtml(e)}</a>`}function we(){Q("callout",he),Q("image-block",ge),Q("imageBlock",ge),Q("image",ge),Q("video-block",ye),Q("videoBlock",ye),Q("video",ye),Q("code-block",be),Q("codeBlock",be),Q("code",be),Q("cta-block",ve),Q("ctaBlock",ve),Q("cta",ve)}export{z as TextFormat,le as isLexicalContent,se as lexicalToHtml,ce as lexicalToPlainText,X as lookupBlockRenderer,ie as lookupLexicalNode,Q as registerBlockRenderer,we as registerDefaultBlocks,oe as registerLexicalNode,Y as registeredBlockTypes,setSanitizerDocument};
|
|
2
2
|
//# sourceMappingURL=lexical.js.map
|