chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions
@@ -0,0 +1,29 @@
/**
* XYWH represents the x, y, width, and height of an element or block.
*/
export type XYWH = [number, number, number, number];
/**
* SerializedXYWH is a string that represents the x, y, width, and height of a block.
*/
export type SerializedXYWH = `[${number},${number},${number},${number}]`;
export function serializeXYWH(
x: number,
y: number,
w: number,
h: number
): SerializedXYWH {
return `[${x},${y},${w},${h}]`;
}
export function deserializeXYWH(xywh: string): XYWH {
try {
return JSON.parse(xywh) as XYWH;
} catch (e) {
console.error('Failed to deserialize xywh', xywh);
console.error(e);
return [0, 0, 0, 0];
}
}