feat: raw boards dnd

This commit is contained in:
2025-07-30 10:59:39 +04:00
parent cb6a814918
commit b8d431ae99
21 changed files with 599 additions and 8 deletions

36
src/utils/lexorank.ts Normal file
View File

@ -0,0 +1,36 @@
import { LexoRank } from "lexorank";
type LexorankSortable = {
rank: string;
};
export function compareByLexorank<T extends LexorankSortable>(
a: T,
b: T
): -1 | 1 | 0 {
if (a.rank < b.rank) {
return -1;
}
if (a.rank > b.rank) {
return 1;
}
return 0;
}
export function sortByLexorank<T extends LexorankSortable>(items: T[]): T[] {
return items.sort(compareByLexorank);
}
export function getNewLexorank(
left?: LexoRank | null,
right?: LexoRank | null
): LexoRank {
if (right) {
if (left) return left?.between(right);
return right.genPrev();
}
if (left) {
return left.genNext();
}
return LexoRank.middle();
}