This commit is contained in:
Rizky 2024-03-23 10:05:33 +07:00
parent 0bdffb4b3a
commit 9ac42edde0
8 changed files with 26 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,13 +35,15 @@ export const EdTreeAction = ({
e.stopPropagation(); e.stopPropagation();
const meta = getMetaById(p, item.id); const meta = getMetaById(p, item.id);
if (meta) meta.mitem?.set("hidden", false); if (meta) meta.mitem?.set("hidden", false);
treeRebuild(p, { note: "show" });
p.render();
}} }}
> >
<HideAll /> <HideEditor />
</div> </div>
</Tooltip> </Tooltip>
)} )}
{item.hidden === "only-editor" && ( {/* {item.hidden === "only-editor" && (
<Tooltip content="Hidden: Only Editor"> <Tooltip content="Hidden: Only Editor">
<div <div
className="mx-1 cursor-pointer hover:opacity-60" className="mx-1 cursor-pointer hover:opacity-60"
@ -54,7 +56,7 @@ export const EdTreeAction = ({
<HideEditor /> <HideEditor />
</div> </div>
</Tooltip> </Tooltip>
)} )} */}
{(!comp.enabled || (comp.enabled && comp.id === active.comp_id)) && ( {(!comp.enabled || (comp.enabled && comp.id === active.comp_id)) && (
<Tooltip <Tooltip

View File

@ -1,6 +1,7 @@
import { IContent } from "../../../../../../../utils/types/general"; import { IContent } from "../../../../../../../utils/types/general";
import { getMetaById } from "../../../../../logic/active/get-meta"; import { getMetaById } from "../../../../../logic/active/get-meta";
import { PG } from "../../../../../logic/ed-global"; import { PG } from "../../../../../logic/ed-global";
import { treeRebuild } from "../../../../../logic/tree/build";
export const edActionHide = ( export const edActionHide = (
p: PG, p: PG,
@ -10,13 +11,8 @@ export const edActionHide = (
const mitem = getMetaById(p, item.id)?.mitem; const mitem = getMetaById(p, item.id)?.mitem;
if (mitem) { if (mitem) {
const hidden = mitem.get("hidden"); const hidden = mitem.get("hidden");
if (mode === "toggle") { if (!hidden) mitem.set("hidden", "all");
if (!hidden) mitem.set("hidden", "only-editor"); else mitem.delete("hidden");
else mitem.delete("hidden"); treeRebuild(p, { note: "hidden" });
} else {
if (!hidden) mitem.set("hidden", "all");
else if (hidden === "all") mitem.set("hidden", "only-editor");
else if (hidden === "only-editor") mitem.delete("hidden");
}
} }
}; };

View File

@ -15,6 +15,7 @@ export const instantiate = (arg: {
if (item.id) { if (item.id) {
newitem.id = item.id; newitem.id = item.id;
} }
newitem.hidden = item.hidden;
if (newitem.component) { if (newitem.component) {
if (newitem.component.props && item.component) { if (newitem.component.props && item.component) {

View File

@ -5,6 +5,7 @@ import { ErrorBox } from "../utils/error-box";
import { ViGlobal } from "./global"; import { ViGlobal } from "./global";
import { viParts } from "./parts"; import { viParts } from "./parts";
import { ViScript } from "./script"; import { ViScript } from "./script";
import get from "lodash.get";
const MAX_RENDER_IN_SECOND = 70; const MAX_RENDER_IN_SECOND = 70;
export const render_stat = { export const render_stat = {
@ -57,7 +58,6 @@ export const ViRender: FC<{
if (meta.item.hidden) return null; if (meta.item.hidden) return null;
if (meta.item.adv?.js || meta.item.component?.id) { if (meta.item.adv?.js || meta.item.component?.id) {
return ( return (
<ErrorBox meta={meta}> <ErrorBox meta={meta}>
<ViScript <ViScript

View File

@ -9,7 +9,7 @@ import { updatePropScope } from "./eval-prop";
import { extractNavigate } from "./extract-nav"; import { extractNavigate } from "./extract-nav";
import { createViLocal } from "./local"; import { createViLocal } from "./local";
import { createViPassProp } from "./passprop"; import { createViPassProp } from "./passprop";
import get from "lodash.get";
export const viEvalScript = ( export const viEvalScript = (
vi: { vi: {
page: VG["page"]; page: VG["page"];
@ -61,6 +61,7 @@ export const viEvalScript = (
...passprop, ...passprop,
}; };
if (typeof passprop === "object") { if (typeof passprop === "object") {
for (const [k, v] of Object.entries(passprop)) { for (const [k, v] of Object.entries(passprop)) {
if (typeof v === "object" && v && (v as any)._jsx) { if (typeof v === "object" && v && (v as any)._jsx) {

View File

@ -5,7 +5,7 @@ import { VG } from "../global";
import { ViRender } from "../render"; import { ViRender } from "../render";
export const createViPassProp = ( export const createViPassProp = (
vi: { meta: VG["meta"] }, vi: { meta: VG["meta"]; render: () => void },
is_layout: boolean, is_layout: boolean,
meta: IMeta, meta: IMeta,
passprop: any passprop: any
@ -52,9 +52,17 @@ export const createViPassProp = (
} }
if (is_meta) { if (is_meta) {
return children.map((item) => { return children.map((item) => {
const cmeta = vi.meta[item.id]; let cmeta = vi.meta[item.id];
if (!cmeta) {
vi.meta[item.id] = { item };
cmeta = vi.meta[item.id];
}
if (cmeta) { if (cmeta) {
if (Object.keys(cmeta.item).length === 1 && cmeta.mitem) {
cmeta.item = cmeta.mitem.toJSON() as any;
}
return ( return (
<ViRender <ViRender
key={item.id} key={item.id}

View File

@ -49,6 +49,7 @@ export const Vi: FC<{
vi.entry = entry; vi.entry = entry;
vi.on_preload = on_preload; vi.on_preload = on_preload;
w.siteurl = (pathname: string, forceOriginal?: boolean) => { w.siteurl = (pathname: string, forceOriginal?: boolean) => {
if (pathname.startsWith("http://") || pathname.startsWith("https://")) if (pathname.startsWith("http://") || pathname.startsWith("https://"))
return pathname; return pathname;