diff --git a/app/web/src/nova/ed/logic/tree/assign-mitem.ts b/app/web/src/nova/ed/logic/tree/assign-mitem.ts index af0d3f67..d809bd24 100644 --- a/app/web/src/nova/ed/logic/tree/assign-mitem.ts +++ b/app/web/src/nova/ed/logic/tree/assign-mitem.ts @@ -1,8 +1,8 @@ +import { createId } from "@paralleldrive/cuid2"; import { TypedMap } from "yjs-types"; import { IItem, MItem } from "../../../../utils/types/item"; import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn"; -import { IMeta, PG } from "../ed-global"; -import { createId } from "@paralleldrive/cuid2"; +import { IMeta } from "../ed-global"; export const assignMitem = (arg: { m: IMeta; diff --git a/app/web/src/nova/ed/panel/tree/node/item/action.tsx b/app/web/src/nova/ed/panel/tree/node/item/action.tsx index 0a8f29e3..eccf614c 100644 --- a/app/web/src/nova/ed/panel/tree/node/item/action.tsx +++ b/app/web/src/nova/ed/panel/tree/node/item/action.tsx @@ -25,9 +25,23 @@ export const EdTreeAction = ({ if (!mode && item.adv?.css) mode = "css"; if (!mode && item.adv?.html) mode = "html"; + let child_jsx_has_script = false; + const child_id = item.component?.props.child.content?.id; + if (child_id) { + const meta = getMetaById(p, child_id); + const item = meta?.item; + child_jsx_has_script = true; + if (item) { + mode = ""; + if (item.adv?.js) mode = "js"; + if (!mode && item.adv?.css) mode = "css"; + if (!mode && item.adv?.html) mode = "html"; + } + } + return (
- {item.hidden === "all" && ( + {!!item.hidden && (
)} */} - {(!comp.enabled || (comp.enabled && comp.id === active.comp_id)) && ( + {(!comp.enabled || + (comp.enabled && comp.id === active.comp_id) || + child_jsx_has_script) && ( { + onClick={(e) => { + if (item.component?.props.child.content?.id) { + e.stopPropagation(); + e.preventDefault(); + + active.item_id = item.component.props.child.content.id; + p.ui.popup.script.open = true; + p.ui.popup.script.type = "item"; + p.ui.popup.script.mode = (mode || "js") as any; + p.render(); + + return; + } + p.ui.popup.script.open = true; p.ui.popup.script.type = "item"; p.ui.popup.script.mode = (mode || "js") as any; 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 f4852ca6..5c71545f 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 @@ -5,6 +5,7 @@ import { IItem, MItem } from "../../../../../../utils/types/item"; import { Tooltip } from "../../../../../../utils/ui/tooltip"; import { EDGlobal, IMeta, PG, active } from "../../../../logic/ed-global"; import { treeRebuild } from "../../../../logic/tree/build"; +import { fillID } from "../../../../logic/tree/fill-id"; export const EdTreeName = ({ node, @@ -116,7 +117,7 @@ export const EdTreeName = ({ } }} onChange={(e) => { - local.rename = e.target.value + local.rename = e.target.value; p.render(); }} /> @@ -237,7 +238,7 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => { } if (mitem) { - const genJSX = findDefaultJSX(p, mitem); + const genJSX = fillID(findDefaultJSX(p, mitem)); const ijson = mitem.toJSON() as IItem; mitem.doc?.transact(() => { @@ -250,16 +251,6 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => { id: ijson.id, hidden: false, originalId: ijson.originalId, - ...(is_child - ? { - adv: { - css: "", - js: "<>{children}", - jsBuilt: - "render(/* @__PURE__ */ React.createElement(React.Fragment, null, children));\n", - }, - } - : {}), }); }); treeRebuild(p);