Skip to content

Commit aca334f

Browse files
committed
🔥(frontend) remove custom DividerBlock
Blocknote now has a built-in divider block, so we can remove our custom implementation.
1 parent 2003e41 commit aca334f

File tree

11 files changed

+8
-153
lines changed

11 files changed

+8
-153
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ and this project adheres to
8888
- ✨(frontend) load docs logo from public folder via url #1462
8989
- 🔧(keycloak) Fix https required issue in dev mode #1286
9090

91+
## Removed
92+
93+
- 🔥(frontend) remove custom DividerBlock ##1375
94+
9195
## [3.7.0] - 2025-09-12
9296

9397
### Added

src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -274,49 +274,6 @@ test.describe('Doc Export', () => {
274274
expect(pdfData.text).toContain('Hello World'); // This is the pdf text
275275
});
276276

277-
/**
278-
* We cannot assert the line break is visible in the pdf, but we can assert the
279-
* line break is visible in the editor and that the pdf is generated.
280-
*/
281-
test('it exports the doc with divider', async ({ page, browserName }) => {
282-
const [randomDoc] = await createDoc(page, 'export-divider', browserName, 1);
283-
284-
const editor = page.locator('.ProseMirror');
285-
await editor.click();
286-
await editor.fill('Hello World');
287-
288-
// Trigger slash menu to show menu
289-
await editor.locator('.bn-block-outer').last().fill('/');
290-
await page.getByText('Add a horizontal line').click();
291-
292-
await expect(
293-
editor.locator('.bn-block-content[data-content-type="divider"]'),
294-
).toBeVisible();
295-
296-
await page
297-
.getByRole('button', {
298-
name: 'Export the document',
299-
})
300-
.click();
301-
302-
await expect(
303-
page.getByTestId('doc-open-modal-download-button'),
304-
).toBeVisible();
305-
306-
const downloadPromise = page.waitForEvent('download', (download) => {
307-
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
308-
});
309-
310-
void page.getByTestId('doc-export-download-button').click();
311-
312-
const download = await downloadPromise;
313-
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
314-
315-
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
316-
const pdfData = await pdf(pdfBuffer);
317-
expect(pdfData.text).toContain('Hello World');
318-
});
319-
320277
test('it exports the doc with multi columns', async ({
321278
page,
322279
browserName,

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { BlockNoteToolbar } from './BlockNoteToolBar/BlockNoteToolbar';
3636
import {
3737
AccessibleImageBlock,
3838
CalloutBlock,
39-
DividerBlock,
4039
PdfBlock,
4140
UploadLoaderBlock,
4241
} from './custom-blocks';
@@ -54,7 +53,6 @@ const baseBlockNoteSchema = withPageBreak(
5453
blockSpecs: {
5554
...defaultBlockSpecs,
5655
callout: CalloutBlock,
57-
divider: DividerBlock,
5856
image: AccessibleImageBlock,
5957
pdf: PdfBlock,
6058
uploadLoader: UploadLoaderBlock,

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteSuggestionMenu.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717

1818
import {
1919
getCalloutReactSlashMenuItems,
20-
getDividerReactSlashMenuItems,
2120
getPdfReactSlashMenuItems,
2221
} from './custom-blocks';
2322
import { useGetInterlinkingMenuItems } from './custom-inline-content';
@@ -59,7 +58,6 @@ export const BlockNoteSuggestionMenu = () => {
5958
getCalloutReactSlashMenuItems(editor, t, basicBlocksName),
6059
getMultiColumnSlashMenuItems?.(editor) || [],
6160
getPageBreakReactSlashMenuItems(editor),
62-
getDividerReactSlashMenuItems(editor, t, basicBlocksName),
6361
getPdfReactSlashMenuItems(editor, t, fileBlocksName),
6462
),
6563
query,

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DividerBlock.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './AccessibleImageBlock';
22
export * from './CalloutBlock';
3-
export * from './DividerBlock';
43
export * from './PdfBlock';
54
export * from './UploadLoaderBlock';

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerDocx.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerPDF.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
export * from './calloutDocx';
22
export * from './calloutPDF';
3-
export * from './dividerDocx';
4-
export * from './dividerPDF';
53
export * from './headingPDF';
64
export * from './imageDocx';
75
export * from './imagePDF';

src/frontend/apps/impress/src/features/docs/doc-export/mappingDocx.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { docxDefaultSchemaMappings } from '@blocknote/xl-docx-exporter';
2-
import { Paragraph } from 'docx';
2+
import { TextRun } from 'docx';
33

44
import {
55
blockMappingCalloutDocx,
6-
blockMappingDividerDocx,
76
blockMappingImageDocx,
87
blockMappingQuoteDocx,
98
blockMappingUploadLoaderDocx,
@@ -16,9 +15,8 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
1615
blockMapping: {
1716
...docxDefaultSchemaMappings.blockMapping,
1817
callout: blockMappingCalloutDocx,
19-
divider: blockMappingDividerDocx,
20-
// We're using the file block mapping for PDF blocks
21-
// The types don't match exactly but the implementation is compatible
18+
// We're reusing the file block mapping for PDF blocks; both share the same
19+
// implementation signature, so we can reuse the handler directly.
2220
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2321
pdf: docxDefaultSchemaMappings.blockMapping.file as any,
2422
quote: blockMappingQuoteDocx,
@@ -27,7 +25,7 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
2725
},
2826
inlineContentMapping: {
2927
...docxDefaultSchemaMappings.inlineContentMapping,
30-
interlinkingSearchInline: () => new Paragraph(''),
28+
interlinkingSearchInline: () => new TextRun(''),
3129
interlinkingLinkInline: inlineContentMappingInterlinkingLinkDocx,
3230
},
3331
styleMapping: {

0 commit comments

Comments
 (0)