@storyblok/vue 7.1.8 → 7.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StoryblokComponent.vue.d.ts +10 -9
- package/dist/storyblok-vue.js +3 -5
- package/dist/storyblok-vue.mjs +113 -110
- package/package.json +7 -7
|
@@ -2,14 +2,15 @@ import type { SbBlokData } from "./types";
|
|
|
2
2
|
export interface SbComponentProps {
|
|
3
3
|
blok: SbBlokData;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import("vue").DefineComponent<
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type: import(
|
|
5
|
+
declare const _default: import("vue").DefineComponent<{
|
|
6
|
+
blok: {
|
|
7
|
+
type: import("vue").PropType<SbBlokData>;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
blok: {
|
|
12
|
+
type: import("vue").PropType<SbBlokData>;
|
|
13
13
|
required: true;
|
|
14
14
|
};
|
|
15
|
-
}
|
|
15
|
+
}>>, {}, {}>;
|
|
16
|
+
export default _default;
|
package/dist/storyblok-vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d
|
|
1
|
+
(function(p,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(p=typeof globalThis<"u"?globalThis:p||self,d(p.storyblokVue={},p.Vue))})(this,function(p,d){"use strict";let R=!1;const j=[],A=o=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}R?r():j.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>e(r),s.onload=r=>{j.forEach(i=>i()),R=!0,t(r)},document.getElementsByTagName("head")[0].appendChild(s)});var M=Object.defineProperty,N=(o,t,e)=>t in o?M(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,h=(o,t,e)=>(N(o,typeof t!="symbol"?t+"":t,e),e);function S(o){return!(o!==o||o===1/0||o===-1/0)}function z(o,t,e){if(!S(t))throw new TypeError("Expected `limit` to be a finite number");if(!S(e))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const a=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==a})},e);r.indexOf(a)<0&&r.push(a);const c=s.shift();c.resolve(o.apply(c.self,c.args))},l=function(...a){const c=this;return new Promise(function(u,g){s.push({resolve:u,reject:g,args:a,self:c}),i<t&&n()})};return l.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},l}const L=function(o,t){const e={};for(const s in o){const r=o[s];t.indexOf(s)>-1&&r!==null&&(e[s]=r)}return e},U=o=>o==="email",q=()=>({singleTag:"hr"}),H=()=>({tag:"blockquote"}),V=()=>({tag:"ul"}),D=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),B=()=>({singleTag:"br"}),J=o=>({tag:`h${o.attrs.level}`}),F=o=>({singleTag:[{tag:"img",attrs:L(o.attrs,["src","alt","title"])}]}),Y=()=>({tag:"li"}),K=()=>({tag:"ol"}),W=()=>({tag:"p"}),G=o=>({tag:[{tag:"span",attrs:{["data-type"]:"emoji",["data-name"]:o.attrs.name,emoji:o.attrs.emoji}}]}),Q=()=>({tag:"b"}),X=()=>({tag:"strike"}),Z=()=>({tag:"u"}),tt=()=>({tag:"strong"}),et=()=>({tag:"code"}),st=()=>({tag:"i"}),rt=o=>{const t={...o.attrs},{linktype:e="url"}=o.attrs;if(U(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ot=o=>({tag:[{tag:"span",attrs:o.attrs}]}),it=()=>({tag:"sub"}),nt=()=>({tag:"sup"}),at=o=>({tag:[{tag:"span",attrs:o.attrs}]}),lt=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},ct=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},P={nodes:{horizontal_rule:q,blockquote:H,bullet_list:V,code_block:D,hard_break:B,heading:J,image:F,list_item:Y,ordered_list:K,paragraph:W,emoji:G},marks:{bold:Q,strike:X,underline:Z,strong:tt,code:et,italic:st,link:rt,styled:ot,subscript:it,superscript:nt,anchor:at,highlight:lt,textStyle:ct}},ht=function(o){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},e=/[&<>"']/g,s=RegExp(e.source);return o&&s.test(o)?o.replace(e,r=>t[r]):o};class b{constructor(t){h(this,"marks"),h(this,"nodes"),t||(t=P),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(r=>{s+=this.renderNode(r)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
|
|
2
2
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
3
3
|
ISbRichtext:
|
|
4
4
|
content?: ISbRichtext[]
|
|
@@ -21,7 +21,5 @@
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
type: 'doc'
|
|
24
|
-
}`),""}optimizeImages(t,e){let s=0,r=0,i="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),typeof e.height=="number"&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),(e.loading==="lazy"||e.loading==="eager")&&(i+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const c=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var l,u;const g=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(g&&g.length>0){const m={srcset:(l=e.srcset)==null?void 0:l.map(f=>{if(typeof f=="number")return`//${g}/m/${f}x0${n} ${f}w`;if(typeof f=="object"&&f.length===2){let _=0,O=0;return typeof f[0]=="number"&&(_=f[0]),typeof f[1]=="number"&&(O=f[1]),`//${g}/m/${_}x${O}${n} ${_}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let T="";return m.srcset&&(T+=`srcset="${m.srcset}" `),m.sizes&&(T+=`sizes="${m.sizes}" `),a.replace(/<img/g,`<img ${T.trim()}`)}return a})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach(r=>{e.push(this.renderNode(r))}):t.text?e.push(ht(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderClosingTag(i.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${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){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class w{constructor(){h(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(t,e=25,s=1)=>({...t,per_page:e,page:s})),h(this,"delay",t=>new Promise(e=>setTimeout(e,t))),h(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),h(this,"range",(t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,(i,n)=>n*r+t)}),h(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),h(this,"flatMap",(t=[],e)=>t.map(e).reduce((s,r)=>[...s,...r],[]))}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=t[i],c=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=this.stringify(n,e?e+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):a=(e?e+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")}getRegionURL(t){const e="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn";switch(t){case"us":return s;case"cn":return r;default:return e}}}class ut{constructor(t){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&t.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(r=>{s.data=r});for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if(t==="get"){const a=new w;e=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:n}=i;let c;this.timeout&&(c=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(c);const l=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise((s,r)=>{if(e.test(`${t.status}`))return s(t);const i={message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug};r(i)})}}let v={};const y={};class dt{constructor(t,e){if(h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations"),!e){const i=new w().getRegionURL,n=t.https===!1?"http":"https";t.oauthToken?e=`${n}://${i(t.region)}/v1`:e=`${n}://${i(t.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),s.forEach((i,n)=>{t.headers&&t.headers[n]&&s.set(n,t.headers[n])});let r=5;t.oauthToken&&(s.set("Authorization",t.oauthToken),r=3),t.rateLimit&&(r=t.rateLimit),t.richTextSchema?this.richTextResolver=new b(t.richTextSchema):this.richTextResolver=new b,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=z(this.throttledRequest,r,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new w,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new ut({baseURL:e,timeout:t.timeout||0,headers:s,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let s="";return e.attrs.body&&e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=y[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(e==null?void 0:e.per_page)||25,i=`/${t}`,n=i.split("/"),c=s||n[n.length-1],a=1,l=await this.makeRequest(i,e,r,a),u=l.total?Math.ceil(l.total/r):1,g=await this.helpers.asyncMap(this.helpers.range(a,u),m=>this.makeRequest(i,e,r,m+1));return this.helpers.flatMap([l,...g],m=>Object.values(m.data[c]))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1){if(typeof t[e]=="string")this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const i=[];t[e].forEach(n=>{this.relations[r][n]&&i.push(this._cleanCopy(this.relations[r][n]))}),t[e]=i}}}iterateTree(t,e,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,e,s),this._insertLinks(i,n,s)),r(i[n])}}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const i=t.link_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(t.link_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const i=t.rel_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(t.rel_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,s){var r,i;let n=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(n=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],n,s);t.story?this.iterateTree(t.story,n,s):t.stories.forEach(c=>{this.iterateTree(c,n,s)}),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({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 n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise((n,c)=>{try{(async()=>{var a;try{const l=await this.throttle("get",t,e);let u={data:l.data,headers:l.headers};if((a=l.headers)!=null&&a["per-page"]&&(u=Object.assign({},u,{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 c(l);if(u.data.story||u.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,e,`${g}`)}return e.version==="published"&&t!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&e.token&&(e.version=="draft"&&y[e.token]!=u.data.cv&&await this.flushCache(),y[e.token]=u.data.cv),n(u)}catch(l){return c(l)}})()}catch{}})}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return y}cacheVersion(){return y[this.accessToken]}setCacheVersion(t){this.accessToken&&(y[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(v[t])},getAll(){return Promise.resolve(v)},set(t,e){return v[t]=e,Promise.resolve(void 0)},flush(){return v={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},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}}const pt=(o={})=>{const{apiOptions:t}=o;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 dt(t)}},gt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const t=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let $;const ft="https://app.storyblok.com/f/storyblok-v2-latest.js",E=(o,t,e={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===o?t(n.story):(n.action==="change"||n.action==="published")&&n.storyId===o&&window.location.reload()})})}},mt=(o={})=>{var t,e;const{bridge:s,accessToken:r,use:i=[],apiOptions:n={},richText:c={}}=o;n.accessToken=n.accessToken||r;const a={bridge:s,apiOptions:n};let l={};i.forEach(g=>{l={...l,...g(a)}});const u=!(typeof window>"u")&&((e=(t=window.location)==null?void 0:t.search)==null?void 0:e.includes("_storyblok_tk"));return s!==!1&&u&&A(ft),$=new b(c.schema),c.resolver&&x($,c.resolver),l},x=(o,t)=>{o.addNode("blok",e=>{let s="";return e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})},yt=(o,t,e)=>{let s=e||$;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return o===""?"":o?(t&&(s=new b(t.schema),t.resolver&&x(s,t.resolver)),s.render(o)):(console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
25
|
-
|
|
26
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},I=p.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o){return(t,e)=>(p.openBlock(),p.createBlock(p.resolveDynamicComponent(t.blok.component),p.normalizeProps(p.guardReactiveProps({...t.$props,...t.$attrs})),null,16))}}),bt={beforeMount(o,t){if(t.value){const e=gt(t.value);o.setAttribute("data-blok-c",e["data-blok-c"]),o.setAttribute("data-blok-uid",e["data-blok-uid"]),o.classList.add("storyblok__outline")}}},C=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
27
|
-
`)};let k=null;const kt=()=>(k||C("useStoryblokApi"),k),vt=async(o,t={},e={})=>{const s=p.ref(null);if(p.onMounted(()=>{s.value&&s.value.id&&E(s.value.id,r=>s.value=r,e)}),k){const{data:r}=await k.get(`cdn/stories/${o}`,t);s.value=r.story}else C("useStoryblok");return s},wt={install(o,t={}){o.directive("editable",bt),o.component("StoryblokComponent",I);const{storyblokApi:e}=mt(t);k=e}};d.RichTextResolver=b,d.RichTextSchema=P,d.StoryblokComponent=I,d.StoryblokVue=wt,d.apiPlugin=pt,d.renderRichText=yt,d.useStoryblok=vt,d.useStoryblokApi=kt,d.useStoryblokBridge=E,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
24
|
+
}`),""}optimizeImages(t,e){let s=0,r=0,i="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),typeof e.height=="number"&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),(e.loading==="lazy"||e.loading==="eager")&&(i+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const l=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,u;const g=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(g&&g.length>0){const m={srcset:(c=e.srcset)==null?void 0:c.map(f=>{if(typeof f=="number")return`//${g}/m/${f}x0${n} ${f}w`;if(typeof f=="object"&&f.length===2){let _=0,O=0;return typeof f[0]=="number"&&(_=f[0]),typeof f[1]=="number"&&(O=f[1]),`//${g}/m/${_}x${O}${n} ${_}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let T="";return m.srcset&&(T+=`srcset="${m.srcset}" `),m.sizes&&(T+=`sizes="${m.sizes}" `),a.replace(/<img/g,`<img ${T.trim()}`)}return a})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach(r=>{e.push(this.renderNode(r))}):t.text?e.push(ht(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderClosingTag(i.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${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){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class w{constructor(){h(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(t,e=25,s=1)=>({...t,per_page:e,page:s})),h(this,"delay",t=>new Promise(e=>setTimeout(e,t))),h(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),h(this,"range",(t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,(i,n)=>n*r+t)}),h(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),h(this,"flatMap",(t=[],e)=>t.map(e).reduce((s,r)=>[...s,...r],[]))}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=t[i],l=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=this.stringify(n,e?e+encodeURIComponent("["+l+"]"):l,Array.isArray(n)):a=(e?e+encodeURIComponent("["+l+"]"):l)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")}getRegionURL(t){const e="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn";switch(t){case"us":return s;case"cn":return r;default:return e}}}class ut{constructor(t){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&t.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(r=>{s.data=r});for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if(t==="get"){const a=new w;e=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:n}=i;let l;this.timeout&&(l=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise((s,r)=>{if(e.test(`${t.status}`))return s(t);const i={message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug};r(i)})}}let v={};const y={};class pt{constructor(t,e){h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations");let s=t.endpoint||e;if(!s){const n=new w().getRegionURL,l=t.https===!1?"http":"https";t.oauthToken?s=`${l}://${n(t.region)}/v1`:s=`${l}://${n(t.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),r.forEach((n,l)=>{t.headers&&t.headers[l]&&r.set(l,t.headers[l])});let i=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),i=3),t.rateLimit&&(i=t.rateLimit),t.richTextSchema?this.richTextResolver=new b(t.richTextSchema):this.richTextResolver=new b,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=z(this.throttledRequest,i,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new w,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new ut({baseURL:s,timeout:t.timeout||0,headers:r,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let s="";return e.attrs.body&&e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=y[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(e==null?void 0:e.per_page)||25,i=`/${t}`,n=i.split("/"),l=s||n[n.length-1],a=1,c=await this.makeRequest(i,e,r,a),u=c.total?Math.ceil(c.total/r):1,g=await this.helpers.asyncMap(this.helpers.range(a,u),m=>this.makeRequest(i,e,r,m+1));return this.helpers.flatMap([c,...g],m=>Object.values(m.data[l]))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1){if(typeof t[e]=="string")this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const i=[];t[e].forEach(n=>{this.relations[r][n]&&i.push(this._cleanCopy(this.relations[r][n]))}),t[e]=i}}}iterateTree(t,e,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,e,s),this._insertLinks(i,n,s)),r(i[n])}}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const i=t.link_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const c=Math.min(i,a+l);n.push(t.link_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const i=t.rel_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const c=Math.min(i,a+l);n.push(t.rel_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,s){var r,i;let n=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(n=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],n,s);t.story?this.iterateTree(t.story,n,s):t.stories.forEach(l=>{this.iterateTree(l,n,s)}),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({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 n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise((n,l)=>{try{(async()=>{var a;try{const c=await this.throttle("get",t,e);let u={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(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 l(c);if(u.data.story||u.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,e,`${g}`)}return e.version==="published"&&t!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&e.token&&(e.version=="draft"&&y[e.token]!=u.data.cv&&await this.flushCache(),y[e.token]=u.data.cv),n(u)}catch(c){return l(c)}})()}catch{}})}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return y}cacheVersion(){return y[this.accessToken]}setCacheVersion(t){this.accessToken&&(y[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(v[t])},getAll(){return Promise.resolve(v)},set(t,e){return v[t]=e,Promise.resolve(void 0)},flush(){return v={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},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}}const dt=(o={})=>{const{apiOptions:t}=o;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 pt(t)}},gt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const t=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let $;const ft="https://app.storyblok.com/f/storyblok-v2-latest.js",E=(o,t,e={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===o?t(n.story):(n.action==="change"||n.action==="published")&&n.storyId===o&&window.location.reload()})})}},mt=(o={})=>{var t,e;const{bridge:s,accessToken:r,use:i=[],apiOptions:n={},richText:l={}}=o;n.accessToken=n.accessToken||r;const a={bridge:s,apiOptions:n};let c={};i.forEach(g=>{c={...c,...g(a)}});const u=!(typeof window>"u")&&((e=(t=window.location)==null?void 0:t.search)==null?void 0:e.includes("_storyblok_tk"));return s!==!1&&u&&A(ft),$=new b(l.schema),l.resolver&&I($,l.resolver),c},I=(o,t)=>{o.addNode("blok",e=>{let s="";return e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})},yt=o=>{var t,e;return!o||((t=o==null?void 0:o.content)==null?void 0:t[0].type)!=="blok"&&!((e=o==null?void 0:o.content)!=null&&e[0].content)},bt=(o,t,e)=>{let s=e||$;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return yt(o)?"":(t&&(s=new b(t.schema),t.resolver&&I(s,t.resolver)),s.render(o))},x=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o){return(t,e)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(t.blok.component),d.normalizeProps(d.guardReactiveProps({...t.$props,...t.$attrs})),null,16))}}),kt={beforeMount(o,t){if(t.value){const e=gt(t.value);o.setAttribute("data-blok-c",e["data-blok-c"]),o.setAttribute("data-blok-uid",e["data-blok-uid"]),o.classList.add("storyblok__outline")}}},C=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
25
|
+
`)};let k=null;const vt=()=>(k||C("useStoryblokApi"),k),wt=async(o,t={},e={})=>{const s=d.ref(null);if(d.onMounted(()=>{s.value&&s.value.id&&E(s.value.id,r=>s.value=r,e)}),k){const{data:r}=await k.get(`cdn/stories/${o}`,t);s.value=r.story}else C("useStoryblok");return s},$t={install(o,t={}){o.directive("editable",kt),o.component("StoryblokComponent",x);const{storyblokApi:e}=mt(t);k=e}};p.RichTextResolver=b,p.RichTextSchema=P,p.StoryblokComponent=x,p.StoryblokVue=$t,p.apiPlugin=dt,p.renderRichText=bt,p.useStoryblok=wt,p.useStoryblokApi=vt,p.useStoryblokBridge=E,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { defineComponent as S, openBlock as E, createBlock as I, resolveDynamicComponent as C, normalizeProps as O, guardReactiveProps as A, ref as M, onMounted as N } from "vue";
|
|
2
|
-
let
|
|
2
|
+
let T = !1;
|
|
3
3
|
const R = [], z = (o) => new Promise((t, e) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
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
|
+
T ? r() : R.push(r);
|
|
10
10
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
11
11
|
return;
|
|
12
12
|
const s = document.createElement("script");
|
|
13
13
|
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => e(r), s.onload = (r) => {
|
|
14
|
-
R.forEach((i) => i()),
|
|
14
|
+
R.forEach((i) => i()), T = !0, t(r);
|
|
15
15
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
16
16
|
});
|
|
17
17
|
var L = Object.defineProperty, U = (o, t, e) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, h = (o, t, e) => (U(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
@@ -33,26 +33,26 @@ function q(o, t, e) {
|
|
|
33
33
|
});
|
|
34
34
|
}, e);
|
|
35
35
|
r.indexOf(a) < 0 && r.push(a);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
const
|
|
40
|
-
return new Promise(function(u,
|
|
36
|
+
const c = s.shift();
|
|
37
|
+
c.resolve(o.apply(c.self, c.args));
|
|
38
|
+
}, l = function(...a) {
|
|
39
|
+
const c = this;
|
|
40
|
+
return new Promise(function(u, p) {
|
|
41
41
|
s.push({
|
|
42
42
|
resolve: u,
|
|
43
|
-
reject:
|
|
43
|
+
reject: p,
|
|
44
44
|
args: a,
|
|
45
|
-
self:
|
|
45
|
+
self: c
|
|
46
46
|
}), i < t && n();
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
-
return
|
|
49
|
+
return l.abort = function() {
|
|
50
50
|
r.forEach(clearTimeout), r = [], s.forEach(function(a) {
|
|
51
51
|
a.reject(function() {
|
|
52
52
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
53
53
|
});
|
|
54
54
|
}), s.length = 0;
|
|
55
|
-
},
|
|
55
|
+
}, l;
|
|
56
56
|
}
|
|
57
57
|
const H = function(o, t) {
|
|
58
58
|
const e = {};
|
|
@@ -162,7 +162,7 @@ const H = function(o, t) {
|
|
|
162
162
|
} : {
|
|
163
163
|
tag: ""
|
|
164
164
|
};
|
|
165
|
-
},
|
|
165
|
+
}, pt = (o) => {
|
|
166
166
|
var t;
|
|
167
167
|
return (t = o.attrs) != null && t.color ? {
|
|
168
168
|
tag: [
|
|
@@ -176,7 +176,7 @@ const H = function(o, t) {
|
|
|
176
176
|
} : {
|
|
177
177
|
tag: ""
|
|
178
178
|
};
|
|
179
|
-
},
|
|
179
|
+
}, dt = {
|
|
180
180
|
nodes: {
|
|
181
181
|
horizontal_rule: B,
|
|
182
182
|
blockquote: V,
|
|
@@ -203,7 +203,7 @@ const H = function(o, t) {
|
|
|
203
203
|
superscript: ct,
|
|
204
204
|
anchor: ht,
|
|
205
205
|
highlight: ut,
|
|
206
|
-
textStyle:
|
|
206
|
+
textStyle: pt
|
|
207
207
|
}
|
|
208
208
|
}, gt = function(o) {
|
|
209
209
|
const t = {
|
|
@@ -217,7 +217,7 @@ const H = function(o, t) {
|
|
|
217
217
|
};
|
|
218
218
|
class b {
|
|
219
219
|
constructor(t) {
|
|
220
|
-
h(this, "marks"), h(this, "nodes"), t || (t =
|
|
220
|
+
h(this, "marks"), h(this, "nodes"), t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
221
221
|
}
|
|
222
222
|
addNode(t, e) {
|
|
223
223
|
this.nodes[t] = e;
|
|
@@ -262,29 +262,29 @@ class b {
|
|
|
262
262
|
optimizeImages(t, e) {
|
|
263
263
|
let s = 0, r = 0, i = "", n = "";
|
|
264
264
|
typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (i += `width="${e.width}" `, s = e.width), typeof e.height == "number" && e.height > 0 && (i += `height="${e.height}" `, r = e.height), (e.loading === "lazy" || e.loading === "eager") && (i += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (i += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (n += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (n += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-Fa-f]{6}/g) || e.filters.fill === "transparent") && (n += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (n += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (n += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (n += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (n += `:rotate(${e.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (t = t.replace(/<img/g, `<img ${i.trim()}`));
|
|
265
|
-
const
|
|
265
|
+
const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
|
|
266
266
|
return t = t.replace(
|
|
267
267
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
268
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
268
|
+
`a.storyblok.com/f/$1/$2.$3/m/${l}`
|
|
269
269
|
), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
270
|
-
var
|
|
271
|
-
const
|
|
270
|
+
var c, u;
|
|
271
|
+
const p = a.match(
|
|
272
272
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
273
273
|
);
|
|
274
|
-
if (
|
|
274
|
+
if (p && p.length > 0) {
|
|
275
275
|
const g = {
|
|
276
|
-
srcset: (
|
|
277
|
-
if (typeof
|
|
278
|
-
return `//${
|
|
279
|
-
if (typeof
|
|
280
|
-
let
|
|
281
|
-
return typeof
|
|
276
|
+
srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
|
|
277
|
+
if (typeof d == "number")
|
|
278
|
+
return `//${p}/m/${d}x0${n} ${d}w`;
|
|
279
|
+
if (typeof d == "object" && d.length === 2) {
|
|
280
|
+
let k = 0, _ = 0;
|
|
281
|
+
return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && (_ = d[1]), `//${p}/m/${k}x${_}${n} ${k}w`;
|
|
282
282
|
}
|
|
283
283
|
}).join(", "),
|
|
284
|
-
sizes: (u = e.sizes) == null ? void 0 : u.map((
|
|
284
|
+
sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
|
|
285
285
|
};
|
|
286
|
-
let
|
|
287
|
-
return g.srcset && (
|
|
286
|
+
let v = "";
|
|
287
|
+
return g.srcset && (v += `srcset="${g.srcset}" `), g.sizes && (v += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${v.trim()}`);
|
|
288
288
|
}
|
|
289
289
|
return a;
|
|
290
290
|
})), t;
|
|
@@ -374,13 +374,13 @@ class w {
|
|
|
374
374
|
for (const i in t) {
|
|
375
375
|
if (!Object.prototype.hasOwnProperty.call(t, i))
|
|
376
376
|
continue;
|
|
377
|
-
const n = t[i],
|
|
377
|
+
const n = t[i], l = s ? "" : encodeURIComponent(i);
|
|
378
378
|
let a;
|
|
379
379
|
typeof n == "object" ? a = this.stringify(
|
|
380
380
|
n,
|
|
381
|
-
e ? e + encodeURIComponent("[" +
|
|
381
|
+
e ? e + encodeURIComponent("[" + l + "]") : l,
|
|
382
382
|
Array.isArray(n)
|
|
383
|
-
) : a = (e ? e + encodeURIComponent("[" +
|
|
383
|
+
) : a = (e ? e + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(n), r.push(a);
|
|
384
384
|
}
|
|
385
385
|
return r.join("&");
|
|
386
386
|
}
|
|
@@ -447,8 +447,8 @@ class ft {
|
|
|
447
447
|
} else
|
|
448
448
|
s = JSON.stringify(this.parameters);
|
|
449
449
|
const r = new URL(e), i = new AbortController(), { signal: n } = i;
|
|
450
|
-
let
|
|
451
|
-
this.timeout && (
|
|
450
|
+
let l;
|
|
451
|
+
this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
|
|
452
452
|
try {
|
|
453
453
|
const a = await this.fetch(`${r}`, {
|
|
454
454
|
method: t,
|
|
@@ -456,9 +456,9 @@ class ft {
|
|
|
456
456
|
body: s,
|
|
457
457
|
signal: n
|
|
458
458
|
});
|
|
459
|
-
this.timeout && clearTimeout(
|
|
460
|
-
const
|
|
461
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
|
459
|
+
this.timeout && clearTimeout(l);
|
|
460
|
+
const c = await this._responseHandler(a);
|
|
461
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
|
|
462
462
|
} catch (a) {
|
|
463
463
|
return {
|
|
464
464
|
message: a
|
|
@@ -491,19 +491,21 @@ class mt {
|
|
|
491
491
|
* @param endpoint string, optional
|
|
492
492
|
*/
|
|
493
493
|
constructor(t, e) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
494
|
+
h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations");
|
|
495
|
+
let s = t.endpoint || e;
|
|
496
|
+
if (!s) {
|
|
497
|
+
const n = new w().getRegionURL, l = t.https === !1 ? "http" : "https";
|
|
498
|
+
t.oauthToken ? s = `${l}://${n(t.region)}/v1` : s = `${l}://${n(t.region)}/v2`;
|
|
497
499
|
}
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
t.headers && t.headers[
|
|
500
|
+
const r = new Headers();
|
|
501
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((n, l) => {
|
|
502
|
+
t.headers && t.headers[l] && r.set(l, t.headers[l]);
|
|
501
503
|
});
|
|
502
|
-
let
|
|
503
|
-
t.oauthToken && (
|
|
504
|
-
baseURL:
|
|
504
|
+
let i = 5;
|
|
505
|
+
t.oauthToken && (r.set("Authorization", t.oauthToken), i = 3), t.rateLimit && (i = t.rateLimit), t.richTextSchema ? this.richTextResolver = new b(t.richTextSchema) : this.richTextResolver = new b(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = q(this.throttledRequest, i, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new w(), this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.client = new ft({
|
|
506
|
+
baseURL: s,
|
|
505
507
|
timeout: t.timeout || 0,
|
|
506
|
-
headers:
|
|
508
|
+
headers: r,
|
|
507
509
|
responseInterceptor: t.responseInterceptor,
|
|
508
510
|
fetch: t.fetch
|
|
509
511
|
});
|
|
@@ -537,13 +539,13 @@ class mt {
|
|
|
537
539
|
return this.cacheResponse(s, r);
|
|
538
540
|
}
|
|
539
541
|
async getAll(t, e, s) {
|
|
540
|
-
const r = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`, n = i.split("/"),
|
|
542
|
+
const r = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`, n = i.split("/"), l = s || n[n.length - 1], a = 1, c = await this.makeRequest(i, e, r, a), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
|
|
541
543
|
this.helpers.range(a, u),
|
|
542
544
|
(g) => this.makeRequest(i, e, r, g + 1)
|
|
543
545
|
);
|
|
544
546
|
return this.helpers.flatMap(
|
|
545
|
-
[
|
|
546
|
-
(g) => Object.values(g.data[
|
|
547
|
+
[c, ...p],
|
|
548
|
+
(g) => Object.values(g.data[l])
|
|
547
549
|
);
|
|
548
550
|
}
|
|
549
551
|
post(t, e) {
|
|
@@ -619,20 +621,20 @@ class mt {
|
|
|
619
621
|
async resolveLinks(t, e, s) {
|
|
620
622
|
let r = [];
|
|
621
623
|
if (t.link_uuids) {
|
|
622
|
-
const i = t.link_uuids.length, n = [],
|
|
623
|
-
for (let a = 0; a < i; a +=
|
|
624
|
-
const
|
|
625
|
-
n.push(t.link_uuids.slice(a,
|
|
624
|
+
const i = t.link_uuids.length, n = [], l = 50;
|
|
625
|
+
for (let a = 0; a < i; a += l) {
|
|
626
|
+
const c = Math.min(i, a + l);
|
|
627
|
+
n.push(t.link_uuids.slice(a, c));
|
|
626
628
|
}
|
|
627
629
|
for (let a = 0; a < n.length; a++)
|
|
628
630
|
(await this.getStories({
|
|
629
|
-
per_page:
|
|
631
|
+
per_page: l,
|
|
630
632
|
language: e.language,
|
|
631
633
|
version: e.version,
|
|
632
634
|
by_uuids: n[a].join(",")
|
|
633
635
|
})).data.stories.forEach(
|
|
634
|
-
(
|
|
635
|
-
r.push(
|
|
636
|
+
(c) => {
|
|
637
|
+
r.push(c);
|
|
636
638
|
}
|
|
637
639
|
);
|
|
638
640
|
} else
|
|
@@ -647,19 +649,19 @@ class mt {
|
|
|
647
649
|
async resolveRelations(t, e, s) {
|
|
648
650
|
let r = [];
|
|
649
651
|
if (t.rel_uuids) {
|
|
650
|
-
const i = t.rel_uuids.length, n = [],
|
|
651
|
-
for (let a = 0; a < i; a +=
|
|
652
|
-
const
|
|
653
|
-
n.push(t.rel_uuids.slice(a,
|
|
652
|
+
const i = t.rel_uuids.length, n = [], l = 50;
|
|
653
|
+
for (let a = 0; a < i; a += l) {
|
|
654
|
+
const c = Math.min(i, a + l);
|
|
655
|
+
n.push(t.rel_uuids.slice(a, c));
|
|
654
656
|
}
|
|
655
657
|
for (let a = 0; a < n.length; a++)
|
|
656
658
|
(await this.getStories({
|
|
657
|
-
per_page:
|
|
659
|
+
per_page: l,
|
|
658
660
|
language: e.language,
|
|
659
661
|
version: e.version,
|
|
660
662
|
by_uuids: n[a].join(",")
|
|
661
|
-
})).data.stories.forEach((
|
|
662
|
-
r.push(
|
|
663
|
+
})).data.stories.forEach((c) => {
|
|
664
|
+
r.push(c);
|
|
663
665
|
});
|
|
664
666
|
} else
|
|
665
667
|
r = t.rels;
|
|
@@ -674,14 +676,14 @@ class mt {
|
|
|
674
676
|
var r, i;
|
|
675
677
|
let n = [];
|
|
676
678
|
if (this.links[s] = {}, this.relations[s] = {}, typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (n = e.resolve_relations.split(",")), await this.resolveRelations(t, e, s)), e.resolve_links && ["1", "story", "url"].indexOf(e.resolve_links) > -1 && ((r = t.links) != null && r.length || (i = t.link_uuids) != null && i.length) && await this.resolveLinks(t, e, s), this.resolveNestedRelations)
|
|
677
|
-
for (const
|
|
679
|
+
for (const l in this.relations[s])
|
|
678
680
|
this.iterateTree(
|
|
679
|
-
this.relations[s][
|
|
681
|
+
this.relations[s][l],
|
|
680
682
|
n,
|
|
681
683
|
s
|
|
682
684
|
);
|
|
683
|
-
t.story ? this.iterateTree(t.story, n, s) : t.stories.forEach((
|
|
684
|
-
this.iterateTree(
|
|
685
|
+
t.story ? this.iterateTree(t.story, n, s) : t.stories.forEach((l) => {
|
|
686
|
+
this.iterateTree(l, n, s);
|
|
685
687
|
}), delete this.links[s], delete this.relations[s];
|
|
686
688
|
}
|
|
687
689
|
async cacheResponse(t, e, s) {
|
|
@@ -691,25 +693,25 @@ class mt {
|
|
|
691
693
|
if (n)
|
|
692
694
|
return Promise.resolve(n);
|
|
693
695
|
}
|
|
694
|
-
return new Promise((n,
|
|
696
|
+
return new Promise((n, l) => {
|
|
695
697
|
try {
|
|
696
698
|
(async () => {
|
|
697
699
|
var a;
|
|
698
700
|
try {
|
|
699
|
-
const
|
|
700
|
-
let u = { data:
|
|
701
|
-
if ((a =
|
|
702
|
-
perPage:
|
|
703
|
-
total:
|
|
704
|
-
})),
|
|
705
|
-
return c
|
|
701
|
+
const c = await this.throttle("get", t, e);
|
|
702
|
+
let u = { data: c.data, headers: c.headers };
|
|
703
|
+
if ((a = c.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
|
|
704
|
+
perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0,
|
|
705
|
+
total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
|
|
706
|
+
})), c.status != 200)
|
|
707
|
+
return l(c);
|
|
706
708
|
if (u.data.story || u.data.stories) {
|
|
707
|
-
const
|
|
708
|
-
await this.resolveStories(u.data, e, `${
|
|
709
|
+
const p = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
710
|
+
await this.resolveStories(u.data, e, `${p}`);
|
|
709
711
|
}
|
|
710
712
|
return e.version === "published" && t != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && e.token && (e.version == "draft" && f[e.token] != u.data.cv && await this.flushCache(), f[e.token] = u.data.cv), n(u);
|
|
711
|
-
} catch (
|
|
712
|
-
return c
|
|
713
|
+
} catch (c) {
|
|
714
|
+
return l(c);
|
|
713
715
|
}
|
|
714
716
|
})();
|
|
715
717
|
} catch {
|
|
@@ -769,7 +771,7 @@ class mt {
|
|
|
769
771
|
return await this.cacheProvider().flush(), this;
|
|
770
772
|
}
|
|
771
773
|
}
|
|
772
|
-
const
|
|
774
|
+
const Rt = (o = {}) => {
|
|
773
775
|
const { apiOptions: t } = o;
|
|
774
776
|
if (!t.accessToken) {
|
|
775
777
|
console.error(
|
|
@@ -790,7 +792,7 @@ const _t = (o = {}) => {
|
|
|
790
792
|
};
|
|
791
793
|
};
|
|
792
794
|
let $;
|
|
793
|
-
const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js",
|
|
795
|
+
const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", vt = (o, t, e = {}) => {
|
|
794
796
|
var s;
|
|
795
797
|
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
796
798
|
"_storyblok"
|
|
@@ -806,24 +808,24 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", kt = (o, t, e =
|
|
|
806
808
|
});
|
|
807
809
|
});
|
|
808
810
|
}
|
|
809
|
-
},
|
|
811
|
+
}, kt = (o = {}) => {
|
|
810
812
|
var t, e;
|
|
811
813
|
const {
|
|
812
814
|
bridge: s,
|
|
813
815
|
accessToken: r,
|
|
814
816
|
use: i = [],
|
|
815
817
|
apiOptions: n = {},
|
|
816
|
-
richText:
|
|
818
|
+
richText: l = {}
|
|
817
819
|
} = o;
|
|
818
820
|
n.accessToken = n.accessToken || r;
|
|
819
821
|
const a = { bridge: s, apiOptions: n };
|
|
820
|
-
let
|
|
821
|
-
i.forEach((
|
|
822
|
-
|
|
822
|
+
let c = {};
|
|
823
|
+
i.forEach((p) => {
|
|
824
|
+
c = { ...c, ...p(a) };
|
|
823
825
|
});
|
|
824
826
|
const u = !(typeof window > "u") && ((e = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : e.includes("_storyblok_tk"));
|
|
825
|
-
return s !== !1 && u && z(bt), $ = new b(
|
|
826
|
-
},
|
|
827
|
+
return s !== !1 && u && z(bt), $ = new b(l.schema), l.resolver && P($, l.resolver), c;
|
|
828
|
+
}, P = (o, t) => {
|
|
827
829
|
o.addNode("blok", (e) => {
|
|
828
830
|
let s = "";
|
|
829
831
|
return e.attrs.body.forEach((r) => {
|
|
@@ -832,7 +834,10 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", kt = (o, t, e =
|
|
|
832
834
|
html: s
|
|
833
835
|
};
|
|
834
836
|
});
|
|
835
|
-
},
|
|
837
|
+
}, wt = (o) => {
|
|
838
|
+
var t, e;
|
|
839
|
+
return !o || ((t = o == null ? void 0 : o.content) == null ? void 0 : t[0].type) !== "blok" && !((e = o == null ? void 0 : o.content) != null && e[0].content);
|
|
840
|
+
}, jt = (o, t, e) => {
|
|
836
841
|
let s = e || $;
|
|
837
842
|
if (!s) {
|
|
838
843
|
console.error(
|
|
@@ -840,10 +845,8 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", kt = (o, t, e =
|
|
|
840
845
|
);
|
|
841
846
|
return;
|
|
842
847
|
}
|
|
843
|
-
return o
|
|
844
|
-
|
|
845
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
846
|
-
}, wt = /* @__PURE__ */ S({
|
|
848
|
+
return wt(o) ? "" : (t && (s = new b(t.schema), t.resolver && P(s, t.resolver)), s.render(o));
|
|
849
|
+
}, $t = /* @__PURE__ */ S({
|
|
847
850
|
__name: "StoryblokComponent",
|
|
848
851
|
props: {
|
|
849
852
|
blok: {}
|
|
@@ -851,22 +854,22 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", kt = (o, t, e =
|
|
|
851
854
|
setup(o) {
|
|
852
855
|
return (t, e) => (E(), I(C(t.blok.component), O(A({ ...t.$props, ...t.$attrs })), null, 16));
|
|
853
856
|
}
|
|
854
|
-
}),
|
|
857
|
+
}), _t = {
|
|
855
858
|
beforeMount(o, t) {
|
|
856
859
|
if (t.value) {
|
|
857
860
|
const e = yt(t.value);
|
|
858
861
|
o.setAttribute("data-blok-c", e["data-blok-c"]), o.setAttribute("data-blok-uid", e["data-blok-uid"]), o.classList.add("storyblok__outline");
|
|
859
862
|
}
|
|
860
863
|
}
|
|
861
|
-
},
|
|
864
|
+
}, x = (o) => {
|
|
862
865
|
console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
863
866
|
`);
|
|
864
867
|
};
|
|
865
868
|
let m = null;
|
|
866
|
-
const
|
|
869
|
+
const Pt = () => (m || x("useStoryblokApi"), m), xt = async (o, t = {}, e = {}) => {
|
|
867
870
|
const s = M(null);
|
|
868
871
|
if (N(() => {
|
|
869
|
-
s.value && s.value.id &&
|
|
872
|
+
s.value && s.value.id && vt(
|
|
870
873
|
s.value.id,
|
|
871
874
|
(r) => s.value = r,
|
|
872
875
|
e
|
|
@@ -878,23 +881,23 @@ const jt = () => (m || P("useStoryblokApi"), m), xt = async (o, t = {}, e = {})
|
|
|
878
881
|
);
|
|
879
882
|
s.value = r.story;
|
|
880
883
|
} else
|
|
881
|
-
|
|
884
|
+
x("useStoryblok");
|
|
882
885
|
return s;
|
|
883
|
-
},
|
|
886
|
+
}, St = {
|
|
884
887
|
install(o, t = {}) {
|
|
885
|
-
o.directive("editable",
|
|
886
|
-
const { storyblokApi: e } =
|
|
888
|
+
o.directive("editable", _t), o.component("StoryblokComponent", $t);
|
|
889
|
+
const { storyblokApi: e } = kt(t);
|
|
887
890
|
m = e;
|
|
888
891
|
}
|
|
889
892
|
};
|
|
890
893
|
export {
|
|
891
894
|
b as RichTextResolver,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
895
|
+
dt as RichTextSchema,
|
|
896
|
+
$t as StoryblokComponent,
|
|
897
|
+
St as StoryblokVue,
|
|
898
|
+
Rt as apiPlugin,
|
|
899
|
+
jt as renderRichText,
|
|
897
900
|
xt as useStoryblok,
|
|
898
|
-
|
|
899
|
-
|
|
901
|
+
Pt as useStoryblokApi,
|
|
902
|
+
vt as useStoryblokBridge
|
|
900
903
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.10",
|
|
4
4
|
"description": "Storyblok directive for get editable elements.",
|
|
5
5
|
"main": "./dist/storyblok-vue.js",
|
|
6
6
|
"module": "./dist/storyblok-vue.mjs",
|
|
@@ -25,26 +25,26 @@
|
|
|
25
25
|
"prepublishOnly": "npm run build && cp ../README.md ./"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@storyblok/js": "^2.1
|
|
28
|
+
"@storyblok/js": "^2.2.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/core": "^7.22.
|
|
31
|
+
"@babel/core": "^7.22.5",
|
|
32
32
|
"@cypress/vite-dev-server": "^5.0.5",
|
|
33
33
|
"@cypress/vue": "^5.0.5",
|
|
34
34
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
35
35
|
"@vue/babel-preset-app": "^5.0.8",
|
|
36
|
-
"@vue/test-utils": "2.
|
|
36
|
+
"@vue/test-utils": "2.4.0",
|
|
37
37
|
"@vue/tsconfig": "^0.1.3",
|
|
38
38
|
"@vue/vue3-jest": "^29.2.4",
|
|
39
39
|
"babel-jest": "^29.4.3",
|
|
40
|
-
"cypress": "^12.
|
|
40
|
+
"cypress": "^12.15.0",
|
|
41
41
|
"eslint-plugin-cypress": "^2.13.3",
|
|
42
|
-
"eslint-plugin-jest": "^27.2.
|
|
42
|
+
"eslint-plugin-jest": "^27.2.2",
|
|
43
43
|
"jest": "^29.4.3",
|
|
44
44
|
"typescript": "^4.9.5",
|
|
45
45
|
"vite": "^4.3.9",
|
|
46
46
|
"vue": "^3.3.4",
|
|
47
|
-
"vue-tsc": "^1.
|
|
47
|
+
"vue-tsc": "^1.8.1"
|
|
48
48
|
},
|
|
49
49
|
"babel": {
|
|
50
50
|
"presets": [
|