"use client"; import { useState, useRef, useEffect } from 'react'; import { useEditor, EditorContent, BubbleMenu, AnyExtension } from '@tiptap/react'; import StarterKit from '@tiptap/starter-kit'; import TextStyle from '@tiptap/extension-text-style'; import Color from '@tiptap/extension-color'; import Highlight from '@tiptap/extension-highlight'; import TextAlign from '@tiptap/extension-text-align'; import Footer from '../footer' import { Bold, Italic, Underline, AlignLeft, AlignCenter, AlignRight, Link, Highlighter, Type} from 'lucide-react'; const SimplePaperNote = () => { const [isEditingTitle] = useState(false); const titleInputRef = useRef(null); const editor = useEditor({ extensions: [ StarterKit.extend() as unknown as AnyExtension, TextStyle, Color, Highlight.configure({ multicolor: true }), TextAlign.configure({ types: ['heading', 'paragraph'], }), ], content: `

Start writing your thoughts here...

`, editorProps: { attributes: { class: 'prose prose-invert max-w-none focus:outline-none min-h-[calc(100vh-8rem)] p-8 text-foreground', }, }, }); const addLink = () => { const previousUrl = editor?.getAttributes('link').href; const url = window.prompt('Enter URL:', previousUrl); if (url === null) return; if (url === '') { editor?.chain().focus().extendMarkRange('link').unsetLink().run(); return; } editor?.chain().focus().extendMarkRange('link').setLink({ href: url }).run(); }; useEffect(() => { if (isEditingTitle && titleInputRef.current) { titleInputRef.current.focus(); } }, [isEditingTitle]); if (!editor) { return null; } // OneNote-like keyboard shortcuts (note editing & navigation) // Two rows, unique qkeys, avoid browser/reserved keys // File/Note operations row const shortcuts = [ [ { key: 'Q', label: 'Resume', action: () => {/* Implement resume logic here */ } }, { key: 'W', label: 'Write', action: () => {/* Implement write logic here */ } }, { key: 'E', label: 'Expand', action: () => {/* Implement expand logic here */ } }, { key: 'R', label: 'One Word', action: () => {/* Implement one word logic here */ } }, { key: 'T', label: 'As List', action: () => {} }, { key: 'Y', label: 'As Mail', action: () => {/* Implement as mail logic here */ } }, { key: 'U', label: 'Copy', action: () => document.execCommand('copy') }, { key: 'I', label: 'Paste', action: () => document.execCommand('paste') }, { key: 'O', label: 'Undo', action: () => editor?.chain().focus().undo().run() }, { key: 'P', label: 'Redo', action: () => editor?.chain().focus().redo().run() }, ], [ { key: 'A', label: 'Select', action: () => {/* Implement select logic here */ } }, { key: 'S', label: 'Select All', action: () => editor?.chain().focus().selectAll().run() }, { key: 'D', label: 'Deselect', action: () => {/* Implement deselect logic here */ } }, { key: 'G', label: 'Random', action: () => {/* Implement insert image logic here */ } }, { key: 'H', label: 'Idea', action: () => {/* Implement insert table logic here */ } }, { key: 'J', label: 'Insert Link', action: addLink }, { key: 'K', label: 'Highlight', action: () => editor?.chain().focus().toggleHighlight({ color: '#ffff00' }).run() }, { key: 'L', label: 'To-Do', action: () => {}}, { key: 'Z', label: 'Zoom In', action: () => {/* Implement zoom in logic here */ } }, { key: 'X', label: 'Zoom Out', action: () => {/* Implement zoom out logic here */ } }, ] ]; return (
{/* Paper Shadow Effect */}
{/* Floating Selection Toolbar */} {editor && (
{/* Text Formatting */}
{/* Text Alignment */}
{/* Highlight */} {/* Link */}
{/* Heading */}
)}
); }; export default SimplePaperNote;