@chaibuilder/sdk 1.2.2 → 1.2.3
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-lBmLPSqX.js} +2 -2
- package/dist/{CanvasArea-jRg53jrS.cjs → CanvasArea-yDkGNbGZ.cjs} +1 -1
- package/dist/{CurrentPage-MLObvs0K.cjs → CurrentPage-0VSOB-Hb.cjs} +1 -1
- package/dist/{CurrentPage-YPI5QTjk.js → CurrentPage-B6hjYNzI.js} +2 -2
- package/dist/{Layers-no2keK4N.js → Layers-IDVZrVlL.js} +2 -2
- package/dist/{Layers-x_mWeT_q.cjs → Layers-y2knU0bT.cjs} +1 -1
- package/dist/{PagesPanel-pOIuFPOA.cjs → PagesPanel-Q_uSjTW1.cjs} +1 -1
- package/dist/{PagesPanel-Q08uN4X3.js → PagesPanel-j_Fpa3sl.js} +3 -3
- package/dist/{ProjectPanel-4bN_GyNm.cjs → ProjectPanel-qEwohLIY.cjs} +1 -1
- package/dist/{ProjectPanel-zzYV9yrV.js → ProjectPanel-vjK_4VSG.js} +3 -3
- package/dist/{Settings-28A7R61i.js → Settings-V07siWr-.js} +2 -2
- package/dist/{Settings-KlTtgu3w.cjs → Settings-ky8B7ncY.cjs} +1 -1
- package/dist/{SidePanels--ZK6Iqou.js → SidePanels-0B2_uHyb.js} +3 -3
- package/dist/{SidePanels-eJBA_cUu.cjs → SidePanels-Rf7LJBOR.cjs} +1 -1
- package/dist/{add-page-modal-OvNXLGf0.cjs → add-page-modal-ELiuGxwH.cjs} +1 -1
- package/dist/{add-page-modal-EHIYTW4T.js → add-page-modal-dQ4vsAOV.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +24 -15
- package/dist/core.js +2 -2
- package/dist/{delete-page-modal-U4yiuhx0.cjs → delete-page-modal-gViErMeG.cjs} +1 -1
- package/dist/{delete-page-modal-qZJCk_JH.js → delete-page-modal-gWvIto0r.js} +2 -2
- 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-hMoPNZVn.cjs → index-99vxkDWJ.cjs} +2 -2
- package/dist/{index-QEchoZ98.js → index-aHQmo59Y.js} +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.js +1 -1
- package/dist/{page-viewer-zFLkUu2I.js → page-viewer-YU2ON-TT.js} +3 -3
- package/dist/{page-viewer-WhM1FSU0.cjs → page-viewer-vW3LE2Lt.cjs} +1 -1
- package/dist/{project-general-setting-MWGOOurD.js → project-general-setting-m6C3KOQm.js} +2 -2
- package/dist/{project-general-setting-y8daY7V9.cjs → project-general-setting-vDHVl9_W.cjs} +1 -1
- package/dist/{single-page-detail-C48IPzbd.js → single-page-detail-GxzBw_k6.js} +3 -3
- package/dist/{single-page-detail--xPv74bX.cjs → single-page-detail-MFwjDf9d.cjs} +1 -1
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +2 -2
- package/dist/web-blocks.cjs +2 -2
- package/dist/web-blocks.js +252 -234
- package/package.json +5 -4
- package/dist/html-to-json-dfALTAdG.cjs +0 -1
- package/dist/html-to-json-xKBERAI1.js +0 -177
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": "1.2.
|
|
8
|
+
"version": "1.2.3",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -108,6 +108,8 @@
|
|
|
108
108
|
"@radix-ui/react-toast": "^1.1.4",
|
|
109
109
|
"@radix-ui/react-toggle": "^1.0.3",
|
|
110
110
|
"@radix-ui/react-tooltip": "^1.0.6",
|
|
111
|
+
"@react-email/components": "^0.0.18",
|
|
112
|
+
"@react-email/render": "^0.0.14",
|
|
111
113
|
"@react-hookz/web": "23.1.0",
|
|
112
114
|
"@rjsf/core": "5.11.2",
|
|
113
115
|
"@rjsf/utils": "5.11.2",
|
|
@@ -143,11 +145,9 @@
|
|
|
143
145
|
"react-dnd": "16.0.1",
|
|
144
146
|
"react-dnd-html5-backend": "16.0.1",
|
|
145
147
|
"react-dom": "^18",
|
|
148
|
+
"react-email": "^2.1.3",
|
|
146
149
|
"react-hotkeys-hook": "4.4.1",
|
|
147
150
|
"react-i18next": "13.0.1",
|
|
148
|
-
"@react-email/components": "^0.0.18",
|
|
149
|
-
"@react-email/render": "^0.0.14",
|
|
150
|
-
"react-email": "^2.1.3",
|
|
151
151
|
"react-icons": "^4.10.1",
|
|
152
152
|
"react-icons-picker": "^1.0.9",
|
|
153
153
|
"react-json-view": "^1.21.3",
|
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
"sonner": "^1.2.0",
|
|
159
159
|
"tailwind-merge": "1.13.2",
|
|
160
160
|
"tippy.js": "^6.3.7",
|
|
161
|
+
"undo-manager": "^1.1.1",
|
|
161
162
|
"unist-util-visit": "^4.1.2",
|
|
162
163
|
"unsplash-js": "^7.0.18"
|
|
163
164
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("himalaya"),p=require("./Functions-N3yhPYKY.cjs"),e=require("lodash-es"),u=require("./MODIFIERS-2FeVfZQ9.cjs"),T=require("lodash"),v={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"}},N=(t,r)=>t.children.length===1&&e.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link"],r._type),h=t=>t.map(r=>r.type==="text"?e.get(r,"content",""):e.isEmpty(r.children)?"":h(r.children)).join(""),g=t=>t===null?!0:t,y=t=>{const r={},s=v[t.tagName]||{},a=t.attributes;return e.forEach(a,({key:l,value:c})=>{if(s[l]){if(t.tagName==="img"&&l==="src"&&!c.startsWith("http")){const i=e.find(t.attributes,{key:"width"}),n=e.find(t.attributes,{key:"height"});i&&n?c=`https://via.placeholder.com/${i==null?void 0:i.value}x${n==null?void 0:n.value}`:c="https://via.placeholder.com/150x150"}e.set(r,s[l],g(c))}else e.includes(["style","class","srcset"],l)||e.set(r,`styles_attrs.${l}`,g(c))}),delete r.class,r},k=(t,r="styles")=>{if(!t.attributes)return{[r]:`${u.STYLES_KEY},`};const s=e.find(t.attributes,{key:"class"});if(s){const a=s.value;return{[r]:`${u.STYLES_KEY},${a}`}}return{[r]:`${u.STYLES_KEY},`}},x=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)}}},m=(t,r=null)=>e.flatMapDeep(t,s=>{var c;if(s.type==="comment")return[];let a={_id:p.generateUUID()};if(r&&(a._parent=r.block._id),s.type==="text")return e.isEmpty(e.get(s,"content",""))?[]:r&&N(r.node,r.block)?(e.set(r,"block.content",e.get(s,"content","")),[]):{...a,_type:"Text",content:e.get(s,"content","")};if(a={...a,...x(s),...y(s),...k(s)},a._type==="Input"){const i=a.inputType||"text";i==="checkbox"?e.set(a,"_type","Checkbox"):i==="radio"&&e.set(a,"_type","Radio")}else{if(s.tagName==="video"||s.tagName==="iframe")return a.content=o.stringify([s]),[a];if(s.tagName==="svg"){const i=e.find(s.attributes,{key:"height"}),n=e.find(s.attributes,{key:"width"}),f=e.get(i,"value")?`[${e.get(i,"value")}px]`:"24px",_=e.get(n,"value")?`[${e.get(n,"value")}px]`:"24px",d=e.get(e.find(s.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${u.STYLES_KEY}, ${p.cn(`w-${_} h-${f}`,d)}`.trim(),s.attributes=e.filter(s.attributes,b=>!e.includes(["style","width","height","class"],b.key)),a.icon=o.stringify([s]),e.set(a,"styles_attrs",T.omit(e.get(a,"styles_attrs")||{},["height","width","style","class"])),[a]}else if(s.tagName=="option"&&r&&((c=r.block)==null?void 0:c._type)==="Select")return r.block.options.push({label:h(s.children),...y(s)}),[]}const l=m(s.children,{block:a,node:s});return[a,...l]}),L=t=>{const r=t.match(/<body[^>]*>[\s\S]*?<\/body>/);return(r&&r.length>0?r[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):t).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},S=t=>{const r=o.parse(L(t));return e.isEmpty(t)?[]:e.flatten(m(r))};exports.getBlocksFromHTML=S;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { stringify as h, parse as N } from "himalaya";
|
|
2
|
-
import { g as k, c as L } from "./Functions-7jnEwJyw.js";
|
|
3
|
-
import { includes as y, get as c, isEmpty as g, forEach as w, find as u, set as o, capitalize as $, flatMapDeep as C, filter as S, flatten as B } from "lodash-es";
|
|
4
|
-
import { a as p } from "./MODIFIERS-RiXS5Mn1.js";
|
|
5
|
-
import { omit as A } from "lodash";
|
|
6
|
-
const I = {
|
|
7
|
-
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
8
|
-
video: {
|
|
9
|
-
src: "url",
|
|
10
|
-
autoplay: "controls.autoPlay",
|
|
11
|
-
muted: "controls.muted",
|
|
12
|
-
loop: "controls.loop",
|
|
13
|
-
controls: "controls.widgets"
|
|
14
|
-
},
|
|
15
|
-
a: {
|
|
16
|
-
href: "link.href",
|
|
17
|
-
target: "link.target",
|
|
18
|
-
type: ""
|
|
19
|
-
// @TODO: Detect here what to url, email, phone, elementId
|
|
20
|
-
},
|
|
21
|
-
input: {
|
|
22
|
-
placeholder: "placeholder",
|
|
23
|
-
required: "required",
|
|
24
|
-
type: "inputType",
|
|
25
|
-
name: "fieldName"
|
|
26
|
-
},
|
|
27
|
-
textarea: {
|
|
28
|
-
placeholder: "placeholder",
|
|
29
|
-
required: "required",
|
|
30
|
-
type: "inputType",
|
|
31
|
-
name: "fieldName"
|
|
32
|
-
},
|
|
33
|
-
select: {
|
|
34
|
-
placeholder: "placeholder",
|
|
35
|
-
required: "required",
|
|
36
|
-
multiple: "multiple",
|
|
37
|
-
name: "fieldName"
|
|
38
|
-
}
|
|
39
|
-
}, H = (t, e) => t.children.length === 1 && y(["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link"], e._type), _ = (t) => t.map((e) => e.type === "text" ? c(e, "content", "") : g(e.children) ? "" : _(e.children)).join(""), m = (t) => t === null ? !0 : t, f = (t) => {
|
|
40
|
-
const e = {}, r = I[t.tagName] || {}, a = t.attributes;
|
|
41
|
-
return w(a, ({ key: l, value: i }) => {
|
|
42
|
-
if (r[l]) {
|
|
43
|
-
if (t.tagName === "img" && l === "src" && !i.startsWith("http")) {
|
|
44
|
-
const s = u(t.attributes, { key: "width" }), n = u(t.attributes, { key: "height" });
|
|
45
|
-
s && n ? i = `https://via.placeholder.com/${s == null ? void 0 : s.value}x${n == null ? void 0 : n.value}` : i = "https://via.placeholder.com/150x150";
|
|
46
|
-
}
|
|
47
|
-
o(e, r[l], m(i));
|
|
48
|
-
} else
|
|
49
|
-
y(["style", "class", "srcset"], l) || o(e, `styles_attrs.${l}`, m(i));
|
|
50
|
-
}), delete e.class, e;
|
|
51
|
-
}, q = (t, e = "styles") => {
|
|
52
|
-
if (!t.attributes)
|
|
53
|
-
return { [e]: `${p},` };
|
|
54
|
-
const r = u(t.attributes, { key: "class" });
|
|
55
|
-
if (r) {
|
|
56
|
-
const a = r.value;
|
|
57
|
-
return { [e]: `${p},${a}` };
|
|
58
|
-
}
|
|
59
|
-
return { [e]: `${p},` };
|
|
60
|
-
}, E = (t) => {
|
|
61
|
-
switch (t.tagName) {
|
|
62
|
-
case "img":
|
|
63
|
-
return { _type: "Image" };
|
|
64
|
-
case "input":
|
|
65
|
-
return { _type: "Input", showLabel: !1 };
|
|
66
|
-
case "hr":
|
|
67
|
-
return { _type: "Divider" };
|
|
68
|
-
case "br":
|
|
69
|
-
return { _type: "LineBreak" };
|
|
70
|
-
case "textarea":
|
|
71
|
-
return { _type: "TextArea", showLabel: !1 };
|
|
72
|
-
case "audio":
|
|
73
|
-
return { _type: "Audio" };
|
|
74
|
-
case "canvas":
|
|
75
|
-
return { _type: "Canvas" };
|
|
76
|
-
case "video":
|
|
77
|
-
case "iframe":
|
|
78
|
-
return { _type: "CustomHTML" };
|
|
79
|
-
case "svg":
|
|
80
|
-
return { _type: "Icon" };
|
|
81
|
-
case "select":
|
|
82
|
-
return { _type: "Select", options: [] };
|
|
83
|
-
case "option":
|
|
84
|
-
return { _type: "Option" };
|
|
85
|
-
case "ul":
|
|
86
|
-
case "ol":
|
|
87
|
-
case "dl":
|
|
88
|
-
return {
|
|
89
|
-
_type: "List",
|
|
90
|
-
tag: t.tagName,
|
|
91
|
-
_listType: t.tagName === "ol" ? "list-decimal" : "list-none"
|
|
92
|
-
};
|
|
93
|
-
case "li":
|
|
94
|
-
case "dt":
|
|
95
|
-
return { _type: "ListItem", tag: t.tagName };
|
|
96
|
-
case "span":
|
|
97
|
-
case "figcaption":
|
|
98
|
-
case "legend":
|
|
99
|
-
return { _type: "Span", tag: t.tagName };
|
|
100
|
-
case "p":
|
|
101
|
-
return { _type: "Paragraph", content: "" };
|
|
102
|
-
case "a":
|
|
103
|
-
return { _type: "Link" };
|
|
104
|
-
case "form":
|
|
105
|
-
return { _type: "Form" };
|
|
106
|
-
case "label":
|
|
107
|
-
return { _type: "Label" };
|
|
108
|
-
case "button":
|
|
109
|
-
return { _type: "Button" };
|
|
110
|
-
case "code":
|
|
111
|
-
return { _type: "Code" };
|
|
112
|
-
case "h1":
|
|
113
|
-
case "h2":
|
|
114
|
-
case "h3":
|
|
115
|
-
case "h4":
|
|
116
|
-
case "h5":
|
|
117
|
-
case "h6":
|
|
118
|
-
return { _type: "Heading", tag: t.tagName };
|
|
119
|
-
case "table":
|
|
120
|
-
return { _type: "Table" };
|
|
121
|
-
case "tr":
|
|
122
|
-
return { _type: "TableRow" };
|
|
123
|
-
case "td":
|
|
124
|
-
case "th":
|
|
125
|
-
return { _type: "TableCell", tag: t.tagName };
|
|
126
|
-
case "thead":
|
|
127
|
-
return { _type: "TableHead" };
|
|
128
|
-
case "tbody":
|
|
129
|
-
return { _type: "TableBody" };
|
|
130
|
-
case "tfoot":
|
|
131
|
-
return { _type: "TableFooter" };
|
|
132
|
-
default:
|
|
133
|
-
return {
|
|
134
|
-
_type: "Box",
|
|
135
|
-
tag: t.tagName,
|
|
136
|
-
_name: t.tagName === "div" ? "Box" : $(t.tagName)
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}, b = (t, e = null) => C(t, (r) => {
|
|
140
|
-
var i;
|
|
141
|
-
if (r.type === "comment")
|
|
142
|
-
return [];
|
|
143
|
-
let a = { _id: k() };
|
|
144
|
-
if (e && (a._parent = e.block._id), r.type === "text")
|
|
145
|
-
return g(c(r, "content", "")) ? [] : e && H(e.node, e.block) ? (o(e, "block.content", c(r, "content", "")), []) : { ...a, _type: "Text", content: c(r, "content", "") };
|
|
146
|
-
if (a = {
|
|
147
|
-
...a,
|
|
148
|
-
...E(r),
|
|
149
|
-
...f(r),
|
|
150
|
-
...q(r)
|
|
151
|
-
}, a._type === "Input") {
|
|
152
|
-
const s = a.inputType || "text";
|
|
153
|
-
s === "checkbox" ? o(a, "_type", "Checkbox") : s === "radio" && o(a, "_type", "Radio");
|
|
154
|
-
} else {
|
|
155
|
-
if (r.tagName === "video" || r.tagName === "iframe")
|
|
156
|
-
return a.content = h([r]), [a];
|
|
157
|
-
if (r.tagName === "svg") {
|
|
158
|
-
const s = u(r.attributes, { key: "height" }), n = u(r.attributes, { key: "width" }), d = c(s, "value") ? `[${c(s, "value")}px]` : "24px", T = c(n, "value") ? `[${c(n, "value")}px]` : "24px", v = c(u(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
159
|
-
return a.styles = `${p}, ${L(`w-${T} h-${d}`, v)}`.trim(), r.attributes = S(r.attributes, (x) => !y(["style", "width", "height", "class"], x.key)), a.icon = h([r]), o(a, "styles_attrs", A(c(a, "styles_attrs") || {}, ["height", "width", "style", "class"])), [a];
|
|
160
|
-
} else if (r.tagName == "option" && e && ((i = e.block) == null ? void 0 : i._type) === "Select")
|
|
161
|
-
return e.block.options.push({
|
|
162
|
-
label: _(r.children),
|
|
163
|
-
...f(r)
|
|
164
|
-
}), [];
|
|
165
|
-
}
|
|
166
|
-
const l = b(r.children, { block: a, node: r });
|
|
167
|
-
return [a, ...l];
|
|
168
|
-
}), M = (t) => {
|
|
169
|
-
const e = t.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
170
|
-
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();
|
|
171
|
-
}, U = (t) => {
|
|
172
|
-
const e = N(M(t));
|
|
173
|
-
return g(t) ? [] : B(b(e));
|
|
174
|
-
};
|
|
175
|
-
export {
|
|
176
|
-
U as g
|
|
177
|
-
};
|