import { Node, mergeAttributes } from '@tiptap/core' import { ReactNodeViewRenderer, NodeViewWrapper, ReactNodeViewProps } from '@tiptap/react' import { motion, AnimatePresence } from 'framer-motion' import { useState } from 'react' import { Check } from 'lucide-react' interface HighlightTextAttributes { type: string; text: string; color: string; } interface HighlightTextOptions { type?: string; text: string; color: string; } export function HighlightText(props: ReactNodeViewProps) { const { text, color } = props.node.attrs as HighlightTextAttributes return ( {text} {/* 暂时空着 为后续可视化文本预留 */} ) } export const HighlightTextExtension = Node.create({ name: 'highlightText', group: 'inline', inline: true, atom: false, addAttributes() { return { type: { default: null }, text: { default: '' }, color: { default: 'blue' }, }; }, parseHTML() { return [{ tag: 'highlight-text' }]; }, renderHTML({ HTMLAttributes }) { return ['highlight-text', mergeAttributes(HTMLAttributes)]; }, addNodeView() { return ReactNodeViewRenderer(HighlightText); }, });