fixing kedap kedip
This commit is contained in:
parent
2c40b191ef
commit
706996a5f1
File diff suppressed because one or more lines are too long
|
|
@ -22,7 +22,13 @@ export const nodeRender: NodeRender<IMeta> = (node, prm) => {
|
|||
if (!node || !node.data) {
|
||||
return <></>;
|
||||
}
|
||||
const item = node.data?.item;
|
||||
let item = node.data?.item;
|
||||
|
||||
if (!item.id && node.data?.mitem) {
|
||||
node.data.item = node.data.mitem.toJSON() as any;
|
||||
item = node.data.item;
|
||||
}
|
||||
|
||||
const isComponent = item.type === "item" && item.component?.id;
|
||||
|
||||
if (p.ui.tree.item_loading.includes(item.id)) {
|
||||
|
|
@ -71,7 +77,7 @@ export const nodeRender: NodeRender<IMeta> = (node, prm) => {
|
|||
}
|
||||
|
||||
if (hide) {
|
||||
return <></>;
|
||||
return <>HIDE</>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,11 +66,14 @@ export const viParts = (
|
|||
|
||||
if (!meta) {
|
||||
if (item.type === "item" && item.component?.id) {
|
||||
console.error(`Warning component ${item.name} - ${item.component.id} failed to load.`);
|
||||
console.error(
|
||||
`Warning component ${item.name} - ${item.component.id} failed to load.`
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<ViRender
|
||||
key={id}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ export const ViRender: FC<{
|
|||
</ErrorBox>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorBox meta={meta}>
|
||||
<ViChild
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export const ViScript: FC<{
|
|||
|
||||
if (meta.item.adv?.js) {
|
||||
viEvalScript(vi, meta, is_layout, _pass, depth, parent_key);
|
||||
|
||||
if (meta.script) return meta.script.result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export const viEvalScript = (
|
|||
|
||||
const script = meta.script;
|
||||
const exports = (window as any).exports;
|
||||
|
||||
const arg = {
|
||||
useEffect,
|
||||
children: parts.props.children,
|
||||
|
|
@ -78,7 +79,7 @@ export const viEvalScript = (
|
|||
el: ReactElement;
|
||||
} => {
|
||||
let should_replace = false;
|
||||
const new_childs = [];
|
||||
let new_childs = [];
|
||||
|
||||
if (isValidElement(el)) {
|
||||
if (el.type === meta.script?.PassProp) {
|
||||
|
|
@ -90,36 +91,45 @@ export const viEvalScript = (
|
|||
},
|
||||
};
|
||||
}
|
||||
if (Array.isArray(el.props?.children)) {
|
||||
for (const child of el.props?.children) {
|
||||
if (Array.isArray(child)) {
|
||||
const sub_child = [];
|
||||
let sub_replace = false;
|
||||
for (const c of child) {
|
||||
let nc = override_children(c);
|
||||
if (nc.should_replace) {
|
||||
sub_child.push(nc.el);
|
||||
sub_replace = true;
|
||||
} else {
|
||||
sub_child.push(c);
|
||||
|
||||
if (el.props?.children) {
|
||||
if (!Array.isArray(el.props.children)) {
|
||||
el.props.children = [el.props.children];
|
||||
}
|
||||
if (Array.isArray(el.props.children)) {
|
||||
for (const child of el.props.children) {
|
||||
if (Array.isArray(child)) {
|
||||
const sub_child = [];
|
||||
let sub_replace = false;
|
||||
for (const c of child) {
|
||||
let nc = override_children(c);
|
||||
if (nc.should_replace) {
|
||||
sub_child.push(nc.el);
|
||||
sub_replace = true;
|
||||
} else {
|
||||
sub_child.push(c);
|
||||
}
|
||||
}
|
||||
if (sub_replace) {
|
||||
should_replace = true;
|
||||
new_childs.push(sub_child);
|
||||
} else {
|
||||
new_childs.push(child);
|
||||
}
|
||||
} else if (typeof child === "object" && child) {
|
||||
if (child.type === meta.script?.PassProp) {
|
||||
should_replace = true;
|
||||
new_childs.push({
|
||||
...child,
|
||||
props: {
|
||||
...child.props,
|
||||
internal_key: child.props.key,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
if (sub_replace) {
|
||||
should_replace = true;
|
||||
new_childs.push(sub_child);
|
||||
} else {
|
||||
new_childs.push(child);
|
||||
}
|
||||
} else if (typeof child === "object" && child) {
|
||||
if (child.type === meta.script?.PassProp) {
|
||||
should_replace = true;
|
||||
new_childs.push({
|
||||
...child,
|
||||
props: { ...child.props, internal_key: child.props.key },
|
||||
});
|
||||
}
|
||||
} else {
|
||||
new_childs.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,6 +146,7 @@ export const viEvalScript = (
|
|||
result = res.el;
|
||||
}
|
||||
}
|
||||
|
||||
if (script) script.result = <Suspense>{result}</Suspense>;
|
||||
},
|
||||
params,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { IMeta } from "../../../ed/logic/ed-global";
|
|||
import { VG } from "../global";
|
||||
import { modifyChild } from "./passprop";
|
||||
import { deepClone } from "web-utils";
|
||||
import { w } from "./eval-prop";
|
||||
|
||||
export const local_cached_value = {} as Record<
|
||||
string,
|
||||
|
|
@ -45,11 +46,13 @@ export const createViLocal = (
|
|||
if (!local_cached_value[curid]) {
|
||||
local_cached_value[curid] = { mounted: true, value: arg.value };
|
||||
} else if (!local_cached_value[curid].mounted) {
|
||||
for (const [k, v] of Object.entries(local_cached_value[curid].value)) {
|
||||
delete local_cached_value[curid].value[k];
|
||||
}
|
||||
for (const [k, v] of Object.entries(deepClone(arg.value))) {
|
||||
local_cached_value[curid].value[k] = v;
|
||||
if (!w.isEditor) {
|
||||
for (const [k, v] of Object.entries(local_cached_value[curid].value)) {
|
||||
delete local_cached_value[curid].value[k];
|
||||
}
|
||||
for (const [k, v] of Object.entries(deepClone(arg.value))) {
|
||||
local_cached_value[curid].value[k] = v;
|
||||
}
|
||||
}
|
||||
local_cached_value[curid].mounted = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue