diff --git a/components/ui/main-editor/HighlightText.tsx b/components/ui/main-editor/HighlightText.tsx index cfdb317..4097535 100644 --- a/components/ui/main-editor/HighlightText.tsx +++ b/components/ui/main-editor/HighlightText.tsx @@ -17,13 +17,25 @@ interface HighlightTextOptions { } export function HighlightText(props: ReactNodeViewProps) { - const { text, color } = props.node.attrs as HighlightTextAttributes + const { text: initialText, color } = props.node.attrs as HighlightTextAttributes + const [text, setText] = useState(initialText) + + const handleInput = (e: React.FormEvent) => { + const newText = e.currentTarget.textContent || '' + setText(newText) + // 通知Tiptap更新内容 + props.updateAttributes({ + text: newText + }) + } return ( {text}