Loading...
Features
- Apply italic formatting for emphasis or stylistic purposes
- Keyboard shortcut support for quick formatting (
Cmd + I
) - Renders as
<em>
HTML element by default
Kit Usage
Installation
The fastest way to add the italic plugin is with the BasicMarksKit
, which includes pre-configured ItalicPlugin
along with other basic marks and their Plate UI components.
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 ItalicPlugin
in your Plate plugins array when creating the editor.
import { ItalicPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ItalicPlugin,
],
});
Configure Plugin
You can configure the ItalicPlugin
with custom keyboard shortcuts.
import { ItalicPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ItalicPlugin.configure({
shortcuts: { toggle: 'mod+i' },
}),
],
});
shortcuts.toggle
: Defines a keyboard shortcut to toggle italic formatting.
Add Toolbar Button
You can add MarkToolbarButton
to your Toolbar to toggle italic formatting.
Plugins
ItalicPlugin
Plugin for italic text formatting. Renders as <em>
HTML element by default.
Transforms
tf.italic.toggle
Toggles the italic formatting for the selected text.
Default Shortcut: Cmd + I