Docs
Block Menu
Block Menu
Provides quick access to block-specific actions.
Installation
npm install @udecode/plate-selection @udecode/plate-node-id
Usage
import { BlockMenuPlugin } from '@udecode/plate-selection/react';
import { NodeIdPlugin } from '@udecode/plate-node-id';
const plugins = [
// ...otherPlugins,
NodeIdPlugin,
BlockSelectionPlugin.configure({
options: {
areaOptions: {
behaviour: {
scrolling: {
speedDivider: 1.5,
},
startThreshold: 10,
},
boundaries: '#scroll_container',
container: '#scroll_container',
selectables: '#scroll_container .slate-selectable',
selectionAreaClass: 'slate-selection-area',
},
enableContextMenu: true,
},
}),
BlockMenuPlugin.configure({
render: { aboveEditable: BlockContextMenu },
}),
]
To control the opening of the context menu for specific elements, you can use the data-plate-open-context-menu
attribute:
<PlateElement data-plate-open-context-menu={false} {...props}>
{children}
</PlateElement>
Generally, we only need to prevent right-clicking on the padding of the <Editor />
.
Examples
Plate UI
Refer to the preview above.
Plate Plus
Plugins
BlockMenuPlugin
Block menu state management.
API
editor.api.blockMenu.hide
Hides the block menu.
editor.api.blockMenu.show
Shows the block menu for a specific block.
Parameters
Collapse all
The ID of the block to show the menu for.
The position to show the menu at.
editor.api.blockMenu.showContextMenu
Shows the context menu for a specific block.
Parameters
Collapse all
The ID of the block to show the context menu for.
The position to show the context menu at.