diff --git a/app/srv/ws/sync/editor/parser/parse-js.ts b/app/srv/ws/sync/editor/parser/parse-js.ts index b549d313..c3a4053f 100644 --- a/app/srv/ws/sync/editor/parser/parse-js.ts +++ b/app/srv/ws/sync/editor/parser/parse-js.ts @@ -62,17 +62,23 @@ export const parseJs = ( attr.value.expression.loc ) { const loc = attr.value.expression.loc as any; - const start = attr.value.expression.properties[0].loc?.start; - const end = - attr.value.expression.properties[ - attr.value.expression.properties.length - 1 - ].loc?.end; + const start = attr.value.expression.properties[0].loc + ?.start as any; + const end = attr.value.expression.properties[ + attr.value.expression.properties.length - 1 + ].loc?.end as any; - if (typeof start === "number" && typeof end === "number") { - local.value = code.substring( - loc.start.index, - loc.end.index - ); + if ( + typeof start === "number" && + typeof end === "number" && + typeof loc.start.index === "number" + ) { + local.value = code.substring(start, end); + local.index = loc.start.index; + } + + if (typeof start === "object" && typeof end === "object") { + local.value = `{${code.substring(start.index, end.index)}}`; local.index = loc.start.index; } } diff --git a/app/web/src/nova/ed/logic/tree/build.tsx b/app/web/src/nova/ed/logic/tree/build.tsx index 06e5426b..b706f8c1 100644 --- a/app/web/src/nova/ed/logic/tree/build.tsx +++ b/app/web/src/nova/ed/logic/tree/build.tsx @@ -177,7 +177,7 @@ export const getMRoot = (p: PG) => { export const getMetaById = (p: PG, id: string) => { if (active.comp_id) { if (p.comp.list[active.comp_id]) - return p.comp.list[active.comp_id].meta[active.item_id]; + return p.comp.list[active.comp_id].meta[id]; } else { return p.page.meta[id]; } diff --git a/app/web/src/nova/ed/logic/tree/sync-walk.tsx b/app/web/src/nova/ed/logic/tree/sync-walk.tsx index b275cc26..978b3a6a 100644 --- a/app/web/src/nova/ed/logic/tree/sync-walk.tsx +++ b/app/web/src/nova/ed/logic/tree/sync-walk.tsx @@ -172,9 +172,7 @@ export const syncWalkMap = ( } const old_id = item.id; - mapItem(mcomp, item, ref_ids); - item.originalId = item.id; item.id = old_id; const meta: EdMeta = { @@ -361,7 +359,7 @@ const mapItem = ( val = e.toJSON() as any; } } - item[k] = val; + if (k !== "originalId") item[k] = val; } else { item[k] = []; const childs = e as unknown as TypedArray<{}>; diff --git a/app/web/src/nova/ed/panel/popup/script/scope.tsx b/app/web/src/nova/ed/panel/popup/script/scope.tsx index 7d95acfd..9c780b41 100644 --- a/app/web/src/nova/ed/panel/popup/script/scope.tsx +++ b/app/web/src/nova/ed/panel/popup/script/scope.tsx @@ -43,6 +43,7 @@ export const declareScope = async ( delete e.s.s.props[e.name]; } } + existing[name] = arg; }); spreadScope(p, s, (arg) => { @@ -125,7 +126,8 @@ const spreadScope = ( arg: { prev?: { comp_id: string; item_id: string } } ) => { let { prev } = arg; - for (const parent_id of parents) { + for (const _parent_id of parents) { + let parent_id = _parent_id; if (parent_id === "root") continue; let item = null as null | ISingleScope; const meta = p.page.meta[parent_id]; @@ -145,6 +147,9 @@ const spreadScope = ( if (comp_id) { const scope = p.comp.list[comp_id].scope; item = scope[meta.item.originalId || meta.item.id]; + if (item) { + parent_id = meta.item.originalId || meta.item.id; + } } } @@ -156,6 +161,7 @@ const spreadScope = ( if (item) { const scope = item.s; + if (scope) { if (scope.local) each({ diff --git a/app/web/src/nova/ed/panel/tree/node/item/indent-hook.ts b/app/web/src/nova/ed/panel/tree/node/item/indent-hook.ts index 9a1ab624..75e5c929 100644 --- a/app/web/src/nova/ed/panel/tree/node/item/indent-hook.ts +++ b/app/web/src/nova/ed/panel/tree/node/item/indent-hook.ts @@ -24,9 +24,11 @@ export const expandTreeHook = ( if (cur && cur.parent_item) { const id = cur.parent_item.mitem?.get("id"); if (id) { + shouldOpen.add(id); + let meta: EdMeta | undefined = getMetaById(p, id); while (meta) { - const id = cur.parent_item.mitem?.get("id"); + const id = meta.parent_item.id; if (id && !shouldOpen.has(id)) { shouldOpen.add(id); meta = getMetaById(p, id); 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 64bd3db1..7857e62c 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 @@ -74,7 +74,7 @@ export const EdTreeName = ({ ) : (