@storyblok/js 5.1.9 → 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 +2 -9
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +37 -48
- package/package.json +4 -4
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 {
|
|
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';
|
package/dist/storyblok-js.js
CHANGED
|
@@ -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,
|
|
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"})}));
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
|
5
5
|
* author: undefined
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
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
|
|
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() :
|
|
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
|
-
|
|
28
|
+
p.forEach((s) => s()), y = !0, o(t);
|
|
30
29
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
31
|
-
}),
|
|
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
|
|
40
|
-
},
|
|
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
|
|
56
|
-
const
|
|
57
|
-
var
|
|
58
|
-
const t = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", s = new URL((
|
|
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
|
-
),
|
|
61
|
-
if (!(!t || !
|
|
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
|
|
69
|
-
n && (n.action === "input" && ((
|
|
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
|
-
},
|
|
74
|
-
var
|
|
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
|
|
84
|
-
let
|
|
85
|
-
r.forEach((
|
|
86
|
-
|
|
87
|
-
}), s && (
|
|
88
|
-
const n = !(typeof window > "u") && ((
|
|
89
|
-
return o !== !1 && n &&
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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": "
|
|
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,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@storyblok/richtext": "
|
|
33
|
-
"storyblok-js-client": "7.6.
|
|
32
|
+
"@storyblok/richtext": "5.0.0",
|
|
33
|
+
"storyblok-js-client": "7.6.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@tsconfig/recommended": "^1.0.8",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vite-plugin-dts": "^4.5.3",
|
|
50
50
|
"vite-plugin-qrcode": "^0.2.4",
|
|
51
51
|
"vitest": "^3.1.3",
|
|
52
|
-
"@storyblok/eslint-config": "0.5.
|
|
52
|
+
"@storyblok/eslint-config": "0.5.1"
|
|
53
53
|
},
|
|
54
54
|
"release": {
|
|
55
55
|
"branches": [
|