diff --git a/memento-note/components/note-editor/note-editor-context.tsx b/memento-note/components/note-editor/note-editor-context.tsx index ddc109c..10a20ba 100644 --- a/memento-note/components/note-editor/note-editor-context.tsx +++ b/memento-note/components/note-editor/note-editor-context.tsx @@ -313,19 +313,27 @@ export function NoteEditorProvider({ note, readOnly = false, fullPage = false, o }, [content, isMarkdown]) const resolveImagesForSave = useCallback((contentToSave: string): string[] => { - if (!contentToSave) return [] - if (!isMarkdown) { - return extractImagesFromHTML(contentToSave) - } else { - const urls = new Set() - const matches = contentToSave.matchAll(/!\[.*?\]\((.*?)\)/g) - for (const match of matches) { - const src = match[1]?.trim() - if (src) urls.add(src) + // Images présentes dans le contenu de l'éditeur (inline dans le HTML ou Markdown) + let contentImages: string[] = [] + if (contentToSave) { + if (!isMarkdown) { + contentImages = extractImagesFromHTML(contentToSave) + } else { + const urls = new Set() + const matches = contentToSave.matchAll(/!\[.*?\]\((.*?)\)/g) + for (const match of matches) { + const src = match[1]?.trim() + if (src) urls.add(src) + } + contentImages = Array.from(urls) } - return Array.from(urls) } - }, [isMarkdown]) + // Images "standalone" uploadées séparément (hors contenu éditeur), non supprimées + const standaloneImages = images.filter(url => !removedImageUrls.includes(url) && !contentImages.includes(url)) + // Fusion dédupliquée : images du contenu + images standalone conservées + return Array.from(new Set([...contentImages, ...standaloneImages])) + }, [isMarkdown, images, removedImageUrls]) + const handleGenerateTitles = async () => { const fullContentForAI = [ diff --git a/memento-note/components/note-editor/note-editor-toolbar.tsx b/memento-note/components/note-editor/note-editor-toolbar.tsx index e7d10a4..0d776ec 100644 --- a/memento-note/components/note-editor/note-editor-toolbar.tsx +++ b/memento-note/components/note-editor/note-editor-toolbar.tsx @@ -91,10 +91,17 @@ export function NoteEditorToolbar({ mode, onClose, onToggleAttachments, attachme } if (mode === 'fullPage') { + const handleCloseWithSave = async () => { + if (state.isDirty && !state.isSaving) { + await actions.handleSaveInPlace() + } + onClose() + } + return (