Skip to content

docs: Update custom drag handle menu example #1628

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
Apr 23, 2025
Merged
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
25 changes: 14 additions & 11 deletions examples/03-ui-components/05-side-menu-drag-handle-items/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "@blocknote/mantine/style.css";
import {
BlockColorsItem,
DragHandleMenu,
DragHandleMenuProps,
RemoveBlockItem,
SideMenu,
SideMenuController,
Expand All @@ -12,6 +13,18 @@ import {

import { ResetBlockTypeItem } from "./ResetBlockTypeItem.js";

// To avoid rendering issues, it's good practice to define your custom drag
// handle menu in a separate component, instead of inline within the `sideMenu`
// prop of `SideMenuController`.
const CustomDragHandleMenu = (props: DragHandleMenuProps) => (
<DragHandleMenu {...props}>
<RemoveBlockItem {...props}>Delete</RemoveBlockItem>
<BlockColorsItem {...props}>Colors</BlockColorsItem>
{/* Item which resets the hovered block's type. */}
<ResetBlockTypeItem {...props}>Reset Type</ResetBlockTypeItem>
</DragHandleMenu>
);

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
Expand Down Expand Up @@ -40,17 +53,7 @@ export default function App() {
<BlockNoteView editor={editor} sideMenu={false}>
<SideMenuController
sideMenu={(props) => (
<SideMenu
{...props}
dragHandleMenu={(props) => (
<DragHandleMenu {...props}>
<RemoveBlockItem {...props}>Delete</RemoveBlockItem>
<BlockColorsItem {...props}>Colors</BlockColorsItem>
{/* Item which resets the hovered block's type. */}
<ResetBlockTypeItem {...props}>Reset Type</ResetBlockTypeItem>
</DragHandleMenu>
)}
/>
<SideMenu {...props} dragHandleMenu={CustomDragHandleMenu} />
)}
/>
</BlockNoteView>
Expand Down
Loading