From 3923747602c2868ef58fd15bfd83401a0ccec647 Mon Sep 17 00:00:00 2001 From: Rizky Date: Sat, 17 Feb 2024 05:02:21 +0700 Subject: [PATCH] wip fix --- .../src/nova/ed/panel/tree/node/on-drop.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/web/src/nova/ed/panel/tree/node/on-drop.tsx b/app/web/src/nova/ed/panel/tree/node/on-drop.tsx index 26f8b85f..547fa64d 100644 --- a/app/web/src/nova/ed/panel/tree/node/on-drop.tsx +++ b/app/web/src/nova/ed/panel/tree/node/on-drop.tsx @@ -33,6 +33,35 @@ export const nodeOnDrop: ( if (to) { if (to.get("component")?.get("id")) { + if (!toMeta.item.component?.id) { + to.doc?.transact(() => { + if (toMeta?.mitem && from && typeof relativeIndex === "number") { + const toChilds = toMeta.mitem.get("childs"); + if (toChilds) { + const map = new Y.Map(); + syncronize(map, fillID(from.toJSON() as any)); + toChilds.insert(relativeIndex, [map]); + } + + if (!fromMeta?.jsx_prop?.is_root) { + from.parent.forEach((e, idx) => { + if ( + from && + !!e && + !!e.get && + e.get("id") === from.get("id") + ) { + from.parent.delete(idx); + } + }); + } + } + }); + + treeRebuild(p); + p.render(); + } + return null; }