mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 00:28:33 +00:00
20 lines
504 B
TypeScript
20 lines
504 B
TypeScript
import { readFileSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
import { applyUpdate, Doc } from 'yjs';
|
|
|
|
export function getDisplayLabel(inputPath: string) {
|
|
const resolved = path.resolve(process.cwd(), inputPath);
|
|
if (resolved === inputPath) {
|
|
return inputPath;
|
|
}
|
|
return `${inputPath} (${resolved})`;
|
|
}
|
|
|
|
export function readYjsDocFromFile(filePath: string): Doc {
|
|
const bin = readFileSync(filePath);
|
|
const doc = new Doc();
|
|
applyUpdate(doc, new Uint8Array(bin));
|
|
return doc;
|
|
}
|