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;
|
const root = doc.getMap("map").get("root") as any;
|
||||||
if (root) {
|
if (root) {
|
||||||
if (mode === "page") {
|
if (mode === "page") {
|
||||||
// await db.page.update({
|
await db.page.update({
|
||||||
// where: { id },
|
where: { id },
|
||||||
// data: {
|
data: {
|
||||||
// content_tree: root.toJSON(),
|
content_tree: root.toJSON(),
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
} else if (mode === "comp") {
|
} else if (mode === "comp") {
|
||||||
// await db.component.update({
|
await db.component.update({
|
||||||
// where: { id },
|
where: { id },
|
||||||
// data: {
|
data: {
|
||||||
// content_tree: root.toJSON(),
|
content_tree: root.toJSON(),
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,22 @@
|
||||||
import { EComp } from "../../../../web/src/nova/ed/logic/ed-global";
|
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) => {
|
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">
|
<div className="flex flex-col">
|
||||||
<Name name={node.text} is_jsx_prop={is_jsx_prop} />
|
<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>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,13 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instances) {
|
if (instances) {
|
||||||
const instance = instances[item.id];
|
let instance = instances[item.id];
|
||||||
|
|
||||||
|
if (!instances[item.id]) {
|
||||||
|
instances[item.id] = {};
|
||||||
|
instance = instances[item.id];
|
||||||
|
}
|
||||||
|
|
||||||
instantiate({
|
instantiate({
|
||||||
item,
|
item,
|
||||||
comp: item_comp,
|
comp: item_comp,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const instantiate = (arg: {
|
||||||
if (item.component.props[k]) {
|
if (item.component.props[k]) {
|
||||||
newitem.component.props[k] = item.component.props[k];
|
newitem.component.props[k] = item.component.props[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = newitem.component.props[k].content;
|
const content = newitem.component.props[k].content;
|
||||||
if (content) {
|
if (content) {
|
||||||
walkChild(content, ids);
|
walkChild(content, ids);
|
||||||
|
|
@ -39,10 +39,7 @@ export const instantiate = (arg: {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const walkChild = (
|
export const walkChild = (item: IItem, ids: Record<string, string>) => {
|
||||||
item: IItem,
|
|
||||||
ids: Exclude<FNComponent["ref_ids"], undefined>
|
|
||||||
) => {
|
|
||||||
if (!item.originalId) {
|
if (!item.originalId) {
|
||||||
item.originalId = item.id;
|
item.originalId = item.id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue