fix: extract images from rich text HTML to enable image description quick action
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 34s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 34s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import { useState, useRef, useEffect, useMemo } from 'react'
|
||||
import { Card } from '@/components/ui/card'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cn, extractImagesFromHTML } from '@/lib/utils'
|
||||
import { toast } from 'sonner'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'
|
||||
import { NoteTypeSelector } from '@/components/note-type-selector'
|
||||
@@ -145,6 +145,11 @@ export function NoteInput({
|
||||
...links.map(l => `${l.title || ''} ${l.description || ''}`)
|
||||
].join(' ').trim();
|
||||
|
||||
const allImages = useMemo(() => {
|
||||
const extracted = type === 'richtext' ? extractImagesFromHTML(content) : [];
|
||||
return Array.from(new Set([...images, ...extracted]));
|
||||
}, [images, content, type]);
|
||||
|
||||
// Auto-tagging hook
|
||||
const { suggestions, isAnalyzing } = useAutoTagging({
|
||||
content: type !== 'checklist' ? fullContentForAI : '',
|
||||
@@ -1036,7 +1041,7 @@ export function NoteInput({
|
||||
onClose={() => setAiOpen(false)}
|
||||
noteTitle={title}
|
||||
noteContent={content}
|
||||
noteImages={images}
|
||||
noteImages={allImages}
|
||||
onApplyToNote={(newContent) => setContent(newContent)}
|
||||
lastActionApplied={false}
|
||||
notebooks={notebooks.map(nb => ({ id: nb.id, name: nb.name }))}
|
||||
|
||||
Reference in New Issue
Block a user