This commit is contained in:
Rizky 2023-12-30 06:30:24 +07:00
parent bd586ce347
commit cdb613651c
2 changed files with 28 additions and 28 deletions

View File

@ -41,8 +41,8 @@ export const declareScope = async (
map_childs(metas, entry, paths); map_childs(metas, entry, paths);
const added = new Set<string>(); const added = new Set<string>();
for (const path of paths) { for (const path of paths) {
console.log(path.map((e) => e.item.name));
const exim = scopeMapExportImport(p, meta, path); const exim = scopeMapExportImport(p, meta, path);
for (const [k, v] of Object.entries(exim.exports)) { for (const [k, v] of Object.entries(exim.exports)) {
for (const [filename, src] of Object.entries(v)) { for (const [filename, src] of Object.entries(v)) {
if (!added.has(filename)) { if (!added.has(filename)) {
@ -64,32 +64,35 @@ const map_childs = (
for (const m of childs) { for (const m of childs) {
const meta = metas[m.id]; const meta = metas[m.id];
if (meta) { if (meta) {
let cur: null | IMeta[] = null; paths.push([...(curpath || []), meta]);
for (const path of paths) { if (
if (path[path.length - 1] === parent) { meta.item.type === "item" &&
cur = path; meta.item.component?.id &&
cur.push(meta); meta.item.component?.id !== active.comp_id
break; ) {
} if (meta.item.component?.props) {
} for (const [_, p] of Object.entries(meta.item.component.props)) {
if (p.meta?.type === "content-element" && p.content) {
if (!cur) { map_childs(
paths.push([...(curpath || []), meta]); metas,
cur = paths[paths.length - 1]; [p.content],
} paths,
[...(curpath || []), meta],
if (cur) { meta
if ( );
meta.item.type === "item" && }
meta.item.component?.id &&
meta.item.component?.id !== active.comp_id
) {
continue;
} else {
if (Array.isArray(meta.item.childs)) {
map_childs(metas, meta.item.childs, paths, cur, meta);
} }
} }
} else {
if (Array.isArray(meta.item.childs)) {
map_childs(
metas,
meta.item.childs,
paths,
[...(curpath || []), meta],
meta
);
}
} }
} }
} }

View File

@ -34,9 +34,6 @@ export const edActionDeleteById = async (p: PG, id: string) => {
const deleteByParent = (p: PG, mitem: MItem, index: number) => { const deleteByParent = (p: PG, mitem: MItem, index: number) => {
const mchild = mitem.parent.get(index); const mchild = mitem.parent.get(index);
const child = mchild?.toJSON() as IItem;
console.log(child);
mitem.parent.delete(index); mitem.parent.delete(index);
treeRebuild(p); treeRebuild(p);
}; };