@storyblok/react 4.5.3 → 4.5.4
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/dist/richtext.mjs +4 -4
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +185 -186
- package/package.json +5 -4
package/dist/richtext.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import o from "react";
|
|
2
|
-
import
|
|
2
|
+
import n from "./storyblok-component.mjs";
|
|
3
3
|
import { BlockTypes as m, richTextResolver as a } from "./storyblok-js.mjs";
|
|
4
4
|
function i(e) {
|
|
5
|
-
var t,
|
|
5
|
+
var t, s;
|
|
6
6
|
const r = (t = e == null ? void 0 : e.attrs) == null ? void 0 : t.body;
|
|
7
|
-
return o.createElement(
|
|
7
|
+
return o.createElement(n, {
|
|
8
8
|
blok: Array.isArray(r) ? r[0] : void 0,
|
|
9
|
-
key: (
|
|
9
|
+
key: (s = e.attrs) == null ? void 0 : s.id
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
function p(e) {
|
package/dist/storyblok-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=o,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{z.forEach(n=>n()),B=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var ne=Object.defineProperty,ie=(o,e,t)=>e in o?ne(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e,t)=>ie(o,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(o,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],n=0,i=!1;const l=async()=>{n++;const h=r.shift();if(h)try{const p=await o(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{n--,r.length>0&&l(),s=s.filter(p=>p!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),n<e&&l()});return a.abort=()=>{i=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),r.length=0},a}class C{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),g(this,"delay",e=>new Promise(t=>setTimeout(t,e))),g(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),g(this,"range",(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(n,i)=>i*s+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),g(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,s=new RegExp(r.source);return e&&s.test(e)?e.replace(r,n=>t[n]):e})}stringify(e,t,r){const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n];if(i==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,s.push(a)}return s.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",s="app.storyblokchina.cn",n="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return s;case"ap":return n;case"ca":return i;default:return t}}}const ce=function(o,e){const t={};for(const r in o){const s=o[r];e.includes(r)&&s!==null&&(t[r]=s)}return t},he=o=>o==="email",ue=()=>({singleTag:"hr"}),de=()=>({tag:"blockquote"}),pe=()=>({tag:"ul"}),ge=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),fe=()=>({singleTag:"br"}),me=o=>({tag:`h${o.attrs.level}`}),ye=o=>({singleTag:[{tag:"img",attrs:ce(o.attrs,["src","alt","title"])}]}),be=()=>({tag:"li"}),ke=()=>({tag:"ol"}),ve=()=>({tag:"p"}),$e=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),we=()=>({tag:"b"}),Te=()=>({tag:"s"}),Re=()=>({tag:"u"}),_e=()=>({tag:"strong"}),Ee=()=>({tag:"code"}),Se=()=>({tag:"i"}),je=o=>{if(!o.attrs)return{tag:""};const e=new C().escapeHTML,t={...o.attrs},{linktype:r="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),he(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ie=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Ae=()=>({tag:"sub"}),Oe=()=>({tag:"sup"}),xe=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Le=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ce=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},V={nodes:{horizontal_rule:ue,blockquote:de,bullet_list:pe,code_block:ge,hard_break:fe,heading:me,image:ye,list_item:be,ordered_list:ke,paragraph:ve,emoji:$e},marks:{bold:we,strike:Te,underline:Re,strong:_e,code:Ee,italic:Se,link:je,styled:Ie,subscript:Ae,superscript:Oe,anchor:xe,highlight:Le,textStyle:Ce}},Pe=function(o){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,r=new RegExp(t.source);return o&&r.test(o)?o.replace(t,s=>e[s]):o};let D=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=V),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},r=!0){if(!D&&r&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),D=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(n=>{s+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
|
|
2
2
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
3
3
|
ISbRichtext:
|
|
4
4
|
content?: ISbRichtext[]
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
type: 'doc'
|
|
24
|
-
}`),""}optimizeImages(e,t){let r=0,s=0,o="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(o+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(o+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(o+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(o+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i=`/filters${i}`))),o.length>0&&(e=e.replace(/<img/g,`<img ${o.trim()}`));const l=r>0||s>0||i.length>0?`${r}x${s}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var h,d;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(w=>{if(typeof w=="number")return`//${p}/m/${w}x0${i} ${w}w`;if(typeof w=="object"&&w.length===2){let E=0,j=0;return typeof w[0]=="number"&&(E=w[0]),typeof w[1]=="number"&&(j=w[1]),`//${p}/m/${E}x${j}${i} ${E}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(w=>w).join(", ")};let $="";return b.srcset&&($+=`srcset="${b.srcset}" `),b.sizes&&($+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${$.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(Pe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs){for(const o in r.attrs)if(Object.prototype.hasOwnProperty.call(r.attrs,o)){const i=r.attrs[o];i!==null&&(s+=` ${o}="${i}"`)}}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class Ne{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const a=new C;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:i}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};s(o)})}}const q="SB-Agent",N={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const S={};class He{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"helpers"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache");let r=e.endpoint||t;if(!r){const i=new C().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{s.set(i,l)}),s.has(q)||(s.set(q,N.defaultAgentName),s.set(N.defaultAgentVersion,N.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),e.richTextSchema?this.richTextResolver=new A(e.richTextSchema):this.richTextResolver=new A,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=le(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new C,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ne({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,r,s,o){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,s));return this.cacheResponse(e,i,void 0,o)}get(e,t,r){t||(t={});const s=`/${e}`,o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t,r,s){const o=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1),a=1,h=await this.makeRequest(i,t,o,a,s),d=h.total?Math.ceil(h.total/o):1,p=await this.helpers.asyncMap(this.helpers.range(a,d),b=>this.makeRequest(i,t,o,b+1,s));return this.helpers.flatMap([h,...p],b=>Object.values(b.data[l]))}post(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t,r))}put(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t,r))}delete(e,t,r){t||(t={});const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t,r))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,i="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,a)=>s(l,`${i}[${a}]`));else if(typeof o=="object")for(const l in o){const a=i?`${i}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,i=[],l=50;for(let a=0;a<o;a+=l){const h=Math.min(o,a+l);i.push(e.link_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,i=[],l=50;for(let a=0;a<o;a+=l){const h=Math.min(o,a+l);i.push(e.rel_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)})}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let i=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],i,r);e.story?this.iterateTree(e.story,i,r):e.stories.forEach(l=>{this.iterateTree(l,i,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var h;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return a(d);let p={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),p.data.story||p.data.stories){const $=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${$}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(o,p);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(b&&S[t.token]&&S[t.token]!==p.data.cv&&await this.flushCache(),S[t.token]=p.data.cv),l(p)}catch(d){if(d.response&&d.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(d)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(x[e])},getAll(){return Promise.resolve(x)},set(e,t){return x[e]=t,Promise.resolve(void 0)},flush(){return x={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}}const Me=(n={})=>{const{apiOptions:e}=n;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new He(e)}},Ue=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Be(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function i(a,h,d,p,b){typeof a!="number"||a<=h||a>=d?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`):b.push(`${p}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:d,fill:p,format:b,grayscale:$,quality:w,rotate:E}=a||{};h&&i(h,0,100,"blur",o),w&&i(w,0,100,"quality",o),d&&i(d,0,100,"brightness",o),p&&o.push(`fill(${p})`),$&&o.push("grayscale()"),E&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${E})`),b&&["webp","png","jpeg"].includes(b)&&o.push(`format(${b})`)}e.srcset&&(s.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${n}/m/${a}x0/${o.length>0?`filters:${o.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,d]=a;return`${n}/m/${h}x${d}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var k=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(k||{}),_=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))(_||{}),U=(n=>(n.TEXT="text",n))(U||{}),I=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(I||{});const ze=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),qe=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function Fe(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const L=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function F(n,e={},t){const r=De(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(ze.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function Ge(n={}){let e=0;const{renderFn:t=F,textFn:r=Fe,resolvers:s={},optimizeImages:o=!1,keyedResolvers:i=!1}=n,l=t!==F,a=c=>u=>{const f=u.attrs||{};return i&&(f.key=`${c}-${e}`),t(c,f,u.children||null)},h=c=>{const{src:u,alt:f,title:y,srcset:R,sizes:v}=c.attrs||{};let m=u,T={};if(o){const{src:se,attrs:ne}=Be(u,o);m=se,T=ne}i&&(T={...T,key:`img-${e}`});const re={src:m,alt:f,title:y,srcset:R,sizes:v,...T};return t("img",L(re))},d=c=>{const{level:u,...f}=c.attrs||{},y={...f};return i&&(y.key=`h${u}-${e}`),t(`h${u}`,y,c.children)},p=c=>{var u,f,y,R;const v=t("img",{src:(u=c.attrs)==null?void 0:u.fallbackImage,alt:(f=c.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}),m={"data-type":"emoji","data-name":(y=c.attrs)==null?void 0:y.name,"data-emoji":(R=c.attrs)==null?void 0:R.emoji};return i&&(m.key=`emoji-${e}`),t("span",m,v)},b=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),$=(c,u=!1)=>({text:f,attrs:y})=>{const{class:R,id:v,...m}=y||{},T=u?{class:R,id:v,style:qe(m)||void 0}:y||{};return i&&(T.key=`${c}-${e}`),t(c,L(T),f)},w=c=>P(c),E=c=>{const{marks:u,...f}=c;return"text"in c?u?u.reduce((y,R)=>w({...R,text:y}),w({...f,children:f.children})):r(f.text):""},j=c=>{const{linktype:u,href:f,anchor:y,...R}=c.attrs||{};let v="";switch(u){case I.ASSET:case I.URL:v=f;break;case I.EMAIL:v=`mailto:${f}`;break;case I.STORY:v=f,y&&(v=`${v}#${y}`);break;default:v=f;break}const m={...R};return v&&(m.href=v),i&&(m.key=`a-${e}`),t("a",m,c.text)},W=c=>{var u,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(u=c==null?void 0:c.attrs)==null?void 0:u.body[0],id:(f=c.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},X=c=>{const u={};return i&&(u.key=`table-${e}`),t("table",u,c.children)},Q=c=>{const u={};return i&&(u.key=`tr-${e}`),t("tr",u,c.children)},Z=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...v}=c.attrs||{},m={...v};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`td-${e}`),t("td",L(m),c.children)},ee=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...v}=c.attrs||{},m={...v};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`th-${e}`),t("th",L(m),c.children)},te=new Map([[k.DOCUMENT,a("")],[k.HEADING,d],[k.PARAGRAPH,a("p")],[k.UL_LIST,a("ul")],[k.OL_LIST,a("ol")],[k.LIST_ITEM,a("li")],[k.IMAGE,h],[k.EMOJI,p],[k.CODE_BLOCK,b],[k.HR,a("hr")],[k.BR,a("br")],[k.QUOTE,a("blockquote")],[k.COMPONENT,W],[U.TEXT,E],[_.LINK,j],[_.ANCHOR,j],[_.STYLED,$("span",!0)],[_.BOLD,$("strong")],[_.TEXT_STYLE,$("span",!0)],[_.ITALIC,$("em")],[_.UNDERLINE,$("u")],[_.STRIKE,$("s")],[_.CODE,$("code")],[_.SUPERSCRIPT,$("sup")],[_.SUBSCRIPT,$("sub")],[_.HIGHLIGHT,$("mark")],[k.TABLE,X],[k.TABLE_ROW,Q],[k.TABLE_CELL,Z],[k.TABLE_HEADER,ee],...Object.entries(s).map(([c,u])=>[c,u])]);function O(c){e+=1;const u=te.get(c.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return u(c);const f=c.content?c.content.map(P):void 0;return u({...c,children:f})}function P(c){return c.type==="doc"?l?c.content.map(O):c.content.map(O).join(""):Array.isArray(c)?c.map(O):O(c)}return{render:P}}let H,M="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),i=o!==null&&+o===n;if(!(!s||!i)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var a;l&&(l.action==="input"&&((a=l.story)==null?void 0:a.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},K=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Ve=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:i={},richText:l={},bridgeUrl:a}=n;i.accessToken=i.accessToken||s;const h={bridge:r,apiOptions:i};let d={};o.forEach(b=>{d={...d,...b(h)}}),a&&(M=a);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&p&&G(M),H=new A(l.schema),l.resolver&&K(H,l.resolver),d},Y=n=>{var e;return!n||!((e=n==null?void 0:n.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Je=(n,e,t)=>{let r=t||H;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Y(n)?"":(e&&(r=new A(e.schema),e.resolver&&K(r,e.resolver)),r.render(n,{},!1))},Ke=()=>G(M);exports.BlockTypes=k;exports.MarkTypes=_;exports.RichTextResolver=A;exports.RichTextSchema=V;exports.TextTypes=U;exports.apiPlugin=Me;exports.isRichTextEmpty=Y;exports.loadStoryblokBridge=Ke;exports.registerStoryblokBridge=J;exports.renderRichText=Je;exports.richTextResolver=Ge;exports.storyblokEditable=Ue;exports.storyblokInit=Ve;exports.useStoryblokBridge=J;
|
|
24
|
+
}`),""}optimizeImages(e,t){let r=0,s=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i=`/filters${i}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=r>0||s>0||i.length>0?`${r}x${s}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var h,d;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(w=>{if(typeof w=="number")return`//${p}/m/${w}x0${i} ${w}w`;if(typeof w=="object"&&w.length===2){let E=0,j=0;return typeof w[0]=="number"&&(E=w[0]),typeof w[1]=="number"&&(j=w[1]),`//${p}/m/${E}x${j}${i} ${E}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(w=>w).join(", ")};let v="";return b.srcset&&(v+=`srcset="${b.srcset}" `),b.sizes&&(v+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${v.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(Pe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs){for(const n in r.attrs)if(Object.prototype.hasOwnProperty.call(r.attrs,n)){const i=r.attrs[n];i!==null&&(s+=` ${n}="${i}"`)}}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class Ne{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const a=new C;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};s(n)})}}const q="SB-Agent",N={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const S={};class He{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"helpers"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache");let r=e.endpoint||t;if(!r){const i=new C().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{s.set(i,l)}),s.has(q)||(s.set(q,N.defaultAgentName),s.set(N.defaultAgentVersion,N.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new A(e.richTextSchema):this.richTextResolver=new A,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=le(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new C,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ne({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,s));return this.cacheResponse(e,i,void 0,n)}get(e,t,r){t||(t={});const s=`/${e}`,n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t,r,s){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1),a=1,h=await this.makeRequest(i,t,n,a,s),d=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(a,d),b=>this.makeRequest(i,t,n,b+1,s));return this.helpers.flatMap([h,...p],b=>Object.values(b.data[l]))}post(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t,r))}put(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t,r))}delete(e,t,r){t||(t={});const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t,r))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,i="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${i}[${a}]`));else if(typeof n=="object")for(const l in n){const a=i?`${i}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);i.push(e.link_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)})}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let i=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],i,r);e.story?this.iterateTree(e.story,i,r):e.stories.forEach(l=>{this.iterateTree(l,i,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var h;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return a(d);let p={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),p.data.story||p.data.stories){const v=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${v}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(n,p);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(b&&S[t.token]&&S[t.token]!==p.data.cv&&await this.flushCache(),S[t.token]=p.data.cv),l(p)}catch(d){if(d.response&&d.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(d)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(x[e])},getAll(){return Promise.resolve(x)},set(e,t){return x[e]=t,Promise.resolve(void 0)},flush(){return x={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}}const Me=(o={})=>{const{apiOptions:e}=o;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new He(e)}},Ue=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Be(o,e){if(!e)return{src:o,attrs:{}};let t=0,r=0;const s={},n=[];function i(a,h,d,p,b){typeof a!="number"||a<=h||a>=d?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`):b.push(`${p}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:d,fill:p,format:b,grayscale:v,quality:w,rotate:E}=a||{};h&&i(h,0,100,"blur",n),w&&i(w,0,100,"quality",n),d&&i(d,0,100,"brightness",n),p&&n.push(`fill(${p})`),v&&n.push("grayscale()"),E&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${E})`),b&&["webp","png","jpeg"].includes(b)&&n.push(`format(${b})`)}e.srcset&&(s.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${o}/m/${a}x0/${n.length>0?`filters:${n.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,d]=a;return`${o}/m/${h}x${d}/${n.length>0?`filters:${n.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${o}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:s}}var k=(o=>(o.DOCUMENT="doc",o.HEADING="heading",o.PARAGRAPH="paragraph",o.QUOTE="blockquote",o.OL_LIST="ordered_list",o.UL_LIST="bullet_list",o.LIST_ITEM="list_item",o.CODE_BLOCK="code_block",o.HR="horizontal_rule",o.BR="hard_break",o.IMAGE="image",o.EMOJI="emoji",o.COMPONENT="blok",o.TABLE="table",o.TABLE_ROW="tableRow",o.TABLE_CELL="tableCell",o.TABLE_HEADER="tableHeader",o))(k||{}),_=(o=>(o.BOLD="bold",o.STRONG="strong",o.STRIKE="strike",o.UNDERLINE="underline",o.ITALIC="italic",o.CODE="code",o.LINK="link",o.ANCHOR="anchor",o.STYLED="styled",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.TEXT_STYLE="textStyle",o.HIGHLIGHT="highlight",o))(_||{}),U=(o=>(o.TEXT="text",o))(U||{}),I=(o=>(o.URL="url",o.STORY="story",o.ASSET="asset",o.EMAIL="email",o))(I||{});const ze=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De=(o={})=>Object.keys(o).map(e=>`${e}="${o[e]}"`).join(" "),qe=(o={})=>Object.keys(o).map(e=>`${e}: ${o[e]}`).join("; ");function Fe(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const L=o=>Object.fromEntries(Object.entries(o).filter(([e,t])=>t!==void 0));function F(o,e={},t){const r=De(e),s=r?`${o} ${r}`:o,n=Array.isArray(t)?t.join(""):t||"";if(o){if(ze.includes(o))return`<${s}>`}else return n;return`<${s}>${n}</${o}>`}function Ge(o={}){let e=0;const{renderFn:t=F,textFn:r=Fe,resolvers:s={},optimizeImages:n=!1,keyedResolvers:i=!1}=o,l=t!==F,a=c=>u=>{const f=u.attrs||{};return i&&(f.key=`${c}-${e}`),t(c,f,u.children||null)},h=c=>{const{src:u,alt:f,title:y,srcset:R,sizes:$}=c.attrs||{};let m=u,T={};if(n){const{src:se,attrs:oe}=Be(u,n);m=se,T=oe}i&&(T={...T,key:`img-${e}`});const re={src:m,alt:f,title:y,srcset:R,sizes:$,...T};return t("img",L(re))},d=c=>{const{level:u,...f}=c.attrs||{},y={...f};return i&&(y.key=`h${u}-${e}`),t(`h${u}`,y,c.children)},p=c=>{var u,f,y,R;const $=t("img",{src:(u=c.attrs)==null?void 0:u.fallbackImage,alt:(f=c.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}),m={"data-type":"emoji","data-name":(y=c.attrs)==null?void 0:y.name,"data-emoji":(R=c.attrs)==null?void 0:R.emoji};return i&&(m.key=`emoji-${e}`),t("span",m,$)},b=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),v=(c,u=!1)=>({text:f,attrs:y})=>{const{class:R,id:$,...m}=y||{},T=u?{class:R,id:$,style:qe(m)||void 0}:y||{};return i&&(T.key=`${c}-${e}`),t(c,L(T),f)},w=c=>P(c),E=c=>{const{marks:u,...f}=c;return"text"in c?u?u.reduce((y,R)=>w({...R,text:y}),w({...f,children:f.children})):r(f.text):""},j=c=>{const{linktype:u,href:f,anchor:y,...R}=c.attrs||{};let $="";switch(u){case I.ASSET:case I.URL:$=f;break;case I.EMAIL:$=`mailto:${f}`;break;case I.STORY:$=f,y&&($=`${$}#${y}`);break;default:$=f;break}const m={...R};return $&&(m.href=$),i&&(m.key=`a-${e}`),t("a",m,c.text)},W=c=>{var u,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(u=c==null?void 0:c.attrs)==null?void 0:u.body[0],id:(f=c.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},X=c=>{const u={};return i&&(u.key=`table-${e}`),t("table",u,c.children)},Q=c=>{const u={};return i&&(u.key=`tr-${e}`),t("tr",u,c.children)},Z=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...$}=c.attrs||{},m={...$};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`td-${e}`),t("td",L(m),c.children)},ee=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...$}=c.attrs||{},m={...$};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`th-${e}`),t("th",L(m),c.children)},te=new Map([[k.DOCUMENT,a("")],[k.HEADING,d],[k.PARAGRAPH,a("p")],[k.UL_LIST,a("ul")],[k.OL_LIST,a("ol")],[k.LIST_ITEM,a("li")],[k.IMAGE,h],[k.EMOJI,p],[k.CODE_BLOCK,b],[k.HR,a("hr")],[k.BR,a("br")],[k.QUOTE,a("blockquote")],[k.COMPONENT,W],[U.TEXT,E],[_.LINK,j],[_.ANCHOR,j],[_.STYLED,v("span",!0)],[_.BOLD,v("strong")],[_.TEXT_STYLE,v("span",!0)],[_.ITALIC,v("em")],[_.UNDERLINE,v("u")],[_.STRIKE,v("s")],[_.CODE,v("code")],[_.SUPERSCRIPT,v("sup")],[_.SUBSCRIPT,v("sub")],[_.HIGHLIGHT,v("mark")],[k.TABLE,X],[k.TABLE_ROW,Q],[k.TABLE_CELL,Z],[k.TABLE_HEADER,ee],...Object.entries(s).map(([c,u])=>[c,u])]);function O(c){e+=1;const u=te.get(c.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return u(c);const f=c.content?c.content.map(P):void 0;return u({...c,children:f})}function P(c){return c.type==="doc"?l?c.content.map(O):c.content.map(O).join(""):Array.isArray(c)?c.map(O):O(c)}return{render:P}}let H,M="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(o,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),i=n!==null&&+n===o;if(!(!s||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var a;l&&(l.action==="input"&&((a=l.story)==null?void 0:a.id)===o?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===o&&window.location.reload())})})}},K=(o,e)=>{o.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Ve=(o={})=>{var e,t;const{bridge:r,accessToken:s,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||s;const h={bridge:r,apiOptions:i};let d={};n.forEach(b=>{d={...d,...b(h)}}),a&&(M=a);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&p&&G(M),H=new A(l.schema),l.resolver&&K(H,l.resolver),d},Y=o=>{var e;return!o||!((e=o==null?void 0:o.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Je=(o,e,t)=>{let r=t||H;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Y(o)?"":(e&&(r=new A(e.schema),e.resolver&&K(r,e.resolver)),r.render(o,{},!1))},Ke=()=>G(M);exports.BlockTypes=k;exports.MarkTypes=_;exports.RichTextResolver=A;exports.RichTextSchema=V;exports.TextTypes=U;exports.apiPlugin=Me;exports.isRichTextEmpty=Y;exports.loadStoryblokBridge=Ke;exports.registerStoryblokBridge=J;exports.renderRichText=Je;exports.richTextResolver=Ge;exports.storyblokEditable=Ue;exports.storyblokInit=Ve;exports.useStoryblokBridge=J;
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let U = !1;
|
|
2
|
-
const B = [], F = (
|
|
2
|
+
const B = [], F = (o) => new Promise((e, t) => {
|
|
3
3
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
4
4
|
if (window.location === window.parent.location) {
|
|
5
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
@@ -9,35 +9,35 @@ const B = [], F = (n) => new Promise((e, t) => {
|
|
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
10
10
|
return;
|
|
11
11
|
const r = document.createElement("script");
|
|
12
|
-
r.async = !0, r.src =
|
|
13
|
-
B.forEach((
|
|
12
|
+
r.async = !0, r.src = o, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
|
|
13
|
+
B.forEach((n) => n()), U = !0, e(s);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
15
15
|
});
|
|
16
|
-
var re = Object.defineProperty, se = (
|
|
17
|
-
class
|
|
16
|
+
var re = Object.defineProperty, se = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, g = (o, e, t) => se(o, typeof e != "symbol" ? e + "" : e, t);
|
|
17
|
+
class oe extends Error {
|
|
18
18
|
constructor(e) {
|
|
19
19
|
super(e), this.name = "AbortError";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function ne(o, e, t) {
|
|
23
23
|
if (!Number.isFinite(e))
|
|
24
24
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
25
25
|
if (!Number.isFinite(t))
|
|
26
26
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
27
27
|
const r = [];
|
|
28
|
-
let s = [],
|
|
28
|
+
let s = [], n = 0, a = !1;
|
|
29
29
|
const l = async () => {
|
|
30
|
-
|
|
30
|
+
n++;
|
|
31
31
|
const h = r.shift();
|
|
32
32
|
if (h)
|
|
33
33
|
try {
|
|
34
|
-
const p = await
|
|
34
|
+
const p = await o(...h.args);
|
|
35
35
|
h.resolve(p);
|
|
36
36
|
} catch (p) {
|
|
37
37
|
h.reject(p);
|
|
38
38
|
}
|
|
39
39
|
const d = setTimeout(() => {
|
|
40
|
-
|
|
40
|
+
n--, r.length > 0 && l(), s = s.filter((p) => p !== d);
|
|
41
41
|
}, t);
|
|
42
42
|
s.includes(d) || s.push(d);
|
|
43
43
|
}, i = (...h) => a ? Promise.reject(
|
|
@@ -49,11 +49,11 @@ function oe(n, e, t) {
|
|
|
49
49
|
resolve: d,
|
|
50
50
|
reject: p,
|
|
51
51
|
args: h
|
|
52
|
-
}),
|
|
52
|
+
}), n < e && l();
|
|
53
53
|
});
|
|
54
54
|
return i.abort = () => {
|
|
55
55
|
a = !0, s.forEach(clearTimeout), s = [], r.forEach(
|
|
56
|
-
(h) => h.reject(() => new
|
|
56
|
+
(h) => h.reject(() => new oe("Throttle function aborted"))
|
|
57
57
|
), r.length = 0;
|
|
58
58
|
}, i;
|
|
59
59
|
}
|
|
@@ -65,7 +65,7 @@ class L {
|
|
|
65
65
|
page: r
|
|
66
66
|
})), g(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), g(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), g(this, "range", (e = 0, t = e) => {
|
|
67
67
|
const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
|
|
68
|
-
return this.arrayFrom(r, (
|
|
68
|
+
return this.arrayFrom(r, (n, a) => a * s + e);
|
|
69
69
|
}), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], [])), g(this, "escapeHTML", function(e) {
|
|
70
70
|
const t = {
|
|
71
71
|
"&": "&",
|
|
@@ -74,7 +74,7 @@ class L {
|
|
|
74
74
|
'"': """,
|
|
75
75
|
"'": "'"
|
|
76
76
|
}, r = /[&<>"']/g, s = new RegExp(r.source);
|
|
77
|
-
return e && s.test(e) ? e.replace(r, (
|
|
77
|
+
return e && s.test(e) ? e.replace(r, (n) => t[n]) : e;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -86,13 +86,13 @@ class L {
|
|
|
86
86
|
*/
|
|
87
87
|
stringify(e, t, r) {
|
|
88
88
|
const s = [];
|
|
89
|
-
for (const
|
|
90
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
89
|
+
for (const n in e) {
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(e, n))
|
|
91
91
|
continue;
|
|
92
|
-
const a = e[
|
|
92
|
+
const a = e[n];
|
|
93
93
|
if (a == null)
|
|
94
94
|
continue;
|
|
95
|
-
const l = r ? "" : encodeURIComponent(
|
|
95
|
+
const l = r ? "" : encodeURIComponent(n);
|
|
96
96
|
let i;
|
|
97
97
|
typeof a == "object" ? i = this.stringify(
|
|
98
98
|
a,
|
|
@@ -108,14 +108,14 @@ class L {
|
|
|
108
108
|
* @return {string} The base URL of the region
|
|
109
109
|
*/
|
|
110
110
|
getRegionURL(e) {
|
|
111
|
-
const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn",
|
|
111
|
+
const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
|
|
112
112
|
switch (e) {
|
|
113
113
|
case "us":
|
|
114
114
|
return r;
|
|
115
115
|
case "cn":
|
|
116
116
|
return s;
|
|
117
117
|
case "ap":
|
|
118
|
-
return
|
|
118
|
+
return n;
|
|
119
119
|
case "ca":
|
|
120
120
|
return a;
|
|
121
121
|
default:
|
|
@@ -123,36 +123,36 @@ class L {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const ae = function(
|
|
126
|
+
const ae = function(o, e) {
|
|
127
127
|
const t = {};
|
|
128
|
-
for (const r in
|
|
129
|
-
const s =
|
|
128
|
+
for (const r in o) {
|
|
129
|
+
const s = o[r];
|
|
130
130
|
e.includes(r) && s !== null && (t[r] = s);
|
|
131
131
|
}
|
|
132
132
|
return t;
|
|
133
|
-
}, ie = (
|
|
133
|
+
}, ie = (o) => o === "email", le = () => ({
|
|
134
134
|
singleTag: "hr"
|
|
135
135
|
}), ce = () => ({
|
|
136
136
|
tag: "blockquote"
|
|
137
137
|
}), he = () => ({
|
|
138
138
|
tag: "ul"
|
|
139
|
-
}), ue = (
|
|
139
|
+
}), ue = (o) => ({
|
|
140
140
|
tag: [
|
|
141
141
|
"pre",
|
|
142
142
|
{
|
|
143
143
|
tag: "code",
|
|
144
|
-
attrs:
|
|
144
|
+
attrs: o.attrs
|
|
145
145
|
}
|
|
146
146
|
]
|
|
147
147
|
}), de = () => ({
|
|
148
148
|
singleTag: "br"
|
|
149
|
-
}), pe = (
|
|
150
|
-
tag: `h${
|
|
151
|
-
}), ge = (
|
|
149
|
+
}), pe = (o) => ({
|
|
150
|
+
tag: `h${o.attrs.level}`
|
|
151
|
+
}), ge = (o) => ({
|
|
152
152
|
singleTag: [
|
|
153
153
|
{
|
|
154
154
|
tag: "img",
|
|
155
|
-
attrs: ae(
|
|
155
|
+
attrs: ae(o.attrs, ["src", "alt", "title"])
|
|
156
156
|
}
|
|
157
157
|
]
|
|
158
158
|
}), fe = () => ({
|
|
@@ -161,22 +161,22 @@ const ae = function(n, e) {
|
|
|
161
161
|
tag: "ol"
|
|
162
162
|
}), ye = () => ({
|
|
163
163
|
tag: "p"
|
|
164
|
-
}), be = (
|
|
164
|
+
}), be = (o) => ({
|
|
165
165
|
tag: [
|
|
166
166
|
{
|
|
167
167
|
tag: "span",
|
|
168
168
|
attrs: {
|
|
169
169
|
"data-type": "emoji",
|
|
170
|
-
"data-name":
|
|
171
|
-
emoji:
|
|
170
|
+
"data-name": o.attrs.name,
|
|
171
|
+
emoji: o.attrs.emoji
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
]
|
|
175
175
|
}), ke = () => ({
|
|
176
176
|
tag: "b"
|
|
177
|
-
}), $e = () => ({
|
|
178
|
-
tag: "s"
|
|
179
177
|
}), ve = () => ({
|
|
178
|
+
tag: "s"
|
|
179
|
+
}), $e = () => ({
|
|
180
180
|
tag: "u"
|
|
181
181
|
}), we = () => ({
|
|
182
182
|
tag: "strong"
|
|
@@ -184,13 +184,13 @@ const ae = function(n, e) {
|
|
|
184
184
|
tag: "code"
|
|
185
185
|
}), Re = () => ({
|
|
186
186
|
tag: "i"
|
|
187
|
-
}), _e = (
|
|
188
|
-
if (!
|
|
187
|
+
}), _e = (o) => {
|
|
188
|
+
if (!o.attrs)
|
|
189
189
|
return {
|
|
190
190
|
tag: ""
|
|
191
191
|
};
|
|
192
|
-
const e = new L().escapeHTML, t = { ...
|
|
193
|
-
if (delete t.linktype, t.href && (t.href = e(
|
|
192
|
+
const e = new L().escapeHTML, t = { ...o.attrs }, { linktype: r = "url" } = o.attrs;
|
|
193
|
+
if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), ie(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
194
194
|
for (const s in t.custom)
|
|
195
195
|
t[s] = t.custom[s];
|
|
196
196
|
delete t.custom;
|
|
@@ -203,46 +203,46 @@ const ae = function(n, e) {
|
|
|
203
203
|
}
|
|
204
204
|
]
|
|
205
205
|
};
|
|
206
|
-
}, Ee = (
|
|
206
|
+
}, Ee = (o) => ({
|
|
207
207
|
tag: [
|
|
208
208
|
{
|
|
209
209
|
tag: "span",
|
|
210
|
-
attrs:
|
|
210
|
+
attrs: o.attrs
|
|
211
211
|
}
|
|
212
212
|
]
|
|
213
213
|
}), Se = () => ({
|
|
214
214
|
tag: "sub"
|
|
215
215
|
}), je = () => ({
|
|
216
216
|
tag: "sup"
|
|
217
|
-
}), Ie = (
|
|
217
|
+
}), Ie = (o) => ({
|
|
218
218
|
tag: [
|
|
219
219
|
{
|
|
220
220
|
tag: "span",
|
|
221
|
-
attrs:
|
|
221
|
+
attrs: o.attrs
|
|
222
222
|
}
|
|
223
223
|
]
|
|
224
|
-
}), xe = (
|
|
224
|
+
}), xe = (o) => {
|
|
225
225
|
var e;
|
|
226
|
-
return (e =
|
|
226
|
+
return (e = o.attrs) != null && e.color ? {
|
|
227
227
|
tag: [
|
|
228
228
|
{
|
|
229
229
|
tag: "span",
|
|
230
230
|
attrs: {
|
|
231
|
-
style: `background-color:${
|
|
231
|
+
style: `background-color:${o.attrs.color};`
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
]
|
|
235
235
|
} : {
|
|
236
236
|
tag: ""
|
|
237
237
|
};
|
|
238
|
-
}, Ae = (
|
|
238
|
+
}, Ae = (o) => {
|
|
239
239
|
var e;
|
|
240
|
-
return (e =
|
|
240
|
+
return (e = o.attrs) != null && e.color ? {
|
|
241
241
|
tag: [
|
|
242
242
|
{
|
|
243
243
|
tag: "span",
|
|
244
244
|
attrs: {
|
|
245
|
-
style: `color:${
|
|
245
|
+
style: `color:${o.attrs.color}`
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
]
|
|
@@ -265,8 +265,8 @@ const ae = function(n, e) {
|
|
|
265
265
|
},
|
|
266
266
|
marks: {
|
|
267
267
|
bold: ke,
|
|
268
|
-
strike:
|
|
269
|
-
underline:
|
|
268
|
+
strike: ve,
|
|
269
|
+
underline: $e,
|
|
270
270
|
strong: we,
|
|
271
271
|
code: Te,
|
|
272
272
|
italic: Re,
|
|
@@ -278,7 +278,7 @@ const ae = function(n, e) {
|
|
|
278
278
|
highlight: xe,
|
|
279
279
|
textStyle: Ae
|
|
280
280
|
}
|
|
281
|
-
}, Le = function(
|
|
281
|
+
}, Le = function(o) {
|
|
282
282
|
const e = {
|
|
283
283
|
"&": "&",
|
|
284
284
|
"<": "<",
|
|
@@ -286,7 +286,7 @@ const ae = function(n, e) {
|
|
|
286
286
|
'"': """,
|
|
287
287
|
"'": "'"
|
|
288
288
|
}, t = /[&<>"']/g, r = new RegExp(t.source);
|
|
289
|
-
return
|
|
289
|
+
return o && r.test(o) ? o.replace(t, (s) => e[s]) : o;
|
|
290
290
|
};
|
|
291
291
|
let z = !1;
|
|
292
292
|
class C {
|
|
@@ -304,8 +304,8 @@ class C {
|
|
|
304
304
|
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
|
305
305
|
), z = !0), e && e.content && Array.isArray(e.content)) {
|
|
306
306
|
let s = "";
|
|
307
|
-
return e.content.forEach((
|
|
308
|
-
s += this.renderNode(
|
|
307
|
+
return e.content.forEach((n) => {
|
|
308
|
+
s += this.renderNode(n);
|
|
309
309
|
}), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
|
|
310
310
|
}
|
|
311
311
|
return console.warn(
|
|
@@ -336,8 +336,8 @@ class C {
|
|
|
336
336
|
), "";
|
|
337
337
|
}
|
|
338
338
|
optimizeImages(e, t) {
|
|
339
|
-
let r = 0, s = 0,
|
|
340
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
|
339
|
+
let r = 0, s = 0, n = "", a = "";
|
|
340
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, r = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, s = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
|
341
341
|
const l = r > 0 || s > 0 || a.length > 0 ? `${r}x${s}${a}` : "";
|
|
342
342
|
return e = e.replace(
|
|
343
343
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
@@ -369,15 +369,15 @@ class C {
|
|
|
369
369
|
renderNode(e) {
|
|
370
370
|
const t = [];
|
|
371
371
|
e.marks && e.marks.forEach((s) => {
|
|
372
|
-
const
|
|
373
|
-
|
|
372
|
+
const n = this.getMatchingMark(s);
|
|
373
|
+
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
|
374
374
|
});
|
|
375
375
|
const r = this.getMatchingNode(e);
|
|
376
376
|
return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((s) => {
|
|
377
377
|
t.push(this.renderNode(s));
|
|
378
378
|
}) : e.text ? t.push(Le(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html ? t.push(r.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
|
|
379
|
-
const
|
|
380
|
-
|
|
379
|
+
const n = this.getMatchingMark(s);
|
|
380
|
+
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
381
381
|
}), t.join("");
|
|
382
382
|
}
|
|
383
383
|
renderTag(e, t) {
|
|
@@ -387,10 +387,10 @@ class C {
|
|
|
387
387
|
{
|
|
388
388
|
let s = `<${r.tag}`;
|
|
389
389
|
if (r.attrs) {
|
|
390
|
-
for (const
|
|
391
|
-
if (Object.prototype.hasOwnProperty.call(r.attrs,
|
|
392
|
-
const a = r.attrs[
|
|
393
|
-
a !== null && (s += ` ${
|
|
390
|
+
for (const n in r.attrs)
|
|
391
|
+
if (Object.prototype.hasOwnProperty.call(r.attrs, n)) {
|
|
392
|
+
const a = r.attrs[n];
|
|
393
|
+
a !== null && (s += ` ${n}="${a}"`);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
return `${s}${t}>`;
|
|
@@ -475,9 +475,9 @@ class Ce {
|
|
|
475
475
|
)}`;
|
|
476
476
|
} else
|
|
477
477
|
r = JSON.stringify(this.parameters);
|
|
478
|
-
const s = new URL(t),
|
|
478
|
+
const s = new URL(t), n = new AbortController(), { signal: a } = n;
|
|
479
479
|
let l;
|
|
480
|
-
this.timeout && (l = setTimeout(() =>
|
|
480
|
+
this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
|
|
481
481
|
try {
|
|
482
482
|
const i = await this.fetch(`${s}`, {
|
|
483
483
|
method: e,
|
|
@@ -508,12 +508,12 @@ class Ce {
|
|
|
508
508
|
return new Promise((r, s) => {
|
|
509
509
|
if (t.test(`${e.status}`))
|
|
510
510
|
return r(e);
|
|
511
|
-
const
|
|
511
|
+
const n = {
|
|
512
512
|
message: e.statusText,
|
|
513
513
|
status: e.status,
|
|
514
514
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
515
515
|
};
|
|
516
|
-
s(
|
|
516
|
+
s(n);
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
}
|
|
@@ -544,10 +544,10 @@ class Pe {
|
|
|
544
544
|
N.defaultAgentVersion,
|
|
545
545
|
N.packageVersion
|
|
546
546
|
));
|
|
547
|
-
let
|
|
548
|
-
e.oauthToken && (s.set("Authorization", e.oauthToken),
|
|
547
|
+
let n = 5;
|
|
548
|
+
e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new C(e.richTextSchema) : this.richTextResolver = new C(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ne(
|
|
549
549
|
this.throttledRequest.bind(this),
|
|
550
|
-
|
|
550
|
+
n,
|
|
551
551
|
1e3
|
|
552
552
|
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new L(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ce({
|
|
553
553
|
baseURL: r,
|
|
@@ -573,28 +573,28 @@ class Pe {
|
|
|
573
573
|
factoryParamOptions(e, t) {
|
|
574
574
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
575
575
|
}
|
|
576
|
-
makeRequest(e, t, r, s,
|
|
576
|
+
makeRequest(e, t, r, s, n) {
|
|
577
577
|
const a = this.factoryParamOptions(
|
|
578
578
|
e,
|
|
579
579
|
this.helpers.getOptionsPage(t, r, s)
|
|
580
580
|
);
|
|
581
|
-
return this.cacheResponse(e, a, void 0,
|
|
581
|
+
return this.cacheResponse(e, a, void 0, n);
|
|
582
582
|
}
|
|
583
583
|
get(e, t, r) {
|
|
584
584
|
t || (t = {});
|
|
585
|
-
const s = `/${e}`,
|
|
586
|
-
return this.cacheResponse(s,
|
|
585
|
+
const s = `/${e}`, n = this.factoryParamOptions(s, t);
|
|
586
|
+
return this.cacheResponse(s, n, void 0, r);
|
|
587
587
|
}
|
|
588
588
|
async getAll(e, t, r, s) {
|
|
589
|
-
const
|
|
589
|
+
const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = r ?? a.substring(a.lastIndexOf("/") + 1), i = 1, h = await this.makeRequest(
|
|
590
590
|
a,
|
|
591
591
|
t,
|
|
592
|
-
|
|
592
|
+
n,
|
|
593
593
|
i,
|
|
594
594
|
s
|
|
595
|
-
), d = h.total ? Math.ceil(h.total /
|
|
595
|
+
), d = h.total ? Math.ceil(h.total / n) : 1, p = await this.helpers.asyncMap(
|
|
596
596
|
this.helpers.range(i, d),
|
|
597
|
-
(b) => this.makeRequest(a, t,
|
|
597
|
+
(b) => this.makeRequest(a, t, n, b + 1, s)
|
|
598
598
|
);
|
|
599
599
|
return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[l]));
|
|
600
600
|
}
|
|
@@ -661,7 +661,7 @@ class Pe {
|
|
|
661
661
|
_resolveField(e, t, r) {
|
|
662
662
|
const s = e[t];
|
|
663
663
|
typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map(
|
|
664
|
-
(
|
|
664
|
+
(n) => this.getStoryReference(r, n)
|
|
665
665
|
).filter(Boolean));
|
|
666
666
|
}
|
|
667
667
|
/**
|
|
@@ -686,8 +686,8 @@ class Pe {
|
|
|
686
686
|
this._resolveField(e, t, s);
|
|
687
687
|
return;
|
|
688
688
|
}
|
|
689
|
-
const
|
|
690
|
-
(Array.isArray(r) ? r.includes(
|
|
689
|
+
const n = e.component ? `${e.component}.${t}` : t;
|
|
690
|
+
(Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, s);
|
|
691
691
|
}
|
|
692
692
|
/**
|
|
693
693
|
* Recursively traverses and resolves relations in the story content tree
|
|
@@ -696,14 +696,14 @@ class Pe {
|
|
|
696
696
|
* @param resolveId - The unique identifier for the current resolution context
|
|
697
697
|
*/
|
|
698
698
|
iterateTree(e, t, r) {
|
|
699
|
-
const s = (
|
|
700
|
-
if (!(!
|
|
701
|
-
if (Array.isArray(
|
|
702
|
-
|
|
703
|
-
else if (typeof
|
|
704
|
-
for (const l in
|
|
699
|
+
const s = (n, a = "") => {
|
|
700
|
+
if (!(!n || n._stopResolving)) {
|
|
701
|
+
if (Array.isArray(n))
|
|
702
|
+
n.forEach((l, i) => s(l, `${a}[${i}]`));
|
|
703
|
+
else if (typeof n == "object")
|
|
704
|
+
for (const l in n) {
|
|
705
705
|
const i = a ? `${a}.${l}` : l;
|
|
706
|
-
(
|
|
706
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, r), this._insertLinks(n, l, r)), s(n[l], i);
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
709
|
};
|
|
@@ -712,9 +712,9 @@ class Pe {
|
|
|
712
712
|
async resolveLinks(e, t, r) {
|
|
713
713
|
let s = [];
|
|
714
714
|
if (e.link_uuids) {
|
|
715
|
-
const
|
|
716
|
-
for (let i = 0; i <
|
|
717
|
-
const h = Math.min(
|
|
715
|
+
const n = e.link_uuids.length, a = [], l = 50;
|
|
716
|
+
for (let i = 0; i < n; i += l) {
|
|
717
|
+
const h = Math.min(n, i + l);
|
|
718
718
|
a.push(e.link_uuids.slice(i, h));
|
|
719
719
|
}
|
|
720
720
|
for (let i = 0; i < a.length; i++)
|
|
@@ -731,9 +731,9 @@ class Pe {
|
|
|
731
731
|
);
|
|
732
732
|
} else
|
|
733
733
|
s = e.links;
|
|
734
|
-
s.forEach((
|
|
735
|
-
this.links[r][
|
|
736
|
-
...
|
|
734
|
+
s.forEach((n) => {
|
|
735
|
+
this.links[r][n.uuid] = {
|
|
736
|
+
...n,
|
|
737
737
|
_stopResolving: !0
|
|
738
738
|
};
|
|
739
739
|
});
|
|
@@ -741,9 +741,9 @@ class Pe {
|
|
|
741
741
|
async resolveRelations(e, t, r) {
|
|
742
742
|
let s = [];
|
|
743
743
|
if (e.rel_uuids) {
|
|
744
|
-
const
|
|
745
|
-
for (let i = 0; i <
|
|
746
|
-
const h = Math.min(
|
|
744
|
+
const n = e.rel_uuids.length, a = [], l = 50;
|
|
745
|
+
for (let i = 0; i < n; i += l) {
|
|
746
|
+
const h = Math.min(n, i + l);
|
|
747
747
|
a.push(e.rel_uuids.slice(i, h));
|
|
748
748
|
}
|
|
749
749
|
for (let i = 0; i < a.length; i++)
|
|
@@ -759,9 +759,9 @@ class Pe {
|
|
|
759
759
|
});
|
|
760
760
|
} else
|
|
761
761
|
s = e.rels;
|
|
762
|
-
s && s.length > 0 && s.forEach((
|
|
763
|
-
this.relations[r][
|
|
764
|
-
...
|
|
762
|
+
s && s.length > 0 && s.forEach((n) => {
|
|
763
|
+
this.relations[r][n.uuid] = {
|
|
764
|
+
...n,
|
|
765
765
|
_stopResolving: !0
|
|
766
766
|
};
|
|
767
767
|
});
|
|
@@ -776,9 +776,9 @@ class Pe {
|
|
|
776
776
|
*
|
|
777
777
|
*/
|
|
778
778
|
async resolveStories(e, t, r) {
|
|
779
|
-
var s,
|
|
779
|
+
var s, n;
|
|
780
780
|
let a = [];
|
|
781
|
-
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (
|
|
781
|
+
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
|
|
782
782
|
for (const l in this.relations[r])
|
|
783
783
|
this.iterateTree(
|
|
784
784
|
this.relations[r][l],
|
|
@@ -790,9 +790,9 @@ class Pe {
|
|
|
790
790
|
}), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
|
|
791
791
|
}
|
|
792
792
|
async cacheResponse(e, t, r, s) {
|
|
793
|
-
const
|
|
793
|
+
const n = this.helpers.stringify({ url: e, params: t }), a = this.cacheProvider();
|
|
794
794
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
795
|
-
const l = await a.get(
|
|
795
|
+
const l = await a.get(n);
|
|
796
796
|
if (l)
|
|
797
797
|
return Promise.resolve(l);
|
|
798
798
|
}
|
|
@@ -815,7 +815,7 @@ class Pe {
|
|
|
815
815
|
const k = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
816
816
|
await this.resolveStories(p.data, t, `${k}`);
|
|
817
817
|
}
|
|
818
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await a.set(
|
|
818
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, p);
|
|
819
819
|
const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
820
820
|
return t.token && p.data.cv && (b && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
|
|
821
821
|
} catch (d) {
|
|
@@ -862,7 +862,6 @@ class Pe {
|
|
|
862
862
|
case "custom":
|
|
863
863
|
if (this.cache.custom)
|
|
864
864
|
return this.cache.custom;
|
|
865
|
-
// eslint-disable-next-line no-fallthrough
|
|
866
865
|
default:
|
|
867
866
|
return {
|
|
868
867
|
get() {
|
|
@@ -884,8 +883,8 @@ class Pe {
|
|
|
884
883
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
885
884
|
}
|
|
886
885
|
}
|
|
887
|
-
const De = (
|
|
888
|
-
const { apiOptions: e } =
|
|
886
|
+
const De = (o = {}) => {
|
|
887
|
+
const { apiOptions: e } = o;
|
|
889
888
|
if (!e || !e.accessToken) {
|
|
890
889
|
console.error(
|
|
891
890
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
@@ -893,12 +892,12 @@ const De = (n = {}) => {
|
|
|
893
892
|
return;
|
|
894
893
|
}
|
|
895
894
|
return { storyblokApi: new Pe(e) };
|
|
896
|
-
}, qe = (
|
|
897
|
-
if (typeof
|
|
895
|
+
}, qe = (o) => {
|
|
896
|
+
if (typeof o != "object" || typeof o._editable > "u")
|
|
898
897
|
return {};
|
|
899
898
|
try {
|
|
900
899
|
const e = JSON.parse(
|
|
901
|
-
|
|
900
|
+
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
902
901
|
);
|
|
903
902
|
return e ? {
|
|
904
903
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -908,38 +907,38 @@ const De = (n = {}) => {
|
|
|
908
907
|
return {};
|
|
909
908
|
}
|
|
910
909
|
};
|
|
911
|
-
function Ne(
|
|
910
|
+
function Ne(o, e) {
|
|
912
911
|
if (!e)
|
|
913
|
-
return { src:
|
|
912
|
+
return { src: o, attrs: {} };
|
|
914
913
|
let t = 0, r = 0;
|
|
915
|
-
const s = {},
|
|
914
|
+
const s = {}, n = [];
|
|
916
915
|
function a(i, h, d, p, b) {
|
|
917
916
|
typeof i != "number" || i <= h || i >= d ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`) : b.push(`${p}(${i})`);
|
|
918
917
|
}
|
|
919
918
|
if (typeof e == "object") {
|
|
920
919
|
if (typeof e.width == "number" && e.width > 0 ? (s.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (s.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
|
|
921
920
|
const { filters: i } = e || {}, { blur: h, brightness: d, fill: p, format: b, grayscale: k, quality: w, rotate: E } = i || {};
|
|
922
|
-
h && a(h, 0, 100, "blur",
|
|
921
|
+
h && a(h, 0, 100, "blur", n), w && a(w, 0, 100, "quality", n), d && a(d, 0, 100, "brightness", n), p && n.push(`fill(${p})`), k && n.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
|
|
923
922
|
}
|
|
924
923
|
e.srcset && (s.srcset = e.srcset.map((i) => {
|
|
925
924
|
if (typeof i == "number")
|
|
926
|
-
return `${
|
|
925
|
+
return `${o}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
|
|
927
926
|
if (Array.isArray(i) && i.length === 2) {
|
|
928
927
|
const [h, d] = i;
|
|
929
|
-
return `${
|
|
928
|
+
return `${o}/m/${h}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
930
929
|
} else {
|
|
931
930
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
932
931
|
return;
|
|
933
932
|
}
|
|
934
933
|
}).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
|
|
935
934
|
}
|
|
936
|
-
let l = `${
|
|
937
|
-
return t > 0 && r > 0 && (l = `${l}${t}x${r}/`),
|
|
935
|
+
let l = `${o}/m/`;
|
|
936
|
+
return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
938
937
|
src: l,
|
|
939
938
|
attrs: s
|
|
940
939
|
};
|
|
941
940
|
}
|
|
942
|
-
var
|
|
941
|
+
var $ = /* @__PURE__ */ ((o) => (o.DOCUMENT = "doc", o.HEADING = "heading", o.PARAGRAPH = "paragraph", o.QUOTE = "blockquote", o.OL_LIST = "ordered_list", o.UL_LIST = "bullet_list", o.LIST_ITEM = "list_item", o.CODE_BLOCK = "code_block", o.HR = "horizontal_rule", o.BR = "hard_break", o.IMAGE = "image", o.EMOJI = "emoji", o.COMPONENT = "blok", o.TABLE = "table", o.TABLE_ROW = "tableRow", o.TABLE_CELL = "tableCell", o.TABLE_HEADER = "tableHeader", o))($ || {}), _ = /* @__PURE__ */ ((o) => (o.BOLD = "bold", o.STRONG = "strong", o.STRIKE = "strike", o.UNDERLINE = "underline", o.ITALIC = "italic", o.CODE = "code", o.LINK = "link", o.ANCHOR = "anchor", o.STYLED = "styled", o.SUPERSCRIPT = "superscript", o.SUBSCRIPT = "subscript", o.TEXT_STYLE = "textStyle", o.HIGHLIGHT = "highlight", o))(_ || {}), G = /* @__PURE__ */ ((o) => (o.TEXT = "text", o))(G || {}), I = /* @__PURE__ */ ((o) => (o.URL = "url", o.STORY = "story", o.ASSET = "asset", o.EMAIL = "email", o))(I || {});
|
|
943
942
|
const He = [
|
|
944
943
|
"area",
|
|
945
944
|
"base",
|
|
@@ -955,35 +954,35 @@ const He = [
|
|
|
955
954
|
"source",
|
|
956
955
|
"track",
|
|
957
956
|
"wbr"
|
|
958
|
-
], Me = (
|
|
959
|
-
function Be(
|
|
960
|
-
return
|
|
957
|
+
], Me = (o = {}) => Object.keys(o).map((e) => `${e}="${o[e]}"`).join(" "), Ue = (o = {}) => Object.keys(o).map((e) => `${e}: ${o[e]}`).join("; ");
|
|
958
|
+
function Be(o) {
|
|
959
|
+
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
961
960
|
}
|
|
962
|
-
const O = (
|
|
963
|
-
function q(
|
|
964
|
-
const r = Me(e), s = r ? `${
|
|
965
|
-
if (
|
|
966
|
-
if (He.includes(
|
|
961
|
+
const O = (o) => Object.fromEntries(Object.entries(o).filter(([e, t]) => t !== void 0));
|
|
962
|
+
function q(o, e = {}, t) {
|
|
963
|
+
const r = Me(e), s = r ? `${o} ${r}` : o, n = Array.isArray(t) ? t.join("") : t || "";
|
|
964
|
+
if (o) {
|
|
965
|
+
if (He.includes(o))
|
|
967
966
|
return `<${s}>`;
|
|
968
|
-
} else return
|
|
969
|
-
return `<${s}>${
|
|
967
|
+
} else return n;
|
|
968
|
+
return `<${s}>${n}</${o}>`;
|
|
970
969
|
}
|
|
971
|
-
function Fe(
|
|
970
|
+
function Fe(o = {}) {
|
|
972
971
|
let e = 0;
|
|
973
972
|
const {
|
|
974
973
|
renderFn: t = q,
|
|
975
974
|
textFn: r = Be,
|
|
976
975
|
resolvers: s = {},
|
|
977
|
-
optimizeImages:
|
|
976
|
+
optimizeImages: n = !1,
|
|
978
977
|
keyedResolvers: a = !1
|
|
979
|
-
} =
|
|
978
|
+
} = o, l = t !== q, i = (c) => (u) => {
|
|
980
979
|
const f = u.attrs || {};
|
|
981
980
|
return a && (f.key = `${c}-${e}`), t(c, f, u.children || null);
|
|
982
981
|
}, h = (c) => {
|
|
983
|
-
const { src: u, alt: f, title: y, srcset: R, sizes:
|
|
982
|
+
const { src: u, alt: f, title: y, srcset: R, sizes: v } = c.attrs || {};
|
|
984
983
|
let m = u, T = {};
|
|
985
|
-
if (
|
|
986
|
-
const { src: ee, attrs: te } = Ne(u,
|
|
984
|
+
if (n) {
|
|
985
|
+
const { src: ee, attrs: te } = Ne(u, n);
|
|
987
986
|
m = ee, T = te;
|
|
988
987
|
}
|
|
989
988
|
a && (T = {
|
|
@@ -995,7 +994,7 @@ function Fe(n = {}) {
|
|
|
995
994
|
alt: f,
|
|
996
995
|
title: y,
|
|
997
996
|
srcset: R,
|
|
998
|
-
sizes:
|
|
997
|
+
sizes: v,
|
|
999
998
|
...T
|
|
1000
999
|
};
|
|
1001
1000
|
return t("img", O(Z));
|
|
@@ -1006,7 +1005,7 @@ function Fe(n = {}) {
|
|
|
1006
1005
|
return a && (y.key = `h${u}-${e}`), t(`h${u}`, y, c.children);
|
|
1007
1006
|
}, p = (c) => {
|
|
1008
1007
|
var u, f, y, R;
|
|
1009
|
-
const
|
|
1008
|
+
const v = t("img", {
|
|
1010
1009
|
src: (u = c.attrs) == null ? void 0 : u.fallbackImage,
|
|
1011
1010
|
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
1012
1011
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
@@ -1017,14 +1016,14 @@ function Fe(n = {}) {
|
|
|
1017
1016
|
"data-name": (y = c.attrs) == null ? void 0 : y.name,
|
|
1018
1017
|
"data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
|
|
1019
1018
|
};
|
|
1020
|
-
return a && (m.key = `emoji-${e}`), t("span", m,
|
|
1019
|
+
return a && (m.key = `emoji-${e}`), t("span", m, v);
|
|
1021
1020
|
}, b = (c) => t("pre", {
|
|
1022
1021
|
...c.attrs,
|
|
1023
1022
|
key: `code-${e}`
|
|
1024
1023
|
}, t("code", { key: `code-${e}` }, c.children || "")), k = (c, u = !1) => ({ text: f, attrs: y }) => {
|
|
1025
|
-
const { class: R, id:
|
|
1024
|
+
const { class: R, id: v, ...m } = y || {}, T = u ? {
|
|
1026
1025
|
class: R,
|
|
1027
|
-
id:
|
|
1026
|
+
id: v,
|
|
1028
1027
|
style: Ue(m) || void 0
|
|
1029
1028
|
} : y || {};
|
|
1030
1029
|
return a && (T.key = `${c}-${e}`), t(c, O(T), f);
|
|
@@ -1038,24 +1037,24 @@ function Fe(n = {}) {
|
|
|
1038
1037
|
) : r(f.text) : "";
|
|
1039
1038
|
}, j = (c) => {
|
|
1040
1039
|
const { linktype: u, href: f, anchor: y, ...R } = c.attrs || {};
|
|
1041
|
-
let
|
|
1040
|
+
let v = "";
|
|
1042
1041
|
switch (u) {
|
|
1043
1042
|
case I.ASSET:
|
|
1044
1043
|
case I.URL:
|
|
1045
|
-
|
|
1044
|
+
v = f;
|
|
1046
1045
|
break;
|
|
1047
1046
|
case I.EMAIL:
|
|
1048
|
-
|
|
1047
|
+
v = `mailto:${f}`;
|
|
1049
1048
|
break;
|
|
1050
1049
|
case I.STORY:
|
|
1051
|
-
|
|
1050
|
+
v = f, y && (v = `${v}#${y}`);
|
|
1052
1051
|
break;
|
|
1053
1052
|
default:
|
|
1054
|
-
|
|
1053
|
+
v = f;
|
|
1055
1054
|
break;
|
|
1056
1055
|
}
|
|
1057
1056
|
const m = { ...R };
|
|
1058
|
-
return
|
|
1057
|
+
return v && (m.href = v), a && (m.key = `a-${e}`), t("a", m, c.text);
|
|
1059
1058
|
}, J = (c) => {
|
|
1060
1059
|
var u, f;
|
|
1061
1060
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
@@ -1071,33 +1070,33 @@ function Fe(n = {}) {
|
|
|
1071
1070
|
const u = {};
|
|
1072
1071
|
return a && (u.key = `tr-${e}`), t("tr", u, c.children);
|
|
1073
1072
|
}, W = (c) => {
|
|
1074
|
-
const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R,
|
|
1075
|
-
|
|
1073
|
+
const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, m = {
|
|
1074
|
+
...v
|
|
1076
1075
|
};
|
|
1077
1076
|
u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
|
|
1078
1077
|
const T = [];
|
|
1079
1078
|
return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `td-${e}`), t("td", O(m), c.children);
|
|
1080
1079
|
}, X = (c) => {
|
|
1081
|
-
const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R,
|
|
1082
|
-
|
|
1080
|
+
const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, m = {
|
|
1081
|
+
...v
|
|
1083
1082
|
};
|
|
1084
1083
|
u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
|
|
1085
1084
|
const T = [];
|
|
1086
1085
|
return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `th-${e}`), t("th", O(m), c.children);
|
|
1087
1086
|
}, Q = new Map([
|
|
1088
|
-
[
|
|
1089
|
-
[
|
|
1090
|
-
[
|
|
1091
|
-
[
|
|
1092
|
-
[
|
|
1093
|
-
[
|
|
1094
|
-
[
|
|
1095
|
-
[
|
|
1096
|
-
[
|
|
1097
|
-
[
|
|
1098
|
-
[
|
|
1099
|
-
[
|
|
1100
|
-
[
|
|
1087
|
+
[$.DOCUMENT, i("")],
|
|
1088
|
+
[$.HEADING, d],
|
|
1089
|
+
[$.PARAGRAPH, i("p")],
|
|
1090
|
+
[$.UL_LIST, i("ul")],
|
|
1091
|
+
[$.OL_LIST, i("ol")],
|
|
1092
|
+
[$.LIST_ITEM, i("li")],
|
|
1093
|
+
[$.IMAGE, h],
|
|
1094
|
+
[$.EMOJI, p],
|
|
1095
|
+
[$.CODE_BLOCK, b],
|
|
1096
|
+
[$.HR, i("hr")],
|
|
1097
|
+
[$.BR, i("br")],
|
|
1098
|
+
[$.QUOTE, i("blockquote")],
|
|
1099
|
+
[$.COMPONENT, J],
|
|
1101
1100
|
[G.TEXT, E],
|
|
1102
1101
|
[_.LINK, j],
|
|
1103
1102
|
[_.ANCHOR, j],
|
|
@@ -1111,10 +1110,10 @@ function Fe(n = {}) {
|
|
|
1111
1110
|
[_.SUPERSCRIPT, k("sup")],
|
|
1112
1111
|
[_.SUBSCRIPT, k("sub")],
|
|
1113
1112
|
[_.HIGHLIGHT, k("mark")],
|
|
1114
|
-
[
|
|
1115
|
-
[
|
|
1116
|
-
[
|
|
1117
|
-
[
|
|
1113
|
+
[$.TABLE, K],
|
|
1114
|
+
[$.TABLE_ROW, Y],
|
|
1115
|
+
[$.TABLE_CELL, W],
|
|
1116
|
+
[$.TABLE_HEADER, X],
|
|
1118
1117
|
...Object.entries(s).map(([c, u]) => [c, u])
|
|
1119
1118
|
]);
|
|
1120
1119
|
function x(c) {
|
|
@@ -1139,25 +1138,25 @@ function Fe(n = {}) {
|
|
|
1139
1138
|
};
|
|
1140
1139
|
}
|
|
1141
1140
|
let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1142
|
-
const Ge = (
|
|
1141
|
+
const Ge = (o, e, t = {}) => {
|
|
1143
1142
|
var r;
|
|
1144
|
-
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u",
|
|
1143
|
+
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
1145
1144
|
"_storyblok"
|
|
1146
|
-
), a =
|
|
1145
|
+
), a = n !== null && +n === o;
|
|
1147
1146
|
if (!(!s || !a)) {
|
|
1148
|
-
if (!
|
|
1147
|
+
if (!o) {
|
|
1149
1148
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
1150
1149
|
return;
|
|
1151
1150
|
}
|
|
1152
1151
|
window.storyblokRegisterEvent(() => {
|
|
1153
1152
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
|
|
1154
1153
|
var i;
|
|
1155
|
-
l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) ===
|
|
1154
|
+
l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === o ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === o && window.location.reload());
|
|
1156
1155
|
});
|
|
1157
1156
|
});
|
|
1158
1157
|
}
|
|
1159
|
-
}, V = (
|
|
1160
|
-
|
|
1158
|
+
}, V = (o, e) => {
|
|
1159
|
+
o.addNode("blok", (t) => {
|
|
1161
1160
|
let r = "";
|
|
1162
1161
|
return t.attrs.body.forEach((s) => {
|
|
1163
1162
|
r += e(s.component, s);
|
|
@@ -1165,28 +1164,28 @@ const Ge = (n, e, t = {}) => {
|
|
|
1165
1164
|
html: r
|
|
1166
1165
|
};
|
|
1167
1166
|
});
|
|
1168
|
-
}, Ve = (
|
|
1167
|
+
}, Ve = (o = {}) => {
|
|
1169
1168
|
var e, t;
|
|
1170
1169
|
const {
|
|
1171
1170
|
bridge: r,
|
|
1172
1171
|
accessToken: s,
|
|
1173
|
-
use:
|
|
1172
|
+
use: n = [],
|
|
1174
1173
|
apiOptions: a = {},
|
|
1175
1174
|
richText: l = {},
|
|
1176
1175
|
bridgeUrl: i
|
|
1177
|
-
} =
|
|
1176
|
+
} = o;
|
|
1178
1177
|
a.accessToken = a.accessToken || s;
|
|
1179
1178
|
const h = { bridge: r, apiOptions: a };
|
|
1180
1179
|
let d = {};
|
|
1181
|
-
|
|
1180
|
+
n.forEach((b) => {
|
|
1182
1181
|
d = { ...d, ...b(h) };
|
|
1183
1182
|
}), i && (M = i);
|
|
1184
1183
|
const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1185
1184
|
return r !== !1 && p && F(M), H = new C(l.schema), l.resolver && V(H, l.resolver), d;
|
|
1186
|
-
}, ze = (
|
|
1185
|
+
}, ze = (o) => {
|
|
1187
1186
|
var e;
|
|
1188
|
-
return !
|
|
1189
|
-
}, Je = (
|
|
1187
|
+
return !o || !((e = o == null ? void 0 : o.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
|
|
1188
|
+
}, Je = (o, e, t) => {
|
|
1190
1189
|
let r = t || H;
|
|
1191
1190
|
if (!r) {
|
|
1192
1191
|
console.error(
|
|
@@ -1194,10 +1193,10 @@ const Ge = (n, e, t = {}) => {
|
|
|
1194
1193
|
);
|
|
1195
1194
|
return;
|
|
1196
1195
|
}
|
|
1197
|
-
return ze(
|
|
1196
|
+
return ze(o) ? "" : (e && (r = new C(e.schema), e.resolver && V(r, e.resolver)), r.render(o, {}, !1));
|
|
1198
1197
|
}, Ke = () => F(M);
|
|
1199
1198
|
export {
|
|
1200
|
-
|
|
1199
|
+
$ as BlockTypes,
|
|
1201
1200
|
_ as MarkTypes,
|
|
1202
1201
|
C as RichTextResolver,
|
|
1203
1202
|
Oe as RichTextSchema,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.5.
|
|
4
|
+
"version": "4.5.4",
|
|
5
5
|
"private": false,
|
|
6
|
-
"packageManager": "pnpm@10.
|
|
6
|
+
"packageManager": "pnpm@10.7.0",
|
|
7
7
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
8
8
|
"author": "Storyblok",
|
|
9
9
|
"license": "MIT",
|
|
@@ -85,13 +85,14 @@
|
|
|
85
85
|
"simple-git-hooks": "^2.11.1",
|
|
86
86
|
"start-server-and-test": "^2.0.10",
|
|
87
87
|
"typescript": "5.7.3",
|
|
88
|
-
"vite": "^
|
|
88
|
+
"vite": "^5.4.16",
|
|
89
89
|
"vite-plugin-dts": "^4.5.0",
|
|
90
90
|
"vitest": "^3.0.5"
|
|
91
91
|
},
|
|
92
92
|
"pnpm": {
|
|
93
93
|
"onlyBuiltDependencies": [
|
|
94
|
-
"cypress"
|
|
94
|
+
"cypress",
|
|
95
|
+
"simple-git-hooks"
|
|
95
96
|
]
|
|
96
97
|
},
|
|
97
98
|
"babel": {
|