Skip to content

docs: Minor docs fixes #733

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
May 10, 2024
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
5 changes: 3 additions & 2 deletions docs/pages/docs/advanced/nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Make sure to use BlockNote in a [Client Component](https://nextjs.org/docs/getti

```typescript jsx
"use client"; // this registers <Editor> as a Client Component
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
import "@blocknote/core/fonts/inter.css";
import "@blocknote/react/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

// Our <Editor> component we can reuse later
export default function Editor() {
Expand Down
12 changes: 3 additions & 9 deletions examples/02-ui-components/05-side-menu-drag-handle-items/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {
RemoveBlockItem,
SideMenu,
SideMenuController,
useComponentsContext,
useCreateBlockNote,
} from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

import { ResetBlockTypeItem } from "./ResetBlockTypeItem";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
Expand All @@ -34,8 +35,6 @@ export default function App() {
],
});

const Components = useComponentsContext()!;

// Renders the editor instance.
return (
<BlockNoteView editor={editor} sideMenu={false}>
Expand All @@ -48,12 +47,7 @@ export default function App() {
<RemoveBlockItem {...props}>Delete</RemoveBlockItem>
<BlockColorsItem {...props}>Colors</BlockColorsItem>
{/* Item which resets the hovered block's type. */}
<Components.Generic.Menu.Item
onClick={() => {
editor.updateBlock(props.block, { type: "paragraph" });
}}>
Reset Type
</Components.Generic.Menu.Item>
<ResetBlockTypeItem {...props}>Reset Type</ResetBlockTypeItem>
</DragHandleMenu>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
DragHandleMenuProps,
useBlockNoteEditor,
useComponentsContext,
} from "@blocknote/react";

export function ResetBlockTypeItem(props: DragHandleMenuProps) {
const editor = useBlockNoteEditor();

const Components = useComponentsContext()!;

return (
<Components.Generic.Menu.Item
onClick={() => {
editor.updateBlock(props.block, { type: "paragraph" });
}}>
Reset Type
</Components.Generic.Menu.Item>
);
}
Loading