diff --git a/app/web/src/nova/ed/logic/tree/build.tsx b/app/web/src/nova/ed/logic/tree/build.tsx index 06f08d5b..1557ae9b 100644 --- a/app/web/src/nova/ed/logic/tree/build.tsx +++ b/app/web/src/nova/ed/logic/tree/build.tsx @@ -1,7 +1,7 @@ -import { deepClone } from "web-utils"; import { IItem, MItem } from "../../../../utils/types/item"; import { genMeta } from "../../../view/logic/meta/meta"; import { PG, active } from "../ed-global"; +import { pushTreeNode } from "./build/push-tree"; export const treeRebuild = async (p: PG, arg?: { note?: string }) => { const is_layout = @@ -27,6 +27,7 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => { mroot?.get("childs")?.forEach((m) => mitems.push(m)); const meta = {}; + p.page.tree = []; for (const mitem of mitems) { const item = mitem.toJSON() as IItem; if (item) { @@ -37,9 +38,7 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => { on: !is_layout ? { visit(meta) { - if (meta.jsx_prop) { - console.log(meta.parent); - } + pushTreeNode(p, meta); }, } : undefined, diff --git a/app/web/src/nova/ed/logic/tree/build/push-tree.tsx b/app/web/src/nova/ed/logic/tree/build/push-tree.tsx new file mode 100644 index 00000000..05fa1f95 --- /dev/null +++ b/app/web/src/nova/ed/logic/tree/build/push-tree.tsx @@ -0,0 +1,19 @@ +import { IMeta, PG } from "../../ed-global"; + +export const pushTreeNode = (p: PG, meta: IMeta) => { + if (!meta.parent?.comp_id) { + p.page.tree.push({ + id: meta.item.id, + parent: meta.parent?.id || "root", + text: meta.item.name, + data: meta, + }); + } else if (meta.jsx_prop) { + p.page.tree.push({ + id: meta.item.id, + parent: meta.parent?.instance_id || "root", + text: meta.item.name, + data: meta, + }); + } +}; diff --git a/app/web/src/nova/ed/panel/tree/node/item/name.tsx b/app/web/src/nova/ed/panel/tree/node/item/name.tsx index 70e11f12..bcb0b9ba 100644 --- a/app/web/src/nova/ed/panel/tree/node/item/name.tsx +++ b/app/web/src/nova/ed/panel/tree/node/item/name.tsx @@ -23,7 +23,7 @@ export const EdTreeName = ({ const mitem = node.data?.mitem; if (!item || !mitem) return <>; - const is_jsx_prop = !!node.data?.jsx_prop_name; + const is_jsx_prop = !!node.data?.jsx_prop; const isRenaming = p.ui.tree.rename_id === item.id; return ( @@ -116,22 +116,5 @@ const Name: FC<{ name: string; is_jsx_prop: boolean }> = ({ ); } - // if (typeof name === "string" && name.startsWith("jsx=")) { - // return ( - //
- //
- // - // - // - // `, - // }} - // >
- //
{name.substring(4)}
- //
- // ); - // } return
{name}
; }; diff --git a/app/web/src/nova/ed/panel/tree/node/render.tsx b/app/web/src/nova/ed/panel/tree/node/render.tsx index c6af4912..2696a3ff 100644 --- a/app/web/src/nova/ed/panel/tree/node/render.tsx +++ b/app/web/src/nova/ed/panel/tree/node/render.tsx @@ -28,32 +28,36 @@ export const nodeRender: NodeRender = (node, prm) => { ); } - if (node.data?.jsx_prop_root && node.data?.jsx_prop_name) { - const prop_name = node.data?.jsx_prop_name; - const meta = getMetaById(p, node.data?.parent_item.id); + if ( + node.data?.jsx_prop?.name && + node.data?.jsx_prop?.name && + node.data?.parent?.instance_id + ) { + const prop_name = node.data?.jsx_prop?.name; + const meta = getMetaById(p, node.data.parent.instance_id); - if (meta && prop_name && !active.comp_id) { - if (!meta.propvis) { - if (!meta.parent_mcomp) { - setTimeout(local.render, 100); - const id = meta.item.originalId || meta.item.id; - if (!jsxPropVis[id] || jsxPropVis[id] === prop_name) { - jsxPropVis[id] = prop_name; - return ( -
- -
- ); - } else { - return <>; - } - } - } else { - if (meta.propvis[prop_name] === false) return <>; - } - } + // if (meta && prop_name && !active.comp_id) { + // if (!meta.propvis) { + // if (!meta.parent_mcomp) { + // setTimeout(local.render, 100); + // const id = meta.item.originalId || meta.item.id; + // if (!jsxPropVis[id] || jsxPropVis[id] === prop_name) { + // jsxPropVis[id] = prop_name; + // return ( + //
+ // + //
+ // ); + // } else { + // return <>; + // } + // } + // } else { + // if (meta.propvis[prop_name] === false) return <>; + // } + // } } return ( diff --git a/app/web/src/nova/view/logic/meta/comp.tsx b/app/web/src/nova/view/logic/meta/comp.tsx index 8b6be7c6..43fdf73a 100644 --- a/app/web/src/nova/view/logic/meta/comp.tsx +++ b/app/web/src/nova/view/logic/meta/comp.tsx @@ -37,6 +37,7 @@ export const genComp = ( const meta: IMeta = { item: simplifyItemChild(item), + mitem, parent: { id: arg.parent.item.id, instance_id: arg.parent?.instance?.id,