Skip to content

Commit 73860ea

Browse files
docs: fix "Adding Formatting Toolbar Buttons" example (#1944)
1 parent 6db49b9 commit 73860ea

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/03-ui-components/02-formatting-toolbar-buttons/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Adding Formatting Toolbar Buttons
22

3-
In this example, we add a blue text/background color and code style button to the Formatting Toolbar.
3+
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.
44

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

examples/03-ui-components/02-formatting-toolbar-buttons/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function App() {
6969
{
7070
type: "paragraph",
7171
content:
72-
"Notice that the button doesn't appear when the image block above is selected, as it has no inline content.",
72+
"Notice that the buttons don't appear when the image block above is selected, as it has no inline content.",
7373
},
7474
{
7575
type: "paragraph",

examples/03-ui-components/02-formatting-toolbar-buttons/src/BlueButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export function BlueButton() {
2727
);
2828
}, editor);
2929

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

0 commit comments

Comments
 (0)