reconciliate order based on fractional index

This commit is contained in:
Ryan Di 2023-12-01 15:59:36 +08:00
parent 1e132e33ae
commit a7154227cf
4 changed files with 35 additions and 131 deletions

View file

@ -18,7 +18,7 @@ import throttle from "lodash.throttle";
import { newElementWith } from "../../src/element/mutateElement";
import { BroadcastedExcalidrawElement } from "./reconciliation";
import { encryptData } from "../../src/data/encryption";
import { PRECEDING_ELEMENT_KEY } from "../../src/constants";
import { normalizeFractionalIndexing } from "../../src/zindex";
class Portal {
collab: TCollabClass;
@ -150,11 +150,7 @@ class Portal {
this.broadcastedElementVersions.get(element.id)!) &&
isSyncableElement(element)
) {
acc.push({
...element,
// z-index info for the reconciler
[PRECEDING_ELEMENT_KEY]: idx === 0 ? "^" : elements[idx - 1]?.id,
});
acc.push(element);
}
return acc;
},
@ -164,7 +160,7 @@ class Portal {
const data: SocketUpdateDataSource[typeof updateType] = {
type: updateType,
payload: {
elements: syncableElements,
elements: normalizeFractionalIndexing(syncableElements),
},
};