diff --git a/app/web/src/nova/ed/panel/popup/script/monaco.tsx b/app/web/src/nova/ed/panel/popup/script/monaco.tsx index 4714d39c..2d3a169c 100644 --- a/app/web/src/nova/ed/panel/popup/script/monaco.tsx +++ b/app/web/src/nova/ed/panel/popup/script/monaco.tsx @@ -389,8 +389,15 @@ const propTypings = (prop: FNCompDef | undefined, types: any, meta: any) => { "active", "_meta", `\ +${ + prop.typings + ? ` ${prop.typings}; -return typings;` +return typings; +` + : "" +} +` ); try { const typings = typings_fn(active, meta); @@ -406,7 +413,7 @@ return typings;` } } } catch (e) { - console.log(typings_fn.toString()); + console.log('WARNING: typings prasi error, bilang mas rizky plis...'); } } }; diff --git a/app/web/src/nova/ed/panel/popup/script/scope/scope.tsx b/app/web/src/nova/ed/panel/popup/script/scope/scope.tsx index 6bd7d914..5d37adad 100644 --- a/app/web/src/nova/ed/panel/popup/script/scope/scope.tsx +++ b/app/web/src/nova/ed/panel/popup/script/scope/scope.tsx @@ -36,6 +36,16 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => { const comp_types = {} as Record; for (const m of cur_path) { + if (m.item.component?.props) { + for (const [name, prop] of Object.entries(m.item.component.props)) { + if (prop.meta?.type === "content-element") { + vars[name] = { mode: "prop", val: "ReactElement" }; + } else { + vars[name] = { mode: "prop", val: prop.value }; + } + } + } + if (m.mitem?.parent && (m.mitem?.parent as any).get("meta")) { let prop_name = ""; const parent = m.mitem?.parent.parent as unknown as TypedArray; @@ -49,7 +59,9 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => { if (prop_name && m_prev && m_prev.item.component) { const prop_typings = m_prev.item.component.props[prop_name].typings; try { - const typings_src = prop_typings.substring(`const typings = `.length); + const typings_src = prop_typings?.substring( + `const typings = `.length + ); const typings_fn = new Function(`return ${typings_src}`); const typings = typings_fn(); if (typeof typings === "object") {