This commit is contained in:
Rizky 2023-10-22 13:36:06 +07:00
parent ecd2dc33f9
commit 3a50f00936
8 changed files with 41 additions and 20 deletions

View File

@ -33,10 +33,16 @@ export const treeRebuild = async (p: PG) => {
})
);
for (const [k, v] of Object.entries(portal.out)) {
for (const [k, portal_out] of Object.entries(portal.out)) {
const name = k.replace(/⮕/gi, "").trim();
const portal_in = portal.in[`${name}`];
if (portal_in) {
for (const key of Object.keys(portal_in)) {
delete (portal_in as any)[key];
}
for (const [k, v] of Object.entries(portal_out)) {
(portal_in as any)[k] = v;
}
}
}
}

View File

@ -99,19 +99,21 @@ export const Editor: FC<{ site_id: string; page_id: string; session: any }> = ({
}
if (p.status === "init") {
(window as any).mok = ((window as any).mok || 0) + 1;
p.ui.loading = <Loading note="load-page" />;
p.ui.preload = <Loading note="preload-root" backdrop={false} />;
p.ui.notfound = (
<div className="flex-1 flex items-center justify-center">NOT FOUND</div>
);
p.ui.error = (
<div className="flex-1 flex items-center justify-center">
PREVIEW ERROR
</div>
);
p.status = "loading";
initEditor(p, site_id);
if (p.ui) {
(window as any).mok = ((window as any).mok || 0) + 1;
p.ui.loading = <Loading note="load-page" />;
p.ui.preload = <Loading note="preload-root" backdrop={false} />;
p.ui.notfound = (
<div className="flex-1 flex items-center justify-center">NOT FOUND</div>
);
p.ui.error = (
<div className="flex-1 flex items-center justify-center">
PREVIEW ERROR
</div>
);
p.status = "loading";
initEditor(p, site_id);
}
}
routeEditor(p, page_id);

View File

@ -41,6 +41,7 @@ export const ERender: FC<{
item.adv.js.startsWith("newElement")
) {
const mitem = meta.mitem;
if (mitem && item.type === "item") {
(async () => {
let childs: any[] = [];

View File

@ -59,12 +59,16 @@ export const treePropEval = (
value = {
_jsx: true,
Comp: ({
prop_name,
parent_id,
_scopeIndex,
}: {
prop_name: string;
parent_id: string;
_scopeIndex?: Record<string, string>;
}) => {
console.log(prop_name);
if (prop.content) {
const meta = p.treeMeta[prop.content.id];
if (meta) {

View File

@ -41,11 +41,19 @@ export const treeScopeEval = (
if (v && typeof v === "object") {
const t: {
_jsx: true;
Comp: FC<{ parent_id: string; _scopeIndex?: Record<string, any> }>;
Comp: FC<{
prop_name: string;
parent_id: string;
_scopeIndex?: Record<string, any>;
}>;
} = v as any;
if (t._jsx && t.Comp) {
finalScope[k] = (
<t.Comp parent_id={meta.item.id} _scopeIndex={_scopeIndex} />
<t.Comp
prop_name={k}
parent_id={meta.item.id}
_scopeIndex={_scopeIndex}
/>
);
}
}

View File

@ -101,6 +101,8 @@ export const editorWS = async (p: PG) => {
}, 5000);
const decoder = new TextDecoder();
ws.addEventListener("message", async (e) => {
if (!e.data || !e.data.arrayBuffer) return;
const raw = decoder.decode(
decompress(new Uint8Array(await e.data.arrayBuffer()))
);

View File

@ -50,7 +50,7 @@ export const AddElement: FC<{}> = ({}) => {
id: createId(),
name: `New Text`,
type: "text",
dim: { w: "full", h: "fit" },
dim: { w: "full", h: "full" },
layout: { align: "center", dir: "col", gap: 0 },
text: "",
html: "",
@ -122,7 +122,7 @@ export const AddElement: FC<{}> = ({}) => {
id: createId(),
name: `New Item`,
type: "item",
dim: { w: "fit", h: "fit" },
dim: { w: "full", h: "full" },
childs: [],
adv: {
css: "",

View File

@ -89,9 +89,7 @@ export const ETreeItemAction: FC<{
onClick={async () => {
if (mitem) {
const ijson = mitem.toJSON() as IItem;
mitem.doc?.transact(() => {
mitem.set("childs", new Y.Array());
syncronize(mitem as any, {
...resetJSXProp,
name: ijson.name,