wip fix root

This commit is contained in:
Rizky 2023-12-07 20:08:22 +07:00
parent 4d47bafb8e
commit 5d1e8b2ee9
4 changed files with 23 additions and 7 deletions

View File

@ -65,7 +65,7 @@ export const comp_new: SAction["comp"]["new"] = async function (
} else if (comp_id) {
const doc = docs.comp[comp_id].doc;
doc.transact(() => {
const root = doc.getMap("map").get("item");
const root = doc.getMap("map").get("root");
if (root) {
root.get("childs")?.forEach((e) => {
walk(e);

View File

@ -74,7 +74,7 @@ export const EdTreeName = ({
) : (
<div className="flex flex-col">
<Name name={node.text} is_jsx_prop={is_jsx_prop} />
<div className={"text-[9px] text-gray-500 -mt-1"}>{node.id} - {item.originalId}</div>
{/* <div className={"text-[9px] text-gray-500 -mt-1"}>{node.id} - {item.originalId}</div> */}
</div>
)}
</div>

View File

@ -39,6 +39,7 @@ export const compPropVal = (
const prop = props[name] || _prop;
let value: any = null;
if (prop.valueBuilt) {
const fn = new Function(
...Object.keys(args),
@ -60,9 +61,7 @@ export const compPropVal = (
prop.value
);
}
}
if (prop.meta?.type === "content-element") {
} else if (prop.meta?.type === "content-element") {
if (!(typeof value === "object" && !!value && value._jsx)) {
const id = `${meta.item.id}-${name}`;
if (!jsxProps[id]) {

View File

@ -68,7 +68,7 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
let meta = p.page.meta[id];
if (active.comp_id) {
meta = p.comp.list[active.comp_id].meta[id];
if (!meta) return false;
return false;
}
active.instance.comp_id = active.comp_id;
@ -81,6 +81,23 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
}
active.comp_id = comp_id;
} else {
if (active.comp_id) {
let meta = p.comp.list[active.comp_id].meta[id];
if (!meta) {
const _id = p.comp.list[active.comp_id].doc
.getMap("map")
.get("root")
?.get("id");
if (_id) {
active.item_id = _id;
p.render();
}
}
return false;
}
active.item_id = id;
}
p.render();