@storyblok/js 5.1.10 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { StoryblokRichTextNode, StoryblokRichTextOptions } from '@storyblok/richtext';
2
1
  import { ISbStoryData, SbInitResult, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokComponentType } from './types';
3
2
  export interface StoryblokBridgeEvent {
4
3
  action: string;
@@ -7,17 +6,11 @@ export interface StoryblokBridgeEvent {
7
6
  }
8
7
  export declare const useStoryblokBridge: <T extends StoryblokComponentType<string> = any>(id: number, cb: (newStory: ISbStoryData<T>) => void, options?: StoryblokBridgeConfigV2) => void;
9
8
  export declare const storyblokInit: (pluginOptions?: SbSDKOptions) => SbInitResult;
10
- /**
11
- * Render Rich Text
12
- * @param data - The rich text data to render
13
- * @param options - The options for the rich text
14
- * @returns The rendered rich text
15
- */
16
- export declare function renderRichText<T = string>(data: StoryblokRichTextNode<T>, options?: StoryblokRichTextOptions<T>): T | undefined;
17
9
  export declare const loadStoryblokBridge: () => Promise<unknown>;
18
10
  export { useStoryblokBridge as registerStoryblokBridge };
19
11
  export { default as apiPlugin } from './api';
20
12
  export { default as storyblokEditable } from './editable';
21
13
  export * from './types';
22
- export { asTag, BlockTypes, ComponentBlok, LinkTypes, MarkTypes, richTextResolver, segmentStoryblokRichText, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, TextTypes, } from '@storyblok/richtext';
14
+ export { buildStoryblokImage, renderRichText, splitTableRows } from '@storyblok/richtext';
15
+ export type { SbRichTextDoc, SbRichTextImageOptions, SbRichTextMark, SbRichTextNode, SbRichTextProps, SbRichTextRenderContext, SbRichTextRendererMap, } from '@storyblok/richtext';
23
16
  export { default as StoryblokClient } from 'storyblok-js-client';
@@ -4,4 +4,4 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- (function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@storyblok/richtext"),require("storyblok-js-client")):typeof define=="function"&&define.amd?define(["exports","@storyblok/richtext","storyblok-js-client"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e.storyblok={},e.StoryblokRichtext,e.StoryblokClient))})(this,(function(e,r,b){"use strict";let f=!1;const k=[],p=t=>new Promise((o,d)=>{if(typeof window>"u"){d(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}f?n():k.push(n)},document.getElementById("storyblok-javascript-bridge")){o(void 0);return}const i=document.createElement("script");i.async=!0,i.src=t,i.id="storyblok-javascript-bridge",i.onerror=n=>d(n),i.onload=n=>{k.forEach(l=>l()),f=!0,o(n)},document.getElementsByTagName("head")[0].appendChild(i)}),m=(t={})=>{const{apiOptions:o}=t;if(!o||!o.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 b(o)}},T=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const o=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return o?{"data-blok-c":JSON.stringify(o),"data-blok-uid":`${o.id}-${o.uid}`}:{}}catch{return{}}};let u="https://app.storyblok.com/f/storyblok-v2-latest.js";const g=(t,o,d={})=>{var c;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",l=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),y=l!==null&&+l===t;if(!(!n||!y)){if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(d).on(["input","published","change"],s=>{var a;s&&(s.action==="input"&&((a=s.story)==null?void 0:a.id)===t?o(s.story):(s.action==="change"||s.action==="published")&&s.storyId===t&&window.location.reload())})})}},h=(t={})=>{var a,w;const{bridge:o,accessToken:d,use:i=[],apiOptions:n={},bridgeUrl:l}=t;n.accessToken=n.accessToken||d;const y={bridge:o,apiOptions:n};let c={};i.forEach(v=>{c={...c,...v(y)}}),l&&(u=l);const s=!(typeof window>"u")&&((w=(a=window.location)==null?void 0:a.search)==null?void 0:w.includes("_storyblok_tk"));return o!==!1&&s&&p(u),c};function S(t,o){return r.richTextResolver(o).render(t)}const B=()=>p(u);Object.defineProperty(e,"BlockTypes",{enumerable:!0,get:()=>r.BlockTypes}),Object.defineProperty(e,"ComponentBlok",{enumerable:!0,get:()=>r.ComponentBlok}),Object.defineProperty(e,"LinkTypes",{enumerable:!0,get:()=>r.LinkTypes}),Object.defineProperty(e,"MarkTypes",{enumerable:!0,get:()=>r.MarkTypes}),Object.defineProperty(e,"TextTypes",{enumerable:!0,get:()=>r.TextTypes}),Object.defineProperty(e,"asTag",{enumerable:!0,get:()=>r.asTag}),Object.defineProperty(e,"richTextResolver",{enumerable:!0,get:()=>r.richTextResolver}),Object.defineProperty(e,"segmentStoryblokRichText",{enumerable:!0,get:()=>r.segmentStoryblokRichText}),e.StoryblokClient=b,e.apiPlugin=m,e.loadStoryblokBridge=B,e.registerStoryblokBridge=g,e.renderRichText=S,e.storyblokEditable=T,e.storyblokInit=h,e.useStoryblokBridge=g,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
7
+ (function(e,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("storyblok-js-client"),require("@storyblok/richtext")):typeof define=="function"&&define.amd?define(["exports","storyblok-js-client","@storyblok/richtext"],l):(e=typeof globalThis<"u"?globalThis:e||self,l(e.storyblok={},e.StoryblokClient,e.StoryblokRichtext))})(this,(function(e,l,u){"use strict";let f=!1;const k=[],p=t=>new Promise((o,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}f?r():k.push(r)},document.getElementById("storyblok-javascript-bridge")){o(void 0);return}const i=document.createElement("script");i.async=!0,i.src=t,i.id="storyblok-javascript-bridge",i.onerror=r=>s(r),i.onload=r=>{k.forEach(d=>d()),f=!0,o(r)},document.getElementsByTagName("head")[0].appendChild(i)}),h=(t={})=>{const{apiOptions:o}=t;if(!o||!o.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 l(o)}},S=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const o=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return o?{"data-blok-c":JSON.stringify(o),"data-blok-uid":`${o.id}-${o.uid}`}:{}}catch{return{}}};let b="https://app.storyblok.com/f/storyblok-v2-latest.js";const w=(t,o,s={})=>{var c;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",d=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),y=d!==null&&+d===t;if(!(!r||!y)){if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],n=>{var a;n&&(n.action==="input"&&((a=n.story)==null?void 0:a.id)===t?o(n.story):(n.action==="change"||n.action==="published")&&n.storyId===t&&window.location.reload())})})}},m=(t={})=>{var a,g;const{bridge:o,accessToken:s,use:i=[],apiOptions:r={},bridgeUrl:d}=t;r.accessToken=r.accessToken||s;const y={bridge:o,apiOptions:r};let c={};i.forEach(T=>{c={...c,...T(y)}}),d&&(b=d);const n=!(typeof window>"u")&&((g=(a=window.location)==null?void 0:a.search)==null?void 0:g.includes("_storyblok_tk"));return o!==!1&&n&&p(b),c},B=()=>p(b);e.StoryblokClient=l,Object.defineProperty(e,"buildStoryblokImage",{enumerable:!0,get:()=>u.buildStoryblokImage}),Object.defineProperty(e,"renderRichText",{enumerable:!0,get:()=>u.renderRichText}),Object.defineProperty(e,"splitTableRows",{enumerable:!0,get:()=>u.splitTableRows}),e.apiPlugin=h,e.loadStoryblokBridge=B,e.registerStoryblokBridge=w,e.storyblokEditable=S,e.storyblokInit=m,e.useStoryblokBridge=w,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
@@ -4,12 +4,11 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- import { richTextResolver as w } from "@storyblok/richtext";
8
- import { BlockTypes as _, ComponentBlok as C, LinkTypes as P, MarkTypes as L, TextTypes as O, asTag as j, richTextResolver as A, segmentStoryblokRichText as D } from "@storyblok/richtext";
9
- import g from "storyblok-js-client";
10
- import { default as $ } from "storyblok-js-client";
7
+ import k from "storyblok-js-client";
8
+ import { default as R } from "storyblok-js-client";
9
+ import { buildStoryblokImage as _, renderRichText as P, splitTableRows as x } from "@storyblok/richtext";
11
10
  let y = !1;
12
- const u = [], f = (e) => new Promise((o, i) => {
11
+ const p = [], b = (e) => new Promise((o, i) => {
13
12
  if (typeof window > "u") {
14
13
  i(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
15
14
  return;
@@ -19,16 +18,16 @@ const u = [], f = (e) => new Promise((o, i) => {
19
18
  console.warn("You are not in Draft Mode or in the Visual Editor.");
20
19
  return;
21
20
  }
22
- y ? t() : u.push(t);
21
+ y ? t() : p.push(t);
23
22
  }, document.getElementById("storyblok-javascript-bridge")) {
24
23
  o(void 0);
25
24
  return;
26
25
  }
27
26
  const r = document.createElement("script");
28
27
  r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (t) => i(t), r.onload = (t) => {
29
- u.forEach((s) => s()), y = !0, o(t);
28
+ p.forEach((s) => s()), y = !0, o(t);
30
29
  }, document.getElementsByTagName("head")[0].appendChild(r);
31
- }), S = (e = {}) => {
30
+ }), h = (e = {}) => {
32
31
  const { apiOptions: o } = e;
33
32
  if (!o || !o.accessToken) {
34
33
  console.error(
@@ -36,8 +35,8 @@ const u = [], f = (e) => new Promise((o, i) => {
36
35
  );
37
36
  return;
38
37
  }
39
- return { storyblokApi: new g(o) };
40
- }, T = (e) => {
38
+ return { storyblokApi: new k(o) };
39
+ }, m = (e) => {
41
40
  if (typeof e != "object" || typeof e._editable > "u")
42
41
  return {};
43
42
  try {
@@ -52,26 +51,26 @@ const u = [], f = (e) => new Promise((o, i) => {
52
51
  return {};
53
52
  }
54
53
  };
55
- let l = "https://app.storyblok.com/f/storyblok-v2-latest.js";
56
- const v = (e, o, i = {}) => {
57
- var a;
58
- const t = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", s = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
54
+ let c = "https://app.storyblok.com/f/storyblok-v2-latest.js";
55
+ const S = (e, o, i = {}) => {
56
+ var d;
57
+ const t = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", s = new URL((d = window.location) == null ? void 0 : d.href).searchParams.get(
59
58
  "_storyblok"
60
- ), c = s !== null && +s === e;
61
- if (!(!t || !c)) {
59
+ ), l = s !== null && +s === e;
60
+ if (!(!t || !l)) {
62
61
  if (!e) {
63
62
  console.warn("Story ID is not defined. Please provide a valid ID.");
64
63
  return;
65
64
  }
66
65
  window.storyblokRegisterEvent(() => {
67
66
  new window.StoryblokBridge(i).on(["input", "published", "change"], (n) => {
68
- var d;
69
- n && (n.action === "input" && ((d = n.story) == null ? void 0 : d.id) === e ? o(n.story) : (n.action === "change" || n.action === "published") && n.storyId === e && window.location.reload());
67
+ var a;
68
+ n && (n.action === "input" && ((a = n.story) == null ? void 0 : a.id) === e ? o(n.story) : (n.action === "change" || n.action === "published") && n.storyId === e && window.location.reload());
70
69
  });
71
70
  });
72
71
  }
73
- }, B = (e = {}) => {
74
- var d, p;
72
+ }, E = (e = {}) => {
73
+ var a, u;
75
74
  const {
76
75
  bridge: o,
77
76
  accessToken: i,
@@ -80,33 +79,23 @@ const v = (e, o, i = {}) => {
80
79
  bridgeUrl: s
81
80
  } = e;
82
81
  t.accessToken = t.accessToken || i;
83
- const c = { bridge: o, apiOptions: t };
84
- let a = {};
85
- r.forEach((k) => {
86
- a = { ...a, ...k(c) };
87
- }), s && (l = s);
88
- const n = !(typeof window > "u") && ((p = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : p.includes("_storyblok_tk"));
89
- return o !== !1 && n && f(l), a;
90
- };
91
- function E(e, o) {
92
- return w(o).render(e);
93
- }
94
- const R = () => f(l);
82
+ const l = { bridge: o, apiOptions: t };
83
+ let d = {};
84
+ r.forEach((w) => {
85
+ d = { ...d, ...w(l) };
86
+ }), s && (c = s);
87
+ const n = !(typeof window > "u") && ((u = (a = window.location) == null ? void 0 : a.search) == null ? void 0 : u.includes("_storyblok_tk"));
88
+ return o !== !1 && n && b(c), d;
89
+ }, v = () => b(c);
95
90
  export {
96
- _ as BlockTypes,
97
- C as ComponentBlok,
98
- P as LinkTypes,
99
- L as MarkTypes,
100
- $ as StoryblokClient,
101
- O as TextTypes,
102
- S as apiPlugin,
103
- j as asTag,
104
- R as loadStoryblokBridge,
105
- v as registerStoryblokBridge,
106
- E as renderRichText,
107
- A as richTextResolver,
108
- D as segmentStoryblokRichText,
109
- T as storyblokEditable,
110
- B as storyblokInit,
111
- v as useStoryblokBridge
91
+ R as StoryblokClient,
92
+ h as apiPlugin,
93
+ _ as buildStoryblokImage,
94
+ v as loadStoryblokBridge,
95
+ S as registerStoryblokBridge,
96
+ P as renderRichText,
97
+ x as splitTableRows,
98
+ m as storyblokEditable,
99
+ E as storyblokInit,
100
+ S as useStoryblokBridge
112
101
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
3
  "type": "module",
4
- "version": "5.1.10",
4
+ "version": "6.0.0",
5
5
  "private": false,
6
6
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
7
7
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@storyblok/richtext": "4.3.5",
32
+ "@storyblok/richtext": "5.0.0",
33
33
  "storyblok-js-client": "7.6.1"
34
34
  },
35
35
  "devDependencies": {