Skip to content

docs: Fix "Adding Formatting Toolbar Buttons" example #1944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Adding Formatting Toolbar Buttons

In this example, we add a blue text/background color and code style button to the Formatting Toolbar.
In this example, we add a blue text/background color and code style button to the Formatting Toolbar. We also make sure it only shows up when some text is selected.

**Try it out:** Select some text to open the Formatting Toolbar, and click one of the new buttons!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function App() {
{
type: "paragraph",
content:
"Notice that the button doesn't appear when the image block above is selected, as it has no inline content.",
"Notice that the buttons don't appear when the image block above is selected, as it has no inline content.",
},
{
type: "paragraph",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export function BlueButton() {
);
}, editor);

// Doesn't render unless a at least one block with inline content is
// selected. You can use a similar pattern of returning `null` to
// Doesn't render unless a at least one block with inline content is
// selected. You can use a similar pattern of returning `null` to
// conditionally render buttons based on the editor state.
const blocks = useSelectedBlocks();
if (blocks.filter((block) => block.content !== undefined)) {
if (blocks.filter((block) => block.content !== undefined).length === 0) {
return null;
}

Expand Down
Loading