diff --git a/memento-note/components/rich-text-editor.tsx b/memento-note/components/rich-text-editor.tsx index 12df1be..3d6f5b9 100644 --- a/memento-note/components/rich-text-editor.tsx +++ b/memento-note/components/rich-text-editor.tsx @@ -67,8 +67,15 @@ const slashCommands: SlashItem[] = [ { title: 'Align Left', description: 'Align text left', icon: AlignLeft, category: 'Formatting', command: (e) => e.chain().focus().setTextAlign('left').run() }, { title: 'Align Center', description: 'Center text', icon: AlignCenter, category: 'Formatting', command: (e) => e.chain().focus().setTextAlign('center').run() }, { title: 'Align Right', description: 'Align text right', icon: AlignRight, category: 'Formatting', command: (e) => e.chain().focus().setTextAlign('right').run() }, - { title: 'Superscript', description: 'Raise text above baseline', icon: SuperscriptIcon, category: 'Formatting', command: (e) => e.chain().focus().toggleSuperscript().run() }, - { title: 'Subscript', description: 'Lower text below baseline', icon: SubscriptIcon, category: 'Formatting', command: (e) => e.chain().focus().toggleSubscript().run() }, + { title: 'Superscript', description: 'Raise text above baseline', icon: SuperscriptIcon, category: 'Formatting', command: (e) => { + // Only apply when text is selected, otherwise typed text gets stuck in superscript mode + if (!e.state.selection.empty) e.chain().focus().toggleSuperscript().run() + else e.chain().focus().run() + }}, + { title: 'Subscript', description: 'Lower text below baseline', icon: SubscriptIcon, category: 'Formatting', command: (e) => { + if (!e.state.selection.empty) e.chain().focus().toggleSubscript().run() + else e.chain().focus().run() + }}, { title: 'Clarifier', description: 'Rendre le texte plus clair', icon: Lightbulb, category: 'IA Note', isAi: true, aiOption: 'clarify', command: () => {} }, { title: 'Raccourcir', description: 'Condenser le texte', icon: Scissors, category: 'IA Note', isAi: true, aiOption: 'shorten', command: () => {} }, { title: 'Améliorer', description: 'Améliorer le style', icon: Wand2, category: 'IA Note', isAi: true, aiOption: 'improve', command: () => {} }, @@ -466,7 +473,11 @@ function SlashCommandMenu({ editor, onInsertImage }: { editor: Editor; onInsertI if (!empty) { if (isOpen) closeMenu(); return } const text = editor.state.doc.textBetween(Math.max(0, from - 50), from, '\n') const m = text.match(/\/([^\s/]*)$/) - if (m) { setQuery(m[1]); setSelectedIndex(0); if (!isOpen) setIsOpen(true) } + if (m) { + setQuery(m[1]) + setSelectedIndex(0) + if (!isOpen) { setIsOpen(true); setActiveCategory(null) } // reset category filter on fresh open + } else if (isOpen) closeMenu() } editor.on('update', handler)