UNPKG

@explita/editor

Version:

`@explita/editor` is a versatile, modern rich-text editor built on TipTap for seamless integration into React applications. It provides extensive customization options and advanced features to cater to diverse content creation needs.

24 lines (23 loc) 1.06 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { parseWordDocument } from "../lib/utils"; import { useEditorStore } from "../store/useEditorState"; import { FaRegFileWord } from "react-icons/fa"; export function WordImport() { const { editor } = useEditorStore(); if (!editor) { return null; } const handleFileUpload = async (event) => { const file = event.target.files?.[0]; if (!file) return; try { const htmlContent = await parseWordDocument(file); editor.chain().focus().setContent(htmlContent).run(); } catch (error) { alert("Failed to import Word document. Please try again."); } }; return (_jsx("button", { type: "button", className: "toolbar-button", title: 'Import "Word" document', children: _jsxs("label", { className: "cursor-pointer", children: [_jsx(FaRegFileWord, { size: 16 }), _jsx("input", { type: "file", accept: ".docx", onChange: handleFileUpload, style: { display: "none" } })] }) })); }