@chaibuilder/sdk 3.1.21 → 3.1.22
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-lG_A5s_w.cjs → code-editor-BclzCCn7.cjs} +1 -1
- package/dist/{code-editor-DRLBAEJb.js → code-editor-D64ahHN_.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +8 -1
- package/dist/core.js +1 -1
- package/dist/{index-B-HhWOKS.cjs → index-BlHe-VXv.cjs} +2 -2
- package/dist/{index-D5zinQbA.js → index-CBT9rRYh.js} +74 -56
- package/dist/{rte-widget-modal-BQbN6b_R.cjs → rte-widget-modal-C4SrkoTQ.cjs} +1 -1
- package/dist/{rte-widget-modal-MiC8MgXv.js → rte-widget-modal-Cd_8db9R.js} +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
3373
|
+
const H = O.getBoundingClientRect();
|
|
3374
3374
|
if (u === "vertical") {
|
|
3375
|
-
const
|
|
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:
|
|
3380
|
+
top: H.bottom + D - 2,
|
|
3381
3381
|
left: F,
|
|
3382
|
-
width:
|
|
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
|
|
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:
|
|
3397
|
-
left:
|
|
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]
|
|
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
|
-
},
|
|
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-
|
|
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-
|
|
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: {
|
|
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:
|
|
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:
|
|
8219
|
-
onDragStart: async (
|
|
8222
|
+
draggable: x,
|
|
8223
|
+
onDragStart: async (S) => {
|
|
8220
8224
|
try {
|
|
8221
8225
|
if (l) {
|
|
8222
|
-
l(
|
|
8226
|
+
l(S);
|
|
8223
8227
|
return;
|
|
8224
8228
|
}
|
|
8225
|
-
let
|
|
8226
|
-
if (
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
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:
|
|
8232
|
-
name: get(
|
|
8249
|
+
blocks: B,
|
|
8250
|
+
name: get(B, "0._type", "Block")
|
|
8233
8251
|
};
|
|
8234
8252
|
} else if (r) {
|
|
8235
|
-
const
|
|
8236
|
-
if (isEmpty(
|
|
8237
|
-
|
|
8253
|
+
const v = typeof r == "function" ? await r() : r;
|
|
8254
|
+
if (isEmpty(v)) return;
|
|
8255
|
+
k = {
|
|
8238
8256
|
type: "Box",
|
|
8239
|
-
blocks:
|
|
8240
|
-
name: get(
|
|
8257
|
+
blocks: v,
|
|
8258
|
+
name: get(v, "0._type", "Block")
|
|
8241
8259
|
};
|
|
8242
8260
|
} else if (o) {
|
|
8243
|
-
const
|
|
8244
|
-
|
|
8261
|
+
const v = typeof o == "function" ? await o() : o;
|
|
8262
|
+
k = typeof v == "object" ? omit(v, ["component", "icon"]) : v;
|
|
8245
8263
|
}
|
|
8246
|
-
if (!
|
|
8247
|
-
|
|
8248
|
-
|
|
8264
|
+
if (!k) return;
|
|
8265
|
+
u(S, k, !0), setTimeout(() => {
|
|
8266
|
+
f([]), h();
|
|
8249
8267
|
}, 200);
|
|
8250
|
-
} catch (
|
|
8251
|
-
console.error("Error in ChaiDraggableBlock drag start:",
|
|
8268
|
+
} catch (k) {
|
|
8269
|
+
console.error("Error in ChaiDraggableBlock drag start:", k);
|
|
8252
8270
|
}
|
|
8253
8271
|
},
|
|
8254
|
-
onDragEnd: (
|
|
8255
|
-
i ? i(
|
|
8272
|
+
onDragEnd: (S) => {
|
|
8273
|
+
i ? i(S) : g();
|
|
8256
8274
|
},
|
|
8257
|
-
className: `${
|
|
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
|
|
9123
|
-
|
|
9124
|
-
const F =
|
|
9125
|
-
F.top >= U.top && F.left >= U.left && F.bottom <= U.bottom && F.right <= U.right || (
|
|
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),
|
|
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(_);
|
|
@@ -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-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-
|
|
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";
|