import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import { Image } from '@tiptap/extension-image'; import { TaskItem, TaskList } from '@tiptap/extension-list'; import { TableKit } from '@tiptap/extension-table'; import { type Editor, EditorContent, useEditor, useEditorState, } from '@tiptap/react'; // eslint-disable-next-line import/no-named-as-default import StarterKit from '@tiptap/starter-kit'; import { LuBold, LuChevronDown, LuCode, LuFileCode, LuImage, LuItalic, LuLink, LuList, LuListOrdered, LuListTodo, LuMinus, LuQuote, LuRedo2, LuStrikethrough, LuTable, LuUndo2, } from 'react-icons/lu'; import { cn } from '../copilot/cn'; import { htmlToMarkdown, markdownToEditorHtml } from './markdown-editor.shared'; interface MarkdownEditorProps { value: string; onChange: (markdown: string) => void; disabled?: boolean; className?: string; } const BLOCK_OPTIONS = [ { value: 'p', label: 'Paragraph' }, { value: 'h1', label: 'Heading 1' }, { value: 'h2', label: 'Heading 2' }, { value: 'h3', label: 'Heading 3' }, { value: 'h4', label: 'Heading 4' }, ] as const; type BlockValue = (typeof BLOCK_OPTIONS)[number]['value']; function ToolButton({ onClick, active = false, disabled = false, label, children, }: { onClick: () => void; active?: boolean; disabled?: boolean; label: string; children: React.ReactNode; }): JSX.Element { return ( ); } function ToolDivider(): JSX.Element { return (