@chaibuilder/sdk 3.1.21 → 3.1.23

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.
@@ -35,7 +35,7 @@ import StarterKit from "@tiptap/starter-kit";
35
35
  import RjForm from "@rjsf/core";
36
36
  import validator from "@rjsf/validator-ajv8";
37
37
  import Autosuggest from "react-autosuggest";
38
- import { pick as pick$1, isFunction as isFunction$1, filter as filter$1, find as find$1 } from "lodash";
38
+ import { pick as pick$1, isFunction as isFunction$1, filter as filter$1, some, find as find$1 } from "lodash";
39
39
  import { Tree } from "react-arborist";
40
40
  import { parse, stringify } from "himalaya";
41
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
@@ -3334,14 +3334,14 @@ function detectDropZone(o, n, r, a, l) {
3334
3334
  if (L) {
3335
3335
  const O = L.getBoundingClientRect();
3336
3336
  if (u === "vertical") {
3337
- const $ = A.width - j - _, H = A.left + P + j;
3337
+ const H = A.width - j - _, $ = A.left + P + j;
3338
3338
  return {
3339
3339
  position: "before",
3340
3340
  placeholderOrientation: R,
3341
3341
  rect: {
3342
3342
  top: O.top + D - 2,
3343
- left: H,
3344
- width: $,
3343
+ left: $,
3344
+ width: H,
3345
3345
  height: 4
3346
3346
  },
3347
3347
  targetElement: L,
@@ -3350,15 +3350,15 @@ function detectDropZone(o, n, r, a, l) {
3350
3350
  confidence: 0.9
3351
3351
  };
3352
3352
  } else {
3353
- const $ = A.top + D + N, H = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3353
+ const H = A.top + D + N, $ = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3354
3354
  return {
3355
3355
  position: "before",
3356
3356
  placeholderOrientation: R,
3357
3357
  rect: {
3358
- top: $,
3358
+ top: H,
3359
3359
  left: O.left + P - 2,
3360
3360
  width: 4,
3361
- height: H
3361
+ height: $
3362
3362
  },
3363
3363
  targetElement: L,
3364
3364
  targetBlockId: L.getAttribute("data-block-id"),
@@ -3370,16 +3370,16 @@ function detectDropZone(o, n, r, a, l) {
3370
3370
  } else {
3371
3371
  const L = getChildBlocks(d), O = L[L.length - 1];
3372
3372
  if (O) {
3373
- const $ = O.getBoundingClientRect();
3373
+ const H = O.getBoundingClientRect();
3374
3374
  if (u === "vertical") {
3375
- const H = A.width - j - _, F = A.left + P + j;
3375
+ const $ = A.width - j - _, F = A.left + P + j;
3376
3376
  return {
3377
3377
  position: "after",
3378
3378
  placeholderOrientation: R,
3379
3379
  rect: {
3380
- top: $.bottom + D - 2,
3380
+ top: H.bottom + D - 2,
3381
3381
  left: F,
3382
- width: H,
3382
+ width: $,
3383
3383
  height: 4
3384
3384
  },
3385
3385
  targetElement: O,
@@ -3388,13 +3388,13 @@ function detectDropZone(o, n, r, a, l) {
3388
3388
  confidence: 0.9
3389
3389
  };
3390
3390
  } else {
3391
- const H = A.top + D + N, F = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3391
+ const $ = A.top + D + N, F = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3392
3392
  return {
3393
3393
  position: "after",
3394
3394
  placeholderOrientation: R,
3395
3395
  rect: {
3396
- top: H,
3397
- left: $.right + P - 2,
3396
+ top: $,
3397
+ left: H.right + P - 2,
3398
3398
  width: 4,
3399
3399
  height: F
3400
3400
  },
@@ -3717,11 +3717,11 @@ function removeDropTargetAttributes$1(o) {
3717
3717
  function createCoreDragImage(o) {
3718
3718
  var i;
3719
3719
  const n = document.createElement("div");
3720
- n.className = "absolute -top-[1000px] -left-[1000px] px-2 py-1 bg-white/60 border border-blue-400/30 rounded shadow-md flex items-center gap-1.5 font-sans pointer-events-none z-[9999] scale-90";
3720
+ n.className = "absolute -top-[1000px] -left-[1000px] pl-3 pr-1 py-1 bg-white/60 border border-blue-400/30 rounded shadow-md flex items-center gap-1.5 font-sans pointer-events-none z-[9999] scale-90";
3721
3721
  const r = o.type || o._type || "Box", a = document.createElement("div");
3722
3722
  a.className = "w-3 h-3 flex items-center justify-center text-blue-600";
3723
3723
  try {
3724
- a.innerHTML = ((i = document.querySelector(`[data-add-core-block-icon="${r}"]`)) == null ? void 0 : i.outerHTML) || '<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4z"/></svg>';
3724
+ r === "Image" ? a.innerHTML = '<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 0.72 0.72"><path d="M.57.12H.15a.09.09 0 0 0-.09.09v.3A.09.09 0 0 0 .15.6h.42A.09.09 0 0 0 .66.51v-.3A.09.09 0 0 0 .57.12M.15.54A.03.03 0 0 1 .12.51V.437L.219.338a.03.03 0 0 1 .042 0L.462.54ZM.6.51a.03.03 0 0 1-.03.03H.547L.433.425.459.399a.03.03 0 0 1 .042 0L.6.498Zm0-.097L.544.357a.09.09 0 0 0-.127 0L.391.383.305.297a.09.09 0 0 0-.127 0L.12.353V.21A.03.03 0 0 1 .15.18h.42A.03.03 0 0 1 .6.21Z"/></svg>' : a.innerHTML = ((i = document.querySelector(`[data-add-core-block-icon="${r}"]`)) == null ? void 0 : i.outerHTML) || '<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4z"/></svg>';
3725
3725
  } catch {
3726
3726
  a.textContent = "";
3727
3727
  }
@@ -3967,7 +3967,10 @@ function getTargetedBlock(o) {
3967
3967
  const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], isRichTextParent = (o) => {
3968
3968
  var n;
3969
3969
  return (o == null ? void 0 : o.getAttribute("data-block-type")) === "RichText" || ((n = o == null ? void 0 : o.parentElement) == null ? void 0 : n.getAttribute("data-block-type")) === "RichText";
3970
- }, isInlineEditable = (o, n) => {
3970
+ }, hasDataBlockIdInChildren = (o) => o ? some(o.children, (n) => {
3971
+ const r = n;
3972
+ return r.hasAttribute("data-block-id") || hasDataBlockIdInChildren(r);
3973
+ }) : !1, isInlineEditable = (o, n) => {
3971
3974
  if (isRichTextParent(o))
3972
3975
  return !0;
3973
3976
  const r = o == null ? void 0 : o.getAttribute("data-block-type");
@@ -3979,7 +3982,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3979
3982
  var d;
3980
3983
  if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
3981
3984
  const l = getTargetedBlock(a.target);
3982
- if (!isInlineEditable(l)) return;
3985
+ if (!isInlineEditable(l) || hasDataBlockIdInChildren(l)) return;
3983
3986
  const i = l.getAttribute("data-block-id");
3984
3987
  if (!i || !l) return;
3985
3988
  const c = l.closest('[data-block-type="Repeater"]');
@@ -5513,7 +5516,7 @@ const RichTextEditor = memo(
5513
5516
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
5514
5517
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
5515
5518
  ] }) });
5516
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DRLBAEJb.js")), CanvasArea = () => {
5519
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-D64ahHN_.js")), CanvasArea = () => {
5517
5520
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
5518
5521
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
5519
5522
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -6083,7 +6086,7 @@ const DataBindingSelector = ({
6083
6086
  ]
6084
6087
  }
6085
6088
  ) });
6086
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-MiC8MgXv.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
6089
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-Cd_8db9R.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
6087
6090
  const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
6088
6091
  blockId: o,
6089
6092
  value: a,
@@ -7760,9 +7763,9 @@ function ManualClasses() {
7760
7763
  let R = [];
7761
7764
  if (P && P.length > 0) {
7762
7765
  const [M] = P, L = D.replace(M, "");
7763
- R = i.search(L).map(($) => ({
7764
- ...$,
7765
- item: { ...$.item, name: M + $.item.name }
7766
+ R = i.search(L).map((H) => ({
7767
+ ...H,
7768
+ item: { ...H.item, name: M + H.item.name }
7766
7769
  }));
7767
7770
  } else
7768
7771
  R = i.search(D);
@@ -8209,52 +8212,67 @@ const registerChaiLibrary = (o, n) => {
8209
8212
  onDragStart: l,
8210
8213
  onDragEnd: i,
8211
8214
  draggable: c,
8212
- className: d = ""
8215
+ className: d = "",
8216
+ type: p = "Box"
8213
8217
  }) => {
8214
- const { onDragStart: p, onDragEnd: u } = useDragAndDrop(), g = useIsDragAndDropEnabled(), [, m] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), h = c !== void 0 ? c : g;
8218
+ const { onDragStart: u, onDragEnd: g } = useDragAndDrop(), m = useIsDragAndDropEnabled(), [, f] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), x = c !== void 0 ? c : m;
8215
8219
  return /* @__PURE__ */ jsx(
8216
8220
  "div",
8217
8221
  {
8218
- draggable: h,
8219
- onDragStart: async (y) => {
8222
+ draggable: x,
8223
+ onDragStart: async (S) => {
8220
8224
  try {
8221
8225
  if (l) {
8222
- l(y);
8226
+ l(S);
8223
8227
  return;
8224
8228
  }
8225
- let S = null;
8226
- if (n) {
8227
- const k = typeof n == "function" ? await n() : n, v = getBlocksFromHTML(k);
8228
- if (isEmpty(v)) return;
8229
- S = {
8229
+ let k = null;
8230
+ if (p === "Image") {
8231
+ if (!(o != null && o.image)) return;
8232
+ k = {
8233
+ type: "Image",
8234
+ blocks: [
8235
+ {
8236
+ _type: "Image",
8237
+ styles: "#styles:,w-full",
8238
+ image: o == null ? void 0 : o.image,
8239
+ alt: (o == null ? void 0 : o.alt) || "",
8240
+ _name: (o == null ? void 0 : o.name) || "Image"
8241
+ }
8242
+ ]
8243
+ };
8244
+ } else if (n) {
8245
+ const v = typeof n == "function" ? await n() : n, B = getBlocksFromHTML(v);
8246
+ if (isEmpty(B)) return;
8247
+ k = {
8230
8248
  type: "Box",
8231
- blocks: v,
8232
- name: get(v, "0._type", "Block")
8249
+ blocks: B,
8250
+ name: get(B, "0._type", "Block")
8233
8251
  };
8234
8252
  } else if (r) {
8235
- const k = typeof r == "function" ? await r() : r;
8236
- if (isEmpty(k)) return;
8237
- S = {
8253
+ const v = typeof r == "function" ? await r() : r;
8254
+ if (isEmpty(v)) return;
8255
+ k = {
8238
8256
  type: "Box",
8239
- blocks: k,
8240
- name: get(k, "0._type", "Block")
8257
+ blocks: v,
8258
+ name: get(v, "0._type", "Block")
8241
8259
  };
8242
8260
  } else if (o) {
8243
- const k = typeof o == "function" ? await o() : o;
8244
- S = typeof k == "object" ? omit(k, ["component", "icon"]) : k;
8261
+ const v = typeof o == "function" ? await o() : o;
8262
+ k = typeof v == "object" ? omit(v, ["component", "icon"]) : v;
8245
8263
  }
8246
- if (!S) return;
8247
- p(y, S, !0), setTimeout(() => {
8248
- m([]), f();
8264
+ if (!k) return;
8265
+ u(S, k, !0), setTimeout(() => {
8266
+ f([]), h();
8249
8267
  }, 200);
8250
- } catch (S) {
8251
- console.error("Error in ChaiDraggableBlock drag start:", S);
8268
+ } catch (k) {
8269
+ console.error("Error in ChaiDraggableBlock drag start:", k);
8252
8270
  }
8253
8271
  },
8254
- onDragEnd: (y) => {
8255
- i ? i(y) : u();
8272
+ onDragEnd: (S) => {
8273
+ i ? i(S) : g();
8256
8274
  },
8257
- className: `${h ? "cursor-grab active:cursor-grabbing" : ""} ${d}`.trim(),
8275
+ className: `${x ? "cursor-grab active:cursor-grabbing" : ""} ${d}`.trim(),
8258
8276
  children: a
8259
8277
  }
8260
8278
  );
@@ -9119,10 +9137,10 @@ const Input = ({ node: o }) => {
9119
9137
  return () => clearTimeout(L);
9120
9138
  }, [b, o, y]);
9121
9139
  const N = (L, O) => {
9122
- const $ = i.contentDocument || i.contentWindow.document, H = $.querySelector(`[data-block-id=${L}]`);
9123
- H && H.setAttribute("data-drop", O);
9124
- const F = H.getBoundingClientRect(), U = i.getBoundingClientRect();
9125
- F.top >= U.top && F.left >= U.left && F.bottom <= U.bottom && F.right <= U.right || ($.documentElement.scrollTop = H.offsetTop - U.top);
9140
+ const H = i.contentDocument || i.contentWindow.document, $ = H.querySelector(`[data-block-id=${L}]`);
9141
+ $ && $.setAttribute("data-drop", O);
9142
+ const F = $.getBoundingClientRect(), U = i.getBoundingClientRect();
9143
+ F.top >= U.top && F.left >= U.left && F.bottom <= U.bottom && F.right <= U.right || (H.documentElement.scrollTop = $.offsetTop - U.top);
9126
9144
  }, T = (L) => {
9127
9145
  j();
9128
9146
  const O = get(o, "parent.id");
@@ -10582,8 +10600,8 @@ const UndoRedo = () => {
10582
10600
  if (j) {
10583
10601
  const _ = j.selectionStart || 0, N = j.value || "", T = j.selectionEnd || _;
10584
10602
  if (T > _) {
10585
- const L = `{{${C}}}`, { text: O } = w(N, _, L), $ = N.slice(0, _) + O + N.slice(T);
10586
- p($);
10603
+ const L = `{{${C}}}`, { text: O } = w(N, _, L), H = N.slice(0, _) + O + N.slice(T);
10604
+ p(H);
10587
10605
  return;
10588
10606
  }
10589
10607
  const P = `{{${C}}}`, { text: R } = w(N, _, P), M = N.slice(0, _) + R + N.slice(_);
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./plugin-CSgw-f78.cjs"),d=require("./apply-binding-DvHNFLQD.cjs"),y=require("react/jsx-runtime"),v=require("@chaibuilder/runtime"),L=require("lodash"),t=require("lodash-es"),g=require("react"),q=require("@tailwindcss/aspect-ratio"),D=require("@tailwindcss/forms"),j=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=v.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),f=t.get(e.repeaterData,"dataKey",""),w=n===s?"":n,h=d.applyBindingToBlockProps(d.applyLanguage(a,w,u),o,{index:_,key:f}),m=d.getBlockTagAttributes(a,!1),I=R(l,a._id,d.getBlockRuntimeProps(a._type)),T=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...h,...m,...I},P={blockProps:{},inBuilder:!1,lang:n||s,...B},b=t.get(B,"_show",!0);if(t.isNull(p)||!b)return null;if(T){const S=t.get(u,"suspenseFallback",H);return y.jsx(g.Suspense,{fallback:g.createElement(S),children:y.jsx(N,{lang:n,pageProps:c,block:B,dataProvider:u.dataProvider,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:$=>g.createElement(p,{...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,{...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}:{}})})})},x=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((_,f)=>g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(x,{...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(x,{...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=v.getRegisteredChaiBlock(a._type),_=t.get(p,"component",null),f=t.get(e.repeaterData,"index",-1),w=t.get(e.repeaterData,"dataKey",""),h=n===s?"":n,m=d.applyBindingToBlockProps(d.applyLanguage(a,h,p),o,{index:f,key:w}),I=d.getBlockTagAttributes(a,!1),T=R(l,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),P={...m,...I,...T},b={blockProps:{},inBuilder:!1,lang:n||s,...P},S=t.get(P,"_show",!0);if(t.isNull(_)||!S)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:P,dataProvider:$,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:F=>g.createElement(_,{...b,...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(_,{...b,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}:{}})})})},E=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((_,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)};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,i=e.blocks.filter(o=>{const l=v.getRegisteredChaiBlock(o._type);return!!(L.has(l,"dataProvider")&&L.isFunction(l.dataProvider))}).reduce((o,l)=>{const r=v.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(E,{...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:[D,j,q,O,C.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./plugin-CSgw-f78.cjs"),d=require("./apply-binding-DvHNFLQD.cjs"),y=require("react/jsx-runtime"),v=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=v.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),f=t.get(e.repeaterData,"dataKey",""),w=n===s?"":n,h=d.applyBindingToBlockProps(d.applyLanguage(a,w,u),o,{index:_,key:f}),m=d.getBlockTagAttributes(a,!1),I=R(l,a._id,d.getBlockRuntimeProps(a._type)),T=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...h,...m,...I},P={blockProps:{},inBuilder:!1,lang:n||s,...B},b=t.get(B,"_show",!0);if(t.isNull(p)||!b)return null;if(T){const S=t.get(u,"suspenseFallback",H);return y.jsx(g.Suspense,{fallback:g.createElement(S),children:y.jsx(N,{lang:n,pageProps:c,block:B,dataProvider:u.dataProvider,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:$=>g.createElement(p,{...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,{...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}:{}})})})},x=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((_,f)=>g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(x,{...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(x,{...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=v.getRegisteredChaiBlock(a._type),_=t.get(p,"component",null),f=t.get(e.repeaterData,"index",-1),w=t.get(e.repeaterData,"dataKey",""),h=n===s?"":n,m=d.applyBindingToBlockProps(d.applyLanguage(a,h,p),o,{index:f,key:w}),I=d.getBlockTagAttributes(a,!1),T=R(l,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),P={...m,...I,...T},b={blockProps:{},inBuilder:!1,lang:n||s,...P},S=t.get(P,"_show",!0);if(t.isNull(_)||!S)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:P,dataProvider:$,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:F=>g.createElement(_,{...b,...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(_,{...b,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}:{}})})})},E=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((_,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)};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,i=e.blocks.filter(o=>{const l=v.getRegisteredChaiBlock(o._type);return!!(L.has(l,"dataProvider")&&L.isFunction(l.dataProvider))}).reduce((o,l)=>{const r=v.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 await Promise.allSettled(Object.values(i)),y.jsx(E,{...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,C.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
2
2
  @tailwind components;
3
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=C.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=C.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=C.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.js CHANGED
@@ -1,12 +1,12 @@
1
1
  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
- 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
- import { f as Ee, h as Je } from "./apply-binding-DCno1xQL.js";
3
+ import { a as O, b as N, g as j, c as E, d as I, e as J } from "./apply-binding-DCno1xQL.js";
4
+ import { f as je, h as Ee } from "./apply-binding-DCno1xQL.js";
5
5
  import { jsx as m } 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
8
  import { has as B, isFunction as x, omit as q, get as c, isNull as H, isArray as b, uniqBy as W, filter as $, isEmpty as h, map as U, find as F, cloneDeep as Z } from "lodash-es";
9
- import { Suspense as S, createElement as u } from "react";
9
+ import { Suspense as S, createElement as p } from "react";
10
10
  import ee from "@tailwindcss/aspect-ratio";
11
11
  import te from "@tailwindcss/forms";
12
12
  import ae from "@tailwindcss/typography";
@@ -27,11 +27,11 @@ async function oe(e) {
27
27
  });
28
28
  }
29
29
  const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
30
- const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, d = C(t._type), p = c(d, "component", null), _ = c(e.repeaterData, "index", -1), y = c(e.repeaterData, "dataKey", ""), f = O(
30
+ const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, d = C(t._type), u = c(d, "component", null), _ = c(e.repeaterData, "index", -1), y = c(e.repeaterData, "dataKey", ""), f = O(
31
31
  N(t, r === i ? "" : r, d),
32
32
  s,
33
33
  { index: _, key: y }
34
- ), g = E(t, !1), L = V(o, t._id, J(t._type)), T = B(d, "dataProvider") && x(d.dataProvider), v = {
34
+ ), g = j(t, !1), L = V(o, t._id, E(t._type)), T = B(d, "dataProvider") && x(d.dataProvider), v = {
35
35
  ...f,
36
36
  ...g,
37
37
  ...L
@@ -41,10 +41,10 @@ const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
41
41
  lang: r || i,
42
42
  ...v
43
43
  }, w = c(v, "_show", !0);
44
- if (H(p) || !w) return null;
44
+ if (H(u) || !w) return null;
45
45
  if (T) {
46
46
  const D = c(d, "suspenseFallback", se);
47
- return /* @__PURE__ */ m(S, { fallback: u(D), children: /* @__PURE__ */ m(
47
+ return /* @__PURE__ */ m(S, { fallback: p(D), children: /* @__PURE__ */ m(
48
48
  oe,
49
49
  {
50
50
  lang: r,
@@ -53,7 +53,7 @@ const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
53
53
  dataProvider: d.dataProvider,
54
54
  ...k ? { dataProviderMetadataCallback: k } : {},
55
55
  draft: a,
56
- children: (K) => u(p, {
56
+ children: (K) => p(u, {
57
57
  ...P,
58
58
  ...K,
59
59
  children: n({
@@ -69,7 +69,7 @@ const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
69
69
  }
70
70
  ) });
71
71
  }
72
- return /* @__PURE__ */ m(S, { children: u(p, {
72
+ return /* @__PURE__ */ m(S, { children: p(u, {
73
73
  ...P,
74
74
  children: n({
75
75
  _id: t._id,
@@ -88,15 +88,15 @@ const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
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__ */ u(le, { ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: p }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ u(
91
+ return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = J(s)), U(s, (a) => a ? /* @__PURE__ */ p(le, { ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: u }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ p(
92
92
  R,
93
93
  {
94
94
  ...e,
95
95
  parent: a._id,
96
96
  key: `${c(a, "_parent", "root")}-${a._id}-${y}`,
97
- repeaterData: { index: y, dataKey: p }
97
+ repeaterData: { index: y, dataKey: u }
98
98
  }
99
- )) : o(l) ? /* @__PURE__ */ u(
99
+ )) : o(l) ? /* @__PURE__ */ p(
100
100
  R,
101
101
  {
102
102
  ...e,
@@ -128,7 +128,7 @@ async function ce(e) {
128
128
  ...q(t, "$metadata")
129
129
  });
130
130
  }
131
- const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
131
+ const de = () => /* @__PURE__ */ m("div", {}), ue = async (e) => {
132
132
  const {
133
133
  block: t,
134
134
  lang: r,
@@ -140,11 +140,11 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
140
140
  pageProps: l,
141
141
  dataProviderMetadataCallback: k,
142
142
  dataProviders: d
143
- } = e, p = C(t._type), _ = c(p, "component", null), y = c(e.repeaterData, "index", -1), M = c(e.repeaterData, "dataKey", ""), g = O(
144
- N(t, r === i ? "" : r, p),
143
+ } = e, u = C(t._type), _ = c(u, "component", null), y = c(e.repeaterData, "index", -1), M = c(e.repeaterData, "dataKey", ""), g = O(
144
+ N(t, r === i ? "" : r, u),
145
145
  s,
146
146
  { index: y, key: M }
147
- ), L = E(t, !1), T = V(o, t._id, J(t._type)), v = B(p, "dataProvider") && x(p.dataProvider), P = {
147
+ ), L = j(t, !1), T = V(o, t._id, E(t._type)), v = B(u, "dataProvider") && x(u.dataProvider), P = {
148
148
  ...g,
149
149
  ...L,
150
150
  ...T
@@ -156,8 +156,8 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
156
156
  }, D = c(P, "_show", !0);
157
157
  if (H(_) || !D) return null;
158
158
  if (v) {
159
- const K = c(d, t._id, Promise.resolve({})), G = c(p, "suspenseFallback", de);
160
- return /* @__PURE__ */ m(S, { fallback: u(G), children: /* @__PURE__ */ m(
159
+ const K = c(d, t._id, Promise.resolve({})), G = c(u, "suspenseFallback", de);
160
+ return /* @__PURE__ */ m(S, { fallback: p(G), children: /* @__PURE__ */ m(
161
161
  ce,
162
162
  {
163
163
  lang: r,
@@ -166,7 +166,7 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
166
166
  dataProvider: K,
167
167
  ...k ? { dataProviderMetadataCallback: k } : {},
168
168
  draft: a,
169
- children: (z) => u(_, {
169
+ children: (z) => p(_, {
170
170
  ...w,
171
171
  ...z,
172
172
  children: n({
@@ -182,7 +182,7 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
182
182
  }
183
183
  ) });
184
184
  }
185
- return /* @__PURE__ */ m(S, { children: u(_, {
185
+ return /* @__PURE__ */ m(S, { children: p(_, {
186
186
  ...w,
187
187
  children: n({
188
188
  _id: t._id,
@@ -201,15 +201,15 @@ const de = () => /* @__PURE__ */ m("div", {}), pe = async (e) => {
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__ */ u(pe, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: p }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ u(
204
+ return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = J(s)), U(s, (a) => a ? /* @__PURE__ */ p(ue, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: u }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ p(
205
205
  A,
206
206
  {
207
207
  ...e,
208
208
  parent: a._id,
209
209
  key: `${c(a, "_parent", "root")}-${a._id}-${y}`,
210
- repeaterData: { index: y, dataKey: p }
210
+ repeaterData: { index: y, dataKey: u }
211
211
  }
212
- )) : o(l) ? /* @__PURE__ */ u(
212
+ )) : o(l) ? /* @__PURE__ */ p(
213
213
  A,
214
214
  {
215
215
  ...e,
@@ -241,7 +241,7 @@ async function Le(e) {
241
241
  },
242
242
  {}
243
243
  );
244
- return /* @__PURE__ */ m(A, { ...e, lang: t, fallbackLang: r, dataProviders: n });
244
+ return await Promise.allSettled(Object.values(n)), /* @__PURE__ */ m(A, { ...e, lang: t, fallbackLang: r, dataProviders: n });
245
245
  }
246
246
  function Te(e, t) {
247
247
  const r = e.filter(({ _type: i }) => i === "GlobalBlock" || i === "PartialBlock");
@@ -258,12 +258,12 @@ function Te(e, t) {
258
258
  const De = (e) => {
259
259
  if (!e) return [];
260
260
  try {
261
- return JSON.parse(ue(e)).filter((r) => !r._type.startsWith("@chai"));
261
+ return JSON.parse(pe(e)).filter((r) => !r._type.startsWith("@chai"));
262
262
  } catch {
263
263
  return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
264
264
  }
265
265
  };
266
- function ue(e) {
266
+ function pe(e) {
267
267
  const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
268
268
  return e.replace(t, (r) => {
269
269
  const i = decodeURIComponent(r), n = i.indexOf("public");
@@ -319,8 +319,8 @@ const fe = (e, t) => {
319
319
  export {
320
320
  Le as AsyncRenderChaiBlocks,
321
321
  xe as RenderChaiBlocks,
322
- Ee as applyChaiDataBinding,
323
- Je as convertHTMLToChaiBlocks,
322
+ je as applyChaiDataBinding,
323
+ Ee as convertHTMLToChaiBlocks,
324
324
  De as convertToBlocks,
325
325
  Ae as getChaiThemeCssVariables,
326
326
  Te as getMergedPartialBlocks,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-B-HhWOKS.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-BlHe-VXv.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;
@@ -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-D5zinQbA.js";
2
+ import { d as N, N as D } from "./index-CBT9rRYh.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";
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "3.1.21",
8
+ "version": "3.1.23",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",