135
135
title: " Data Tables"
136
136
},
137
137
{
138
- path: " /EEosVXz7hywFwYimddQdu5 " ,
138
+ path: " /uEeEXzYZLWyfXxyTzaWpAN " ,
139
139
title: " Python Extensions"
140
140
},
141
141
{
@@ -1938,7 +1938,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
1938
1938
}
1939
1939
}
1940
1940
1941
- async function getMarkdown(getShareableLink = false ) {
1941
+ async function getMarkdown(getShareableLink = false , centerEquations = false ) {
1942
1942
let markdown = ` # ${appState .title }\n ` ;
1943
1943
1944
1944
if (getShareableLink ) {
@@ -1958,17 +1958,21 @@ Please include a link to this sheet in the email to assist in debugging the prob
1958
1958
modalInfo .modalOpen = false ;
1959
1959
}
1960
1960
1961
- markdown += await cellList .getMarkdown ();
1961
+ markdown += await cellList .getMarkdown (centerEquations );
1962
1962
1963
1963
return markdown ;
1964
1964
}
1965
1965
1966
- async function getDocument(docType : " docx" | " pdf" | " md" | " tex" , getShareableLink = false ) {
1967
- const markDown = " <!-- Created with EngineeringPaper.xyz -->\n " + await getMarkdown (getShareableLink );
1966
+ async function getDocument(settings : {docType: " docx" | " pdf" | " md" | " tex" ,
1967
+ getShareableLink: boolean ,
1968
+ centerEquations: boolean ,
1969
+ paperSize: " a4" | " letter" }) {
1970
+ const markDown = " <!-- Created with EngineeringPaper.xyz -->\n " +
1971
+ await getMarkdown (settings .getShareableLink , settings .centerEquations );
1968
1972
const upload_blob = new Blob ([markDown ], {type: " text/markdown" });
1969
1973
1970
- if (docType === " md" ) {
1971
- saveFileBlob (upload_blob , ` ${appState .title }.${docType } ` );
1974
+ if (settings . docType === " md" ) {
1975
+ saveFileBlob (upload_blob , ` ${appState .title }.${settings . docType } ` );
1972
1976
return
1973
1977
}
1974
1978
@@ -1979,15 +1983,21 @@ Please include a link to this sheet in the email to assist in debugging the prob
1979
1983
modalInfo = {state: " generatingDocument" , modalOpen: true , heading: " Generating Document" };
1980
1984
1981
1985
try {
1982
- const response = await fetch (` ${apiUrl }/docgen/${docType } ` , {
1986
+ let size_modifier: string ;
1987
+ if (settings .paperSize .toLowerCase () === " a4" ) {
1988
+ size_modifier = " _a4" ;
1989
+ } else {
1990
+ size_modifier = " " ;
1991
+ }
1992
+ const response = await fetch (` ${apiUrl }/docgen/${settings .docType }${size_modifier } ` , {
1983
1993
method: " POST" ,
1984
1994
body: formData
1985
1995
});
1986
1996
1987
1997
if (response .ok ) {
1988
1998
const fileBlob = await response .blob ();
1989
1999
1990
- saveFileBlob (fileBlob , ` ${appState .title }.${docType } ` );
2000
+ saveFileBlob (fileBlob , ` ${appState .title }.${settings . docType } ` );
1991
2001
1992
2002
modalInfo .modalOpen = false ;
1993
2003
} else {
@@ -2001,7 +2011,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
2001
2011
throw new Error (` ${response .status } ${errorMessage } ` );
2002
2012
}
2003
2013
} catch (error ) {
2004
- console .log (` Error creating ${docType } document: ${error } ` );
2014
+ console .log (` Error creating ${settings . docType } document: ${error } ` );
2005
2015
modalInfo = {
2006
2016
state: " error" ,
2007
2017
error: error ,
@@ -2917,7 +2927,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
2917
2927
<DownloadDocumentModal
2918
2928
bind:open ={modalInfo .modalOpen }
2919
2929
downloadSheet ={(e ) => saveSheetToFile (e .detail .saveAs )}
2920
- downloadDocument ={(e ) => getDocument (e .detail . docType , e . detail . getShareableLink )}
2930
+ downloadDocument ={(e ) => getDocument (e .detail )}
2921
2931
/>
2922
2932
{:else if modalInfo .state === " insertSheet" }
2923
2933
<InsertSheetModal
0 commit comments