@storyblok/react 5.4.8 → 5.4.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/core/richtext-hoc.js +1 -1
- package/dist/core/richtext-hoc.mjs +25 -20
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +50 -26
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),l=require("@storyblok/js");function u(c,{isServerContext:t=!1}={}){return function(e){var o,n;const r=(o=e==null?void 0:e.attrs)==null?void 0:o.body;if(!Array.isArray(r)||r.length===0)return[];const a=((n=e.attrs)==null?void 0:n.id)||(t?`fallback-key-${JSON.stringify(e.attrs)}`:void 0);return r.map((i,m)=>s.createElement(c,{blok:i,key:`${a}-${m}`}))}}function R(c,{isServerContext:t=!1}={}){return function(e){const r=u(c,{isServerContext:t}),{resolvers:a,...o}=e,n={...t?e:{},renderFn:s.createElement,textFn:i=>s.createElement(s.Fragment,{key:Math.random().toString(36).substring(2,15)},i),resolvers:{[l.BlockTypes.COMPONENT]:r,...a},keyedResolvers:!0,...t?{}:o};return l.richTextResolver(n)}}exports.createComponentResolver=u;exports.createRichTextHook=R;
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BlockTypes as
|
|
3
|
-
function
|
|
1
|
+
import s from "react";
|
|
2
|
+
import { BlockTypes as u, richTextResolver as f } from "@storyblok/js";
|
|
3
|
+
function y(c, {
|
|
4
4
|
isServerContext: t = !1
|
|
5
5
|
} = {}) {
|
|
6
6
|
return function(e) {
|
|
7
|
-
var
|
|
8
|
-
const r = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var o, n;
|
|
8
|
+
const r = (o = e == null ? void 0 : e.attrs) == null ? void 0 : o.body;
|
|
9
|
+
if (!Array.isArray(r) || r.length === 0)
|
|
10
|
+
return [];
|
|
11
|
+
const a = ((n = e.attrs) == null ? void 0 : n.id) || (t ? `fallback-key-${JSON.stringify(e.attrs)}` : void 0);
|
|
12
|
+
return r.map(
|
|
13
|
+
(i, m) => s.createElement(c, {
|
|
14
|
+
blok: i,
|
|
15
|
+
key: `${a}-${m}`
|
|
16
|
+
})
|
|
17
|
+
);
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
|
-
function
|
|
20
|
+
function k(c, {
|
|
16
21
|
isServerContext: t = !1
|
|
17
22
|
} = {}) {
|
|
18
23
|
return function(e) {
|
|
19
|
-
const r =
|
|
24
|
+
const r = y(c, { isServerContext: t }), { resolvers: a, ...o } = e, n = {
|
|
20
25
|
...t ? e : {},
|
|
21
|
-
renderFn:
|
|
22
|
-
textFn: (
|
|
26
|
+
renderFn: s.createElement,
|
|
27
|
+
textFn: (i) => s.createElement(s.Fragment, {
|
|
23
28
|
key: Math.random().toString(36).substring(2, 15)
|
|
24
|
-
},
|
|
29
|
+
}, i),
|
|
25
30
|
resolvers: {
|
|
26
|
-
[
|
|
27
|
-
...
|
|
31
|
+
[u.COMPONENT]: r,
|
|
32
|
+
...a
|
|
28
33
|
},
|
|
29
34
|
keyedResolvers: !0,
|
|
30
|
-
...t ? {} :
|
|
35
|
+
...t ? {} : o
|
|
31
36
|
};
|
|
32
|
-
return
|
|
37
|
+
return f(n);
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
y as createComponentResolver,
|
|
42
|
+
k as createRichTextHook
|
|
38
43
|
};
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");function f(e){return e.replace(/-([a-z])/g,o=>o[1].toUpperCase())}function m(e){return e.split(";").reduce((o,i)=>{let[t,n]=i.split(":");return t=t==null?void 0:t.trim(),n=n==null?void 0:n.trim(),t&&n&&(o[f(t)]=n),o},{})}function c(e){if(Array.isArray(e))return e.map(r=>c(r));const o={allowfullscreen:"allowFullScreen",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",charset:"charSet",class:"className",colspan:"colSpan",colwidth:"colWidth",contenteditable:"contentEditable",crossorigin:"crossOrigin",enctype:"encType",for:"htmlFor",formnovalidate:"formNoValidate",frameborder:"frameBorder",inputmode:"inputMode",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",minlength:"minLength",novalidate:"noValidate",playsinline:"playsInline",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",srcset:"srcSet",tabindex:"tabIndex",targetAttr:"targetattr",usemap:"useMap"},i=Object.keys(e.props).reduce((r,a)=>{let s=e.props[a];a==="style"&&typeof s=="string"&&(s=m(s));const u=o[a]||a;return r[u]=s,r},{});i.key=e.key;const t=d.Children.map(e.props.children,r=>typeof r=="string"?r:c(r));return d.createElement(e.type,i,t)}const l=()=>typeof window<"u",g=()=>typeof window>"u",w=()=>l()&&typeof window.storyblokRegisterEvent<"u",p=()=>l()&&window.self!==window.top,y=()=>l()&&p()&&window.location.search.includes("_storyblok");exports.convertAttributesInElement=c;exports.isBridgeLoaded=w;exports.isBrowser=l;exports.isIframe=p;exports.isServer=g;exports.isVisualEditor=y;
|
package/dist/utils.mjs
CHANGED
|
@@ -1,37 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import c from "react";
|
|
2
|
+
function u(e) {
|
|
3
|
+
return e.replace(/-([a-z])/g, (o) => o[1].toUpperCase());
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return
|
|
7
|
-
let [
|
|
8
|
-
return
|
|
5
|
+
function f(e) {
|
|
6
|
+
return e.split(";").reduce((o, i) => {
|
|
7
|
+
let [t, n] = i.split(":");
|
|
8
|
+
return t = t == null ? void 0 : t.trim(), n = n == null ? void 0 : n.trim(), t && n && (o[u(t)] = n), o;
|
|
9
9
|
}, {});
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
if (Array.isArray(
|
|
13
|
-
return
|
|
11
|
+
function p(e) {
|
|
12
|
+
if (Array.isArray(e))
|
|
13
|
+
return e.map((r) => p(r));
|
|
14
14
|
const o = {
|
|
15
|
+
allowfullscreen: "allowFullScreen",
|
|
16
|
+
autocomplete: "autoComplete",
|
|
17
|
+
autofocus: "autoFocus",
|
|
18
|
+
autoplay: "autoPlay",
|
|
19
|
+
charset: "charSet",
|
|
15
20
|
class: "className",
|
|
21
|
+
colspan: "colSpan",
|
|
22
|
+
colwidth: "colWidth",
|
|
23
|
+
contenteditable: "contentEditable",
|
|
24
|
+
crossorigin: "crossOrigin",
|
|
25
|
+
enctype: "encType",
|
|
16
26
|
for: "htmlFor",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
formnovalidate: "formNoValidate",
|
|
28
|
+
frameborder: "frameBorder",
|
|
29
|
+
inputmode: "inputMode",
|
|
30
|
+
marginheight: "marginHeight",
|
|
31
|
+
marginwidth: "marginWidth",
|
|
32
|
+
maxlength: "maxLength",
|
|
33
|
+
minlength: "minLength",
|
|
34
|
+
novalidate: "noValidate",
|
|
35
|
+
playsinline: "playsInline",
|
|
36
|
+
readonly: "readOnly",
|
|
37
|
+
referrerpolicy: "referrerPolicy",
|
|
38
|
+
rowspan: "rowSpan",
|
|
39
|
+
srcset: "srcSet",
|
|
40
|
+
tabindex: "tabIndex",
|
|
41
|
+
targetAttr: "targetattr",
|
|
42
|
+
usemap: "useMap"
|
|
43
|
+
}, i = Object.keys(e.props).reduce((r, a) => {
|
|
44
|
+
let s = e.props[a];
|
|
45
|
+
a === "style" && typeof s == "string" && (s = f(s));
|
|
46
|
+
const d = o[a] || a;
|
|
47
|
+
return r[d] = s, r;
|
|
24
48
|
}, {});
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
return
|
|
49
|
+
i.key = e.key;
|
|
50
|
+
const t = c.Children.map(e.props.children, (r) => typeof r == "string" ? r : p(r));
|
|
51
|
+
return c.createElement(e.type, i, t);
|
|
28
52
|
}
|
|
29
|
-
const
|
|
53
|
+
const l = () => typeof window < "u", y = () => typeof window > "u", g = () => l() && typeof window.storyblokRegisterEvent < "u", m = () => l() && window.self !== window.top, h = () => l() && m() && window.location.search.includes("_storyblok");
|
|
30
54
|
export {
|
|
31
|
-
|
|
55
|
+
p as convertAttributesInElement,
|
|
32
56
|
g as isBridgeLoaded,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
l as isBrowser,
|
|
58
|
+
m as isIframe,
|
|
59
|
+
y as isServer,
|
|
60
|
+
h as isVisualEditor
|
|
37
61
|
};
|