@storyblok/svelte 2.3.8 → 2.4.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 +7 -5
- package/dist/storyblok-svelte.js +3 -7
- package/dist/storyblok-svelte.mjs +702 -695
- package/dist/types.d.ts +2 -1
- package/package.json +6 -11
- package/types.ts +14 -14
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Install `@storyblok/svelte`
|
|
|
48
48
|
npm install @storyblok/svelte
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Please note that you have to use npm - unfortunately we are currently not supporting yarn or pnpm for this SDK.
|
|
51
|
+
Please note that you have to use npm - unfortunately we are currently not supporting yarn or pnpm for this SDK.
|
|
52
52
|
|
|
53
53
|
Initialize the library in your application by adding the `apiPlugin` and the [access token](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte) of your Storyblok space:
|
|
54
54
|
|
|
@@ -60,13 +60,13 @@ storyblokInit({
|
|
|
60
60
|
accessToken: "<your-token>",
|
|
61
61
|
// bridge: false,
|
|
62
62
|
use: [apiPlugin],
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
components: {
|
|
65
65
|
teaser: Teaser,
|
|
66
66
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// if you are using a space located in US region
|
|
68
|
+
// you have to use apiOptions.region:
|
|
69
|
+
/*
|
|
70
70
|
apiOptions: {
|
|
71
71
|
region: "us" // region code here
|
|
72
72
|
}
|
|
@@ -76,6 +76,7 @@ storyblokInit({
|
|
|
76
76
|
|
|
77
77
|
Add all your components to the components object in the storyblokInit function. You can load all of them at the same time by adding them to the list.
|
|
78
78
|
|
|
79
|
+
⚠️ This SDK uses the Fetch API under the hood. If your environment doesn't support it, you need to install a polyfill like [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch). More info on [storyblok-js-client docs](https://github.com/storyblok/storyblok-js-client#fetch-use-polyfill-if-needed---version-5).
|
|
79
80
|
|
|
80
81
|
## ℹ️ More Resources
|
|
81
82
|
|
|
@@ -86,6 +87,7 @@ The parts are:
|
|
|
86
87
|
- Part 2: [Render Storyblok Stories Dynamically in SvelteKit](https://www.storyblok.com/tp/render-storyblok-stories-dynamically-in-sveltekit) - [Source Code](https://github.com/storyblok/sveltekit-ultimate-tutorial-series/tree/part-2-sveltekit-ut)
|
|
87
88
|
- Part 3: [Create Dynamic Menus in Storyblok and SvelteKit](https://www.storyblok.com/tp/create-dynamic-menus-in-storyblok-and-sveltekit) - [Source Code](https://github.com/storyblok/sveltekit-ultimate-tutorial-series/tree/part-3-sveltekit-ut)
|
|
88
89
|
- Part 4: [Create Custom Components in Storyblok and SvelteKit](https://www.storyblok.com/tp/create-custom-components-in-storyblok-and-sveltekit) - [Source Code](https://github.com/storyblok/sveltekit-ultimate-tutorial-series/tree/part-4-sveltekit-ut)
|
|
90
|
+
- Part 5: [Create and Render Blog Articles in Storyblok and SvelteKit](https://www.storyblok.com/tp/create-and-render-blog-articles-in-storyblok-and-sveltekit) - [Source Code](https://github.com/storyblok/sveltekit-ultimate-tutorial-series/tree/part-5-sveltekit-ut)
|
|
89
91
|
|
|
90
92
|
### Support
|
|
91
93
|
|
package/dist/storyblok-svelte.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
(function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.storyblokSvelte={},h.e))})(this,function(h,m){"use strict";const ct=(r=>r&&typeof r=="object"&&"default"in r?r:{default:r})(m);var ut=Object.defineProperty,ht=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,D=(r,t,e)=>t in r?ut(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t)=>{for(var e in t||(t={}))dt.call(t,e)&&D(r,e,t[e]);if(B)for(var e of B(t))pt.call(t,e)&&D(r,e,t[e]);return r},E=(r,t)=>ht(r,ft(t));let z=!1;const U=[],gt=r=>new Promise((t,e)=>{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}z?s():U.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const n=document.createElement("script");n.async=!0,n.src=r,n.id="storyblok-javascript-bridge",n.onerror=s=>e(s),n.onload=s=>{U.forEach(o=>o()),z=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),mt=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e},yt=r=>r==="email";var H={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(r){return{tag:["pre",{tag:"code",attrs:r.attrs}]}},hard_break(){return{singleTag:"br"}},heading(r){return{tag:`h${r.attrs.level}`}},image(r){return{singleTag:[{tag:"img",attrs:mt(r.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return yt(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled(r){return{tag:[{tag:"span",attrs:r.attrs}]}}}};const kt=function(r){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},e=/[&<>"']/g,n=RegExp(e.source);return r&&n.test(r)?r.replace(e,s=>t[s]):r};class V{constructor(t){t||(t=H),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(kt(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let o=`<${s.tag}`;if(s.attrs)for(let a in s.attrs){let i=s.attrs[a];i!==null&&(o+=` ${a}="${i}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}/*!
|
|
2
|
-
* storyblok-js-client v4.5.2
|
|
3
|
-
* Universal JavaScript SDK for Storyblok's API
|
|
4
|
-
* (c) 2020-2022 Stobylok Team
|
|
5
|
-
*/function J(r){return typeof r=="number"&&r==r&&r!==1/0&&r!==-1/0}function Y(r,t,e){if(!J(t))throw new TypeError("Expected `limit` to be a finite number");if(!J(e))throw new TypeError("Expected `interval` to be a finite number");var n=[],s=[],o=0,a=function(){o++;var l=setTimeout(function(){o--,n.length>0&&a(),s=s.filter(function(u){return u!==l})},e);s.indexOf(l)<0&&s.push(l);var c=n.shift();c.resolve(r.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,f){n.push({resolve:u,reject:f,args:l,self:c}),o<t&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],n.forEach(function(l){l.reject(new throttle.AbortError)}),n.length=0},i}Y.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const _t=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e};var bt={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:r=>({tag:`h${r.attrs.level}`}),image:r=>({singleTag:[{tag:"img",attrs:_t(r.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:r=>({tag:[{tag:"span",attrs:r.attrs}]})}};class vt{constructor(t){t||(t=bt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(function(s){const o={"&":"&","<":"<",">":">",'"':""","'":"'"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,l=>o[l]):s}(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(n=>{if(n.constructor===String)return`<${n}${e}>`;{let s=`<${n.tag}`;if(n.attrs)for(let o in n.attrs){let a=n.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const $t=(r=0,t=r)=>{const e=Math.abs(t-r)||0,n=r<t?1:-1;return((s=0,o)=>[...Array(s)].map(o))(e,(s,o)=>o*n+r)},S=(r,t,e)=>{const n=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const o=r[s],a=e?"":encodeURIComponent(s);let i;i=typeof o=="object"?S(o,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),n.push(i)}return n.join("&")};let b={},g={};class wt{constructor(t,e){if(!e){let o=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let n=Object.assign({},t.headers),s=5;t.oauthToken!==void 0&&(n.Authorization=t.oauthToken,s=3),t.rateLimit!==void 0&&(s=t.rateLimit),this.richTextResolver=new vt(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=Y(this.throttledRequest,s,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=ct.default.create({baseURL:e,timeout:t.timeout||0,headers:n,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(o=>t.responseInterceptor(o)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((n="")=>n.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,n,s){const o=this.factoryParamOptions(t,((a={},i=25,l=1)=>E(d({},a),{per_page:i,page:l}))(e,n,s));return this.cacheResponse(t,o)}get(t,e){let n=`/${t}`;const s=this.factoryParamOptions(n,e);return this.cacheResponse(n,s)}async getAll(t,e={},n){const s=e.per_page||25,o=`/${t}`,a=o.split("/");n=n||a[a.length-1];const i=await this.makeRequest(o,e,s,1),l=i.total?Math.ceil(i.total/s):1;return((c=[],u)=>c.map(u).reduce((f,R)=>[...f,...R],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))($t(1,l),async c=>this.makeRequest(o,e,s,c+1))],c=>Object.values(c.data[n]))}post(t,e){let n=`/${t}`;return this.throttle("post",n,e)}put(t,e){let n=`/${t}`;return this.throttle("put",n,e)}delete(t,e){let n=`/${t}`;return this.throttle("delete",n,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const n=t[e];n&&n.fieldtype=="multilink"&&n.linktype=="story"&&typeof n.id=="string"&&this.links[n.id]?n.story=this._cleanCopy(this.links[n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[n.uuid]&&(n.story=this._cleanCopy(this.links[n.uuid]))}_insertRelations(t,e,n){if(n.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let s=[];t[e].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),t[e]=s}}}_insertAssetsRelations(t,e){e.forEach(n=>{t.id===n.id&&(t.original=n,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let n=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)n(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,e),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,e),n(s[o])}}};n(t.content)}async resolveLinks(t,e){let n=[];if(t.link_uuids){const s=t.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.link_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.links;n.forEach(s=>{this.links[s.uuid]=E(d({},s),{_stopResolving:!0})})}async resolveRelations(t,e){let n=[];if(t.rel_uuids){const s=t.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.rel_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.rels;n.forEach(s=>{this.relations[s.uuid]=E(d({},s),{_stopResolving:!0})})}async resolveStories(t,e){let n=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(n=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],n);t.story?this.iterateTree(t.story,n):t.stories.forEach(s=>{this.iterateTree(s,n)})}resolveAssetsRelations(t){const{assets:e,stories:n,story:s}=t;if(n)for(const o of n)this.iterateTree(o,e);else{if(!s)return t;this.iterateTree(s,e)}}cacheResponse(t,e,n){return n===void 0&&(n=0),new Promise(async(s,o)=>{let a=S({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return s(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:f=>S(f)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),u=Object.assign({},u,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0}),c.status!=200)return o(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),s(u)}catch(c){if(c.response&&c.response.status===429&&(n+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${n} seconds.`),await(l=1e3*n,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,n).then(s).catch(o);o(c)}var l})}throttledRequest(t,e,n){return this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const Tt=(r={})=>{const{apiOptions:t}=r;if(!t.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 wt(t)}};var Rt=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let x;const Et="https://app.storyblok.com/f/storyblok-v2-latest.js",St=(r,t,e={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],s=>{s.action==="input"&&s.story.id===r?t(s.story):(s.action==="change"||s.action==="published")&&s.storyId===r&&window.location.reload()})})}},xt=(r={})=>{const{bridge:t,accessToken:e,use:n=[],apiOptions:s={},richText:o={}}=r;s.accessToken=s.accessToken||e;const a={bridge:t,apiOptions:s};let i={};return n.forEach(l=>{i=d(d({},i),l(a))}),t!==!1&>(Et),x=new V(o.schema),o.resolver&&F(x,o.resolver),i},F=(r,t)=>{r.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})},Ot=(r,t,e)=>{let n=e||x;if(!n){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(t&&(n=new V(t.schema),t.resolver&&F(n,t.resolver)),n.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
1
|
+
(function(d,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(d=typeof globalThis<"u"?globalThis:d||self,_(d.storyblokSvelte={}))})(this,function(d){"use strict";var _=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,q=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e)=>{for(var t in e||(e={}))he.call(e,t)&&q(r,t,e[t]);if(B)for(var t of B(e))de.call(e,t)&&q(r,t,e[t]);return r},x=(r,e)=>le(r,ue(e));let D=!1;const F=[],fe=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=n=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}D?n():F.push(n)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=r,s.id="storyblok-javascript-bridge",s.onerror=n=>t(n),s.onload=n=>{F.forEach(o=>o()),D=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(s)});var pe=Object.defineProperty,ge=(r,e,t)=>e in r?pe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e,t)=>(ge(r,typeof e!="symbol"?e+"":e,t),t);function J(r){return!(r!==r||r===1/0||r===-1/0)}function me(r,e,t){if(!J(e))throw new TypeError("Expected `limit` to be a finite number");if(!J(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0;const a=function(){o++;const c=setTimeout(function(){o--,s.length>0&&a(),n=n.filter(function(h){return h!==c})},t);n.indexOf(c)<0&&n.push(c);const l=s.shift();l.resolve(r.apply(l.self,l.args))},i=function(...c){const l=this;return new Promise(function(h,f){s.push({resolve:h,reject:f,args:c,self:l}),o<e&&a()})};return i.abort=function(){n.forEach(clearTimeout),n=[],s.forEach(function(c){c.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},i}const ye=function(r,e){const t={};for(const s in r){const n=r[s];e.indexOf(s)>-1&&n!==null&&(t[s]=n)}return t},_e=r=>r==="email",be=()=>({singleTag:"hr"}),ke=()=>({tag:"blockquote"}),ve=()=>({tag:"ul"}),we=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),$e=()=>({singleTag:"br"}),Te=r=>({tag:`h${r.attrs.level}`}),Re=r=>({singleTag:[{tag:"img",attrs:ye(r.attrs,["src","alt","title"])}]}),je=()=>({tag:"li"}),Pe=()=>({tag:"ol"}),xe=()=>({tag:"p"}),Oe=()=>({tag:"b"}),Se=()=>({tag:"strike"}),Ee=()=>({tag:"u"}),Ce=()=>({tag:"strong"}),Ie=()=>({tag:"code"}),Ae=()=>({tag:"i"}),Ne=r=>{const e=p({},r.attrs),{linktype:t="url"}=r.attrs;return _e(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},Me=r=>({tag:[{tag:"span",attrs:r.attrs}]}),V={nodes:{horizontal_rule:be,blockquote:ke,bullet_list:ve,code_block:we,hard_break:$e,heading:Te,image:Re,list_item:je,ordered_list:Pe,paragraph:xe},marks:{bold:Oe,strike:Se,underline:Ee,strong:Ce,code:Ie,italic:Ae,link:Ne,styled:Me}},Le=function(r){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,s=RegExp(t.source);return r&&s.test(r)?r.replace(t,n=>e[n]):r};class w{constructor(e){u(this,"marks"),u(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){if(e&&e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(s=>{t+=this.renderNode(s)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const t=[];e.marks&&e.marks.forEach(n=>{const o=this.getMatchingMark(n);o&&t.push(this.renderOpeningTag(o.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(n=>{t.push(this.renderNode(n))}):e.text?t.push(Le(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html&&t.push(s.html),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(n=>{const o=this.getMatchingMark(n);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let n=`<${s.tag}`;if(s.attrs)for(const o in s.attrs){const a=s.attrs[o];a!==null&&(n+=` ${o}="${a}"`)}return`${n}${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)}}class z{constructor(){u(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),u(this,"getOptionsPage",(e,t=25,s=1)=>x(p({},e),{per_page:t,page:s})),u(this,"delay",e=>new Promise(t=>setTimeout(t,e))),u(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),u(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,n=e<t?1:-1;return this.arrayFrom(s,(o,a)=>a*n+e)}),u(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),u(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,n)=>[...s,...n],[]))}stringify(e,t,s){const n=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const a=e[o],i=s?"":encodeURIComponent(o);let c;typeof a=="object"?c=this.stringify(a,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(a)):c=(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(a),n.push(c)}return n.join("&")}}class Ue{constructor(e){u(this,"baseURL"),u(this,"timeout"),u(this,"headers"),u(this,"responseInterceptor"),u(this,"fetch"),u(this,"ejectInterceptor"),u(this,"url"),u(this,"parameters"),this.baseURL=e.baseURL,this.headers=e.headers||[],this.timeout=e.timeout?e.timeout*1e3:1e3,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={}}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=[],s={data:{},headers:{},status:0,statusText:""};await e.json().then(n=>{s.data=n});for(const n of e.headers.entries())t[n[0]]=n[1];return s.headers=p({},t),s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){const t=new URL(`${this.baseURL}${this.url}`);let s=null;if(e==="get"){const i=new z;t.search=i.stringify(this.parameters)}else s=JSON.stringify(this.parameters);const n=new AbortController,{signal:o}=n,a=setTimeout(()=>n.abort(),this.timeout);try{const i=await this.fetch(`${t}`,{method:e,headers:this.headers,body:s,signal:o});clearTimeout(a);const c=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(i){return i}}eject(){this.ejectInterceptor=!0}_statusHandler(e){if(/20[01]/g.test(`${e.status}`))return e;throw{message:new Error(e.statusText||`status: ${e.status}`),response:e}}}let $={};const m={};class He{constructor(e,t){if(u(this,"client"),u(this,"maxRetries"),u(this,"throttle"),u(this,"accessToken"),u(this,"cache"),u(this,"helpers"),u(this,"relations"),u(this,"links"),u(this,"richTextResolver"),u(this,"resolveNestedRelations"),!t){const o=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";e.oauthToken?t=`${a}://api${o}.storyblok.com/v1`:t=`${a}://api${o}.storyblok.com/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),s.forEach((o,a)=>{e.headers&&e.headers[a]&&s.set(a,e.headers[a])});let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new w(e.richTextSchema):this.richTextResolver=new w,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries,this.throttle=me(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new z,this.resolveNestedRelations=!1,this.client=new Ue({baseURL:t,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body.forEach(n=>{s+=e(n.component,n)}),{html:s}})}parseParams(e){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=m[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,n){const o=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,n));return this.cacheResponse(e,o)}get(e,t){t||(t={});const s=`/${e}`,n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n)}async getAll(e,t,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`,a=o.split("/"),i=s||a[a.length-1],c=1,l=await this.makeRequest(o,t,n,c),h=l.total?Math.ceil(l.total/n):1,f=await this.helpers.asyncMap(this.helpers.range(c,h),y=>this.makeRequest(o,t,n,y+1));return this.helpers.flatMap([l,...f],y=>Object.values(y.data[i]))}post(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t))}put(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t))}delete(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const s=e[t];s&&s.fieldtype=="multilink"&&s.linktype=="story"&&typeof s.id=="string"&&this.links[s.id]?s.story=this._cleanCopy(this.links[s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[s.uuid]&&(s.story=this._cleanCopy(this.links[s.uuid]))}_insertRelations(e,t,s){if(s.indexOf(`${e.component}.${t}`)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t]&&e[t].constructor===Array){const n=[];e[t].forEach(o=>{this.relations[o]&&n.push(this._cleanCopy(this.relations[o]))}),e[t]=n}}}iterateTree(e,t){const s=n=>{if(n!=null){if(n.constructor===Array)for(let o=0;o<n.length;o++)s(n[o]);else if(n.constructor===Object){if(n._stopResolving)return;for(const o in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,o,t),this._insertLinks(n,o)),s(n[o])}}};s(e.content)}async resolveLinks(e,t){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],a=50;for(let i=0;i<n;i+=a){const c=Math.min(n,i+a);o.push(e.link_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[n.uuid]=x(p({},n),{_stopResolving:!0})})}async resolveRelations(e,t){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],a=50;for(let i=0;i<n;i+=a){const c=Math.min(n,i+a);o.push(e.rel_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[n.uuid]=x(p({},n),{_stopResolving:!0})})}async resolveStories(e,t){var s,n;let o=[];if(typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t)),t.resolve_links&&["1","story","url"].indexOf(t.resolve_links)>-1&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const a in this.relations)this.iterateTree(this.relations[a],o);e.story?this.iterateTree(e.story,o):e.stories.forEach(a=>{this.iterateTree(a,o)})}cacheResponse(e,t,s){return new Promise((n,o)=>{const a=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const c=i.get(a);if(c)return n(c)}try{(async()=>{var c;const l=await this.throttle("get",e,t);let h={data:l.data,headers:l.headers};if((c=l.headers)!=null&&c["per-page"]&&(h=Object.assign({},h,{perPage:l.headers["per-page"]?parseInt(l.headers["per-page"]):0,total:l.headers["per-page"]?parseInt(l.headers.total):0})),l.status!=200)return o(l);(h.data.story||h.data.stories)&&await this.resolveStories(h.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,h),h.data.cv&&t.token&&(t.version=="draft"&&m[t.token]!=h.data.cv&&this.flushCache(),m[t.token]=h.data.cv),n(h)})()}catch{}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return $[e]},getAll(){return $},set(e,t){$[e]=t},flush(){$={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}flushCache(){return this.cacheProvider().flush(),this}}const Be=(r={})=>{const{apiOptions:e}=r;if(!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)}};var qe=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let O;const De="https://app.storyblok.com/f/storyblok-v2-latest.js",Fe=(r,e,t={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===r?e(n.story):(n.action==="change"||n.action==="published")&&n.storyId===r&&window.location.reload()})})}},Je=(r={})=>{const{bridge:e,accessToken:t,use:s=[],apiOptions:n={},richText:o={}}=r;n.accessToken=n.accessToken||t;const a={bridge:e,apiOptions:n};let i={};return s.forEach(c=>{i=p(p({},i),c(a))}),e!==!1&&fe(De),O=new w(o.schema),o.resolver&&Y(O,o.resolver),i},Y=(r,e)=>{r.addNode("blok",t=>{let s="";return t.attrs.body.forEach(n=>{s+=e(n.component,n)}),{html:s}})},Ve=(r,e,t)=>{let s=t||O;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(e&&(s=new w(e.schema),e.resolver&&Y(s,e.resolver)),s.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
6
2
|
|
|
7
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function
|
|
3
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function S(){}function E(r,e){for(const t in e)r[t]=e[t];return r}function K(r){return r()}function Q(){return Object.create(null)}function b(r){r.forEach(K)}function G(r){return typeof r=="function"}function ze(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Ye(r){return Object.keys(r).length===0}function Ke(r){const e={};for(const t in r)t[0]!=="$"&&(e[t]=r[t]);return e}function W(r,e){const t={};e=new Set(e);for(const s in r)!e.has(s)&&s[0]!=="$"&&(t[s]=r[s]);return t}function Qe(r,e,t){r.insertBefore(e,t||null)}function X(r){r.parentNode&&r.parentNode.removeChild(r)}function Ge(r){return document.createTextNode(r)}function We(){return Ge("")}function Xe(r){return Array.from(r.childNodes)}function Z(r,e){return new r(e)}let C;function k(r){C=r}const v=[],ee=[],T=[],te=[],Ze=Promise.resolve();let I=!1;function et(){I||(I=!0,Ze.then(re))}function A(r){T.push(r)}const N=new Set;let R=0;function re(){const r=C;do{for(;R<v.length;){const e=v[R];R++,k(e),tt(e.$$)}for(k(null),v.length=0,R=0;ee.length;)ee.pop()();for(let e=0;e<T.length;e+=1){const t=T[e];N.has(t)||(N.add(t),t())}T.length=0}while(v.length);for(;te.length;)te.pop()();I=!1,N.clear(),k(r)}function tt(r){if(r.fragment!==null){r.update(),b(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(A)}}const j=new Set;let g;function rt(){g={r:0,c:[],p:g}}function st(){g.r||b(g.c),g=g.p}function M(r,e){r&&r.i&&(j.delete(r),r.i(e))}function se(r,e,t,s){if(r&&r.o){if(j.has(r))return;j.add(r),g.c.push(()=>{j.delete(r),s&&(t&&r.d(1),s())}),r.o(e)}else s&&s()}function nt(r,e){const t={},s={},n={$$scope:1};let o=r.length;for(;o--;){const a=r[o],i=e[o];if(i){for(const c in a)c in i||(s[c]=1);for(const c in i)n[c]||(t[c]=i[c],n[c]=1);r[o]=i}else for(const c in a)n[c]=1}for(const a in s)a in t||(t[a]=void 0);return t}function ot(r){return typeof r=="object"&&r!==null?r:{}}function ne(r){r&&r.c()}function L(r,e,t,s){const{fragment:n,after_update:o}=r.$$;n&&n.m(e,t),s||A(()=>{const a=r.$$.on_mount.map(K).filter(G);r.$$.on_destroy?r.$$.on_destroy.push(...a):b(a),r.$$.on_mount=[]}),o.forEach(A)}function U(r,e){const t=r.$$;t.fragment!==null&&(b(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function it(r,e){r.$$.dirty[0]===-1&&(v.push(r),et(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function at(r,e,t,s,n,o,a,i=[-1]){const c=C;k(r);const l=r.$$={fragment:null,ctx:[],props:o,update:S,not_equal:n,bound:Q(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Q(),dirty:i,skip_bound:!1,root:e.target||c.$$.root};a&&a(l.root);let h=!1;if(l.ctx=t?t(r,e.props||{},(f,y,...ae)=>{const ce=ae.length?ae[0]:y;return l.ctx&&n(l.ctx[f],l.ctx[f]=ce)&&(!l.skip_bound&&l.bound[f]&&l.bound[f](ce),h&&it(r,f)),y}):[],l.update(),h=!0,b(l.before_update),l.fragment=s?s(l.ctx):!1,e.target){if(e.hydrate){const f=Xe(e.target);l.fragment&&l.fragment.l(f),f.forEach(X)}else l.fragment&&l.fragment.c();e.intro&&M(r.$$.fragment),L(r,e.target,e.anchor,e.customElement),re()}k(c)}class ct{$destroy(){U(this,1),this.$destroy=S}$on(e,t){if(!G(t))return S;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const n=s.indexOf(t);n!==-1&&s.splice(n,1)}}$set(e){this.$$set&&!Ye(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function lt(r){let e,t,s;const n=[{blok:r[0]},r[2]];var o=r[1];function a(i){let c={};for(let l=0;l<n.length;l+=1)c=E(c,n[l]);return{props:c}}return o&&(e=Z(o,a())),{c(){e&&ne(e.$$.fragment),t=We()},m(i,c){e&&L(e,i,c),Qe(i,t,c),s=!0},p(i,[c]){const l=c&5?nt(n,[c&1&&{blok:i[0]},c&4&&ot(i[2])]):{};if(o!==(o=i[1])){if(e){rt();const h=e;se(h.$$.fragment,1,0,()=>{U(h,1)}),st()}o?(e=Z(o,a()),ne(e.$$.fragment),M(e.$$.fragment,1),L(e,t.parentNode,t)):e=null}else o&&e.$set(l)},i(i){s||(e&&M(e.$$.fragment,i),s=!0)},o(i){e&&se(e.$$.fragment,i),s=!1},d(i){i&&X(t),e&&U(e,i)}}}function ut(r,e,t){const s=["blok"];let n=W(e,s),o,{blok:a}=e;return a?o=ie(a.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),r.$$set=i=>{e=E(E({},e),Ke(i)),t(2,n=W(e,s)),"blok"in i&&t(0,a=i.blok)},[a,o,n]}class ht extends ct{constructor(e){super(),at(this,e,ut,lt,ze,{blok:0})}}const dt=(r,e)=>{const t=s=>{const n=qe(s);n["data-blok-c"]&&(r.setAttribute("data-blok-c",n["data-blok-c"]),r.setAttribute("data-blok-uid",n["data-blok-uid"]),r.classList.add("storyblok__outline"))};return t(e),{update(s){t(s)}}};let H=null;const oe=()=>(H||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),H);let P=null;const ft=r=>{const{storyblokApi:e}=Je(r);H=e,P=r.components||{}},ie=r=>{let e=null;return e=typeof P=="function"?P()[r]:P[r],e||console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
|
|
8
4
|
storyblokInit({
|
|
9
5
|
accessToken: "<your-token>",
|
|
10
6
|
components: {
|
|
11
7
|
"teaser": Teaser
|
|
12
8
|
}
|
|
13
9
|
})
|
|
14
|
-
`),
|
|
10
|
+
`),e};d.RichTextSchema=V,d.StoryblokComponent=ht,d.apiPlugin=Be,d.getComponent=ie,d.getStoryblokApi=oe,d.renderRichText=Ve,d.storyblokEditable=dt,d.storyblokInit=ft,d.useStoryblokApi=oe,d.useStoryblokBridge=Fe,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|