This commit is contained in:
Rizky 2023-12-29 17:02:18 +07:00
parent 624758dc69
commit 742d40f1d5
4 changed files with 38 additions and 8 deletions

View File

@ -145,20 +145,39 @@ export const code_edit: SAction["code"]["edit"] = async function (
};
const findId = (mitem: MContent | MRoot, id: string) => {
if ((mitem as MItem).get("id") === id) {
return mitem as MItem;
let found: null | MItem = null;
const m = mitem as MItem;
if (m.get("id") === id) {
return m;
}
const childs = (mitem as MItem).get("childs");
const childs = m.get("childs");
if (childs) {
let found: null | MItem = null;
childs.forEach((child) => {
const f = findId(child, id);
if (f) {
found = f;
}
});
if (found) return found;
}
if (!found) {
const mprops = m.get("component")?.get("props");
if (mprops) {
mprops.forEach((mprop) => {
if (mprop.get("meta")?.get("type") === "content-element") {
const mcontent = mprop.get("content");
if (mcontent) {
const f = findId(mcontent, id);
if (f) {
found = f;
}
}
}
});
}
}
if (found) return found;
};

View File

@ -214,6 +214,7 @@ export const EDGlobal = {
type: "item" as "item" | "prop-master" | "prop-instance",
prop_kind: "" as PropFieldKind,
prop_name: "",
on_close: () => {},
},
site: null as null | ((site_id: string) => void | Promise<void>),
site_form: null as null | {

View File

@ -189,7 +189,8 @@ export const EdScriptMonaco: FC<{}> = () => {
local.value = val || "";
local.render();
clearTimeout(scriptEdit.timeout);
scriptEdit.timeout = setTimeout(async () => {
const applyChanges = async () => {
const meta = getActiveMeta(p);
const type = p.ui.popup.script.mode;
if (meta && meta.mitem) {
@ -232,7 +233,14 @@ export const EdScriptMonaco: FC<{}> = () => {
meta.item.script = scope;
}
}
}, 1000);
};
p.ui.popup.script.on_close = () => {
clearTimeout(scriptEdit.timeout);
applyChanges();
p.ui.popup.script.on_close = () => {};
};
scriptEdit.timeout = setTimeout(applyChanges, 1000);
}}
onMount={async (editor, monaco) => {
local.monaco = monaco;

View File

@ -26,6 +26,8 @@ export const EdPopScript = () => {
delete p.script.init_local_effect[active.item_id];
}
script.on_close();
p.render();
}
}