♻️(frontend) adapt custom blocks to new implementation

Last release of Blocknote introduced breaking
changes for custom blocks.
We adapted our custom blocks to the new
implementation.
"code-block" is considered as a block now, we
update the way to import and use it.
The custom blocks should be now more tiptap friendly.
This commit is contained in:
Anthony LC
2025-10-16 12:10:05 +02:00
parent aca334f81f
commit fe24c00178
30 changed files with 1720 additions and 3066 deletions

View File

@@ -20,6 +20,7 @@
"@hocuspocus/server": "2.15.2",
"@sentry/node": "10.17.0",
"@sentry/profiling-node": "10.17.0",
"@tiptap/extensions": "*",
"axios": "1.12.2",
"cors": "2.8.5",
"express": "5.1.0",
@@ -29,6 +30,7 @@
"yjs": "*"
},
"devDependencies": {
"@blocknote/core": "0.41.1",
"@hocuspocus/provider": "2.15.2",
"@types/cors": "2.8.19",
"@types/express": "5.0.3",

View File

@@ -1,4 +1,9 @@
import { PartialBlock } from '@blocknote/core';
import {
DefaultBlockSchema,
DefaultInlineContentSchema,
DefaultStyleSchema,
PartialBlock,
} from '@blocknote/core';
import { ServerBlockNoteEditor } from '@blocknote/server-util';
import { Request, Response } from 'express';
import * as Y from 'yjs';
@@ -9,7 +14,11 @@ interface ErrorResponse {
error: string;
}
const editor = ServerBlockNoteEditor.create();
const editor = ServerBlockNoteEditor.create<
DefaultBlockSchema,
DefaultInlineContentSchema,
DefaultStyleSchema
>();
export const convertHandler = async (
req: Request<object, Uint8Array | ErrorResponse, Buffer, object>,
@@ -27,7 +36,13 @@ export const convertHandler = async (
';',
)[0];
let blocks: PartialBlock[] | null = null;
let blocks:
| PartialBlock<
DefaultBlockSchema,
DefaultInlineContentSchema,
DefaultStyleSchema
>[]
| null = null;
try {
// First, convert from the input format to blocks
// application/x-www-form-urlencoded is interpreted as Markdown for backward compatibility