fix: reset category on menu reopen + superscript/subscript require text selection
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 44s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 44s
This commit is contained in:
@@ -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 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 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: '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: 'Superscript', description: 'Raise text above baseline', icon: SuperscriptIcon, category: 'Formatting', command: (e) => {
|
||||||
{ title: 'Subscript', description: 'Lower text below baseline', icon: SubscriptIcon, category: 'Formatting', command: (e) => e.chain().focus().toggleSubscript().run() },
|
// 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: '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: '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: () => {} },
|
{ 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 }
|
if (!empty) { if (isOpen) closeMenu(); return }
|
||||||
const text = editor.state.doc.textBetween(Math.max(0, from - 50), from, '\n')
|
const text = editor.state.doc.textBetween(Math.max(0, from - 50), from, '\n')
|
||||||
const m = text.match(/\/([^\s/]*)$/)
|
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()
|
else if (isOpen) closeMenu()
|
||||||
}
|
}
|
||||||
editor.on('update', handler)
|
editor.on('update', handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user