diff --git a/src/components/documents/UploadMenuDialog.tsx b/src/components/documents/UploadMenuDialog.tsx index 760f755..47062b0 100644 --- a/src/components/documents/UploadMenuDialog.tsx +++ b/src/components/documents/UploadMenuDialog.tsx @@ -56,6 +56,7 @@ export function UploadMenuDialog({ // --- Import URL State --- const [webUrl, setWebUrl] = useState(''); + const [webTitle, setWebTitle] = useState(''); const [importStep, setImportStep] = useState< 'idle' | 'fetching' | 'converting' | 'uploading' | 'error' >('idle'); @@ -126,7 +127,8 @@ export function UploadMenuDialog({ setImportStep('uploading'); // Create virtual file from markdown content - const safeTitle = (scrapeResult.title || 'Imported Web Page') + const displayTitle = webTitle.trim() || scrapeResult.title || 'Imported Web Page'; + const safeTitle = displayTitle .replace(/[/\\?%*:|"<>\s]/g, '_') .substring(0, 80); const filename = `${safeTitle}.md`; @@ -137,8 +139,9 @@ export function UploadMenuDialog({ await uploadDocuments([file]); // Success - toast.success(`Successfully imported "${scrapeResult.title}"!`); + toast.success(`Successfully imported "${displayTitle}"!`); setWebUrl(''); + setWebTitle(''); setImportStep('idle'); onClose(); } catch (err) { @@ -265,18 +268,48 @@ export function UploadMenuDialog({ {activeTab === 'url' && (
-
- -
+
+
+ +
+ setWebUrl(e.target.value)} + placeholder="https://en.wikipedia.org/wiki/Speed_reading" + className="flex-1" + disabled={importStep !== 'idle' && importStep !== 'error'} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault(); + handleImportUrl(); + } + }} + /> + +
+
+ +
+ setWebUrl(e.target.value)} - placeholder="https://en.wikipedia.org/wiki/Speed_reading" - className="flex-1" + id="web-title" + type="text" + value={webTitle} + onChange={(e) => setWebTitle(e.target.value)} + placeholder="Leave empty to use article title" + className="w-full" disabled={importStep !== 'idle' && importStep !== 'error'} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -285,14 +318,8 @@ export function UploadMenuDialog({ } }} /> -
+

Extracts the central article body, removes boilerplate noise (headers, sidebars, ads), and converts it into a clean Markdown document for synchrony reading.