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