@chaibuilder/sdk 3.1.22 → 3.1.24
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/{code-editor-BclzCCn7.cjs → code-editor-Wr7ezSY6.cjs} +1 -1
- package/dist/{code-editor-D64ahHN_.js → code-editor-azfhn0NL.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +15 -0
- package/dist/core.js +1 -1
- package/dist/{index-CBT9rRYh.js → index-CCfSMyxt.js} +2162 -1813
- package/dist/index-CgmYAq2I.cjs +154 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +1 -0
- package/dist/render.js +91 -88
- package/dist/{rte-widget-modal-Cd_8db9R.js → rte-widget-modal-BqcjColT.js} +1 -1
- package/dist/{rte-widget-modal-C4SrkoTQ.cjs → rte-widget-modal-CD5g4cJG.cjs} +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +130 -130
- package/package.json +1 -1
- package/dist/index-BlHe-VXv.cjs +0 -154
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./plugin-CSgw-f78.cjs"),d=require("./apply-binding-DvHNFLQD.cjs"),y=require("react/jsx-runtime"),b=require("@chaibuilder/runtime"),L=require("lodash"),t=require("lodash-es"),g=require("react"),q=require("@tailwindcss/aspect-ratio"),j=require("@tailwindcss/forms"),D=require("@tailwindcss/typography");require("tailwindcss-animate");const K=require("./get-chai-builder-theme-B1tr_NJB.cjs"),M=require("@mhsdesign/jit-browser-tailwindcss"),O=require("@tailwindcss/container-queries");async function N(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const H=()=>y.jsx("div",{}),J=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k}=e,u=b.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),P=t.get(e.repeaterData,"index",-1),f=t.get(e.repeaterData,"dataKey",""),I=n===s?"":n,h=d.applyBindingToBlockProps(d.applyLanguage(a,I,u),o,{index:P,key:f}),m=d.getBlockTagAttributes(a,!1),T=R(l,a._id,d.getBlockRuntimeProps(a._type)),S=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...h,...m,...T},_={blockProps:{},inBuilder:!1,lang:n||s,...B},v=t.get(B,"_show",!0);if(t.isNull(p)||!v)return null;if(S){const x=t.get(u,"suspenseFallback",H);return y.jsx(g.Suspense,{fallback:g.createElement(x),children:y.jsx(N,{lang:n,pageProps:c,block:B,dataProvider:u.dataProvider,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:$=>g.createElement(p,{..._,...$,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return y.jsx(g.Suspense,{children:g.createElement(p,{..._,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})},E=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(J,{...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((P,f)=>g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)},R=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,o])=>{const l=[];let r=t.find(e,{_id:a});for(;r;)l.push(r),r=t.find(e,{_id:r._parent});const c=t.find(l,{_type:o.block});return c&&(s[i]=t.get(c,t.get(o,"prop"),null)),s},{});function V(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return y.jsx(E,{...e,lang:a,fallbackLang:n})}async function W(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const U=()=>y.jsx("div",{}),G=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k,dataProviders:u}=e,p=b.getRegisteredChaiBlock(a._type),P=t.get(p,"component",null),f=t.get(e.repeaterData,"index",-1),I=t.get(e.repeaterData,"dataKey",""),h=n===s?"":n,m=d.applyBindingToBlockProps(d.applyLanguage(a,h,p),o,{index:f,key:I}),T=d.getBlockTagAttributes(a,!1),S=R(l,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),_={...m,...T,...S},v={blockProps:{},inBuilder:!1,lang:n||s,..._},x=t.get(_,"_show",!0);if(t.isNull(P)||!x)return null;if(B){const $=t.get(u,a._id,Promise.resolve({})),A=t.get(p,"suspenseFallback",U);return y.jsx(g.Suspense,{fallback:g.createElement(A),children:y.jsx(W,{lang:n,pageProps:c,block:_,dataProvider:$,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:F=>g.createElement(P,{...v,...F,children:i({_id:a._id,_type:a._type,...t.isArray(m.repeaterItems)?{repeaterItems:d.applyLimit(m.repeaterItems,a),$repeaterItemsKey:m.$repeaterItemsKey,repeaterTotalItems:m.repeaterTotalItems??-1}:{}})})})})}return y.jsx(g.Suspense,{children:g.createElement(P,{...v,children:i({_id:a._id,_type:a._type,...t.isArray(m.repeaterItems)?{repeaterItems:d.applyLimit(m.repeaterItems,a),$repeaterItemsKey:m.$repeaterItemsKey,repeaterTotalItems:m.repeaterTotalItems??-1}:{}})})})},C=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(G,{dataProviders:e.dataProviders,...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((P,f)=>g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function z(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return y.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(o=>{const l=b.getRegisteredChaiBlock(o._type);return!!(L.has(l,"dataProvider")&&L.isFunction(l.dataProvider))}).reduce((o,l)=>{const r=b.getRegisteredChaiBlock(l._type),c={pageProps:e.pageProps,block:l,lang:e.lang,draft:e.draft,inBuilder:!1};return o[l._id]=r.dataProvider(c),o},{});return y.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:i})}function Q(e,a){const n=e.filter(({_type:s})=>s==="GlobalBlock"||s==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],o=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(o==="")continue;let l=t.cloneDeep(t.get(a,o,[]));i._parent&&(l==null?void 0:l.length)>0&&(l=l.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...l)}return e}const X=e=>{if(!e)return[];try{return JSON.parse(Y(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function Y(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Z(e,a=[],n=!1){return await M.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...K.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[j,D,q,O,w.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,e)}const ee=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/,/g," ")}`.replace(/#styles:/g,""));return Z([n],[],a)},te=async(e,a=!1)=>await ee(e,a);exports.getChaiThemeCssVariables=
|
|
3
|
+
@tailwind utilities;`,e)}const ee=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/,/g," ")}`.replace(/#styles:/g,""));return Z([n],[],a)},te=async(e,a=!1)=>await ee(e,a);exports.getChaiThemeCssVariables=w.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=w.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=w.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=d.applyChaiDataBinding;exports.convertHTMLToChaiBlocks=d.getBlocksFromHTML;exports.AsyncRenderChaiBlocks=z;exports.RenderChaiBlocks=V;exports.convertToBlocks=X;exports.getMergedPartialBlocks=Q;exports.getStylesForBlocks=te;
|
package/dist/render.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ declare type RenderChaiBlocksProps = {
|
|
|
89
89
|
pageProps?: ChaiPageProps;
|
|
90
90
|
draft?: boolean;
|
|
91
91
|
dataProviderMetadataCallback?: (block: ChaiBlock, meta: Record<string, any>) => void;
|
|
92
|
+
dataProviders?: Record<string, Promise<Record<string, any>>>;
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
declare type RenderChaiBlocksProps_2 = {
|
package/dist/render.js
CHANGED
|
@@ -2,11 +2,11 @@ import { c as Q } from "./plugin-BOcGV_IY.js";
|
|
|
2
2
|
import { a as Ae, b as Me, e as Oe } from "./plugin-BOcGV_IY.js";
|
|
3
3
|
import { a as O, b as N, g as E, c as J, d as I, e as j } from "./apply-binding-DCno1xQL.js";
|
|
4
4
|
import { f as Ee, h as Je } from "./apply-binding-DCno1xQL.js";
|
|
5
|
-
import { jsx as
|
|
5
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
6
6
|
import { getRegisteredChaiBlock as C } from "@chaibuilder/runtime";
|
|
7
7
|
import { has as X, isFunction as Y } from "lodash";
|
|
8
|
-
import { has as
|
|
9
|
-
import { Suspense as S, createElement as
|
|
8
|
+
import { has as b, isFunction as L, omit as q, get as d, isNull as H, isArray as v, uniqBy as W, filter as $, isEmpty as h, map as U, find as R, cloneDeep as Z } from "lodash-es";
|
|
9
|
+
import { Suspense as S, createElement as g } from "react";
|
|
10
10
|
import ee from "@tailwindcss/aspect-ratio";
|
|
11
11
|
import te from "@tailwindcss/forms";
|
|
12
12
|
import ae from "@tailwindcss/typography";
|
|
@@ -22,97 +22,97 @@ async function oe(e) {
|
|
|
22
22
|
draft: e.draft,
|
|
23
23
|
inBuilder: !1
|
|
24
24
|
}, r = await e.dataProvider(t);
|
|
25
|
-
return
|
|
25
|
+
return b(r, "$metadata") && L(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, r.$metadata), e.children({
|
|
26
26
|
...q(r, "$metadata")
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
const se = () => /* @__PURE__ */
|
|
30
|
-
const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e,
|
|
31
|
-
N(t, r === i ? "" : r,
|
|
29
|
+
const se = () => /* @__PURE__ */ f("div", {}), le = (e) => {
|
|
30
|
+
const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, c = C(t._type), u = d(c, "component", null), _ = d(e.repeaterData, "index", -1), y = d(e.repeaterData, "dataKey", ""), m = O(
|
|
31
|
+
N(t, r === i ? "" : r, c),
|
|
32
32
|
s,
|
|
33
33
|
{ index: _, key: y }
|
|
34
|
-
),
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
...
|
|
34
|
+
), p = E(t, !1), T = V(o, t._id, J(t._type)), D = b(c, "dataProvider") && L(c.dataProvider), B = {
|
|
35
|
+
...m,
|
|
36
|
+
...p,
|
|
37
|
+
...T
|
|
38
38
|
}, P = {
|
|
39
39
|
blockProps: {},
|
|
40
40
|
inBuilder: !1,
|
|
41
41
|
lang: r || i,
|
|
42
|
-
...
|
|
43
|
-
}, w =
|
|
44
|
-
if (H(
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
return /* @__PURE__ */
|
|
42
|
+
...B
|
|
43
|
+
}, w = d(B, "_show", !0);
|
|
44
|
+
if (H(u) || !w) return null;
|
|
45
|
+
if (D) {
|
|
46
|
+
const K = d(c, "suspenseFallback", se);
|
|
47
|
+
return /* @__PURE__ */ f(S, { fallback: g(K), children: /* @__PURE__ */ f(
|
|
48
48
|
oe,
|
|
49
49
|
{
|
|
50
50
|
lang: r,
|
|
51
51
|
pageProps: l,
|
|
52
|
-
block:
|
|
53
|
-
dataProvider:
|
|
52
|
+
block: B,
|
|
53
|
+
dataProvider: c.dataProvider,
|
|
54
54
|
...k ? { dataProviderMetadataCallback: k } : {},
|
|
55
55
|
draft: a,
|
|
56
|
-
children: (
|
|
56
|
+
children: (F) => g(u, {
|
|
57
57
|
...P,
|
|
58
|
-
...
|
|
58
|
+
...F,
|
|
59
59
|
children: n({
|
|
60
60
|
_id: t._id,
|
|
61
61
|
_type: t._type,
|
|
62
|
-
...
|
|
63
|
-
repeaterItems: I(
|
|
64
|
-
$repeaterItemsKey:
|
|
65
|
-
repeaterTotalItems:
|
|
62
|
+
...v(m.repeaterItems) ? {
|
|
63
|
+
repeaterItems: I(m.repeaterItems, t),
|
|
64
|
+
$repeaterItemsKey: m.$repeaterItemsKey,
|
|
65
|
+
repeaterTotalItems: m.repeaterTotalItems ?? -1
|
|
66
66
|
} : {}
|
|
67
67
|
})
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
70
|
) });
|
|
71
71
|
}
|
|
72
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ f(S, { children: g(u, {
|
|
73
73
|
...P,
|
|
74
74
|
children: n({
|
|
75
75
|
_id: t._id,
|
|
76
76
|
_type: t._type,
|
|
77
|
-
...
|
|
78
|
-
repeaterItems: I(
|
|
79
|
-
$repeaterItemsKey:
|
|
80
|
-
repeaterTotalItems:
|
|
77
|
+
...v(m.repeaterItems) ? {
|
|
78
|
+
repeaterItems: I(m.repeaterItems, t),
|
|
79
|
+
$repeaterItemsKey: m.$repeaterItemsKey,
|
|
80
|
+
repeaterTotalItems: m.repeaterTotalItems ?? -1
|
|
81
81
|
} : {}
|
|
82
82
|
})
|
|
83
83
|
}) });
|
|
84
|
-
},
|
|
84
|
+
}, A = (e) => {
|
|
85
85
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
86
86
|
let s = W(
|
|
87
|
-
$(t, (a) =>
|
|
87
|
+
$(t, (a) => b(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
88
88
|
"_id"
|
|
89
89
|
);
|
|
90
90
|
const o = (a) => $(t, (l) => l._parent === a).length > 0;
|
|
91
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */
|
|
92
|
-
|
|
91
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ g(le, { ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: c, $repeaterItemsKey: u }) => k === "Repeater" ? v(c) && c.map((_, y) => /* @__PURE__ */ g(
|
|
92
|
+
A,
|
|
93
93
|
{
|
|
94
94
|
...e,
|
|
95
95
|
parent: a._id,
|
|
96
|
-
key: `${
|
|
97
|
-
repeaterData: { index: y, dataKey:
|
|
96
|
+
key: `${d(a, "_parent", "root")}-${a._id}-${y}`,
|
|
97
|
+
repeaterData: { index: y, dataKey: u }
|
|
98
98
|
}
|
|
99
|
-
)) : o(l) ? /* @__PURE__ */
|
|
100
|
-
|
|
99
|
+
)) : o(l) ? /* @__PURE__ */ g(
|
|
100
|
+
A,
|
|
101
101
|
{
|
|
102
102
|
...e,
|
|
103
103
|
parent: a._id,
|
|
104
|
-
key: `${
|
|
104
|
+
key: `${d(a, "_parent", "root")}-${a._id}`,
|
|
105
105
|
repeaterData: i,
|
|
106
106
|
type: a._type
|
|
107
107
|
}
|
|
108
108
|
) : null) : null);
|
|
109
109
|
}, V = (e, t, r) => h(r) ? {} : Object.entries(r).reduce((i, [n, s]) => {
|
|
110
110
|
const o = [];
|
|
111
|
-
let a =
|
|
111
|
+
let a = R(e, { _id: t });
|
|
112
112
|
for (; a; )
|
|
113
|
-
o.push(a), a =
|
|
114
|
-
const l =
|
|
115
|
-
return l && (i[n] =
|
|
113
|
+
o.push(a), a = R(e, { _id: a._parent });
|
|
114
|
+
const l = R(o, { _type: s.block });
|
|
115
|
+
return l && (i[n] = d(l, d(s, "prop"), null)), i;
|
|
116
116
|
}, {});
|
|
117
117
|
function xe(e) {
|
|
118
118
|
if (h(e.lang) && !h(e.fallbackLang))
|
|
@@ -120,15 +120,15 @@ function xe(e) {
|
|
|
120
120
|
if (h(e.blocks))
|
|
121
121
|
return null;
|
|
122
122
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
123
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ f(A, { ...e, lang: t, fallbackLang: r });
|
|
124
124
|
}
|
|
125
|
-
async function
|
|
125
|
+
async function de(e) {
|
|
126
126
|
const t = await e.dataProvider;
|
|
127
|
-
return
|
|
127
|
+
return b(t, "$metadata") && L(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
128
128
|
...q(t, "$metadata")
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
131
|
+
const ce = () => /* @__PURE__ */ f("div", {}), ue = async (e) => {
|
|
132
132
|
const {
|
|
133
133
|
block: t,
|
|
134
134
|
lang: r,
|
|
@@ -139,82 +139,82 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
|
|
|
139
139
|
draft: a,
|
|
140
140
|
pageProps: l,
|
|
141
141
|
dataProviderMetadataCallback: k,
|
|
142
|
-
dataProviders:
|
|
143
|
-
} = e,
|
|
144
|
-
N(t, r === i ? "" : r,
|
|
142
|
+
dataProviders: c
|
|
143
|
+
} = e, u = C(t._type), _ = d(u, "component", null), y = d(e.repeaterData, "index", -1), M = d(e.repeaterData, "dataKey", ""), p = O(
|
|
144
|
+
N(t, r === i ? "" : r, u),
|
|
145
145
|
s,
|
|
146
146
|
{ index: y, key: M }
|
|
147
|
-
),
|
|
148
|
-
...
|
|
149
|
-
...
|
|
150
|
-
...
|
|
147
|
+
), T = E(t, !1), D = V(o, t._id, J(t._type)), B = b(u, "dataProvider") && L(u.dataProvider), P = {
|
|
148
|
+
...p,
|
|
149
|
+
...T,
|
|
150
|
+
...D
|
|
151
151
|
}, w = {
|
|
152
152
|
blockProps: {},
|
|
153
153
|
inBuilder: !1,
|
|
154
154
|
lang: r || i,
|
|
155
155
|
...P
|
|
156
|
-
},
|
|
157
|
-
if (H(_) || !
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
156
|
+
}, K = d(P, "_show", !0);
|
|
157
|
+
if (H(_) || !K) return null;
|
|
158
|
+
if (B) {
|
|
159
|
+
const F = d(c, t._id, Promise.resolve({})), G = d(u, "suspenseFallback", ce);
|
|
160
|
+
return /* @__PURE__ */ f(S, { fallback: g(G), children: /* @__PURE__ */ f(
|
|
161
|
+
de,
|
|
162
162
|
{
|
|
163
163
|
lang: r,
|
|
164
164
|
pageProps: l,
|
|
165
165
|
block: P,
|
|
166
|
-
dataProvider:
|
|
166
|
+
dataProvider: F,
|
|
167
167
|
...k ? { dataProviderMetadataCallback: k } : {},
|
|
168
168
|
draft: a,
|
|
169
|
-
children: (z) =>
|
|
169
|
+
children: (z) => g(_, {
|
|
170
170
|
...w,
|
|
171
171
|
...z,
|
|
172
172
|
children: n({
|
|
173
173
|
_id: t._id,
|
|
174
174
|
_type: t._type,
|
|
175
|
-
...
|
|
176
|
-
repeaterItems: I(
|
|
177
|
-
$repeaterItemsKey:
|
|
178
|
-
repeaterTotalItems:
|
|
175
|
+
...v(p.repeaterItems) ? {
|
|
176
|
+
repeaterItems: I(p.repeaterItems, t),
|
|
177
|
+
$repeaterItemsKey: p.$repeaterItemsKey,
|
|
178
|
+
repeaterTotalItems: p.repeaterTotalItems ?? -1
|
|
179
179
|
} : {}
|
|
180
180
|
})
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
) });
|
|
184
184
|
}
|
|
185
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ f(S, { children: g(_, {
|
|
186
186
|
...w,
|
|
187
187
|
children: n({
|
|
188
188
|
_id: t._id,
|
|
189
189
|
_type: t._type,
|
|
190
|
-
...
|
|
191
|
-
repeaterItems: I(
|
|
192
|
-
$repeaterItemsKey:
|
|
193
|
-
repeaterTotalItems:
|
|
190
|
+
...v(p.repeaterItems) ? {
|
|
191
|
+
repeaterItems: I(p.repeaterItems, t),
|
|
192
|
+
$repeaterItemsKey: p.$repeaterItemsKey,
|
|
193
|
+
repeaterTotalItems: p.repeaterTotalItems ?? -1
|
|
194
194
|
} : {}
|
|
195
195
|
})
|
|
196
196
|
}) });
|
|
197
|
-
},
|
|
197
|
+
}, x = async (e) => {
|
|
198
198
|
const { blocks: t, parent: r, repeaterData: i, type: n } = e;
|
|
199
199
|
let s = W(
|
|
200
|
-
$(t, (a) =>
|
|
200
|
+
$(t, (a) => b(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
|
|
201
201
|
"_id"
|
|
202
202
|
);
|
|
203
203
|
const o = (a) => $(t, (l) => l._parent === a).length > 0;
|
|
204
|
-
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */
|
|
205
|
-
|
|
204
|
+
return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ g(ue, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: c, $repeaterItemsKey: u }) => k === "Repeater" ? v(c) && c.map((_, y) => /* @__PURE__ */ g(
|
|
205
|
+
x,
|
|
206
206
|
{
|
|
207
207
|
...e,
|
|
208
208
|
parent: a._id,
|
|
209
|
-
key: `${
|
|
210
|
-
repeaterData: { index: y, dataKey:
|
|
209
|
+
key: `${d(a, "_parent", "root")}-${a._id}-${y}`,
|
|
210
|
+
repeaterData: { index: y, dataKey: u }
|
|
211
211
|
}
|
|
212
|
-
)) : o(l) ? /* @__PURE__ */
|
|
213
|
-
|
|
212
|
+
)) : o(l) ? /* @__PURE__ */ g(
|
|
213
|
+
x,
|
|
214
214
|
{
|
|
215
215
|
...e,
|
|
216
216
|
parent: a._id,
|
|
217
|
-
key: `${
|
|
217
|
+
key: `${d(a, "_parent", "root")}-${a._id}`,
|
|
218
218
|
repeaterData: i,
|
|
219
219
|
type: a._type
|
|
220
220
|
}
|
|
@@ -225,7 +225,10 @@ async function Le(e) {
|
|
|
225
225
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
226
226
|
if (h(e.blocks))
|
|
227
227
|
return null;
|
|
228
|
-
const t = e.lang ?? "en", r = e.fallbackLang ?? t
|
|
228
|
+
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
229
|
+
if (e.dataProviders)
|
|
230
|
+
return /* @__PURE__ */ f(x, { ...e, lang: t, fallbackLang: r, dataProviders: e.dataProviders });
|
|
231
|
+
const n = e.blocks.filter((s) => {
|
|
229
232
|
const o = C(s._type);
|
|
230
233
|
return !!(X(o, "dataProvider") && Y(o.dataProvider));
|
|
231
234
|
}).reduce(
|
|
@@ -241,14 +244,14 @@ async function Le(e) {
|
|
|
241
244
|
},
|
|
242
245
|
{}
|
|
243
246
|
);
|
|
244
|
-
return /* @__PURE__ */
|
|
247
|
+
return /* @__PURE__ */ f(x, { ...e, lang: t, fallbackLang: r, dataProviders: n });
|
|
245
248
|
}
|
|
246
249
|
function Te(e, t) {
|
|
247
250
|
const r = e.filter(({ _type: i }) => i === "GlobalBlock" || i === "PartialBlock");
|
|
248
251
|
for (let i = 0; i < r.length; i++) {
|
|
249
|
-
const n = r[i], s =
|
|
252
|
+
const n = r[i], s = d(n, "partialBlockId", d(n, "globalBlock", ""));
|
|
250
253
|
if (s === "") continue;
|
|
251
|
-
let o = Z(
|
|
254
|
+
let o = Z(d(t, s, []));
|
|
252
255
|
n._parent && (o == null ? void 0 : o.length) > 0 && (o = o.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
|
|
253
256
|
const a = e.indexOf(n);
|
|
254
257
|
e.splice(a, 1, ...o);
|
|
@@ -258,19 +261,19 @@ function Te(e, t) {
|
|
|
258
261
|
const De = (e) => {
|
|
259
262
|
if (!e) return [];
|
|
260
263
|
try {
|
|
261
|
-
return JSON.parse(
|
|
264
|
+
return JSON.parse(ge(e)).filter((r) => !r._type.startsWith("@chai"));
|
|
262
265
|
} catch {
|
|
263
266
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
264
267
|
}
|
|
265
268
|
};
|
|
266
|
-
function
|
|
269
|
+
function ge(e) {
|
|
267
270
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
268
271
|
return e.replace(t, (r) => {
|
|
269
272
|
const i = decodeURIComponent(r), n = i.indexOf("public");
|
|
270
273
|
return n !== -1 ? i.substring(n + 6) : i;
|
|
271
274
|
});
|
|
272
275
|
}
|
|
273
|
-
async function
|
|
276
|
+
async function pe(e, t = [], r = !1) {
|
|
274
277
|
return await ne({
|
|
275
278
|
tailwindConfig: {
|
|
276
279
|
darkMode: "class",
|
|
@@ -314,7 +317,7 @@ async function ge(e, t = [], r = !1) {
|
|
|
314
317
|
}
|
|
315
318
|
const fe = (e, t) => {
|
|
316
319
|
const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, n) => `#styles:${n.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
317
|
-
return
|
|
320
|
+
return pe([r], [], t);
|
|
318
321
|
}, Ke = async (e, t = !1) => await fe(e, t);
|
|
319
322
|
export {
|
|
320
323
|
Le as AsyncRenderChaiBlocks,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { d as N, N as D } from "./index-
|
|
2
|
+
import { d as N, N as D } from "./index-CCfSMyxt.js";
|
|
3
3
|
import { a1 as v, a3 as S, a6 as j, a9 as w, v as y } from "./tooltip-Bz2MxMHf.js";
|
|
4
4
|
import "clsx";
|
|
5
5
|
import "tailwind-merge";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-CgmYAq2I.cjs"),n=require("./tooltip-CzZ7Fvt7.cjs");require("clsx");require("tailwind-merge");const S=({isOpen:m,onClose:l,editor:t,rteElement:f})=>{const r=u.usePageExternalData(),j=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:p,to:g}=t.state.selection;if(p!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,s=c.selection.from,x=c.doc.textBetween(Math.max(0,s-1),s),a=c.doc.textBetween(s,Math.min(s+1,c.doc.content.size));let d="";s>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";a&&a!==" "&&!/[.,!?;:]/.test(a)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(n.Dialog,{open:m,onOpenChange:o=>!o&&l(),children:e.jsxs(n.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(n.DialogHeader,{children:e.jsxs(n.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),Object.keys(r).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(u.NestedPathSelector,{data:r,onSelect:j})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(n.Button,{onClick:l,children:"Done"})})]})})};exports.default=S;
|