uchill/excalidraw-server/patches/fractional-indexing+3.2.0.p...

24 lines
941 B
Diff

diff --git a/node_modules/fractional-indexing/src/index.js b/node_modules/fractional-indexing/src/index.js
index 0c26359..027e483 100644
--- a/node_modules/fractional-indexing/src/index.js
+++ b/node_modules/fractional-indexing/src/index.js
@@ -19,7 +19,8 @@ export const BASE_62_DIGITS =
function midpoint(a, b, digits) {
const zero = digits[0];
if (b != null && a >= b) {
- throw new Error(a + " >= " + b);
+ // Duplicate keys: return key after a (avoids "c1NY >= c1NY" from y-excalidraw)
+ return a + digits[1];
}
if (a.slice(-1) === zero || (b && b.slice(-1) === zero)) {
throw new Error("trailing zero");
@@ -213,7 +214,7 @@ export function generateKeyBetween(a, b, digits = BASE_62_DIGITS) {
validateOrderKey(b, digits);
}
if (a != null && b != null && a >= b) {
- throw new Error(a + " >= " + b);
+ return generateKeyBetween(a, null, digits);
}
if (a == null) {
if (b == null) {