From ddad7fcbecb3917259207bf2e740928ca5611516 Mon Sep 17 00:00:00 2001 From: Rizky Date: Fri, 29 Mar 2024 10:08:18 +0700 Subject: [PATCH] wip fix auto add jsx child --- .../src/nova/ed/panel/header/mid/comp-picker.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/web/src/nova/ed/panel/header/mid/comp-picker.tsx b/app/web/src/nova/ed/panel/header/mid/comp-picker.tsx index af858524..05510cb7 100644 --- a/app/web/src/nova/ed/panel/header/mid/comp-picker.tsx +++ b/app/web/src/nova/ed/panel/header/mid/comp-picker.tsx @@ -9,7 +9,6 @@ import { loadComponent } from "../../../logic/comp/load"; import { EDGlobal, active } from "../../../logic/ed-global"; import { fillID } from "../../../logic/tree/fill-id"; import { TopBtn } from "../top-btn"; -import { useEffect } from "react"; export const EdCompPicker = () => { const p = useGlobal(EDGlobal, "EDITOR"); @@ -111,11 +110,25 @@ const addComponent = (mitem: MItem | MSection, comp: IItem) => { comp.component.instances = {}; } + const jsx = {} as Record; + for (const child of comp.childs) { + if (child.name.startsWith("jsx:")) { + jsx[child.name.substring("jsx:".length).trim()] = child as IItem; + } + } + + for (const [k, v] of Object.entries(comp.component?.props || {})) { + if (jsx[k] && v.content) { + v.content = jsx[k]; + } + } + syncronize(map as any, fillID(comp)); const childs = mitem.get("childs"); if (childs) { childs.push([map]); } + const newitem = map.toJSON(); active.item_id = newitem.id; }