@chaibuilder/sdk 1.2.2 → 1.2.4
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/{AddBlocks-QvCc-oag.js → AddBlocks-gbfzju1d.js} +15 -15
- package/dist/{AddBlocks-57-vroWk.cjs → AddBlocks-wuKI1ieB.cjs} +1 -1
- package/dist/{CanvasArea-59Gm0EZx.js → CanvasArea-WS9dnLyS.js} +8 -6
- package/dist/{CanvasArea-jRg53jrS.cjs → CanvasArea-wpskKN1H.cjs} +1 -1
- package/dist/CurrentPage-X9fCVXgY.cjs +1 -0
- package/dist/{CurrentPage-YPI5QTjk.js → CurrentPage-iaGHiR2B.js} +11 -9
- package/dist/Layers-EGhZWmvD.cjs +1 -0
- package/dist/{Layers-no2keK4N.js → Layers-V15IDskJ.js} +6 -4
- package/dist/{PagesPanel-pOIuFPOA.cjs → PagesPanel-Vla7HZkm.cjs} +1 -1
- package/dist/{PagesPanel-Q08uN4X3.js → PagesPanel-wfyKhLJ5.js} +6 -4
- package/dist/ProjectPanel-YLS4oOuU.cjs +1 -0
- package/dist/{ProjectPanel-zzYV9yrV.js → ProjectPanel-aiKhpNvr.js} +13 -11
- package/dist/{Settings-28A7R61i.js → Settings-JjYbPJrt.js} +5 -4
- package/dist/Settings-rnHnjhZ4.cjs +1 -0
- package/dist/{SidePanels--ZK6Iqou.js → SidePanels-XABN8kD3.js} +31 -29
- package/dist/SidePanels-vcWHxatg.cjs +1 -0
- package/dist/{add-page-modal-EHIYTW4T.js → add-page-modal-Gwhl6J1F.js} +5 -4
- package/dist/{add-page-modal-OvNXLGf0.cjs → add-page-modal-o5dy8nwt.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +24 -15
- package/dist/core.js +55 -53
- package/dist/delete-page-modal-IO_9ZCm4.cjs +1 -0
- package/dist/{delete-page-modal-qZJCk_JH.js → delete-page-modal-xGWX8RHn.js} +19 -17
- package/dist/email-blocks.cjs +1 -1
- package/dist/email-blocks.d.ts +1 -1
- package/dist/email-blocks.js +5 -5
- package/dist/html-to-json-5UoswV2Q.cjs +1 -0
- package/dist/html-to-json-yjzEN9OX.js +184 -0
- package/dist/{index-QEchoZ98.js → index-7mV_OcXd.js} +34 -33
- package/dist/{index-hMoPNZVn.cjs → index-mUPP605-.cjs} +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.js +1 -1
- package/dist/{page-viewer-zFLkUu2I.js → page-viewer-Xl1i1V3J.js} +7 -5
- package/dist/page-viewer-pJFW_LaN.cjs +1 -0
- package/dist/{project-general-setting-MWGOOurD.js → project-general-setting-8H1Rka2z.js} +5 -4
- package/dist/{project-general-setting-y8daY7V9.cjs → project-general-setting-lNEoQK1n.cjs} +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/{single-page-detail-C48IPzbd.js → single-page-detail-1hsqXV8c.js} +6 -5
- package/dist/single-page-detail-VKqGt-s1.cjs +1 -0
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +5 -3
- package/dist/web-blocks.cjs +2 -2
- package/dist/web-blocks.js +253 -235
- package/package.json +5 -4
- package/dist/CurrentPage-MLObvs0K.cjs +0 -1
- package/dist/Layers-x_mWeT_q.cjs +0 -1
- package/dist/ProjectPanel-4bN_GyNm.cjs +0 -1
- package/dist/Settings-KlTtgu3w.cjs +0 -1
- package/dist/SidePanels-eJBA_cUu.cjs +0 -1
- package/dist/delete-page-modal-U4yiuhx0.cjs +0 -1
- package/dist/html-to-json-dfALTAdG.cjs +0 -1
- package/dist/html-to-json-xKBERAI1.js +0 -177
- package/dist/page-viewer-WhM1FSU0.cjs +0 -1
- package/dist/single-page-detail--xPv74bX.cjs +0 -1
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { k as
|
|
2
|
-
import { N as
|
|
3
|
-
import { useTranslation as
|
|
1
|
+
import { k as ss } from "./index-7mV_OcXd.js";
|
|
2
|
+
import { N as as, af as os, O as ts, ah as rs, P as is, ae as ps, x as ls, i as ms, y as us, Q as cs, p as ds, R as Bs, U as ks, k as ns, V as Ss, n as Cs, W as Ps, X as vs, m as gs, L as ys, Y as As, Z as Ms, _ as hs, $ as Ds, a0 as Is, o as Rs, h as fs, a1 as xs, M as Ts, l as Us, a3 as bs, ag as js, a6 as ws, a5 as Hs, a4 as Os, j as Fs, ad as Gs, ai as Ls, aj as Ws, w as Zs, a7 as Es, a9 as Ns, a2 as Qs, aa as Vs, a8 as Xs, ab as Ys, ac as _s } from "./index-_OgCuSUz.js";
|
|
3
|
+
import { useTranslation as qs } from "react-i18next";
|
|
4
4
|
import "i18next";
|
|
5
5
|
import "./jsx-runtime-WbnYoNE9.js";
|
|
6
6
|
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
@@ -21,11 +21,13 @@ import "react-hotkeys-hook";
|
|
|
21
21
|
import "@chaibuilder/runtime";
|
|
22
22
|
import "@radix-ui/react-icons";
|
|
23
23
|
import "sonner";
|
|
24
|
-
import "./html-to-json-
|
|
24
|
+
import "./html-to-json-yjzEN9OX.js";
|
|
25
25
|
import "himalaya";
|
|
26
26
|
import "./MODIFIERS-RiXS5Mn1.js";
|
|
27
27
|
import "lodash";
|
|
28
28
|
import "lucide-react";
|
|
29
|
+
import "./web-blocks.js";
|
|
30
|
+
import "./controls-XPXGHKht.js";
|
|
29
31
|
import "@radix-ui/react-toggle";
|
|
30
32
|
import "class-variance-authority";
|
|
31
33
|
import "./utils-AvyFzbPC.js";
|
|
@@ -52,53 +54,53 @@ import "flat-to-nested";
|
|
|
52
54
|
import "redux-undo";
|
|
53
55
|
import "@react-hookz/web";
|
|
54
56
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
57
|
+
ss as ChaiBuilderEditor,
|
|
58
|
+
as as useActiveModal,
|
|
59
|
+
os as useActivePanel,
|
|
60
|
+
ts as useAddBlock,
|
|
61
|
+
rs as useAddBlockParent,
|
|
62
|
+
is as useAddClassesToBlocks,
|
|
63
|
+
ps as useAllBlocks,
|
|
64
|
+
ls as useBrandingOptions,
|
|
65
|
+
ms as useBuilderProp,
|
|
66
|
+
us as useBuilderReset,
|
|
67
|
+
cs as useBuildingBlocks,
|
|
68
|
+
ds as useCanvasHistory,
|
|
69
|
+
Bs as useCanvasWidth,
|
|
70
|
+
ks as useCanvasZoom,
|
|
71
|
+
ns as useCopyBlockIds,
|
|
72
|
+
Ss as useCurrentPage,
|
|
73
|
+
Cs as useCutBlockIds,
|
|
74
|
+
Ps as useDarkMode,
|
|
75
|
+
vs as useDeveloperPreviewMode,
|
|
76
|
+
gs as useDuplicateBlocks,
|
|
77
|
+
ys as useFeatureSupport,
|
|
78
|
+
As as useGetPageData,
|
|
79
|
+
Ms as useHiddenBlockIds,
|
|
80
|
+
hs as useHighlightBlockId,
|
|
81
|
+
Ds as useMarkAsGlobalBlock,
|
|
82
|
+
Is as useMoveBlocks,
|
|
83
|
+
Rs as usePasteBlocks,
|
|
84
|
+
fs as usePreviewMode,
|
|
85
|
+
xs as useProject,
|
|
86
|
+
Ts as useReadOnlyMode,
|
|
87
|
+
Us as useRemoveBlocks,
|
|
88
|
+
bs as useRemoveClassesFromBlocks,
|
|
89
|
+
js as useSavePage,
|
|
90
|
+
ws as useSelectedBlock,
|
|
91
|
+
Hs as useSelectedBlockAllClasses,
|
|
92
|
+
Os as useSelectedBlockCurrentClasses,
|
|
93
|
+
Fs as useSelectedBlockIds,
|
|
94
|
+
Gs as useSelectedBlocksDisplayChild,
|
|
95
|
+
Ls as useSelectedBreakpoints,
|
|
96
|
+
Ws as useSelectedStylingBlocks,
|
|
97
|
+
Zs as useSetAllBlocks,
|
|
98
|
+
Es as useStylingBreakpoint,
|
|
99
|
+
Ns as useStylingState,
|
|
100
|
+
qs as useTranslation,
|
|
101
|
+
Qs as useTranslations,
|
|
102
|
+
Vs as useTreeData,
|
|
103
|
+
Xs as useUILibraryBlocks,
|
|
104
|
+
Ys as useUpdateBlocksProps,
|
|
105
|
+
_s as useUpdateBlocksPropsRealtime
|
|
104
106
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),r=require("./index-IIJ_o44s.cjs"),q=require("./index-mUPP605-.cjs"),l=require("@radix-ui/react-icons");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("react");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-PTxFk6qT.cjs");require("lodash-es");require("./MODIFIERS-2FeVfZQ9.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("./Functions-N3yhPYKY.cjs");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("sonner");require("./html-to-json-5UoswV2Q.cjs");require("himalaya");require("lodash");require("lucide-react");require("./web-blocks.cjs");require("./controls-Dy1qa8Dc.cjs");const d=({pageData:i,projectData:t})=>{const n={},u=q.useDeletePage(),s=i.uuid===t.homepage,o=()=>{u.mutate(i,{onSuccess:()=>{n({uuid:t.homepage,slug:"/home"})}})};return e.jsxRuntimeExports.jsxs(r.AlertDialog,{children:[e.jsxRuntimeExports.jsx(r.AlertDialogTrigger,{disabled:s,children:e.jsxRuntimeExports.jsx("div",{className:`flex h-full items-center justify-center rounded-md border px-2 py-2 font-medium hover:bg-red-400 hover:text-white ${s?"cursor-not-allowed border-red-200 text-red-200":"cursor-pointer border-red-400 text-red-400"}`,children:e.jsxRuntimeExports.jsx(l.TrashIcon,{})})}),e.jsxRuntimeExports.jsxs(r.AlertDialogContent,{children:[e.jsxRuntimeExports.jsxs(r.AlertDialogTitle,{children:["Are you sure you want to delete ",e.jsxRuntimeExports.jsx("i",{className:"text-red-500",children:i.name})," page?"]}),e.jsxRuntimeExports.jsx(r.AlertDialogDescription,{children:"This action cannot be undone. This will permanently delete your page."}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-x-3",children:[e.jsxRuntimeExports.jsx(r.AlertDialogCancel,{disabled:u.isPending,children:"Cancel"}),e.jsxRuntimeExports.jsx(r.Button,{variant:"destructive",onClick:o,disabled:u.isPending,children:"Yes, Delete"})]})]})]})};exports.default=d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as r } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
2
|
import { D as s, E as l, F as n, H as d, I as a, K as c, B as u } from "./index-_OgCuSUz.js";
|
|
3
|
-
import { j as x } from "./index-
|
|
3
|
+
import { j as x } from "./index-7mV_OcXd.js";
|
|
4
4
|
import { TrashIcon as h } from "@radix-ui/react-icons";
|
|
5
5
|
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
6
6
|
import "react";
|
|
@@ -47,40 +47,42 @@ import "react-dnd";
|
|
|
47
47
|
import "@minoru/react-dnd-treeview";
|
|
48
48
|
import "react-hotkeys-hook";
|
|
49
49
|
import "sonner";
|
|
50
|
-
import "./html-to-json-
|
|
50
|
+
import "./html-to-json-yjzEN9OX.js";
|
|
51
51
|
import "himalaya";
|
|
52
52
|
import "lodash";
|
|
53
53
|
import "lucide-react";
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
import "./web-blocks.js";
|
|
55
|
+
import "./controls-XPXGHKht.js";
|
|
56
|
+
const jr = ({ pageData: e, projectData: i }) => {
|
|
57
|
+
const m = {}, t = x(), o = e.uuid === i.homepage, p = () => {
|
|
58
|
+
t.mutate(e, {
|
|
57
59
|
onSuccess: () => {
|
|
58
60
|
m({ uuid: i.homepage, slug: "/home" });
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
};
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ r.jsxs(s, { children: [
|
|
65
|
+
/* @__PURE__ */ r.jsx(l, { disabled: o, children: /* @__PURE__ */ r.jsx(
|
|
64
66
|
"div",
|
|
65
67
|
{
|
|
66
68
|
className: `flex h-full items-center justify-center rounded-md border px-2 py-2 font-medium hover:bg-red-400 hover:text-white ${o ? "cursor-not-allowed border-red-200 text-red-200" : "cursor-pointer border-red-400 text-red-400"}`,
|
|
67
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ r.jsx(h, {})
|
|
68
70
|
}
|
|
69
71
|
) }),
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ r.jsxs(n, { children: [
|
|
73
|
+
/* @__PURE__ */ r.jsxs(d, { children: [
|
|
72
74
|
"Are you sure you want to delete ",
|
|
73
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ r.jsx("i", { className: "text-red-500", children: e.name }),
|
|
74
76
|
" page?"
|
|
75
77
|
] }),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ r.jsx(a, { children: "This action cannot be undone. This will permanently delete your page." }),
|
|
79
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-end gap-x-3", children: [
|
|
80
|
+
/* @__PURE__ */ r.jsx(c, { disabled: t.isPending, children: "Cancel" }),
|
|
81
|
+
/* @__PURE__ */ r.jsx(u, { variant: "destructive", onClick: p, disabled: t.isPending, children: "Yes, Delete" })
|
|
80
82
|
] })
|
|
81
83
|
] })
|
|
82
84
|
] });
|
|
83
85
|
};
|
|
84
86
|
export {
|
|
85
|
-
|
|
87
|
+
jr as default
|
|
86
88
|
};
|
package/dist/email-blocks.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),r=require("@react-email/components"),s=require("@chaibuilder/runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-Z_BpKhVy.cjs"),r=require("@react-email/components"),s=require("@chaibuilder/runtime"),i=require("./controls-Dy1qa8Dc.cjs"),c=require("lodash-es");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("react");const l=({blockProps:o,styles:t,children:n})=>e.jsxRuntimeExports.jsxs(r.Container,{...o,...t,children:[e.jsxRuntimeExports.jsx("h1",{children:"Hello"}),e.jsxRuntimeExports.jsx(r.Button,{href:"https://example.com",className:"c-bg-red-500 c-px-4 c-py-1 c-border c-rounded-md c-inline-block c-text-white c-font-bold",children:"Click me"}),e.jsxRuntimeExports.jsx(r.Hr,{}),e.jsxRuntimeExports.jsx(r.CodeInline,{children:"@react-email/code-inline"}),";",n]});s.registerChaiBlock(l,{type:"Container",label:"Container",group:"basic",category:"core",props:{styles:i.S({default:""})}});const u=c.noop;exports.loadEmailBlocks=u;
|
package/dist/email-blocks.d.ts
CHANGED
package/dist/email-blocks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as o } from "./jsx-runtime-WbnYoNE9.js";
|
|
2
2
|
import { Container as i, Button as c, Hr as n, CodeInline as l } from "@react-email/components";
|
|
3
|
-
import { registerChaiBlock as
|
|
4
|
-
import { S as
|
|
3
|
+
import { registerChaiBlock as m } from "@chaibuilder/runtime";
|
|
4
|
+
import { S as s } from "./controls-XPXGHKht.js";
|
|
5
5
|
import { noop as p } from "lodash-es";
|
|
6
6
|
import "./_commonjsHelpers-UyOWmZb0.js";
|
|
7
7
|
import "react";
|
|
@@ -20,16 +20,16 @@ const a = ({ blockProps: e, styles: r, children: t }) => /* @__PURE__ */ o.jsxs(
|
|
|
20
20
|
";",
|
|
21
21
|
t
|
|
22
22
|
] });
|
|
23
|
-
|
|
23
|
+
m(a, {
|
|
24
24
|
type: "Container",
|
|
25
25
|
label: "Container",
|
|
26
26
|
group: "basic",
|
|
27
27
|
category: "core",
|
|
28
28
|
props: {
|
|
29
|
-
styles:
|
|
29
|
+
styles: s({ default: "" })
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
const u = p;
|
|
33
33
|
export {
|
|
34
|
-
u as
|
|
34
|
+
u as loadEmailBlocks
|
|
35
35
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("himalaya"),p=require("./Functions-N3yhPYKY.cjs"),e=require("lodash-es"),o=require("./MODIFIERS-2FeVfZQ9.cjs"),h=require("lodash"),v=t=>{const s=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return s.test(t)||r.test(t)},w=t=>{if(h.isEmpty(t))return t;const s=/<video[^>]+src=['"]([^'">]+)['"]/,r=/<iframe[^>]+src=['"]([^'">]+)['"]/,a=t.match(s),l=t.match(r),i=a?a[1]:l?l[1]:null,c=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return i&&(c.test(i)||n.test(i))?i:t},x={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"}},S=(t,s)=>t.children.length===1&&e.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link"],s._type),m=t=>t.map(s=>s.type==="text"?e.get(s,"content",""):e.isEmpty(s.children)?"":m(s.children)).join(""),g=t=>t===null?!0:t,y=t=>{const s={},r=x[t.tagName]||{},a=t.attributes;return e.forEach(a,({key:l,value:i})=>{if(r[l]){if(t.tagName==="img"&&l==="src"&&!i.startsWith("http")){const c=e.find(t.attributes,{key:"width"}),n=e.find(t.attributes,{key:"height"});c&&n?i=`https://via.placeholder.com/${c==null?void 0:c.value}x${n==null?void 0:n.value}`:i="https://via.placeholder.com/150x150"}e.set(s,r[l],g(i))}else e.includes(["style","class","srcset"],l)||e.set(s,`styles_attrs.${l}`,g(i))}),delete s.class,s},L=(t,s="styles")=>{if(!t.attributes)return{[s]:`${o.STYLES_KEY},`};const r=e.find(t.attributes,{key:"class"});if(r){const a=r.value;return{[s]:`${o.STYLES_KEY},${a}`}}return{[s]:`${o.STYLES_KEY},`}},N=t=>{switch(t.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:t.tagName,_listType:t.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:t.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:t.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:t.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:t.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:return{_type:"Box",tag:t.tagName,_name:t.tagName==="div"?"Box":e.capitalize(t.tagName)}}},f=(t,s=null)=>e.flatMapDeep(t,r=>{var i;if(r.type==="comment")return[];let a={_id:p.generateUUID()};if(s&&(a._parent=s.block._id),r.type==="text")return e.isEmpty(e.get(r,"content",""))?[]:s&&S(s.node,s.block)?(e.set(s,"block.content",e.get(r,"content","")),[]):{...a,_type:"Text",content:e.get(r,"content","")};if(a={...a,...N(r),...y(r),...L(r)},a._type==="Input"){const c=a.inputType||"text";c==="checkbox"?e.set(a,"_type","Checkbox"):c==="radio"&&e.set(a,"_type","Radio")}else if(r.tagName==="video"||r.tagName==="iframe"){const c=u.stringify([r]);return v(c)&&(e.set(a,"_type","Video"),e.set(a,"url",w(c)),e.set(a,"styles",`${o.STYLES_KEY},absolute top-0 left-0 w-full h-full`),e.set(a,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),a.content=c,[a]}else if(r.tagName==="svg"){const c=e.find(r.attributes,{key:"height"}),n=e.find(r.attributes,{key:"width"}),d=e.get(c,"value")?`[${e.get(c,"value")}px]`:"24px",b=e.get(n,"value")?`[${e.get(n,"value")}px]`:"24px",_=e.get(e.find(r.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${o.STYLES_KEY}, ${p.cn(`w-${b} h-${d}`,_)}`.trim(),r.attributes=e.filter(r.attributes,T=>!e.includes(["style","width","height","class"],T.key)),a.icon=u.stringify([r]),e.set(a,"styles_attrs",h.omit(e.get(a,"styles_attrs")||{},["height","width","style","class"])),[a]}else if(r.tagName=="option"&&s&&((i=s.block)==null?void 0:i._type)==="Select")return s.block.options.push({label:m(r.children),...y(r)}),[];const l=f(r.children,{block:a,node:r});return[a,...l]}),k=t=>{const s=t.match(/<body[^>]*>[\s\S]*?<\/body>/);return(s&&s.length>0?s[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):t).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},E=t=>{const s=u.parse(k(t));return e.isEmpty(t)?[]:e.flatten(f(s))};exports.getBlocksFromHTML=E;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { stringify as m, parse as x } from "himalaya";
|
|
2
|
+
import { g as N, c as k } from "./Functions-7jnEwJyw.js";
|
|
3
|
+
import { includes as y, get as l, isEmpty as g, forEach as L, find as u, set as o, capitalize as S, flatMapDeep as $, filter as C, flatten as A } from "lodash-es";
|
|
4
|
+
import { a as p } from "./MODIFIERS-RiXS5Mn1.js";
|
|
5
|
+
import { isEmpty as R, omit as B } from "lodash";
|
|
6
|
+
const H = (t) => {
|
|
7
|
+
const e = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, a = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
8
|
+
return e.test(t) || a.test(t);
|
|
9
|
+
}, M = (t) => {
|
|
10
|
+
if (R(t))
|
|
11
|
+
return t;
|
|
12
|
+
const e = /<video[^>]+src=['"]([^'">]+)['"]/, a = /<iframe[^>]+src=['"]([^'">]+)['"]/, r = t.match(e), i = t.match(a), c = r ? r[1] : i ? i[1] : null, s = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, n = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
13
|
+
return c && (s.test(c) || n.test(c)) ? c : t;
|
|
14
|
+
}, E = {
|
|
15
|
+
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
16
|
+
video: {
|
|
17
|
+
src: "url",
|
|
18
|
+
autoplay: "controls.autoPlay",
|
|
19
|
+
muted: "controls.muted",
|
|
20
|
+
loop: "controls.loop",
|
|
21
|
+
controls: "controls.widgets"
|
|
22
|
+
},
|
|
23
|
+
a: {
|
|
24
|
+
href: "link.href",
|
|
25
|
+
target: "link.target",
|
|
26
|
+
type: ""
|
|
27
|
+
// @TODO: Detect here what to url, email, phone, elementId
|
|
28
|
+
},
|
|
29
|
+
input: {
|
|
30
|
+
placeholder: "placeholder",
|
|
31
|
+
required: "required",
|
|
32
|
+
type: "inputType",
|
|
33
|
+
name: "fieldName"
|
|
34
|
+
},
|
|
35
|
+
textarea: {
|
|
36
|
+
placeholder: "placeholder",
|
|
37
|
+
required: "required",
|
|
38
|
+
type: "inputType",
|
|
39
|
+
name: "fieldName"
|
|
40
|
+
},
|
|
41
|
+
select: {
|
|
42
|
+
placeholder: "placeholder",
|
|
43
|
+
required: "required",
|
|
44
|
+
multiple: "multiple",
|
|
45
|
+
name: "fieldName"
|
|
46
|
+
}
|
|
47
|
+
}, I = (t, e) => t.children.length === 1 && y(["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link"], e._type), b = (t) => t.map((e) => e.type === "text" ? l(e, "content", "") : g(e.children) ? "" : b(e.children)).join(""), h = (t) => t === null ? !0 : t, f = (t) => {
|
|
48
|
+
const e = {}, a = E[t.tagName] || {}, r = t.attributes;
|
|
49
|
+
return L(r, ({ key: i, value: c }) => {
|
|
50
|
+
if (a[i]) {
|
|
51
|
+
if (t.tagName === "img" && i === "src" && !c.startsWith("http")) {
|
|
52
|
+
const s = u(t.attributes, { key: "width" }), n = u(t.attributes, { key: "height" });
|
|
53
|
+
s && n ? c = `https://via.placeholder.com/${s == null ? void 0 : s.value}x${n == null ? void 0 : n.value}` : c = "https://via.placeholder.com/150x150";
|
|
54
|
+
}
|
|
55
|
+
o(e, a[i], h(c));
|
|
56
|
+
} else
|
|
57
|
+
y(["style", "class", "srcset"], i) || o(e, `styles_attrs.${i}`, h(c));
|
|
58
|
+
}), delete e.class, e;
|
|
59
|
+
}, q = (t, e = "styles") => {
|
|
60
|
+
if (!t.attributes)
|
|
61
|
+
return { [e]: `${p},` };
|
|
62
|
+
const a = u(t.attributes, { key: "class" });
|
|
63
|
+
if (a) {
|
|
64
|
+
const r = a.value;
|
|
65
|
+
return { [e]: `${p},${r}` };
|
|
66
|
+
}
|
|
67
|
+
return { [e]: `${p},` };
|
|
68
|
+
}, P = (t) => {
|
|
69
|
+
switch (t.tagName) {
|
|
70
|
+
case "img":
|
|
71
|
+
return { _type: "Image" };
|
|
72
|
+
case "input":
|
|
73
|
+
return { _type: "Input", showLabel: !1 };
|
|
74
|
+
case "hr":
|
|
75
|
+
return { _type: "Divider" };
|
|
76
|
+
case "br":
|
|
77
|
+
return { _type: "LineBreak" };
|
|
78
|
+
case "textarea":
|
|
79
|
+
return { _type: "TextArea", showLabel: !1 };
|
|
80
|
+
case "audio":
|
|
81
|
+
return { _type: "Audio" };
|
|
82
|
+
case "canvas":
|
|
83
|
+
return { _type: "Canvas" };
|
|
84
|
+
case "video":
|
|
85
|
+
case "iframe":
|
|
86
|
+
return { _type: "CustomHTML" };
|
|
87
|
+
case "svg":
|
|
88
|
+
return { _type: "Icon" };
|
|
89
|
+
case "select":
|
|
90
|
+
return { _type: "Select", options: [] };
|
|
91
|
+
case "option":
|
|
92
|
+
return { _type: "Option" };
|
|
93
|
+
case "ul":
|
|
94
|
+
case "ol":
|
|
95
|
+
case "dl":
|
|
96
|
+
return {
|
|
97
|
+
_type: "List",
|
|
98
|
+
tag: t.tagName,
|
|
99
|
+
_listType: t.tagName === "ol" ? "list-decimal" : "list-none"
|
|
100
|
+
};
|
|
101
|
+
case "li":
|
|
102
|
+
case "dt":
|
|
103
|
+
return { _type: "ListItem", tag: t.tagName };
|
|
104
|
+
case "span":
|
|
105
|
+
case "figcaption":
|
|
106
|
+
case "legend":
|
|
107
|
+
return { _type: "Span", tag: t.tagName };
|
|
108
|
+
case "p":
|
|
109
|
+
return { _type: "Paragraph", content: "" };
|
|
110
|
+
case "a":
|
|
111
|
+
return { _type: "Link" };
|
|
112
|
+
case "form":
|
|
113
|
+
return { _type: "Form" };
|
|
114
|
+
case "label":
|
|
115
|
+
return { _type: "Label" };
|
|
116
|
+
case "button":
|
|
117
|
+
return { _type: "Button" };
|
|
118
|
+
case "code":
|
|
119
|
+
return { _type: "Code" };
|
|
120
|
+
case "h1":
|
|
121
|
+
case "h2":
|
|
122
|
+
case "h3":
|
|
123
|
+
case "h4":
|
|
124
|
+
case "h5":
|
|
125
|
+
case "h6":
|
|
126
|
+
return { _type: "Heading", tag: t.tagName };
|
|
127
|
+
case "table":
|
|
128
|
+
return { _type: "Table" };
|
|
129
|
+
case "tr":
|
|
130
|
+
return { _type: "TableRow" };
|
|
131
|
+
case "td":
|
|
132
|
+
case "th":
|
|
133
|
+
return { _type: "TableCell", tag: t.tagName };
|
|
134
|
+
case "thead":
|
|
135
|
+
return { _type: "TableHead" };
|
|
136
|
+
case "tbody":
|
|
137
|
+
return { _type: "TableBody" };
|
|
138
|
+
case "tfoot":
|
|
139
|
+
return { _type: "TableFooter" };
|
|
140
|
+
default:
|
|
141
|
+
return {
|
|
142
|
+
_type: "Box",
|
|
143
|
+
tag: t.tagName,
|
|
144
|
+
_name: t.tagName === "div" ? "Box" : S(t.tagName)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, d = (t, e = null) => $(t, (a) => {
|
|
148
|
+
var c;
|
|
149
|
+
if (a.type === "comment")
|
|
150
|
+
return [];
|
|
151
|
+
let r = { _id: N() };
|
|
152
|
+
if (e && (r._parent = e.block._id), a.type === "text")
|
|
153
|
+
return g(l(a, "content", "")) ? [] : e && I(e.node, e.block) ? (o(e, "block.content", l(a, "content", "")), []) : { ...r, _type: "Text", content: l(a, "content", "") };
|
|
154
|
+
if (r = {
|
|
155
|
+
...r,
|
|
156
|
+
...P(a),
|
|
157
|
+
...f(a),
|
|
158
|
+
...q(a)
|
|
159
|
+
}, r._type === "Input") {
|
|
160
|
+
const s = r.inputType || "text";
|
|
161
|
+
s === "checkbox" ? o(r, "_type", "Checkbox") : s === "radio" && o(r, "_type", "Radio");
|
|
162
|
+
} else if (a.tagName === "video" || a.tagName === "iframe") {
|
|
163
|
+
const s = m([a]);
|
|
164
|
+
return H(s) && (o(r, "_type", "Video"), o(r, "url", M(s)), o(r, "styles", `${p},absolute top-0 left-0 w-full h-full`), o(r, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), r.content = s, [r];
|
|
165
|
+
} else if (a.tagName === "svg") {
|
|
166
|
+
const s = u(a.attributes, { key: "height" }), n = u(a.attributes, { key: "width" }), _ = l(s, "value") ? `[${l(s, "value")}px]` : "24px", v = l(n, "value") ? `[${l(n, "value")}px]` : "24px", T = l(u(a.attributes, { key: "class" }), "value", "w-full h-full");
|
|
167
|
+
return r.styles = `${p}, ${k(`w-${v} h-${_}`, T)}`.trim(), a.attributes = C(a.attributes, (w) => !y(["style", "width", "height", "class"], w.key)), r.icon = m([a]), o(r, "styles_attrs", B(l(r, "styles_attrs") || {}, ["height", "width", "style", "class"])), [r];
|
|
168
|
+
} else if (a.tagName == "option" && e && ((c = e.block) == null ? void 0 : c._type) === "Select")
|
|
169
|
+
return e.block.options.push({
|
|
170
|
+
label: b(a.children),
|
|
171
|
+
...f(a)
|
|
172
|
+
}), [];
|
|
173
|
+
const i = d(a.children, { block: r, node: a });
|
|
174
|
+
return [r, ...i];
|
|
175
|
+
}), z = (t) => {
|
|
176
|
+
const e = t.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
177
|
+
return (e && e.length > 0 ? e[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : t).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
178
|
+
}, Y = (t) => {
|
|
179
|
+
const e = x(z(t));
|
|
180
|
+
return g(t) ? [] : A(d(e));
|
|
181
|
+
};
|
|
182
|
+
export {
|
|
183
|
+
Y as g
|
|
184
|
+
};
|