docs/(plugins)/(marks)/italic.cn.mdx
Cmd + I)<em> HTML 元素添加斜体插件最快的方式是使用 BasicMarksKit,它包含预配置的 ItalicPlugin 以及其他基础标记及其 Plate UI 组件。
将套件添加到你的插件中:
import { createPlateEditor } from 'platejs/react';
import { BasicMarksKit } from '@/components/editor/plugins/basic-marks-kit';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
...BasicMarksKit,
],
});
npm install @platejs/basic-nodes
在创建编辑器时,将 ItalicPlugin 包含到你的 Plate 插件数组中。
import { ItalicPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
ItalicPlugin,
],
});
你可以为 ItalicPlugin 配置自定义快捷键。
import { ItalicPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
ItalicPlugin.configure({
shortcuts: { toggle: 'mod+i' },
}),
],
});
shortcuts.toggle: 定义用于切换斜体格式的键盘快捷键。你可以将 MarkToolbarButton 添加到你的工具栏中来切换斜体格式。
ItalicPlugin用于斜体文本格式化的插件。默认渲染为 <em> HTML 元素。
tf.italic.toggle切换所选文本的斜体格式。
默认快捷键: Cmd + I