Skip to content

Commit 97ef2fb

Browse files
authored
Merge pull request #25 from opf/fix/slightly-better-logs
Slightly better logs
2 parents a5a7edb + ce4f59f commit 97ef2fb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/extensions/openProjectApi.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export const editorSchema = BlockNoteSchema.create().extend({
1313
},
1414
});
1515

16+
function printLog(message:string) {
17+
console.log(`[${new Date().toISOString()}] ${message}`);
18+
}
19+
1620
export function createEditor() {
1721
return ServerBlockNoteEditor.create({ schema: editorSchema });
1822
}
@@ -58,7 +62,7 @@ export class OpenProjectApi implements Extension {
5862
async onLoadDocument(data: onLoadDocumentPayload) {
5963
const { resourceUrl } = data.context;
6064

61-
console.log(`GET ${resourceUrl}`);
65+
printLog(`GET ${resourceUrl}`);
6266

6367
const response = await fetch(resourceUrl, {
6468
method: "GET",
@@ -78,6 +82,8 @@ export class OpenProjectApi implements Extension {
7882
const update = new Uint8Array(Buffer.from(jsonData.contentBinary, 'base64'));
7983
Y.applyUpdate(data.document, update);
8084
}
85+
86+
return data.document;
8187
}
8288

8389
/**
@@ -95,7 +101,7 @@ export class OpenProjectApi implements Extension {
95101
return;
96102
}
97103

98-
console.log(`PATCH ${resourceUrl}`);
104+
printLog(`PATCH ${resourceUrl}`);
99105

100106
const base64Data = Buffer.from(Y.encodeStateAsUpdate(data.document)).toString("base64");
101107

0 commit comments

Comments
 (0)