wip fix component
This commit is contained in:
parent
1c1ea7767d
commit
4d186c8580
|
|
@ -42,6 +42,9 @@ export const loadCompSnapshot = async (
|
|||
comp_id: string,
|
||||
snapshot: Uint8Array
|
||||
) => {
|
||||
if (p.comp.list[comp_id] && p.comp.list[comp_id].doc) {
|
||||
return;
|
||||
}
|
||||
const doc = new Y.Doc() as DComp;
|
||||
Y.applyUpdate(doc as any, decompress(snapshot));
|
||||
const mitem = doc.getMap("map").get("root");
|
||||
|
|
@ -85,7 +88,11 @@ export const loadCompSnapshot = async (
|
|||
comp_id,
|
||||
Buffer.from(compress(diff_local))
|
||||
);
|
||||
const updated = await updateComponentMeta(p, doc, comp_id);
|
||||
const updated = await updateComponentMeta(
|
||||
p,
|
||||
p.comp.list[comp_id].doc,
|
||||
comp_id
|
||||
);
|
||||
if (updated) {
|
||||
p.comp.list[comp_id].meta = updated.meta;
|
||||
p.comp.list[comp_id].tree = updated.tree;
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ export const edInitSync = (p: PG) => {
|
|||
p.comp.list[data.id].meta = updated.meta;
|
||||
p.comp.list[data.id].tree = updated.tree;
|
||||
}
|
||||
|
||||
await treeRebuild(p, { note: "sv_remote" });
|
||||
}
|
||||
p.render();
|
||||
|
|
|
|||
|
|
@ -41,13 +41,11 @@ export const mainPerItemVisit = (
|
|||
};
|
||||
|
||||
parts.props.ref = (el) => {
|
||||
if (
|
||||
el &&
|
||||
text_edit.caret &&
|
||||
(text_edit.id === meta.item.id || text_edit.id === meta.item.originalId)
|
||||
) {
|
||||
setCaret(el, text_edit.caret);
|
||||
text_edit.caret = null;
|
||||
if (el && text_edit.caret) {
|
||||
if (text_edit.id === meta.item.id) {
|
||||
setCaret(el, text_edit.caret);
|
||||
text_edit.caret = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -71,8 +69,8 @@ export const mainPerItemVisit = (
|
|||
|
||||
clearTimeout(text_edit.timeout);
|
||||
text_edit.timeout = setTimeout(() => {
|
||||
text_edit.id = meta.item.id;
|
||||
text_edit.caret = getCaret(el);
|
||||
text_edit.id = meta.item.originalId || meta.item.id;
|
||||
|
||||
if (active.comp_id && meta.parent?.comp_id === active.comp_id) {
|
||||
const comp = p.comp.list[active.comp_id];
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ export const ViRender: FC<{
|
|||
meta: IMeta;
|
||||
children?: ReactNode;
|
||||
}> = ({ meta, children }) => {
|
||||
const vi = useGlobal(ViGlobal, "VI");
|
||||
if (!meta) return null;
|
||||
|
||||
if (meta.item.adv?.js || meta.item.component?.id) {
|
||||
|
|
@ -27,7 +26,7 @@ export const ViChild: FC<{
|
|||
const vi = useGlobal(ViGlobal, "VI");
|
||||
const parts = viParts(meta);
|
||||
if (vi.visit) vi.visit(meta, parts);
|
||||
|
||||
|
||||
let renderChild = undefined;
|
||||
|
||||
if (parts.shouldRenderChild) {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ export const ViScript: FC<{ meta: IMeta; children: ReactNode }> = ({
|
|||
const scope_meta = getScopeMeta({ meta: vi.meta }, meta);
|
||||
const scope = getScopeValue(scope_meta);
|
||||
|
||||
|
||||
if (meta.item.component?.id) {
|
||||
viEvalProps(vi, meta, scope);
|
||||
}
|
||||
|
||||
if (meta.item.adv?.jsBuilt) {
|
||||
if (meta.item.adv?.js) {
|
||||
viEvalScript(vi, meta, scope);
|
||||
|
||||
if (meta.script) return meta.script.result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue