From 018db001b49248bc2aa196c62dd6edb3575121ce Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sat, 20 Jun 2026 16:14:07 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20s=C3=A9lection=20texte=20=E2=86=92=20To?= =?UTF-8?q?ggle/Callout=20dans=20le=20BubbleMenu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand l'utilisateur sélectionne du texte (1 ou plusieurs paragraphes), la barre flottante affiche deux boutons: - ChevronsRightLeft → enveloppe dans un Toggle - MessageSquareWarning → enveloppe dans un Callout Le contenu sélectionné devient le contenu du bloc. --- memento-note/components/rich-text-editor.tsx | 29 +++++++++++++++++++ .../components/tiptap-math-extension.tsx | 2 -- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/memento-note/components/rich-text-editor.tsx b/memento-note/components/rich-text-editor.tsx index 78167bb..b1c5757 100644 --- a/memento-note/components/rich-text-editor.tsx +++ b/memento-note/components/rich-text-editor.tsx @@ -1350,6 +1350,28 @@ function BubbleToolbar({ editor, onSuggestCharts }: { editor: Editor | null; onS toast.error(msg && msg !== AI_REFORMULATE_FALLBACK ? msg : t('richTextEditor.aiReformulateFailed')) } + // Wrap the current text selection in a container block (toggle or callout) + const wrapSelectionInBlock = useCallback((blockType: string) => { + if (!editor) return + const { from, to } = editor.state.selection + if (from === to) return + + // Get the selected slice (all blocks in the range) + const slice = editor.state.doc.slice(from, to) + const content = slice.content + + // Create the container node with the selected content inside + const containerNode = editor.state.schema.nodes[blockType].create( + blockType === 'calloutBlock' ? { type: 'info' } : { opened: true }, + content, + ) + + // Replace the selection with the container + const tr = editor.state.tr + tr.replaceRangeWith(from, to, containerNode) + editor.view.dispatch(tr) + }, [editor]) + const [aiOpen, setAiOpen] = useState(false) const [aiLoading, setAiLoading] = useState(false) const [linkOpen, setLinkOpen] = useState(false) @@ -1477,6 +1499,13 @@ function BubbleToolbar({ editor, onSuggestCharts }: { editor: Editor | null; onS
+
+ + {editorState.isImage && ( <>
diff --git a/memento-note/components/tiptap-math-extension.tsx b/memento-note/components/tiptap-math-extension.tsx index 7a488c2..a542af4 100644 --- a/memento-note/components/tiptap-math-extension.tsx +++ b/memento-note/components/tiptap-math-extension.tsx @@ -296,8 +296,6 @@ export const MathEquationExtension = Node.create({ ] }, }) - }, -}) // Inline math mark — detects $...$ in text export const InlineMathExtension = Node.create({