File tree Expand file tree Collapse file tree
src/renderer/components/editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,19 +93,30 @@ const setSrcDoc = () => {
9393 }
9494 `
9595
96- srcDoc .value = ` <html>
97- <body>${html || htmlDefault }<body>
98- <style>${cssDefault + css }<style>
99- </html>
96+ srcDoc .value = ` <!DOCTYPE html>
97+ <html>
98+ <head>
99+ <meta charset="UTF-8">
100+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
101+ <title>${snippetStore .selected ?.name }</title>
102+ </head>
103+ <body>${html || htmlDefault }</body>
104+ <style>${cssDefault + css }</style>
105+ </html>
100106 `
101107}
108+
102109setSrcDoc ()
103110
104- const onSaveToHtml = () => {
111+ const onSaveToHtml = async () => {
112+ const formatted = await ipc .invoke (' main:prettier' , {
113+ source: srcDoc .value ,
114+ parser: ' html'
115+ })
116+
105117 const a = document .createElement (' a' )
106118
107- a .href = ` data:text/plain;charset=utf-8, ${encodeURIComponent (srcDoc .value )} `
108- console .log (a )
119+ a .href = ` data:text/plain;charset=utf-8, ${encodeURIComponent (formatted )} `
109120 a .download = ` ${snippetStore .selected ?.name }.html `
110121 a .click ()
111122}
You can’t perform that action at this time.
0 commit comments