import { NodeViewContent, Editor, NodeViewWrapper } from "@tiptap/react" import { Icon } from "../../../components/ui/icon" import { useCallback } from "react" import { Node as ProseMirrorNode } from "@tiptap/pm/model" import { Node } from "@tiptap/core" interface TaskItemProps { editor: Editor node: ProseMirrorNode updateAttributes: (attrs: Record) => void extension: Node } export const TaskItemView: React.FC = ({ node, updateAttributes, editor, extension }) => { const handleChange = useCallback( (event: React.ChangeEvent) => { const checked = event.target.checked if (!editor.isEditable && !extension.options.onReadOnlyChecked) { return } if (editor.isEditable) { updateAttributes({ checked }) } else if (extension.options.onReadOnlyChecked) { if (!extension.options.onReadOnlyChecked(node, checked)) { event.target.checked = !checked } } }, [editor.isEditable, extension.options, node, updateAttributes] ) return (
) } export default TaskItemView