@@ -91,24 +91,30 @@ export default function HomePage() {
9191
9292 const handleExport = async ( format : "html" | "pdf" | "docx" ) => {
9393 try {
94- // For HTML, prompt user to choose save location
9594 let outputPath : string | undefined ;
96- if ( format === "html" ) {
97- try {
98- const { save } = await import ( "@tauri-apps/plugin-dialog" ) ;
99- const selected = await save ( {
100- defaultPath : `${ editor . activeTab . label . replace ( / \. [ ^ / . ] + $ / , "" ) || "document" } .html` ,
101- filters : [ { name : "HTML files" , extensions : [ "html" ] } ] ,
102- } ) ;
103- if ( ! selected ) return ; // User cancelled
104- outputPath = Array . isArray ( selected ) ? selected [ 0 ] : selected ;
105- } catch {
106- // In browser mode, fallback to download (no save dialog)
107- alert ( "HTML export requires Tauri desktop app for save dialog. Use download instead." ) ;
95+ try {
96+ const { save } = await import ( "@tauri-apps/plugin-dialog" ) ;
97+ const extension = format === "pdf" ? "pdf" : format === "docx" ? "docx" : "html" ;
98+ const defaultName = `${ editor . activeTab . label . replace ( / \. [ ^ / . ] + $ / , "" ) || "document" } .${ extension } ` ;
99+ const filters = [
100+ { name : "HTML files" , extensions : [ "html" ] } ,
101+ { name : "PDF files" , extensions : [ "pdf" ] } ,
102+ { name : "Word files" , extensions : [ "docx" ] } ,
103+ ] ;
104+ const selected = await save ( {
105+ defaultPath : defaultName ,
106+ filters : [ { name : `${ extension . toUpperCase ( ) } files` , extensions : [ extension ] } ] ,
107+ } ) ;
108+ if ( ! selected ) return ;
109+ outputPath = Array . isArray ( selected ) ? selected [ 0 ] : selected ;
110+ } catch {
111+ if ( format === "html" ) {
112+ alert ( "HTML export requires Tauri desktop app for save dialog. Use the browser download path instead." ) ;
108113 return ;
109114 }
115+ alert ( "PDF/DOCX export requires Tauri desktop app for save dialog." ) ;
116+ return ;
110117 }
111- // For PDF/DOCX, export directly (backend handles temp file for now)
112118 const result = await editor . exportAs ( format , outputPath ) ;
113119 if ( result ) {
114120 alert ( `Exported to:\n${ result . path } ` ) ;
0 commit comments