This commit is contained in:
Rizky 2023-12-14 18:30:55 +07:00
parent 27085ccd12
commit 51807aa0c7
3 changed files with 45 additions and 2 deletions

View File

@ -50,7 +50,7 @@ export const loadCompSnapshot = async (
doc.off("update", p.comp.list[id_comp].on_update);
}
const meta = {};
const meta: Record<string, IMeta> = {};
const tree: NodeModel<IMeta>[] = [];
const item = mitem.toJSON() as IItem;
p.comp.loaded[id_comp] = {
@ -63,6 +63,24 @@ export const loadCompSnapshot = async (
on: {
visit(m) {
pushTreeNode(p, m, meta, tree);
if (m.parent) {
if (m.parent.id === "root") {
if (m.item.id === item.id) {
m.mitem = mitem;
}
} else {
const parent = meta[m.parent.id];
if (parent.mitem) {
parent.mitem.get("childs")?.forEach((child) => {
if (child.get("id") === m.item.id) {
m.mitem = child;
}
});
}
}
}
},
},
note: "load-comp",

View File

@ -40,6 +40,24 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => {
async visit(m) {
if (!is_layout) {
pushTreeNode(p, m, meta, p.page.tree);
if (m.parent) {
if (m.parent.id === "root") {
if (m.item.id === item.id) {
m.mitem = mitem;
}
} else {
const parent = meta[m.parent.id];
if (parent.mitem) {
parent.mitem.get("childs")?.forEach((child) => {
if (child.get("id") === m.item.id) {
m.mitem = child;
}
});
}
}
}
}
},
},

View File

@ -9,7 +9,14 @@ export const EdMain = () => {
active.hover.renderMain = local.render;
return (
<div className="flex flex-1 relative overflow-auto">
<div
className={cx(
"flex flex-1 relative overflow-auto",
css`
contain: content;
`
)}
>
<div
className={cx(
"absolute inset-0 flex",