┌───────────────────────────────────────────────────────────────────┐ │ 📄 shadcn/directory/udecode/plate/(plugins)/(serializing)/docx.cn │ └───────────────────────────────────────────────────────────────────┘
╔══════════════════════════════════════════════════════════════════════════════════════════════╗
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║
添加 DOCX 导入功能的最快方式是使用 DocxKit,它包含预配置的 DocxPlugin 和 JuicePlugin,用于处理 DOCX 内容和 CSS 处理。
import { createPlateEditor } from 'platejs/react';
import { DocxKit } from '@/components/editor/plugins/docx-kit';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
...DocxKit,
],
});
</Steps>
npm install @platejs/docx @platejs/juice
import { DocxPlugin } from '@platejs/docx';
import { JuicePlugin } from '@platejs/juice';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
DocxPlugin,
JuicePlugin,
],
});
import { DocxPlugin } from '@platejs/docx';
import { JuicePlugin } from '@platejs/juice';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...其他插件,
DocxPlugin, // 处理 DOCX 内容转换
JuicePlugin, // 将 CSS 属性内联到 style 属性中
],
});
DocxPlugin: 处理粘贴的 DOCX 内容并转换为 Plate 格式JuicePlugin: 将 CSS 属性内联到 style 属性中以提高兼容性当用户从 Microsoft Word 粘贴内容时,DOCX 插件会自动:
该插件与粘贴功能无缝协作 - 安装后无需额外代码。
用于在粘贴操作中处理 DOCX 内容的插件。
用于将 CSS 属性内联到 HTML 元素中的插件。将外部 CSS 样式转换为内联的 style 属性。这对于 DOCX 处理至关重要,因为它能确保从 Word 文档粘贴内容时保留样式信息。
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║
╚══════════════════════════════════════════════════════════════════════════════════════════════╝