feat: fractional indexing (#7359)

* Introducing fractional indices as part of `element.index`

* Ensuring invalid fractional indices are always synchronized with the array order

* Simplifying reconciliation based on the fractional indices

* Moving reconciliation inside the `@excalidraw/excalidraw` package

---------

Co-authored-by: Marcel Mraz <marcel@excalidraw.com>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Ryan Di 2024-04-04 20:51:11 +08:00 committed by GitHub
parent bbdcd30a73
commit 32df5502ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 3640 additions and 2047 deletions

View file

@ -15,6 +15,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
@ -42,8 +43,8 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
"versionNonce": 401146281,
"version": 4,
"versionNonce": 2019559783,
"width": 30,
"x": 30,
"y": 20,
@ -63,6 +64,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -77,8 +79,8 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 30,
"y": 20,
@ -98,6 +100,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -112,8 +115,8 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 30,
"y": 20,
@ -133,6 +136,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
@ -160,8 +164,8 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 3,
"versionNonce": 401146281,
"version": 4,
"versionNonce": 2019559783,
"width": 30,
"x": 30,
"y": 20,
@ -181,6 +185,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -195,8 +200,8 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 30,
"y": 20,

View file

@ -11,6 +11,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 5`] = `
"groupIds": [],
"height": 50,
"id": "id0_copy",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -19,14 +20,14 @@ exports[`duplicate element on move when ALT is clicked > rectangle 5`] = `
"roundness": {
"type": 3,
},
"seed": 1014066025,
"seed": 238820263,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 4,
"versionNonce": 238820263,
"version": 5,
"versionNonce": 400692809,
"width": 30,
"x": 30,
"y": 20,
@ -44,6 +45,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 6`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a1",
"isDeleted": false,
"link": null,
"locked": false,
@ -58,8 +60,8 @@ exports[`duplicate element on move when ALT is clicked > rectangle 6`] = `
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 4,
"versionNonce": 1604849351,
"version": 6,
"versionNonce": 23633383,
"width": 30,
"x": -10,
"y": 60,
@ -77,6 +79,7 @@ exports[`move element > rectangle 5`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -91,8 +94,8 @@ exports[`move element > rectangle 5`] = `
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 3,
"versionNonce": 1150084233,
"version": 4,
"versionNonce": 1116226695,
"width": 30,
"x": 0,
"y": 40,
@ -115,6 +118,7 @@ exports[`move element > rectangles with binding arrow 5`] = `
"groupIds": [],
"height": 100,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -129,8 +133,8 @@ exports[`move element > rectangles with binding arrow 5`] = `
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 3,
"versionNonce": 81784553,
"version": 4,
"versionNonce": 760410951,
"width": 100,
"x": 0,
"y": 0,
@ -153,6 +157,7 @@ exports[`move element > rectangles with binding arrow 6`] = `
"groupIds": [],
"height": 300,
"id": "id1",
"index": "a1",
"isDeleted": false,
"link": null,
"locked": false,
@ -161,14 +166,14 @@ exports[`move element > rectangles with binding arrow 6`] = `
"roundness": {
"type": 3,
},
"seed": 2019559783,
"seed": 1150084233,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 6,
"versionNonce": 927333447,
"version": 7,
"versionNonce": 745419401,
"width": 300,
"x": 201,
"y": 2,
@ -192,6 +197,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"groupIds": [],
"height": 81.48231043525051,
"id": "id2",
"index": "a2",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
@ -211,7 +217,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"roundness": {
"type": 2,
},
"seed": 238820263,
"seed": 1604849351,
"startArrowhead": null,
"startBinding": {
"elementId": "id0",
@ -223,8 +229,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 11,
"versionNonce": 1051383431,
"version": 12,
"versionNonce": 1984422985,
"width": 81,
"x": 110,
"y": 49.981789081137734,

View file

@ -13,6 +13,7 @@ exports[`multi point mode in linear elements > arrow 3`] = `
"groupIds": [],
"height": 110,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": [
70,
@ -47,8 +48,8 @@ exports[`multi point mode in linear elements > arrow 3`] = `
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 7,
"versionNonce": 1505387817,
"version": 8,
"versionNonce": 23633383,
"width": 70,
"x": 30,
"y": 30,
@ -68,6 +69,7 @@ exports[`multi point mode in linear elements > line 3`] = `
"groupIds": [],
"height": 110,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": [
70,
@ -102,8 +104,8 @@ exports[`multi point mode in linear elements > line 3`] = `
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 7,
"versionNonce": 1505387817,
"version": 8,
"versionNonce": 23633383,
"width": 70,
"x": 30,
"y": 30,

View file

@ -13,6 +13,7 @@ exports[`select single element on the scene > arrow 1`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
@ -40,8 +41,8 @@ exports[`select single element on the scene > arrow 1`] = `
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
"versionNonce": 401146281,
"version": 4,
"versionNonce": 2019559783,
"width": 30,
"x": 10,
"y": 10,
@ -61,6 +62,7 @@ exports[`select single element on the scene > arrow escape 1`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
@ -88,8 +90,8 @@ exports[`select single element on the scene > arrow escape 1`] = `
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 3,
"versionNonce": 401146281,
"version": 4,
"versionNonce": 2019559783,
"width": 30,
"x": 10,
"y": 10,
@ -107,6 +109,7 @@ exports[`select single element on the scene > diamond 1`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -121,8 +124,8 @@ exports[`select single element on the scene > diamond 1`] = `
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 10,
"y": 10,
@ -140,6 +143,7 @@ exports[`select single element on the scene > ellipse 1`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -154,8 +158,8 @@ exports[`select single element on the scene > ellipse 1`] = `
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 10,
"y": 10,
@ -173,6 +177,7 @@ exports[`select single element on the scene > rectangle 1`] = `
"groupIds": [],
"height": 50,
"id": "id0",
"index": "a0",
"isDeleted": false,
"link": null,
"locked": false,
@ -187,8 +192,8 @@ exports[`select single element on the scene > rectangle 1`] = `
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,
"versionNonce": 453191,
"version": 3,
"versionNonce": 401146281,
"width": 30,
"x": 10,
"y": 10,