wip fix component
This commit is contained in:
parent
e474131a87
commit
68ef147f13
|
|
@ -23,19 +23,19 @@ export const yjs_diff_local: SAction["yjs"]["diff_local"] = async function (
|
|||
const root = doc.getMap("map").get("root") as any;
|
||||
if (root) {
|
||||
if (mode === "page") {
|
||||
// await db.page.update({
|
||||
// where: { id },
|
||||
// data: {
|
||||
// content_tree: root.toJSON(),
|
||||
// },
|
||||
// });
|
||||
await db.page.update({
|
||||
where: { id },
|
||||
data: {
|
||||
content_tree: root.toJSON(),
|
||||
},
|
||||
});
|
||||
} else if (mode === "comp") {
|
||||
// await db.component.update({
|
||||
// where: { id },
|
||||
// data: {
|
||||
// content_tree: root.toJSON(),
|
||||
// },
|
||||
// });
|
||||
await db.component.update({
|
||||
where: { id },
|
||||
data: {
|
||||
content_tree: root.toJSON(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
import { EComp } from "../../../../web/src/nova/ed/logic/ed-global";
|
||||
import { IRoot } from "../../../../web/src/utils/types/root";
|
||||
import { docs } from "../entity/docs";
|
||||
import { snapshot } from "../entity/snapshot";
|
||||
import { gzipAsync } from "../entity/zlib";
|
||||
|
||||
export const prepareComponentForPage = async (page_id: string) => {
|
||||
return {} as Record<string, EComp>;
|
||||
const doc = docs.page[page_id].doc;
|
||||
const root = doc.getMap("map").get("root")?.toJSON() as IRoot;
|
||||
|
||||
const result = {} as Record<string, EComp>;
|
||||
if (root.component_ids) {
|
||||
for (const id of root.component_ids) {
|
||||
const snap = snapshot.get("comp", id);
|
||||
if (snap) {
|
||||
result[id] = { id, snapshot: await gzipAsync(snap.bin) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -98,7 +98,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>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,13 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
|||
}
|
||||
|
||||
if (instances) {
|
||||
const instance = instances[item.id];
|
||||
let instance = instances[item.id];
|
||||
|
||||
if (!instances[item.id]) {
|
||||
instances[item.id] = {};
|
||||
instance = instances[item.id];
|
||||
}
|
||||
|
||||
instantiate({
|
||||
item,
|
||||
comp: item_comp,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export const instantiate = (arg: {
|
|||
if (item.component.props[k]) {
|
||||
newitem.component.props[k] = item.component.props[k];
|
||||
}
|
||||
|
||||
|
||||
const content = newitem.component.props[k].content;
|
||||
if (content) {
|
||||
walkChild(content, ids);
|
||||
|
|
@ -39,10 +39,7 @@ export const instantiate = (arg: {
|
|||
}
|
||||
};
|
||||
|
||||
export const walkChild = (
|
||||
item: IItem,
|
||||
ids: Exclude<FNComponent["ref_ids"], undefined>
|
||||
) => {
|
||||
export const walkChild = (item: IItem, ids: Record<string, string>) => {
|
||||
if (!item.originalId) {
|
||||
item.originalId = item.id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue