Loading...
Features
- Display keyboard shortcuts and key combinations
- Keyboard shortcut support for quick formatting
- Renders as
<kbd>
HTML element by default
Kit Usage
Installation
The fastest way to add the kbd plugin is with the BasicMarksKit
, which includes pre-configured KbdPlugin
along with other basic marks and their Plate UI components.
KbdLeaf
: Renders keyboard shortcut elements.
Add Kit
Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { BasicMarksKit } from '@/components/editor/plugins/basic-marks-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...BasicMarksKit,
],
});
Manual Usage
Installation
pnpm add @platejs/basic-nodes
Add Plugin
Include KbdPlugin
in your Plate plugins array when creating the editor.
import { KbdPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
KbdPlugin,
],
});
Configure Plugin
You can configure the KbdPlugin
with a custom component.
import { KbdPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
import { KbdLeaf } from '@/components/ui/kbd-node';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
KbdPlugin.withComponent(KbdLeaf),
],
});
withComponent
: AssignsKbdLeaf
to render keyboard shortcut elements.
Add Toolbar Button
You can add MarkToolbarButton
to your Toolbar to toggle kbd formatting.
Plugins
KbdPlugin
Plugin for keyboard input text formatting. Renders as <kbd>
HTML element by default.
Transforms
tf.kbd.toggle
Toggles the kbd formatting for the selected text.