Skip to content

Commit f2c389e

Browse files
committed
🐛(frontend) add default toolbar buttons
We are overriding the default toolbar to add the markdown and ai buttons. By doing that we were missing some default buttons that are useful depend on the block type. This commit adds the default buttons to the toolbar.
1 parent 305359a commit f2c389e

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to
1313

1414
- 📝Contributing.md #352
1515

16+
## Fixed
17+
18+
- 🐛(frontend) add default toolbar buttons #355
19+
1620

1721
## [1.6.0] - 2024-10-17
1822

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,43 @@ test.beforeEach(async ({ page }) => {
99
});
1010

1111
test.describe('Doc Editor', () => {
12+
test('it checks default toolbar buttons are displayed', async ({
13+
page,
14+
browserName,
15+
}) => {
16+
await createDoc(page, 'doc-toolbar', browserName, 1);
17+
18+
const editor = page.locator('.ProseMirror');
19+
await editor.click();
20+
await editor.fill('test content');
21+
22+
await editor.getByText('test content').dblclick();
23+
24+
const toolbar = page.locator('.bn-formatting-toolbar');
25+
await expect(toolbar.locator('button[data-test="bold"]')).toBeVisible();
26+
await expect(toolbar.locator('button[data-test="italic"]')).toBeVisible();
27+
await expect(
28+
toolbar.locator('button[data-test="underline"]'),
29+
).toBeVisible();
30+
await expect(toolbar.locator('button[data-test="strike"]')).toBeVisible();
31+
await expect(
32+
toolbar.locator('button[data-test="alignTextLeft"]'),
33+
).toBeVisible();
34+
await expect(
35+
toolbar.locator('button[data-test="alignTextCenter"]'),
36+
).toBeVisible();
37+
await expect(
38+
toolbar.locator('button[data-test="alignTextRight"]'),
39+
).toBeVisible();
40+
await expect(toolbar.locator('button[data-test="colors"]')).toBeVisible();
41+
await expect(
42+
toolbar.locator('button[data-test="unnestBlock"]'),
43+
).toBeVisible();
44+
await expect(
45+
toolbar.locator('button[data-test="createLink"]'),
46+
).toBeVisible();
47+
});
48+
1249
test('checks the Doc is connected to the provider server', async ({
1350
page,
1451
browserName,

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

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import '@blocknote/mantine/style.css';
22
import {
3-
BasicTextStyleButton,
4-
BlockTypeSelect,
5-
ColorStyleButton,
6-
CreateLinkButton,
73
FormattingToolbar,
84
FormattingToolbarController,
9-
NestBlockButton,
10-
TextAlignButton,
11-
UnnestBlockButton,
5+
getFormattingToolbarItems,
126
} from '@blocknote/react';
137
import React from 'react';
148

@@ -18,42 +12,15 @@ import { MarkdownButton } from './MarkdownButton';
1812
export const BlockNoteToolbar = () => {
1913
return (
2014
<FormattingToolbarController
21-
formattingToolbar={() => (
15+
formattingToolbar={({ blockTypeSelectItems }) => (
2216
<FormattingToolbar>
23-
<BlockTypeSelect key="blockTypeSelect" />
17+
{getFormattingToolbarItems(blockTypeSelectItems)}
2418

2519
{/* Extra button to do some AI powered actions */}
2620
<AIGroupButton key="AIButton" />
2721

2822
{/* Extra button to convert from markdown to json */}
2923
<MarkdownButton key="customButton" />
30-
31-
<BasicTextStyleButton basicTextStyle="bold" key="boldStyleButton" />
32-
<BasicTextStyleButton
33-
basicTextStyle="italic"
34-
key="italicStyleButton"
35-
/>
36-
<BasicTextStyleButton
37-
basicTextStyle="underline"
38-
key="underlineStyleButton"
39-
/>
40-
<BasicTextStyleButton
41-
basicTextStyle="strike"
42-
key="strikeStyleButton"
43-
/>
44-
{/* Extra button to toggle code styles */}
45-
<BasicTextStyleButton key="codeStyleButton" basicTextStyle="code" />
46-
47-
<TextAlignButton textAlignment="left" key="textAlignLeftButton" />
48-
<TextAlignButton textAlignment="center" key="textAlignCenterButton" />
49-
<TextAlignButton textAlignment="right" key="textAlignRightButton" />
50-
51-
<ColorStyleButton key="colorStyleButton" />
52-
53-
<NestBlockButton key="nestBlockButton" />
54-
<UnnestBlockButton key="unnestBlockButton" />
55-
56-
<CreateLinkButton key="createLinkButton" />
5724
</FormattingToolbar>
5825
)}
5926
/>

0 commit comments

Comments
 (0)