From 045c98924d0a7ba178dbb71e8e868de135d69240 Mon Sep 17 00:00:00 2001 From: sepehr Date: Sat, 2 May 2026 22:30:38 +0200 Subject: [PATCH] feat: add superscript/subscript to BubbleMenu + fix slash menu descriptions --- memento-note/components/rich-text-editor.tsx | 21 ++++++++++---------- memento-note/locales/fr.json | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/memento-note/components/rich-text-editor.tsx b/memento-note/components/rich-text-editor.tsx index 3d6f5b9..831ab7d 100644 --- a/memento-note/components/rich-text-editor.tsx +++ b/memento-note/components/rich-text-editor.tsx @@ -67,12 +67,11 @@ 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) => { - // Only apply when text is selected, otherwise typed text gets stuck in superscript mode + { title: 'Superscript', description: 'Sélectionner du texte d’abord', icon: SuperscriptIcon, category: 'Formatting', command: (e) => { 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) => { + { title: 'Subscript', description: 'Sélectionner du texte d’abord', icon: SubscriptIcon, category: 'Formatting', command: (e) => { if (!e.state.selection.empty) e.chain().focus().toggleSubscript().run() else e.chain().focus().run() }}, @@ -246,12 +245,14 @@ function BubbleToolbar({ editor }: { editor: Editor | null }) { if (!editor) return null const marks = [ - { icon: Bold, active: editor.isActive('bold'), action: () => editor.chain().focus().toggleBold().run() }, - { icon: Italic, active: editor.isActive('italic'), action: () => editor.chain().focus().toggleItalic().run() }, - { icon: UnderlineIcon, active: editor.isActive('underline'), action: () => editor.chain().focus().toggleUnderline().run() }, - { icon: Strikethrough, active: editor.isActive('strike'), action: () => editor.chain().focus().toggleStrike().run() }, - { icon: Code, active: editor.isActive('code'), action: () => editor.chain().focus().toggleCode().run() }, - { icon: Highlighter, active: editor.isActive('highlight'), action: () => editor.chain().focus().toggleHighlight().run() }, + { icon: Bold, active: editor.isActive('bold'), action: () => editor.chain().focus().toggleBold().run(), title: 'Gras' }, + { icon: Italic, active: editor.isActive('italic'), action: () => editor.chain().focus().toggleItalic().run(), title: 'Italique' }, + { icon: UnderlineIcon, active: editor.isActive('underline'), action: () => editor.chain().focus().toggleUnderline().run(), title: 'Souligné' }, + { icon: Strikethrough, active: editor.isActive('strike'), action: () => editor.chain().focus().toggleStrike().run(), title: 'Barré' }, + { icon: Code, active: editor.isActive('code'), action: () => editor.chain().focus().toggleCode().run(), title: 'Code' }, + { icon: Highlighter, active: editor.isActive('highlight'), action: () => editor.chain().focus().toggleHighlight().run(), title: 'Surligner' }, + { icon: SuperscriptIcon, active: editor.isActive('superscript'), action: () => editor.chain().focus().toggleSuperscript().run(), title: 'Exposant' }, + { icon: SubscriptIcon, active: editor.isActive('subscript'), action: () => editor.chain().focus().toggleSubscript().run(), title: 'Indice' }, ] const handleAI = async (option: 'clarify' | 'shorten' | 'improve') => { @@ -313,7 +314,7 @@ function BubbleToolbar({ editor }: { editor: Editor | null }) { return (
{marks.map((m, i) => ( - ))} diff --git a/memento-note/locales/fr.json b/memento-note/locales/fr.json index 47fcd49..98c5253 100644 --- a/memento-note/locales/fr.json +++ b/memento-note/locales/fr.json @@ -492,9 +492,9 @@ "slashAlignRight": "Aligner à droite", "slashAlignRightDesc": "Aligner le texte à droite", "slashSuperscript": "Exposant", - "slashSuperscriptDesc": "Texte au-dessus de la ligne de base", + "slashSuperscriptDesc": "Sélectionner du texte d'abord", "slashSubscript": "Indice", - "slashSubscriptDesc": "Texte sous la ligne de base", + "slashSubscriptDesc": "Sélectionner du texte d'abord", "slashClarify": "Clarifier", "slashClarifyDesc": "Rendre le texte plus clair", "slashShorten": "Raccourcir",