This commit is contained in:
Rizky 2024-08-02 11:47:18 +07:00
parent b5dabe01a2
commit 2f0125dd8e
2 changed files with 18 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import { IItem } from "../../../../utils/types/item";
import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn"; import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn";
import { Menu, MenuItem } from "../../../../utils/ui/context-menu"; import { Menu, MenuItem } from "../../../../utils/ui/context-menu";
import { EDGlobal, IMeta, PG, active } from "../../logic/ed-global"; import { EDGlobal, IMeta, PG, active } from "../../logic/ed-global";
import { ChevronDown, ChevronRight } from "../tree/node/item/indent";
import { createEditScript } from "./prop-instance/edit-script"; import { createEditScript } from "./prop-instance/edit-script";
import { EdPropInstanceButton } from "./prop-instance/prop-button"; import { EdPropInstanceButton } from "./prop-instance/prop-button";
import { EdPropInstanceCode } from "./prop-instance/prop-code"; import { EdPropInstanceCode } from "./prop-instance/prop-code";
@ -12,8 +13,8 @@ import { EdPropInstanceOptions } from "./prop-instance/prop-option";
import { reset } from "./prop-instance/prop-reset"; import { reset } from "./prop-instance/prop-reset";
import { EdPropInstanceText } from "./prop-instance/prop-text"; import { EdPropInstanceText } from "./prop-instance/prop-text";
import { EdStyleAll } from "./style/side-all"; import { EdStyleAll } from "./style/side-all";
import { ChevronDown, ChevronRight } from "../tree/node/item/indent"; import { NodeModel } from "@minoru/react-dnd-treeview";
import { ChevronLeft } from "../popup/script/workbench"; import { PropItem } from "./prop-master/tree-item";
const w = window as any; const w = window as any;
@ -89,10 +90,7 @@ export const EdSidePropInstance: FC<{ meta: IMeta }> = ({ meta }) => {
for (const [k, v] of Object.entries(meta.item.script?.props)) { for (const [k, v] of Object.entries(meta.item.script?.props)) {
if (v.value && v.value.length > 3) { if (v.value && v.value.length > 3) {
try { try {
const evn = new Function( const evn = new Function("arg", `arg["${k}"] = ${v.value}`);
"arg",
`arg["${k}"] = (() => { ${v.value} })()`
);
evn(arg); evn(arg);
} catch (e) {} } catch (e) {}
} }
@ -103,7 +101,7 @@ export const EdSidePropInstance: FC<{ meta: IMeta }> = ({ meta }) => {
try { try {
const evn = new Function( const evn = new Function(
"arg", "arg",
`arg["${k}"] = (() => { ${v.valueBuilt} })()` `arg["${k}"] = ${v.valueBuilt}`
); );
evn(arg); evn(arg);
} catch (e) { } catch (e) {

View File

@ -97,16 +97,27 @@ export const EdSidePropComp: FC<{ meta: IMeta }> = ({ meta }) => {
grouped[group].push(item); grouped[group].push(item);
} }
const final_tree: NodeModel<PropItem>[] = [];
let final_tree: NodeModel<PropItem>[] = [];
let root_tree: NodeModel<PropItem>[] = [];
for (const items of Object.values(grouped)) { for (const items of Object.values(grouped)) {
const idx = items.findIndex((e) => e.text.endsWith("__")); const idx = items.findIndex((e) => e.text.endsWith("__"));
const plucked = items.splice(idx, 1); const plucked = items.splice(idx, 1);
items.unshift(plucked[0]); items.unshift(plucked[0]);
for (const item of items) { for (const item of items) {
final_tree.push(item); if (item.data?.name.includes("__")) {
final_tree.push(item);
} else {
root_tree.push(item);
}
} }
} }
root_tree = root_tree.sort((a, b) => {
return (a.data?.prop?.idx || 0) - (b.data?.prop?.idx || 0);
});
final_tree = [...root_tree, ...final_tree];
let hide = localStorage.getItem("prasi-prop-hide")?.split(",") || []; let hide = localStorage.getItem("prasi-prop-hide")?.split(",") || [];
return ( return (