diff --git a/app/web/src/nova/ed/ed-mid.tsx b/app/web/src/nova/ed/ed-mid.tsx index 5da8d715..c27fb0e1 100644 --- a/app/web/src/nova/ed/ed-mid.tsx +++ b/app/web/src/nova/ed/ed-mid.tsx @@ -8,6 +8,7 @@ import { EdPagePicker } from "./panel/header/mid/page-picker"; import { TopBtn } from "./panel/header/top-btn"; import { useGlobal } from "web-utils"; import { ResponsiveToggle } from "./panel/header/right/responsive-toggle"; +import { EdCompEditable } from "./panel/header/mid/comp-editable"; export const EdMid: FC<{}> = () => { const ed = useGlobal(EDGlobal, "EDITORF"); @@ -31,6 +32,7 @@ export const EdMid: FC<{}> = () => { +
diff --git a/app/web/src/nova/ed/logic/ed-global.ts b/app/web/src/nova/ed/logic/ed-global.ts index 9761f18e..a35a9036 100644 --- a/app/web/src/nova/ed/logic/ed-global.ts +++ b/app/web/src/nova/ed/logic/ed-global.ts @@ -197,6 +197,7 @@ export const EDGlobal = { code: {} as Record, global_prop: [] as string[], ui: { + comp_editable: localStorage.getItem("prasi-comp-editable") === "yes", zoom: localStorage.zoom || "100%", side: { prop: true }, layout: { diff --git a/app/web/src/nova/ed/panel/header/mid/comp-editable.tsx b/app/web/src/nova/ed/panel/header/mid/comp-editable.tsx new file mode 100644 index 00000000..e92e9afd --- /dev/null +++ b/app/web/src/nova/ed/panel/header/mid/comp-editable.tsx @@ -0,0 +1,45 @@ +import { useGlobal } from "web-utils"; +import { EDGlobal } from "../../../logic/ed-global"; +import { TopBtn } from "../top-btn"; + +export const EdCompEditable = () => { + const p = useGlobal(EDGlobal, "EDITOR"); + + const size = 12; + return ( + { + p.ui.comp_editable = !p.ui.comp_editable; + localStorage.setItem( + "prasi-comp-editable", + p.ui.comp_editable ? "yes" : "no" + ); + p.render(); + }} + style="slim" + > +
+
` + : ``, + }} + >
+
+
Component
+
{p.ui.comp_editable ? "Editable" : "Locked"}
+
+
+
+ ); +}; diff --git a/app/web/src/nova/ed/panel/side/prop-instance.tsx b/app/web/src/nova/ed/panel/side/prop-instance.tsx index cc2fc57f..cc13fd12 100644 --- a/app/web/src/nova/ed/panel/side/prop-instance.tsx +++ b/app/web/src/nova/ed/panel/side/prop-instance.tsx @@ -79,33 +79,35 @@ export const EdSidePropInstance: FC<{ meta: IMeta }> = ({ meta }) => {
{_meta.item.name}
-
{ - const item = _meta.item as IItem; + {p.ui.comp_editable && ( +
{ + const item = _meta.item as IItem; - const comp_id = item.component?.id; + const comp_id = item.component?.id; - if (comp_id) { - if (!p.comp.list[comp_id]) return; + if (comp_id) { + if (!p.comp.list[comp_id]) return; - active.instance.item_id = item.id; - active.instance.comp_id = active.comp_id; + active.instance.item_id = item.id; + active.instance.comp_id = active.comp_id; - active.comp_id = comp_id || ""; - const root = p.comp.list[comp_id].tree.find( - (e) => e.parent === "root" - ); - if (root && typeof root.id === "string") { - active.item_id = root.id || ""; + active.comp_id = comp_id || ""; + const root = p.comp.list[comp_id].tree.find( + (e) => e.parent === "root" + ); + if (root && typeof root.id === "string") { + active.item_id = root.id || ""; + } + + p.render(); } - - p.render(); - } - }} - > - Edit Component -
+ }} + > + Edit Component +
+ )}
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 1bccb295..5d6fac5c 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 @@ -97,7 +97,7 @@ export const EdTreeAction = ({ {comp.enabled && ( <> - {comp.id !== active.comp_id && ( + {comp.id !== active.comp_id && p.ui.comp_editable && (