@chaibuilder/sdk 3.0.27 → 3.0.28

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.
@@ -2799,6 +2799,24 @@ const useInlineEditing = () => {
2799
2799
  setEditingBlockId: n,
2800
2800
  setEditingItemIndex: a
2801
2801
  };
2802
+ }, replaceBlock = (o, n, r) => {
2803
+ const a = find(o, { _id: n });
2804
+ if (!a) return o;
2805
+ const l = a._parent, i = r.map((d) => ({
2806
+ ...d,
2807
+ _parent: l
2808
+ }));
2809
+ return [...filter(o, (d) => d._id !== n && d._parent !== n), ...i];
2810
+ }, useReplaceBlock = () => {
2811
+ const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
2812
+ return useCallback(
2813
+ (l, i) => {
2814
+ if (!a(PERMISSIONS.EDIT_BLOCK)) return;
2815
+ const c = replaceBlock(o, l, i);
2816
+ r(c), i.length > 0 && setTimeout(() => n([i[0]._id]), 200);
2817
+ },
2818
+ [o, n, r, a]
2819
+ );
2802
2820
  }, useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
2803
2821
  sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
2804
2822
  const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS = [
@@ -4327,7 +4345,7 @@ const CanvasEventsWatcher = () => {
4327
4345
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
4328
4346
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
4329
4347
  ] }) });
4330
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-H0MQ5vzI.js")), CanvasArea = () => {
4348
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DmN41-qr.js")), CanvasArea = () => {
4331
4349
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4332
4350
  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: [
4333
4351
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4897,7 +4915,7 @@ const DataBindingSelector = ({
4897
4915
  ]
4898
4916
  }
4899
4917
  ) });
4900
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-HU1ZwziZ.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
4918
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-jYxk5Q4W.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
4901
4919
  const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
4902
4920
  blockId: o,
4903
4921
  value: a,
@@ -10642,26 +10660,27 @@ export {
10642
10660
  useRemoveAllClassesForBlock as ab,
10643
10661
  useRemoveBlocks as ac,
10644
10662
  useRemoveClassesFromBlocks as ad,
10645
- useResetBlockStyles as ae,
10646
- useRightPanel as af,
10647
- useSavePage as ag,
10648
- useSelectedBlock as ah,
10649
- useSelectedBlockAllClasses as ai,
10650
- useSelectedBlockCurrentClasses as aj,
10651
- useSelectedBlocksDisplayChild as ak,
10652
- useSelectedBreakpoints as al,
10653
- useSelectedStylingBlocks as am,
10654
- useStylingBreakpoint as an,
10655
- useStylingState as ao,
10656
- useTheme as ap,
10657
- useThemeOptions as aq,
10658
- useUndoManager as ar,
10659
- useWrapperBlock as as,
10660
- useBlocksStoreUndoableActions as at,
10661
- useCanvasDisplayWidth as au,
10662
- useScreenSizeWidth as av,
10663
- useSelectedLibrary as aw,
10664
- useSidebarActivePanel as ax,
10663
+ useReplaceBlock as ae,
10664
+ useResetBlockStyles as af,
10665
+ useRightPanel as ag,
10666
+ useSavePage as ah,
10667
+ useSelectedBlock as ai,
10668
+ useSelectedBlockAllClasses as aj,
10669
+ useSelectedBlockCurrentClasses as ak,
10670
+ useSelectedBlocksDisplayChild as al,
10671
+ useSelectedBreakpoints as am,
10672
+ useSelectedStylingBlocks as an,
10673
+ useStylingBreakpoint as ao,
10674
+ useStylingState as ap,
10675
+ useTheme as aq,
10676
+ useThemeOptions as ar,
10677
+ useUndoManager as as,
10678
+ useWrapperBlock as at,
10679
+ useBlocksStoreUndoableActions as au,
10680
+ useCanvasDisplayWidth as av,
10681
+ useScreenSizeWidth as aw,
10682
+ useSelectedLibrary as ax,
10683
+ useSidebarActivePanel as ay,
10665
10684
  useUpdateBlocksProps as b,
10666
10685
  useUpdateBlocksPropsRealtime as c,
10667
10686
  usePageExternalData as d,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-CcmtMRO-.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-BtVNiUIw.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-B9XD9X3W.js";
2
+ import { d as N, N as D } from "./index-Ct0lOt4c.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.0.27",
8
+ "version": "3.0.28",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",