Repository navigation
ref: decrease size of block-note toolbar - #25023
Conversation
WalkthroughThis change refactors the text alignment UI in shared notes: it adds a new TextAlignSelect dropdown component (left/center/right/justify), replaces the multiple TextAlignButton controls in the secondary FormattingToolbar with this select, updates BlockNote imports, injects toolbar CSS adjustments, and adds the react-icons dependency used by the new component. Sequence Diagram(s)sequenceDiagram
participant User
participant FormattingToolbar
participant TextAlignSelect
participant Editor
participant TableHandlesExtension
User->>FormattingToolbar: open alignment dropdown
FormattingToolbar->>TextAlignSelect: render options / show current alignment
User->>TextAlignSelect: choose alignment option
TextAlignSelect->>Editor: focus() and apply textAlignment to selected blocks
Editor->>TableHandlesExtension: mapTableCell() for table selection
TableHandlesExtension->>Editor: return cell mapping
Editor->>TextAlignSelect: confirm update (selection/cursor updated)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx (1)
47-52: 💤 Low value
editor.focus()called beforeupdateBlock— works but is reversed from BlockNote's own convention.BlockNote's built-in toolbar buttons consistently call
editor.focus()after making changes, not before. Calling it first here is safe in practice (React 18 event-handler batching prevents interleaved re-renders), but aligning with the library's pattern avoids subtle surprises if that batching assumption ever changes.♻️ Suggested order
onClick: () => { - editor.focus(); state.blocks.forEach((block) => { editor.updateBlock(block, { props: { textAlignment: a.value } as never }); }); + editor.focus(); },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx` around lines 47 - 52, The onClick handler currently calls editor.focus() before mutating blocks; change the order to perform the updates first and call editor.focus() afterwards so it matches BlockNote's convention — i.e., in the onClick for the text-align button, iterate state.blocks and call editor.updateBlock(block, { props: { textAlignment: a.value } }) first, then call editor.focus(); keep references to the existing symbols (onClick, state.blocks, editor.updateBlock, editor.focus) and preserve all other logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx`:
- Around line 244-249: The two new global selectors (.mantine-Button-label and
.mantine-Button-inner > .mantine-Button-section:first-child) must be scoped to
the BlockNote toolbar and the label must remain in the accessibility tree:
update the rules so they are prefixed with .bn-toolbar-row (e.g. .bn-toolbar-row
.mantine-Button-label and .bn-toolbar-row .mantine-Button-inner >
.mantine-Button-section:first-child) and replace display: none on
.mantine-Button-label with a visually-hidden approach (clip/size/overflow
technique or an existing .sr-only utility) so the label is visually hidden but
still readable by screen readers; change the selector references in
component.tsx accordingly.
In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 17-20: Replace the hardcoded English labels in the alignment items
array so they are internationalized: define messages (e.g. via defineMessages)
for "Left", "Center", "Right", "Justify", obtain intl via useIntl(), and pass
intl.formatMessage(...) as the label for each item used by
Components.FormattingToolbar.Select (the items array in component.tsx using
RiAlignLeft/RiAlignCenter/RiAlignRight/RiAlignJustify). Ensure the same message
IDs are used elsewhere in bn-shared-notes/component.tsx style for consistency
and accessibility.
---
Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 47-52: The onClick handler currently calls editor.focus() before
mutating blocks; change the order to perform the updates first and call
editor.focus() afterwards so it matches BlockNote's convention — i.e., in the
onClick for the text-align button, iterate state.blocks and call
editor.updateBlock(block, { props: { textAlignment: a.value } }) first, then
call editor.focus(); keep references to the existing symbols (onClick,
state.blocks, editor.updateBlock, editor.focus) and preserve all other logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4d091e4e-83ad-4ff7-9e9b-cbf7f9fc7898
⛔ Files ignored due to path filters (1)
bigbluebutton-html5/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsxbigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsxbigbluebutton-html5/package.json
TiagoJacobs
left a comment
There was a problem hiding this comment.
Hello @GuiLeme
A few comments:
1 - Please adjust the toolbar button alignment.
2 - Please change the button order:
a. Text size (already correct)
b. Text styles (already correct)
c. Alignment tools (needs to move)
d. Color (needs to move)
3 - Please open a PR in BlockNote proposing the alignment dropdown, and add a comment in the code with the PR link so that, if they merge it in the future, we can easily remove our custom implementation.
|
✅ Automated tests have passed! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx (1)
80-93: ⚖️ Poor tradeoffConsider extracting table cell mapping logic to reduce nesting.
The nested maps at line 82 create a 5-level nesting depth (function → forEach → else if → map → map), exceeding the typical 4-level guideline flagged by SonarCloud. While the logic is correct, extracting the table cell transformation into a helper function would improve readability and maintainability.
♻️ Optional refactor to reduce nesting
+const updateTableCellsAlignment = ( + rows: TableContent<never, never>['rows'], + cellSelection: { row: number; col: number }[], + alignment: TextAlignment +) => { + const newTable = rows.map((row) => ({ + ...row, + cells: row.cells.map((cell) => mapTableCell(cell)), + })); + + cellSelection.forEach(({ row, col }) => { + newTable[row].cells[col] = { + ...newTable[row].cells[col], + props: { + ...newTable[row].cells[col].props, + textAlignment: alignment, + }, + }; + }); + + return newTable; +}; + const setTextAlignment = useCallback( (alignment: TextAlignment) => { // ... existing code ... } else if (block.type === 'table') { const cellSelection = editor.getExtension(TableHandlesExtension)?.getCellSelection(); if (!cellSelection) return; - const newTable = (block.content as TableContent<never, never>).rows.map((row) => ({ - ...row, - cells: row.cells.map((cell) => mapTableCell(cell)), - })); - - cellSelection.cells.forEach(({ row, col }) => { - newTable[row].cells[col] = { - ...newTable[row].cells[col], - props: { - ...newTable[row].cells[col].props, - textAlignment: alignment, - }, - }; - }); + const newTable = updateTableCellsAlignment( + (block.content as TableContent<never, never>).rows, + cellSelection.cells, + alignment + ); editor.updateBlock(block, {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx` around lines 80 - 93, The current nested mapping/forEach that builds newTable and applies alignment (using mapTableCell and cellSelection) creates excessive nesting; extract the table transformation into a helper (e.g., mapTableWithAlignment or applyAlignmentToTableCells) that accepts the TableContent (block.content), the alignment value, and the cellSelection, returns the transformed rows/cells with updated props.textAlignment, and then replace the inline maps/forEach with a single call to that helper; ensure the helper reuses mapTableCell for individual cell mapping and updates targeted cells by row/col while preserving other cell props.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 80-93: The current nested mapping/forEach that builds newTable and
applies alignment (using mapTableCell and cellSelection) creates excessive
nesting; extract the table transformation into a helper (e.g.,
mapTableWithAlignment or applyAlignmentToTableCells) that accepts the
TableContent (block.content), the alignment value, and the cellSelection,
returns the transformed rows/cells with updated props.textAlignment, and then
replace the inline maps/forEach with a single call to that helper; ensure the
helper reuses mapTableCell for individual cell mapping and updates targeted
cells by row/col while preserving other cell props.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1ef1ea59-b81d-4818-baf9-d9f8d7654e43
📒 Files selected for processing (2)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsxbigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx



What does this PR do?
That is done so that the toolbar is smaller in order to render in one line for some monitors.
How to test
Play around with the alignment and block-types making sure they don't break
More
See screenshot ahead:
