@storyblok/vue 8.1.0 → 8.1.2
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 +3 -3
- package/dist/FallbackComponent-C2j8Ky5h.mjs +24 -0
- package/dist/FallbackComponent.vue.d.ts +1 -1
- package/dist/StoryblokComponent.vue.d.ts +3 -3
- package/dist/components/StoryblokRichText.vue.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/storyblok-vue.js +3 -3
- package/dist/storyblok-vue.mjs +141 -140
- package/package.json +9 -9
- package/dist/FallbackComponent-D9TGQNbC.mjs +0 -24
package/README.md
CHANGED
|
@@ -130,15 +130,15 @@ Check the available [apiOptions](https://www.storyblok.com/docs/api/content-deli
|
|
|
130
130
|
|
|
131
131
|
### Rendering Rich Text
|
|
132
132
|
|
|
133
|
-
You can render rich-text fields by using the `
|
|
133
|
+
You can render rich-text fields by using the `StoryblokRichText` component:
|
|
134
134
|
|
|
135
135
|
```html
|
|
136
136
|
<script setup>
|
|
137
|
-
import {
|
|
137
|
+
import { StoryblokRichText } from "@storyblok/vue";
|
|
138
138
|
</script>
|
|
139
139
|
|
|
140
140
|
<template>
|
|
141
|
-
<
|
|
141
|
+
<StoryblokRichText :doc="blok.articleContent" />
|
|
142
142
|
</template>
|
|
143
143
|
```
|
|
144
144
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineComponent as r, openBlock as p, createElementBlock as a, createElementVNode as n, createTextVNode as c, toDisplayString as m } from "vue";
|
|
2
|
+
const _ = { class: "fallback-component" }, d = { class: "component" }, f = /* @__PURE__ */ r({
|
|
3
|
+
__name: "FallbackComponent",
|
|
4
|
+
props: {
|
|
5
|
+
blok: {}
|
|
6
|
+
},
|
|
7
|
+
setup(t) {
|
|
8
|
+
return (e, o) => (p(), a("div", _, [
|
|
9
|
+
n("p", null, [
|
|
10
|
+
o[0] || (o[0] = c(" Component could not be found for blok ")),
|
|
11
|
+
n("span", d, m(e.blok.component), 1),
|
|
12
|
+
o[1] || (o[1] = c("! Is it configured correctly? "))
|
|
13
|
+
])
|
|
14
|
+
]));
|
|
15
|
+
}
|
|
16
|
+
}), i = (t, e) => {
|
|
17
|
+
const o = t.__vccOpts || t;
|
|
18
|
+
for (const [s, l] of e)
|
|
19
|
+
o[s] = l;
|
|
20
|
+
return o;
|
|
21
|
+
}, u = /* @__PURE__ */ i(f, [["__scopeId", "data-v-93c770c0"]]);
|
|
22
|
+
export {
|
|
23
|
+
u as default
|
|
24
|
+
};
|
|
@@ -2,7 +2,7 @@ import type { SbBlokData } from "./types";
|
|
|
2
2
|
export interface SbComponentProps {
|
|
3
3
|
blok: SbBlokData;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<SbComponentProps
|
|
5
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
6
|
export default _default;
|
|
7
7
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
8
8
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SbComponentProps } from "./types";
|
|
2
|
-
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<SbComponentProps
|
|
3
|
-
value: import("vue").Ref<any>;
|
|
4
|
-
},
|
|
2
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>, {
|
|
3
|
+
value: import("vue").Ref<any, any>;
|
|
4
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
5
5
|
export default _default;
|
|
6
6
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
7
7
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryblokRichTextProps } from "../types";
|
|
2
|
-
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<StoryblokRichTextProps
|
|
2
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<StoryblokRichTextProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<StoryblokRichTextProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
3
3
|
export default _default;
|
|
4
4
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
5
5
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export * from "./composables/useStoryblokRichText";
|
|
|
7
7
|
export declare const useStoryblokApi: () => StoryblokClient;
|
|
8
8
|
export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<Ref<ISbStoryData<import("@storyblok/js").StoryblokComponentType<string> & {
|
|
9
9
|
[index: string]: any;
|
|
10
|
+
}>, ISbStoryData<import("@storyblok/js").StoryblokComponentType<string> & {
|
|
11
|
+
[index: string]: any;
|
|
10
12
|
}>>>;
|
|
11
13
|
export declare const StoryblokVue: Plugin;
|
|
12
14
|
export * from "./types";
|
package/dist/storyblok-vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(m,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(m=typeof globalThis<"u"?globalThis:m||self,g(m.storyblokVue={},m.Vue))})(this,function(m,g){"use strict";let
|
|
1
|
+
(function(m,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(m=typeof globalThis<"u"?globalThis:m||self,g(m.storyblokVue={},m.Vue))})(this,function(m,g){"use strict";let U=!1;const D=[],Z=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}U?o():D.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=s,r.id="storyblok-javascript-bridge",r.onerror=o=>t(o),r.onload=o=>{D.forEach(n=>n()),U=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});var ee=Object.defineProperty,te=(s,e,t)=>e in s?ee(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,p=(s,e,t)=>te(s,typeof e!="symbol"?e+"":e,t);function z(s){return!(s!==s||s===1/0||s===-1/0)}function re(s,e,t){if(!z(e))throw new TypeError("Expected `limit` to be a finite number");if(!z(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let o=[],n=0;const i=function(){n++;const a=setTimeout(function(){n--,r.length>0&&i(),o=o.filter(function(d){return d!==a})},t);o.indexOf(a)<0&&o.push(a);const u=r.shift();u.resolve(s.apply(u.self,u.args))},l=function(...a){const u=this;return new Promise(function(d,h){r.push({resolve:d,reject:h,args:a,self:u}),n<e&&i()})};return l.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),r.length=0},l}class O{constructor(){p(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),p(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),p(this,"delay",e=>new Promise(t=>setTimeout(t,e))),p(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),p(this,"range",(e=0,t=e)=>{const r=Math.abs(t-e)||0,o=e<t?1:-1;return this.arrayFrom(r,(n,i)=>i*o+e)}),p(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),p(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,o)=>[...r,...o],[])),p(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,o=RegExp(r.source);return e&&o.test(e)?e.replace(r,n=>t[n]):e})}stringify(e,t,r){const o=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],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),o.push(a)}return o.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",o="app.storyblokchina.cn",n="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return o;case"ap":return n;case"ca":return i;default:return t}}}const se=function(s,e){const t={};for(const r in s){const o=s[r];e.indexOf(r)>-1&&o!==null&&(t[r]=o)}return t},oe=s=>s==="email",ne=()=>({singleTag:"hr"}),ie=()=>({tag:"blockquote"}),ae=()=>({tag:"ul"}),le=s=>({tag:["pre",{tag:"code",attrs:s.attrs}]}),ce=()=>({singleTag:"br"}),he=s=>({tag:`h${s.attrs.level}`}),ue=s=>({singleTag:[{tag:"img",attrs:se(s.attrs,["src","alt","title"])}]}),de=()=>({tag:"li"}),pe=()=>({tag:"ol"}),ge=()=>({tag:"p"}),fe=s=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":s.attrs.name,emoji:s.attrs.emoji}}]}),me=()=>({tag:"b"}),ye=()=>({tag:"s"}),be=()=>({tag:"u"}),ke=()=>({tag:"strong"}),ve=()=>({tag:"code"}),Te=()=>({tag:"i"}),$e=s=>{if(!s.attrs)return{tag:""};const e=new O().escapeHTML,t={...s.attrs},{linktype:r="url"}=s.attrs;if(delete t.linktype,t.href&&(t.href=e(s.attrs.href||"")),oe(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const o in t.custom)t[o]=t.custom[o];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},_e=s=>({tag:[{tag:"span",attrs:s.attrs}]}),Re=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Se=s=>({tag:[{tag:"span",attrs:s.attrs}]}),Ee=s=>{var e;return(e=s.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${s.attrs.color};`}}]}:{tag:""}},Ce=s=>{var e;return(e=s.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${s.attrs.color}`}}]}:{tag:""}},B={nodes:{horizontal_rule:ne,blockquote:ie,bullet_list:ae,code_block:le,hard_break:ce,heading:he,image:ue,list_item:de,ordered_list:pe,paragraph:ge,emoji:fe},marks:{bold:me,strike:ye,underline:be,strong:ke,code:ve,italic:Te,link:$e,styled:_e,subscript:Re,superscript:we,anchor:Se,highlight:Ee,textStyle:Ce}},je=function(s){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,r=RegExp(t.source);return s&&r.test(s)?s.replace(t,o=>e[o]):s};let V=!1;class Ie{constructor(e){p(this,"marks"),p(this,"nodes"),e||(e=B),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(!V&&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/"),V=!0),e&&e.content&&Array.isArray(e.content)){let o="";return e.content.forEach(n=>{o+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(o,t.optimizeImages):o}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,5 +21,5 @@
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
type: 'doc'
|
|
24
|
-
}`),""}optimizeImages(e,t){let r=0,o=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}" `,o=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-Fa-f]{6}/g)||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||o>0||i.length>0?`${r}x${o}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|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 u,p;const h=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(h&&h.length>0){const b={srcset:(u=t.srcset)==null?void 0:u.map(k=>{if(typeof k=="number")return`//${h}/m/${k}x0${i} ${k}w`;if(typeof k=="object"&&k.length===2){let S=0,A=0;return typeof k[0]=="number"&&(S=k[0]),typeof k[1]=="number"&&(A=k[1]),`//${h}/m/${S}x${A}${i} ${S}w`}}).join(", "),sizes:(p=t.sizes)==null?void 0:p.map(k=>k).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(o=>{const n=this.getMatchingMark(o);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(o=>{t.push(this.renderNode(o))}):e.text?t.push(Ce(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(o=>{const n=this.getMatchingMark(o);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 o=`<${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&&(o+=` ${n}="${i}"`)}}return`${o}${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," /")}}const C=Ie;class je{constructor(e){d(this,"baseURL"),d(this,"timeout"),d(this,"headers"),d(this,"responseInterceptor"),d(this,"fetch"),d(this,"ejectInterceptor"),d(this,"url"),d(this,"parameters"),d(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(o=>{r.data=o});for(const o of e.headers.entries())t[o[0]]=o[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 O;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const o=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(`${o}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const u=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}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,o)=>{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};o(n)})}}const Oe=je,V="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const E={};class xe{constructor(e,t){d(this,"client"),d(this,"maxRetries"),d(this,"retriesDelay"),d(this,"throttle"),d(this,"accessToken"),d(this,"cache"),d(this,"helpers"),d(this,"resolveCounter"),d(this,"relations"),d(this,"links"),d(this,"richTextResolver"),d(this,"resolveNestedRelations"),d(this,"stringifiedStoriesCache");let r=e.endpoint||t;if(!r){const i=new O().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const o=new Headers;o.set("Content-Type","application/json"),o.set("Accept","application/json"),e.headers&&e.headers.entries().toArray().forEach(([i,l])=>{o.set(i,l)}),o.has(V)||(o.set(V,P.defaultAgentName),o.set(P.defaultAgentVersion,P.packageVersion));let n=5;e.oauthToken&&(o.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=te(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new O,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Oe({baseURL:r,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[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,o,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,o));return this.cacheResponse(e,i,void 0,n)}get(e,t,r){t||(t={});const o=`/${e}`,n=this.factoryParamOptions(o,t);return this.cacheResponse(o,n,void 0,r)}async getAll(e,t,r,o){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`,l=i.split("/"),a=r||l[l.length-1],u=1,p=await this.makeRequest(i,t,n,u,o),h=p.total?Math.ceil(p.total/n):1,b=await this.helpers.asyncMap(this.helpers.range(u,h),_=>this.makeRequest(i,t,n,_+1,o));return this.helpers.flatMap([p,...b],_=>Object.values(_.data[a]))}post(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("post",o,t,r))}put(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("put",o,t,r))}delete(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("delete",o,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 o=e[t];o&&o.fieldtype=="multilink"&&o.linktype=="story"&&typeof o.id=="string"&&this.links[r][o.id]?o.story=this._cleanCopy(this.links[r][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[r][o.uuid]&&(o.story=this._cleanCopy(this.links[r][o.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,r,o){r.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(o,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(o,n)).filter(Boolean)))}iterateTree(e,t,r){const o=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)o(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,r),this._insertLinks(n,i,r)),o(n[i])}}};o(e.content)}async resolveLinks(e,t,r){let o=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const u=Math.min(n,a+l);i.push(e.link_uuids.slice(a,u))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(u=>{o.push(u)})}else o=e.links;o.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let o=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const u=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,u))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{o.push(u)})}else o=e.rels;o&&o.length>0&&o.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var o,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"].indexOf(t.resolve_links)>-1&&((o=e.links)!=null&&o.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,o){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),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 u;try{const p=await this.throttle("get",e,t,o);if(p.status!==200)return a(p);let h={data:p.data,headers:p.headers};if((u=p.headers)!=null&&u["per-page"]&&(h=Object.assign({},h,{perPage:p.headers["per-page"]?parseInt(p.headers["per-page"]):0,total:p.headers["per-page"]?parseInt(p.headers.total):0})),h.data.story||h.data.stories){const b=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(h.data,t,`${b}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(n,h),h.data.cv&&t.token&&(t.version==="draft"&&E[t.token]!=h.data.cv&&await this.flushCache(),E[t.token]=t.cv?t.cv:h.data.cv),l(h)}catch(p){if(p.response&&p.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(p)}})}throttledRequest(e,t,r,o){return this.client.setFetchOptions(o),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[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 Ae=(s={})=>{const{apiOptions:e}=s;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 xe(e)}},Pe=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};var v=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s))(v||{}),T=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))(T||{}),L=(s=>(s.TEXT="text",s))(L||{}),I=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(I||{});function Le(s,e){if(!e)return{src:s,attrs:{}};let t=0,r=0;const o={},n=[];function i(a,u,p,h,b){typeof a!="number"||a<=u||a>=p?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${u} and ${p} (inclusive)`):b.push(`${h}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(o.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?(o.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)&&(o.loading=e.loading),e.class&&(o.class=e.class),e.filters){const{filters:a}=e||{},{blur:u,brightness:p,fill:h,format:b,grayscale:_,quality:k,rotate:S}=a||{};u&&i(u,0,100,"blur",n),k&&i(k,0,100,"quality",n),p&&i(p,0,100,"brightness",n),h&&n.push(`fill(${h})`),_&&n.push("grayscale()"),S&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${S})`),b&&["webp","png","jpeg"].includes(b)&&n.push(`format(${b})`)}e.srcset&&(o.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${s}/m/${a}x0/${n.length>0?"filters:"+n.join(":"):""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[u,p]=a;return`${s}/m/${u}x${p}/${n.length>0?"filters:"+n.join(":"):""} ${u}w`}}).join(", ")),e.sizes&&(o.sizes=e.sizes.join(", "))}let l=`${s}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:o}}const Ne=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),Me=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function Ue(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function De(s,e={},t){const r=Ne(e);return`<${r?`${s} ${r}`:s}>${Array.isArray(t)?t.join(""):t||""}</${s}>`}function F(s={}){let e=0;const{renderFn:t=De,textFn:r=Ue,resolvers:o={},optimizeImages:n=!1}=s,i=c=>f=>t(c,{...f.attrs,key:`${c}-${e}`},f.children||null),l=c=>{const{src:f,alt:y,...$}=c.attrs||{};let R=f,w={};if(n){const{src:Qe,attrs:Ze}=Le(f,n);R=Qe,w=Ze}const We={src:R,alt:y||"",key:`img-${e}`,...$,...w};return t("img",We,"")},a=c=>{const{level:f,...y}=c.attrs||{};return t(`h${f}`,{...y,key:`h${f}-${e}`},c.children)},u=c=>{var f,y,$,R;return t("span",{"data-type":"emoji","data-name":(f=c.attrs)==null?void 0:f.name,emoji:(y=c.attrs)==null?void 0:y.emoji,key:`emoji-${e}`},t("img",{src:($=c.attrs)==null?void 0:$.fallbackImage,alt:(R=c.attrs)==null?void 0:R.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"},""))},p=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),h=(c,f=!1)=>({text:y,attrs:$})=>t(c,f?{style:Me($),key:`${c}-${e}`}:{...$,key:`${c}-${e}`},y),b=c=>U(c),_=c=>{const{marks:f,...y}=c;return"text"in c?f?f.reduce(($,R)=>b({...R,text:$}),b({...y,children:y.children})):r(y.text):""},k=c=>{const{linktype:f,href:y,anchor:$,...R}=c.attrs||{};let w="";switch(f){case I.ASSET:case I.URL:w=y;break;case I.EMAIL:w=`mailto:${y}`;break;case I.STORY:w=y;break}return $&&(w=`${w}#${$}`),t("a",{...R,href:w,key:`a-${e}`},c.text)},S=c=>{var f,y;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(f=c==null?void 0:c.attrs)==null?void 0:f.body[0],id:(y=c.attrs)==null?void 0:y.id,key:`component-${e}`,style:"display: none"},"")},A=new Map([[v.DOCUMENT,i("div")],[v.HEADING,a],[v.PARAGRAPH,i("p")],[v.UL_LIST,i("ul")],[v.OL_LIST,i("ol")],[v.LIST_ITEM,i("li")],[v.IMAGE,l],[v.EMOJI,u],[v.CODE_BLOCK,p],[v.HR,i("hr")],[v.BR,i("br")],[v.QUOTE,i("blockquote")],[v.COMPONENT,S],[L.TEXT,_],[T.LINK,k],[T.ANCHOR,k],[T.STYLED,h("span",!0)],[T.BOLD,h("strong")],[T.TEXT_STYLE,h("span",!0)],[T.ITALIC,h("em")],[T.UNDERLINE,h("u")],[T.STRIKE,h("s")],[T.CODE,h("code")],[T.SUPERSCRIPT,h("sup")],[T.SUBSCRIPT,h("sub")],[T.HIGHLIGHT,h("mark")],...Object.entries(o).map(([c,f])=>[c,f])]);function W(c){e+=1;const f=A.get(c.type);if(!f)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return f(c);const y=c.content?c.content.map(U):void 0;return f({...c,children:y})}function U(c){return Array.isArray(c)?c.map(W):W(c)}return{render:U}}let N,q="https://app.storyblok.com/f/storyblok-v2-latest.js";const G=(s,e,t={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok")===s;if(!(!o||!n)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],i=>{i.action==="input"&&i.story.id===s?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===s&&window.location.reload()})})}},He=(s={})=>{var e,t;const{bridge:r,accessToken:o,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=s;i.accessToken=i.accessToken||o;const u={bridge:r,apiOptions:i};let p={};n.forEach(b=>{p={...p,...b(u)}}),a&&(q=a);const h=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&h&&Q(q),N=new C(l.schema),l.resolver&&K(N,l.resolver),p},K=(s,e)=>{s.addNode("blok",t=>{let r="";return t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})},ze=s=>!s||!(s!=null&&s.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Be=(s,e,t)=>{let r=t||N;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ze(s)?"":(e&&(r=new C(e.schema),e.resolver&&K(r,e.resolver)),r.render(s))},M=g.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,r=g.ref();e({value:r});const o=typeof g.resolveDynamicComponent(t.blok.component)!="string",n=g.inject("VueSDKOptions"),i=g.ref(t.blok.component);return o||(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof g.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,a)=>(g.openBlock(),g.createBlock(g.resolveDynamicComponent(i.value),g.mergeProps({ref_key:"blokRef",ref:r},{...l.$props,...l.$attrs}),null,16))}}),Ve=s=>{var e,t;return g.h(M,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function J(s){const e={renderFn:g.h,textFn:g.createTextVNode,resolvers:{[v.COMPONENT]:Ve,...s.resolvers}};return F(e)}const Y=g.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,{render:t}=J({resolvers:e.resolvers??{}}),r=()=>t(e.doc);return(o,n)=>(g.openBlock(),g.createBlock(r))}}),Fe={beforeMount(s,e){if(e.value){const t=Pe(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},X=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
25
|
-
`)};let
|
|
24
|
+
}`),""}optimizeImages(e,t){let r=0,o=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}" `,o=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-Fa-f]{6}/g)||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||o>0||i.length>0?`${r}x${o}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|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 u,d;const h=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(h&&h.length>0){const b={srcset:(u=t.srcset)==null?void 0:u.map(k=>{if(typeof k=="number")return`//${h}/m/${k}x0${i} ${k}w`;if(typeof k=="object"&&k.length===2){let S=0,A=0;return typeof k[0]=="number"&&(S=k[0]),typeof k[1]=="number"&&(A=k[1]),`//${h}/m/${S}x${A}${i} ${S}w`}}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(k=>k).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(o=>{const n=this.getMatchingMark(o);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(o=>{t.push(this.renderNode(o))}):e.text?t.push(je(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(o=>{const n=this.getMatchingMark(o);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 o=`<${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&&(o+=` ${n}="${i}"`)}}return`${o}${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," /")}}const C=Ie;class Oe{constructor(e){p(this,"baseURL"),p(this,"timeout"),p(this,"headers"),p(this,"responseInterceptor"),p(this,"fetch"),p(this,"ejectInterceptor"),p(this,"url"),p(this,"parameters"),p(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(o=>{r.data=o});for(const o of e.headers.entries())t[o[0]]=o[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 O;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const o=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(`${o}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const u=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}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,o)=>{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};o(n)})}}const xe=Oe,F="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const E={};class Ae{constructor(e,t){p(this,"client"),p(this,"maxRetries"),p(this,"retriesDelay"),p(this,"throttle"),p(this,"accessToken"),p(this,"cache"),p(this,"helpers"),p(this,"resolveCounter"),p(this,"relations"),p(this,"links"),p(this,"richTextResolver"),p(this,"resolveNestedRelations"),p(this,"stringifiedStoriesCache");let r=e.endpoint||t;if(!r){const i=new O().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const o=new Headers;o.set("Content-Type","application/json"),o.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{o.set(i,l)}),o.has(F)||(o.set(F,P.defaultAgentName),o.set(P.defaultAgentVersion,P.packageVersion));let n=5;e.oauthToken&&(o.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=re(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new O,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new xe({baseURL:r,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[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,o,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,o));return this.cacheResponse(e,i,void 0,n)}get(e,t,r){t||(t={});const o=`/${e}`,n=this.factoryParamOptions(o,t);return this.cacheResponse(o,n,void 0,r)}async getAll(e,t,r,o){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`,l=i.split("/"),a=r||l[l.length-1],u=1,d=await this.makeRequest(i,t,n,u,o),h=d.total?Math.ceil(d.total/n):1,b=await this.helpers.asyncMap(this.helpers.range(u,h),_=>this.makeRequest(i,t,n,_+1,o));return this.helpers.flatMap([d,...b],_=>Object.values(_.data[a]))}post(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("post",o,t,r))}put(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("put",o,t,r))}delete(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("delete",o,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 o=e[t];o&&o.fieldtype=="multilink"&&o.linktype=="story"&&typeof o.id=="string"&&this.links[r][o.id]?o.story=this._cleanCopy(this.links[r][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[r][o.uuid]&&(o.story=this._cleanCopy(this.links[r][o.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,r,o){r.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(o,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(o,n)).filter(Boolean)))}iterateTree(e,t,r){const o=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)o(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,r),this._insertLinks(n,i,r)),o(n[i])}}};o(e.content)}async resolveLinks(e,t,r){let o=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const u=Math.min(n,a+l);i.push(e.link_uuids.slice(a,u))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(u=>{o.push(u)})}else o=e.links;o.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let o=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const u=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,u))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{o.push(u)})}else o=e.rels;o&&o.length>0&&o.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var o,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"].indexOf(t.resolve_links)>-1&&((o=e.links)!=null&&o.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,o){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),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 u;try{const d=await this.throttle("get",e,t,o);if(d.status!==200)return a(d);let h={data:d.data,headers:d.headers};if((u=d.headers)!=null&&u["per-page"]&&(h=Object.assign({},h,{perPage:d.headers["per-page"]?parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?parseInt(d.headers.total):0})),h.data.story||h.data.stories){const b=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(h.data,t,`${b}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(n,h),h.data.cv&&t.token&&(t.version==="draft"&&E[t.token]!=h.data.cv&&await this.flushCache(),E[t.token]=t.cv?t.cv:h.data.cv),l(h)}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,o){return this.client.setFetchOptions(o),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[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 Pe=(s={})=>{const{apiOptions:e}=s;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 Ae(e)}},Le=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};var v=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s))(v||{}),T=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))(T||{}),L=(s=>(s.TEXT="text",s))(L||{}),j=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(j||{});function Ne(s,e){if(!e)return{src:s,attrs:{}};let t=0,r=0;const o={},n=[];function i(a,u,d,h,b){typeof a!="number"||a<=u||a>=d?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${u} and ${d} (inclusive)`):b.push(`${h}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(o.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?(o.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)&&(o.loading=e.loading),e.class&&(o.class=e.class),e.filters){const{filters:a}=e||{},{blur:u,brightness:d,fill:h,format:b,grayscale:_,quality:k,rotate:S}=a||{};u&&i(u,0,100,"blur",n),k&&i(k,0,100,"quality",n),d&&i(d,0,100,"brightness",n),h&&n.push(`fill(${h})`),_&&n.push("grayscale()"),S&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${S})`),b&&["webp","png","jpeg"].includes(b)&&n.push(`format(${b})`)}e.srcset&&(o.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${s}/m/${a}x0/${n.length>0?"filters:"+n.join(":"):""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[u,d]=a;return`${s}/m/${u}x${d}/${n.length>0?"filters:"+n.join(":"):""} ${u}w`}}).join(", ")),e.sizes&&(o.sizes=e.sizes.join(", "))}let l=`${s}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:o}}const Me=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),He=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function Ue(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function De(s,e={},t){const r=Me(e);return`<${r?`${s} ${r}`:s}>${Array.isArray(t)?t.join(""):t||""}</${s}>`}function q(s={}){let e=0;const{renderFn:t=De,textFn:r=Ue,resolvers:o={},optimizeImages:n=!1}=s,i=c=>f=>t(c,{...f.attrs,key:`${c}-${e}`},f.children||null),l=c=>{const{src:f,alt:y,...$}=c.attrs||{};let R=f,w={};if(n){const{src:Ze,attrs:et}=Ne(f,n);R=Ze,w=et}const Qe={src:R,alt:y||"",key:`img-${e}`,...$,...w};return t("img",Qe,"")},a=c=>{const{level:f,...y}=c.attrs||{};return t(`h${f}`,{...y,key:`h${f}-${e}`},c.children)},u=c=>{var f,y,$,R;return t("span",{"data-type":"emoji","data-name":(f=c.attrs)==null?void 0:f.name,emoji:(y=c.attrs)==null?void 0:y.emoji,key:`emoji-${e}`},t("img",{src:($=c.attrs)==null?void 0:$.fallbackImage,alt:(R=c.attrs)==null?void 0:R.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"},""))},d=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),h=(c,f=!1)=>({text:y,attrs:$})=>t(c,f?{style:He($),key:`${c}-${e}`}:{...$,key:`${c}-${e}`},y),b=c=>H(c),_=c=>{const{marks:f,...y}=c;return"text"in c?f?f.reduce(($,R)=>b({...R,text:$}),b({...y,children:y.children})):r(y.text):""},k=c=>{const{linktype:f,href:y,anchor:$,...R}=c.attrs||{};let w="";switch(f){case j.ASSET:case j.URL:w=y;break;case j.EMAIL:w=`mailto:${y}`;break;case j.STORY:w=y;break}return $&&(w=`${w}#${$}`),t("a",{...R,href:w,key:`a-${e}`},c.text)},S=c=>{var f,y;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(f=c==null?void 0:c.attrs)==null?void 0:f.body[0],id:(y=c.attrs)==null?void 0:y.id,key:`component-${e}`,style:"display: none"},"")},A=new Map([[v.DOCUMENT,i("div")],[v.HEADING,a],[v.PARAGRAPH,i("p")],[v.UL_LIST,i("ul")],[v.OL_LIST,i("ol")],[v.LIST_ITEM,i("li")],[v.IMAGE,l],[v.EMOJI,u],[v.CODE_BLOCK,d],[v.HR,i("hr")],[v.BR,i("br")],[v.QUOTE,i("blockquote")],[v.COMPONENT,S],[L.TEXT,_],[T.LINK,k],[T.ANCHOR,k],[T.STYLED,h("span",!0)],[T.BOLD,h("strong")],[T.TEXT_STYLE,h("span",!0)],[T.ITALIC,h("em")],[T.UNDERLINE,h("u")],[T.STRIKE,h("s")],[T.CODE,h("code")],[T.SUPERSCRIPT,h("sup")],[T.SUBSCRIPT,h("sub")],[T.HIGHLIGHT,h("mark")],...Object.entries(o).map(([c,f])=>[c,f])]);function Q(c){e+=1;const f=A.get(c.type);if(!f)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return f(c);const y=c.content?c.content.map(H):void 0;return f({...c,children:y})}function H(c){return Array.isArray(c)?c.map(Q):Q(c)}return{render:H}}let N,G="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(s,e,t={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok")===s;if(!(!o||!n)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],i=>{i.action==="input"&&i.story.id===s?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===s&&window.location.reload()})})}},ze=(s={})=>{var e,t;const{bridge:r,accessToken:o,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=s;i.accessToken=i.accessToken||o;const u={bridge:r,apiOptions:i};let d={};n.forEach(b=>{d={...d,...b(u)}}),a&&(G=a);const h=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&h&&Z(G),N=new C(l.schema),l.resolver&&J(N,l.resolver),d},J=(s,e)=>{s.addNode("blok",t=>{let r="";return t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})},Be=s=>!s||!(s!=null&&s.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ve=(s,e,t)=>{let r=t||N;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Be(s)?"":(e&&(r=new C(e.schema),e.resolver&&J(r,e.resolver)),r.render(s,{},!1))},M=g.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,r=g.ref();e({value:r});const o=typeof g.resolveDynamicComponent(t.blok.component)!="string",n=g.inject("VueSDKOptions"),i=g.ref(t.blok.component);return o||(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof g.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,a)=>(g.openBlock(),g.createBlock(g.resolveDynamicComponent(i.value),g.mergeProps({ref_key:"blokRef",ref:r},{...l.$props,...l.$attrs}),null,16))}}),Fe=s=>{var e,t;return g.h(M,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function Y(s){const e={renderFn:g.h,textFn:g.createTextVNode,resolvers:{[v.COMPONENT]:Fe,...s.resolvers}};return q(e)}const X=g.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,{render:t}=Y({resolvers:e.resolvers??{}}),r=()=>t(e.doc);return(o,n)=>(g.openBlock(),g.createBlock(r))}}),qe={beforeMount(s,e){if(e.value){const t=Le(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},W=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
25
|
+
`)};let I=null;const Ge=()=>(I||W("useStoryblokApi"),I),Ke=async(s,e={},t={})=>{const r=g.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,g.onMounted(()=>{r.value&&r.value.id&&K(r.value.id,o=>r.value=o,t)}),I){const{data:o}=await I.get(`cdn/stories/${s}`,e);r.value=o.story}else W("useStoryblok");return r},Je={install(s,e={}){s.directive("editable",qe),s.component("StoryblokComponent",M),s.component("StoryblokRichText",X),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",g.defineAsyncComponent(()=>Promise.resolve().then(()=>We)));const{storyblokApi:t}=ze(e);I=t,s.provide("VueSDKOptions",e)}},Ye={class:"fallback-component"},Xe={class:"component"},We=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[r,o]of e)t[r]=o;return t})(g.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(g.openBlock(),g.createElementBlock("div",Ye,[g.createElementVNode("p",null,[t[0]||(t[0]=g.createTextVNode(" Component could not be found for blok ")),g.createElementVNode("span",Xe,g.toDisplayString(e.blok.component),1),t[1]||(t[1]=g.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-93c770c0"]])},Symbol.toStringTag,{value:"Module"}));m.BlockTypes=v,m.MarkTypes=T,m.RichTextResolver=C,m.RichTextSchema=B,m.StoryblokComponent=M,m.StoryblokRichText=X,m.StoryblokVue=Je,m.TextTypes=L,m.apiPlugin=Pe,m.renderRichText=Ve,m.richTextResolver=q,m.useStoryblok=Ke,m.useStoryblokApi=Ge,m.useStoryblokBridge=K,m.useStoryblokRichText=Y,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as F, ref as P, resolveDynamicComponent as A, inject as te, openBlock as V, createBlock as G, mergeProps as re, h as K, createTextVNode as se, onMounted as oe, defineAsyncComponent as ne } from "vue";
|
|
2
|
+
let H = !1;
|
|
3
|
+
const U = [], ie = (s) => new Promise((e, t) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
|
|
5
5
|
if (window.location === window.parent.location) {
|
|
6
6
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
H ? o() : U.push(o);
|
|
10
10
|
}, document.getElementById("storyblok-javascript-bridge"))) return;
|
|
11
11
|
const r = document.createElement("script");
|
|
12
12
|
r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (o) => t(o), r.onload = (o) => {
|
|
13
|
-
|
|
13
|
+
U.forEach((n) => n()), H = !0, e(o);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
16
|
+
var ae = Object.defineProperty, le = (s, e, t) => e in s ? ae(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, d = (s, e, t) => le(s, typeof e != "symbol" ? e + "" : e, t);
|
|
17
17
|
function D(s) {
|
|
18
18
|
return !(s !== s || s === 1 / 0 || s === -1 / 0);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ce(s, e, t) {
|
|
21
21
|
if (!D(e))
|
|
22
22
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
23
|
if (!D(t))
|
|
@@ -116,20 +116,20 @@ class j {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const he = function(s, e) {
|
|
120
120
|
const t = {};
|
|
121
121
|
for (const r in s) {
|
|
122
122
|
const o = s[r];
|
|
123
123
|
e.indexOf(r) > -1 && o !== null && (t[r] = o);
|
|
124
124
|
}
|
|
125
125
|
return t;
|
|
126
|
-
},
|
|
126
|
+
}, ue = (s) => s === "email", pe = () => ({
|
|
127
127
|
singleTag: "hr"
|
|
128
|
-
}), pe = () => ({
|
|
129
|
-
tag: "blockquote"
|
|
130
128
|
}), de = () => ({
|
|
129
|
+
tag: "blockquote"
|
|
130
|
+
}), ge = () => ({
|
|
131
131
|
tag: "ul"
|
|
132
|
-
}),
|
|
132
|
+
}), fe = (s) => ({
|
|
133
133
|
tag: [
|
|
134
134
|
"pre",
|
|
135
135
|
{
|
|
@@ -137,24 +137,24 @@ const ce = function(s, e) {
|
|
|
137
137
|
attrs: s.attrs
|
|
138
138
|
}
|
|
139
139
|
]
|
|
140
|
-
}),
|
|
140
|
+
}), me = () => ({
|
|
141
141
|
singleTag: "br"
|
|
142
|
-
}), me = (s) => ({
|
|
143
|
-
tag: `h${s.attrs.level}`
|
|
144
142
|
}), ye = (s) => ({
|
|
143
|
+
tag: `h${s.attrs.level}`
|
|
144
|
+
}), be = (s) => ({
|
|
145
145
|
singleTag: [
|
|
146
146
|
{
|
|
147
147
|
tag: "img",
|
|
148
|
-
attrs:
|
|
148
|
+
attrs: he(s.attrs, ["src", "alt", "title"])
|
|
149
149
|
}
|
|
150
150
|
]
|
|
151
|
-
}), be = () => ({
|
|
152
|
-
tag: "li"
|
|
153
151
|
}), ke = () => ({
|
|
154
|
-
tag: "
|
|
152
|
+
tag: "li"
|
|
155
153
|
}), ve = () => ({
|
|
154
|
+
tag: "ol"
|
|
155
|
+
}), $e = () => ({
|
|
156
156
|
tag: "p"
|
|
157
|
-
}),
|
|
157
|
+
}), Te = (s) => ({
|
|
158
158
|
tag: [
|
|
159
159
|
{
|
|
160
160
|
tag: "span",
|
|
@@ -165,25 +165,25 @@ const ce = function(s, e) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
]
|
|
168
|
-
}), Te = () => ({
|
|
169
|
-
tag: "b"
|
|
170
168
|
}), Re = () => ({
|
|
171
|
-
tag: "
|
|
169
|
+
tag: "b"
|
|
172
170
|
}), we = () => ({
|
|
173
|
-
tag: "
|
|
171
|
+
tag: "s"
|
|
174
172
|
}), _e = () => ({
|
|
175
|
-
tag: "
|
|
173
|
+
tag: "u"
|
|
176
174
|
}), Se = () => ({
|
|
177
|
-
tag: "
|
|
175
|
+
tag: "strong"
|
|
178
176
|
}), Ee = () => ({
|
|
177
|
+
tag: "code"
|
|
178
|
+
}), xe = () => ({
|
|
179
179
|
tag: "i"
|
|
180
|
-
}),
|
|
180
|
+
}), Ie = (s) => {
|
|
181
181
|
if (!s.attrs)
|
|
182
182
|
return {
|
|
183
183
|
tag: ""
|
|
184
184
|
};
|
|
185
185
|
const e = new j().escapeHTML, t = { ...s.attrs }, { linktype: r = "url" } = s.attrs;
|
|
186
|
-
if (delete t.linktype, t.href && (t.href = e(s.attrs.href || "")),
|
|
186
|
+
if (delete t.linktype, t.href && (t.href = e(s.attrs.href || "")), ue(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
187
187
|
for (const o in t.custom)
|
|
188
188
|
t[o] = t.custom[o];
|
|
189
189
|
delete t.custom;
|
|
@@ -196,25 +196,25 @@ const ce = function(s, e) {
|
|
|
196
196
|
}
|
|
197
197
|
]
|
|
198
198
|
};
|
|
199
|
-
},
|
|
199
|
+
}, je = (s) => ({
|
|
200
200
|
tag: [
|
|
201
201
|
{
|
|
202
202
|
tag: "span",
|
|
203
203
|
attrs: s.attrs
|
|
204
204
|
}
|
|
205
205
|
]
|
|
206
|
-
}), je = () => ({
|
|
207
|
-
tag: "sub"
|
|
208
206
|
}), Ce = () => ({
|
|
207
|
+
tag: "sub"
|
|
208
|
+
}), Oe = () => ({
|
|
209
209
|
tag: "sup"
|
|
210
|
-
}),
|
|
210
|
+
}), Ae = (s) => ({
|
|
211
211
|
tag: [
|
|
212
212
|
{
|
|
213
213
|
tag: "span",
|
|
214
214
|
attrs: s.attrs
|
|
215
215
|
}
|
|
216
216
|
]
|
|
217
|
-
}),
|
|
217
|
+
}), Le = (s) => {
|
|
218
218
|
var e;
|
|
219
219
|
return (e = s.attrs) != null && e.color ? {
|
|
220
220
|
tag: [
|
|
@@ -228,7 +228,7 @@ const ce = function(s, e) {
|
|
|
228
228
|
} : {
|
|
229
229
|
tag: ""
|
|
230
230
|
};
|
|
231
|
-
},
|
|
231
|
+
}, Pe = (s) => {
|
|
232
232
|
var e;
|
|
233
233
|
return (e = s.attrs) != null && e.color ? {
|
|
234
234
|
tag: [
|
|
@@ -242,36 +242,36 @@ const ce = function(s, e) {
|
|
|
242
242
|
} : {
|
|
243
243
|
tag: ""
|
|
244
244
|
};
|
|
245
|
-
},
|
|
245
|
+
}, Ne = {
|
|
246
246
|
nodes: {
|
|
247
|
-
horizontal_rule:
|
|
248
|
-
blockquote:
|
|
249
|
-
bullet_list:
|
|
250
|
-
code_block:
|
|
251
|
-
hard_break:
|
|
252
|
-
heading:
|
|
253
|
-
image:
|
|
254
|
-
list_item:
|
|
255
|
-
ordered_list:
|
|
256
|
-
paragraph:
|
|
257
|
-
emoji:
|
|
247
|
+
horizontal_rule: pe,
|
|
248
|
+
blockquote: de,
|
|
249
|
+
bullet_list: ge,
|
|
250
|
+
code_block: fe,
|
|
251
|
+
hard_break: me,
|
|
252
|
+
heading: ye,
|
|
253
|
+
image: be,
|
|
254
|
+
list_item: ke,
|
|
255
|
+
ordered_list: ve,
|
|
256
|
+
paragraph: $e,
|
|
257
|
+
emoji: Te
|
|
258
258
|
},
|
|
259
259
|
marks: {
|
|
260
|
-
bold:
|
|
261
|
-
strike:
|
|
262
|
-
underline:
|
|
263
|
-
strong:
|
|
264
|
-
code:
|
|
265
|
-
italic:
|
|
266
|
-
link:
|
|
267
|
-
styled:
|
|
268
|
-
subscript:
|
|
269
|
-
superscript:
|
|
270
|
-
anchor:
|
|
271
|
-
highlight:
|
|
272
|
-
textStyle:
|
|
273
|
-
}
|
|
274
|
-
},
|
|
260
|
+
bold: Re,
|
|
261
|
+
strike: we,
|
|
262
|
+
underline: _e,
|
|
263
|
+
strong: Se,
|
|
264
|
+
code: Ee,
|
|
265
|
+
italic: xe,
|
|
266
|
+
link: Ie,
|
|
267
|
+
styled: je,
|
|
268
|
+
subscript: Ce,
|
|
269
|
+
superscript: Oe,
|
|
270
|
+
anchor: Ae,
|
|
271
|
+
highlight: Le,
|
|
272
|
+
textStyle: Pe
|
|
273
|
+
}
|
|
274
|
+
}, Me = function(s) {
|
|
275
275
|
const e = {
|
|
276
276
|
"&": "&",
|
|
277
277
|
"<": "<",
|
|
@@ -281,9 +281,10 @@ const ce = function(s, e) {
|
|
|
281
281
|
}, t = /[&<>"']/g, r = RegExp(t.source);
|
|
282
282
|
return s && r.test(s) ? s.replace(t, (o) => e[o]) : s;
|
|
283
283
|
};
|
|
284
|
-
|
|
284
|
+
let z = !1;
|
|
285
|
+
class He {
|
|
285
286
|
constructor(e) {
|
|
286
|
-
d(this, "marks"), d(this, "nodes"), e || (e =
|
|
287
|
+
d(this, "marks"), d(this, "nodes"), e || (e = Ne), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
287
288
|
}
|
|
288
289
|
addNode(e, t) {
|
|
289
290
|
this.nodes[e] = t;
|
|
@@ -291,14 +292,14 @@ class Me {
|
|
|
291
292
|
addMark(e, t) {
|
|
292
293
|
this.marks[e] = t;
|
|
293
294
|
}
|
|
294
|
-
render(e, t = { optimizeImages: !1 }) {
|
|
295
|
-
if (console.warn(
|
|
295
|
+
render(e, t = { optimizeImages: !1 }, r = !0) {
|
|
296
|
+
if (!z && r && (console.warn(
|
|
296
297
|
"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/"
|
|
297
|
-
), e && e.content && Array.isArray(e.content)) {
|
|
298
|
-
let
|
|
299
|
-
return e.content.forEach((
|
|
300
|
-
|
|
301
|
-
}), t.optimizeImages ? this.optimizeImages(
|
|
298
|
+
), z = !0), e && e.content && Array.isArray(e.content)) {
|
|
299
|
+
let o = "";
|
|
300
|
+
return e.content.forEach((n) => {
|
|
301
|
+
o += this.renderNode(n);
|
|
302
|
+
}), t.optimizeImages ? this.optimizeImages(o, t.optimizeImages) : o;
|
|
302
303
|
}
|
|
303
304
|
return console.warn(
|
|
304
305
|
`The render method must receive an Object with a "content" field.
|
|
@@ -366,7 +367,7 @@ class Me {
|
|
|
366
367
|
const r = this.getMatchingNode(e);
|
|
367
368
|
return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
|
|
368
369
|
t.push(this.renderNode(o));
|
|
369
|
-
}) : e.text ? t.push(
|
|
370
|
+
}) : e.text ? t.push(Me(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((o) => {
|
|
370
371
|
const n = this.getMatchingMark(o);
|
|
371
372
|
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
372
373
|
}), t.join("");
|
|
@@ -421,7 +422,7 @@ class Me {
|
|
|
421
422
|
return this.renderTag(t, " /");
|
|
422
423
|
}
|
|
423
424
|
}
|
|
424
|
-
const C =
|
|
425
|
+
const C = He;
|
|
425
426
|
class Ue {
|
|
426
427
|
constructor(e) {
|
|
427
428
|
d(this, "baseURL"), d(this, "timeout"), d(this, "headers"), d(this, "responseInterceptor"), d(this, "fetch"), d(this, "ejectInterceptor"), d(this, "url"), d(this, "parameters"), d(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 = {};
|
|
@@ -509,14 +510,14 @@ class Ue {
|
|
|
509
510
|
});
|
|
510
511
|
}
|
|
511
512
|
}
|
|
512
|
-
const
|
|
513
|
+
const De = Ue, B = "SB-Agent", L = {
|
|
513
514
|
defaultAgentName: "SB-JS-CLIENT",
|
|
514
515
|
defaultAgentVersion: "SB-Agent-Version",
|
|
515
516
|
packageVersion: "6.0.0"
|
|
516
517
|
};
|
|
517
518
|
let I = {};
|
|
518
519
|
const _ = {};
|
|
519
|
-
class
|
|
520
|
+
class ze {
|
|
520
521
|
/**
|
|
521
522
|
*
|
|
522
523
|
* @param config ISbConfig interface
|
|
@@ -530,14 +531,14 @@ class De {
|
|
|
530
531
|
e.oauthToken ? r = `${l}://${i(e.region)}/v1` : r = `${l}://${i(e.region)}/v2`;
|
|
531
532
|
}
|
|
532
533
|
const o = new Headers();
|
|
533
|
-
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && e.headers.entries().toArray().forEach(([i, l]) => {
|
|
534
|
+
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
|
|
534
535
|
o.set(i, l);
|
|
535
|
-
}), o.has(
|
|
536
|
+
}), o.has(B) || (o.set(B, L.defaultAgentName), o.set(
|
|
536
537
|
L.defaultAgentVersion,
|
|
537
538
|
L.packageVersion
|
|
538
539
|
));
|
|
539
540
|
let n = 5;
|
|
540
|
-
e.oauthToken && (o.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 =
|
|
541
|
+
e.oauthToken && (o.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 = ce(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new j(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new De({
|
|
541
542
|
baseURL: r,
|
|
542
543
|
timeout: e.timeout || 0,
|
|
543
544
|
headers: o,
|
|
@@ -826,7 +827,7 @@ class De {
|
|
|
826
827
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
827
828
|
}
|
|
828
829
|
}
|
|
829
|
-
const
|
|
830
|
+
const st = (s = {}) => {
|
|
830
831
|
const { apiOptions: e } = s;
|
|
831
832
|
if (!e.accessToken) {
|
|
832
833
|
console.error(
|
|
@@ -834,8 +835,8 @@ const rt = (s = {}) => {
|
|
|
834
835
|
);
|
|
835
836
|
return;
|
|
836
837
|
}
|
|
837
|
-
return { storyblokApi: new
|
|
838
|
-
},
|
|
838
|
+
return { storyblokApi: new ze(e) };
|
|
839
|
+
}, Be = (s) => {
|
|
839
840
|
if (typeof s != "object" || typeof s._editable > "u")
|
|
840
841
|
return {};
|
|
841
842
|
try {
|
|
@@ -850,8 +851,8 @@ const rt = (s = {}) => {
|
|
|
850
851
|
return {};
|
|
851
852
|
}
|
|
852
853
|
};
|
|
853
|
-
var b = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s))(b || {}), k = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))(k || {}),
|
|
854
|
-
function
|
|
854
|
+
var b = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s))(b || {}), k = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))(k || {}), J = /* @__PURE__ */ ((s) => (s.TEXT = "text", s))(J || {}), S = /* @__PURE__ */ ((s) => (s.URL = "url", s.STORY = "story", s.ASSET = "asset", s.EMAIL = "email", s))(S || {});
|
|
855
|
+
function qe(s, e) {
|
|
855
856
|
if (!e) return { src: s, attrs: {} };
|
|
856
857
|
let t = 0, r = 0;
|
|
857
858
|
const o = {}, n = [];
|
|
@@ -878,36 +879,36 @@ function Be(s, e) {
|
|
|
878
879
|
attrs: o
|
|
879
880
|
};
|
|
880
881
|
}
|
|
881
|
-
const
|
|
882
|
-
function
|
|
882
|
+
const Fe = (s = {}) => Object.keys(s).map((e) => `${e}="${s[e]}"`).join(" "), Ve = (s = {}) => Object.keys(s).map((e) => `${e}: ${s[e]}`).join("; ");
|
|
883
|
+
function Ge(s) {
|
|
883
884
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
884
885
|
}
|
|
885
|
-
function
|
|
886
|
-
const r =
|
|
886
|
+
function Ke(s, e = {}, t) {
|
|
887
|
+
const r = Fe(e);
|
|
887
888
|
return `<${r ? `${s} ${r}` : s}>${Array.isArray(t) ? t.join("") : t || ""}</${s}>`;
|
|
888
889
|
}
|
|
889
|
-
function
|
|
890
|
+
function Je(s = {}) {
|
|
890
891
|
let e = 0;
|
|
891
892
|
const {
|
|
892
|
-
renderFn: t =
|
|
893
|
-
textFn: r =
|
|
893
|
+
renderFn: t = Ke,
|
|
894
|
+
textFn: r = Ge,
|
|
894
895
|
resolvers: o = {},
|
|
895
896
|
optimizeImages: n = !1
|
|
896
897
|
} = s, i = (c) => (g) => t(c, { ...g.attrs, key: `${c}-${e}` }, g.children || null), l = (c) => {
|
|
897
898
|
const { src: g, alt: f, ...v } = c.attrs || {};
|
|
898
899
|
let T = g, R = {};
|
|
899
900
|
if (n) {
|
|
900
|
-
const { src:
|
|
901
|
-
T =
|
|
901
|
+
const { src: Z, attrs: ee } = qe(g, n);
|
|
902
|
+
T = Z, R = ee;
|
|
902
903
|
}
|
|
903
|
-
const
|
|
904
|
+
const Q = {
|
|
904
905
|
src: T,
|
|
905
906
|
alt: f || "",
|
|
906
907
|
key: `img-${e}`,
|
|
907
908
|
...v,
|
|
908
909
|
...R
|
|
909
910
|
};
|
|
910
|
-
return t("img",
|
|
911
|
+
return t("img", Q, "");
|
|
911
912
|
}, a = (c) => {
|
|
912
913
|
const { level: g, ...f } = c.attrs || {};
|
|
913
914
|
return t(`h${g}`, { ...f, key: `h${g}-${e}` }, c.children);
|
|
@@ -926,7 +927,7 @@ function Ke(s = {}) {
|
|
|
926
927
|
loading: "lazy"
|
|
927
928
|
}, ""));
|
|
928
929
|
}, p = (c) => t("pre", { ...c.attrs, key: `code-${e}` }, t("code", { key: `code-${e}` }, c.children || "")), h = (c, g = !1) => ({ text: f, attrs: v }) => t(c, g ? {
|
|
929
|
-
style:
|
|
930
|
+
style: Ve(v),
|
|
930
931
|
key: `${c}-${e}`
|
|
931
932
|
} : { ...v, key: `${c}-${e}` }, f), m = (c) => O(c), $ = (c) => {
|
|
932
933
|
const { marks: g, ...f } = c;
|
|
@@ -974,7 +975,7 @@ function Ke(s = {}) {
|
|
|
974
975
|
[b.BR, i("br")],
|
|
975
976
|
[b.QUOTE, i("blockquote")],
|
|
976
977
|
[b.COMPONENT, w],
|
|
977
|
-
[
|
|
978
|
+
[J.TEXT, $],
|
|
978
979
|
[k.LINK, y],
|
|
979
980
|
[k.ANCHOR, y],
|
|
980
981
|
[k.STYLED, h("span", !0)],
|
|
@@ -1010,8 +1011,8 @@ function Ke(s = {}) {
|
|
|
1010
1011
|
render: O
|
|
1011
1012
|
};
|
|
1012
1013
|
}
|
|
1013
|
-
let N,
|
|
1014
|
-
const
|
|
1014
|
+
let N, q = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1015
|
+
const Ye = (s, e, t = {}) => {
|
|
1015
1016
|
var r;
|
|
1016
1017
|
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
1017
1018
|
"_storyblok"
|
|
@@ -1027,7 +1028,7 @@ const Je = (s, e, t = {}) => {
|
|
|
1027
1028
|
});
|
|
1028
1029
|
});
|
|
1029
1030
|
}
|
|
1030
|
-
},
|
|
1031
|
+
}, Xe = (s = {}) => {
|
|
1031
1032
|
var e, t;
|
|
1032
1033
|
const {
|
|
1033
1034
|
bridge: r,
|
|
@@ -1042,10 +1043,10 @@ const Je = (s, e, t = {}) => {
|
|
|
1042
1043
|
let p = {};
|
|
1043
1044
|
n.forEach((m) => {
|
|
1044
1045
|
p = { ...p, ...m(u) };
|
|
1045
|
-
}), a && (
|
|
1046
|
+
}), a && (q = a);
|
|
1046
1047
|
const h = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1047
|
-
return r !== !1 && h &&
|
|
1048
|
-
},
|
|
1048
|
+
return r !== !1 && h && ie(q), N = new C(l.schema), l.resolver && Y(N, l.resolver), p;
|
|
1049
|
+
}, Y = (s, e) => {
|
|
1049
1050
|
s.addNode("blok", (t) => {
|
|
1050
1051
|
let r = "";
|
|
1051
1052
|
return t.attrs.body.forEach((o) => {
|
|
@@ -1054,7 +1055,7 @@ const Je = (s, e, t = {}) => {
|
|
|
1054
1055
|
html: r
|
|
1055
1056
|
};
|
|
1056
1057
|
});
|
|
1057
|
-
},
|
|
1058
|
+
}, We = (s) => !s || !(s != null && s.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ot = (s, e, t) => {
|
|
1058
1059
|
let r = t || N;
|
|
1059
1060
|
if (!r) {
|
|
1060
1061
|
console.error(
|
|
@@ -1062,8 +1063,8 @@ const Je = (s, e, t = {}) => {
|
|
|
1062
1063
|
);
|
|
1063
1064
|
return;
|
|
1064
1065
|
}
|
|
1065
|
-
return
|
|
1066
|
-
},
|
|
1066
|
+
return We(s) ? "" : (e && (r = new C(e.schema), e.resolver && Y(r, e.resolver)), r.render(s, {}, !1));
|
|
1067
|
+
}, X = /* @__PURE__ */ F({
|
|
1067
1068
|
__name: "StoryblokComponent",
|
|
1068
1069
|
props: {
|
|
1069
1070
|
blok: {}
|
|
@@ -1073,20 +1074,20 @@ const Je = (s, e, t = {}) => {
|
|
|
1073
1074
|
e({
|
|
1074
1075
|
value: r
|
|
1075
1076
|
});
|
|
1076
|
-
const o = typeof A(t.blok.component) != "string", n =
|
|
1077
|
+
const o = typeof A(t.blok.component) != "string", n = te("VueSDKOptions"), i = P(t.blok.component);
|
|
1077
1078
|
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof A(i.value) == "string" && console.error(
|
|
1078
1079
|
`Is the Fallback component "${i.value}" registered properly?`
|
|
1079
1080
|
)) : console.error(
|
|
1080
1081
|
`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
|
|
1081
|
-
)), (l, a) => (
|
|
1082
|
+
)), (l, a) => (V(), G(A(i.value), re({
|
|
1082
1083
|
ref_key: "blokRef",
|
|
1083
1084
|
ref: r
|
|
1084
1085
|
}, { ...l.$props, ...l.$attrs }), null, 16));
|
|
1085
1086
|
}
|
|
1086
|
-
}),
|
|
1087
|
+
}), Qe = (s) => {
|
|
1087
1088
|
var e, t;
|
|
1088
|
-
return
|
|
1089
|
-
|
|
1089
|
+
return K(
|
|
1090
|
+
X,
|
|
1090
1091
|
{
|
|
1091
1092
|
blok: (e = s == null ? void 0 : s.attrs) == null ? void 0 : e.body[0],
|
|
1092
1093
|
id: (t = s.attrs) == null ? void 0 : t.id
|
|
@@ -1094,45 +1095,45 @@ const Je = (s, e, t = {}) => {
|
|
|
1094
1095
|
s.children
|
|
1095
1096
|
);
|
|
1096
1097
|
};
|
|
1097
|
-
function
|
|
1098
|
+
function Ze(s) {
|
|
1098
1099
|
const e = {
|
|
1099
|
-
renderFn:
|
|
1100
|
-
textFn:
|
|
1100
|
+
renderFn: K,
|
|
1101
|
+
textFn: se,
|
|
1101
1102
|
resolvers: {
|
|
1102
|
-
[b.COMPONENT]:
|
|
1103
|
+
[b.COMPONENT]: Qe,
|
|
1103
1104
|
...s.resolvers
|
|
1104
1105
|
}
|
|
1105
1106
|
};
|
|
1106
|
-
return
|
|
1107
|
+
return Je(e);
|
|
1107
1108
|
}
|
|
1108
|
-
const
|
|
1109
|
+
const et = /* @__PURE__ */ F({
|
|
1109
1110
|
__name: "StoryblokRichText",
|
|
1110
1111
|
props: {
|
|
1111
1112
|
doc: {},
|
|
1112
1113
|
resolvers: {}
|
|
1113
1114
|
},
|
|
1114
1115
|
setup(s) {
|
|
1115
|
-
const e = s, { render: t } =
|
|
1116
|
+
const e = s, { render: t } = Ze({
|
|
1116
1117
|
resolvers: e.resolvers ?? {}
|
|
1117
1118
|
}), r = () => t(e.doc);
|
|
1118
|
-
return (o, n) => (
|
|
1119
|
+
return (o, n) => (V(), G(r));
|
|
1119
1120
|
}
|
|
1120
|
-
}),
|
|
1121
|
+
}), tt = {
|
|
1121
1122
|
beforeMount(s, e) {
|
|
1122
1123
|
if (e.value) {
|
|
1123
|
-
const t =
|
|
1124
|
+
const t = Be(e.value);
|
|
1124
1125
|
Object.keys(t).length > 0 && (s.setAttribute("data-blok-c", t["data-blok-c"]), s.setAttribute("data-blok-uid", t["data-blok-uid"]), s.classList.add("storyblok__outline"));
|
|
1125
1126
|
}
|
|
1126
1127
|
}
|
|
1127
|
-
},
|
|
1128
|
+
}, W = (s) => {
|
|
1128
1129
|
console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1129
1130
|
`);
|
|
1130
1131
|
};
|
|
1131
1132
|
let E = null;
|
|
1132
|
-
const
|
|
1133
|
+
const nt = () => (E || W("useStoryblokApi"), E), it = async (s, e = {}, t = {}) => {
|
|
1133
1134
|
const r = P(null);
|
|
1134
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
1135
|
-
r.value && r.value.id &&
|
|
1135
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, oe(() => {
|
|
1136
|
+
r.value && r.value.id && Ye(
|
|
1136
1137
|
r.value.id,
|
|
1137
1138
|
(o) => r.value = o,
|
|
1138
1139
|
t
|
|
@@ -1143,15 +1144,15 @@ const ot = () => (E || X("useStoryblokApi"), E), nt = async (s, e = {}, t = {})
|
|
|
1143
1144
|
e
|
|
1144
1145
|
);
|
|
1145
1146
|
r.value = o.story;
|
|
1146
|
-
} else
|
|
1147
|
+
} else W("useStoryblok");
|
|
1147
1148
|
return r;
|
|
1148
|
-
},
|
|
1149
|
+
}, at = {
|
|
1149
1150
|
install(s, e = {}) {
|
|
1150
|
-
s.directive("editable",
|
|
1151
|
+
s.directive("editable", tt), s.component("StoryblokComponent", X), s.component("StoryblokRichText", et), e.enableFallbackComponent && !e.customFallbackComponent && s.component(
|
|
1151
1152
|
"FallbackComponent",
|
|
1152
|
-
|
|
1153
|
+
ne(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
|
|
1153
1154
|
);
|
|
1154
|
-
const { storyblokApi: t } =
|
|
1155
|
+
const { storyblokApi: t } = Xe(e);
|
|
1155
1156
|
E = t, s.provide("VueSDKOptions", e);
|
|
1156
1157
|
}
|
|
1157
1158
|
};
|
|
@@ -1159,16 +1160,16 @@ export {
|
|
|
1159
1160
|
b as BlockTypes,
|
|
1160
1161
|
k as MarkTypes,
|
|
1161
1162
|
C as RichTextResolver,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1163
|
+
Ne as RichTextSchema,
|
|
1164
|
+
X as StoryblokComponent,
|
|
1165
|
+
et as StoryblokRichText,
|
|
1166
|
+
at as StoryblokVue,
|
|
1167
|
+
J as TextTypes,
|
|
1168
|
+
st as apiPlugin,
|
|
1169
|
+
ot as renderRichText,
|
|
1170
|
+
Je as richTextResolver,
|
|
1171
|
+
it as useStoryblok,
|
|
1172
|
+
nt as useStoryblokApi,
|
|
1173
|
+
Ye as useStoryblokBridge,
|
|
1174
|
+
Ze as useStoryblokRichText
|
|
1174
1175
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.2",
|
|
4
4
|
"description": "Storyblok directive for get editable elements.",
|
|
5
5
|
"main": "./dist/storyblok-vue.js",
|
|
6
6
|
"module": "./dist/storyblok-vue.mjs",
|
|
@@ -25,25 +25,25 @@
|
|
|
25
25
|
"prepublishOnly": "npm run build && cp ../README.md ./"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@storyblok/js": "^3.1.
|
|
28
|
+
"@storyblok/js": "^3.1.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/core": "^7.
|
|
32
|
-
"@cypress/vite-dev-server": "^5.
|
|
33
|
-
"@cypress/vue": "^6.0.
|
|
31
|
+
"@babel/core": "^7.25.2",
|
|
32
|
+
"@cypress/vite-dev-server": "^5.2.0",
|
|
33
|
+
"@cypress/vue": "^6.0.1",
|
|
34
34
|
"@vitejs/plugin-vue": "^5.0.5",
|
|
35
35
|
"@vue/babel-preset-app": "^5.0.8",
|
|
36
36
|
"@vue/test-utils": "2.4.6",
|
|
37
37
|
"@vue/tsconfig": "^0.1.3",
|
|
38
38
|
"@vue/vue3-jest": "^29.2.6",
|
|
39
39
|
"babel-jest": "^29.4.3",
|
|
40
|
-
"cypress": "^13.
|
|
40
|
+
"cypress": "^13.15.0",
|
|
41
41
|
"eslint-plugin-cypress": "^2.15.1",
|
|
42
|
-
"eslint-plugin-jest": "^28.
|
|
42
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
43
43
|
"jest": "^29.6.4",
|
|
44
44
|
"typescript": "^4.9.5",
|
|
45
|
-
"vite": "^5.4.
|
|
46
|
-
"vue": "^3.
|
|
45
|
+
"vite": "^5.4.6",
|
|
46
|
+
"vue": "^3.5.10",
|
|
47
47
|
"vue-tsc": "^1.8.0"
|
|
48
48
|
},
|
|
49
49
|
"babel": {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineComponent as l, openBlock as r, createElementBlock as p, createElementVNode as n, createTextVNode as c, toDisplayString as _ } from "vue";
|
|
2
|
-
const m = { class: "fallback-component" }, d = { class: "component" }, f = /* @__PURE__ */ l({
|
|
3
|
-
__name: "FallbackComponent",
|
|
4
|
-
props: {
|
|
5
|
-
blok: {}
|
|
6
|
-
},
|
|
7
|
-
setup(o) {
|
|
8
|
-
return (e, t) => (r(), p("div", m, [
|
|
9
|
-
n("p", null, [
|
|
10
|
-
c(" Component could not be found for blok "),
|
|
11
|
-
n("span", d, _(e.blok.component), 1),
|
|
12
|
-
c("! Is it configured correctly? ")
|
|
13
|
-
])
|
|
14
|
-
]));
|
|
15
|
-
}
|
|
16
|
-
}), i = (o, e) => {
|
|
17
|
-
const t = o.__vccOpts || o;
|
|
18
|
-
for (const [s, a] of e)
|
|
19
|
-
t[s] = a;
|
|
20
|
-
return t;
|
|
21
|
-
}, u = /* @__PURE__ */ i(f, [["__scopeId", "data-v-93c770c0"]]);
|
|
22
|
-
export {
|
|
23
|
-
u as default
|
|
24
|
-
};
|