Skip to content

Commit

Permalink
feat: save as
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Feb 27, 2024
1 parent 3cfe00b commit ead873e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
22 changes: 15 additions & 7 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
const apiUrl = window.location.origin;
const currentVersion = 20240226;
const currentVersion = 20240227;
const tutorialHash = "fFjTsnFoSQMLwcvteVoNtL";
const termsVersion = 20240110;
Expand Down Expand Up @@ -554,16 +554,24 @@
loadBlankSheet();
}
break;
case "s":
case "S":
case "l":
case "L":
if (!event[$modifierKey] || modalInfo.modalOpen) {
return;
} else if (event.shiftKey) {
} else {
modalInfo = {
state: "uploadSheet",
modalOpen: true,
heading: "Save as Sharable Link"
};
}
break;
case "s":
case "S":
if (!event[$modifierKey] || modalInfo.modalOpen) {
return;
} else if (event.shiftKey) {
saveSheetToFile(true);
} else {
saveSheetToFile();
}
Expand Down Expand Up @@ -1515,7 +1523,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
// Save using a download anchor element
// Will be saved to users downloads folder
async function saveSheetToFile() {
async function saveSheetToFile(saveAs = false) {
$history = [{
url: $title,
hash: 'file',
Expand All @@ -1536,7 +1544,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
// use current file handle if user has already saved this sheet
const currentFileHandle = getFileHandleFromKey(window.history.state?.fileKey);
if (currentFileHandle && window.history.state?.fileKey === currentFileHandle.name + $title + $sheetId) {
if (!saveAs && currentFileHandle && window.history.state?.fileKey === currentFileHandle.name + $title + $sheetId) {
modalInfo = {state: "saving", modalOpen: true, heading: "Saving File"};
try {
const writable = await currentFileHandle.createWritable();
Expand Down Expand Up @@ -2679,7 +2687,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
{:else if modalInfo.state === "downloadDocument"}
<DownloadDocumentModal
bind:open={modalInfo.modalOpen}
on:downloadSheet={saveSheetToFile}
on:downloadSheet={(e) => saveSheetToFile(e.detail.saveAs)}
on:downloadDocument={(e) => getDocument(e.detail.docType, e.detail.getShareableLink)}
/>
{:else}
Expand Down
17 changes: 14 additions & 3 deletions src/DownloadDocumentModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
const dispatch = createEventDispatcher<{
downloadDocument: {docType: "docx" | "pdf" | "md" | "tex", getShareableLink: boolean};
downloadSheet: null;
downloadSheet: {saveAs: boolean};
}>();
let docType: "epxyz" | "docx" | "pdf" | "md" | "tex" = "epxyz";
let getShareableLink = false;
let saveAs = false;
async function handleSave() {
open = false;
if (docType === "epxyz") {
dispatch("downloadSheet");
dispatch("downloadSheet", {saveAs: saveAs});
} else {
dispatch("downloadDocument", {docType: docType, getShareableLink: getShareableLink});
}
Expand Down Expand Up @@ -52,12 +53,22 @@
required={true}
bind:selected={docType}
>
<RadioButton labelText="Native EngineeringPaper.xyz .epxyz Sheet File (no data leaves your computer)" value="epxyz" />
<RadioButton labelText="Native EngineeringPaper.xyz .epxyz Sheet File (no data leaves your computer)" value="epxyz"/>
<RadioButton labelText="Markdown File (no data leaves your computer)" value="md" />
<RadioButton labelText="Microsoft Word .docx File (processed on the EngineeringPaper.xyz server, no data is retained on the server)" value="docx" />
<RadioButton labelText="PDF File (processed on the EngineeringPaper.xyz server, no data is retained on the server)" value="pdf" />
<RadioButton labelText="LaTeX File (images and plots are not included, processed on the EngineeringPaper.xyz server, no data is retained on the server)" value="tex" />
</RadioButtonGroup>
{#if window.showSaveFilePicker}
<div>
<div class="bx--label">Save As</div>
<Checkbox
labelText="Prompt to change file name"
bind:checked={saveAs}
disabled={docType !== "epxyz"}
/>
</div>
{/if}
<div>
<div class="bx--label">Shareable Link</div>
<Checkbox
Expand Down
4 changes: 4 additions & 0 deletions src/KeyboardShortcuts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
</tr>
<tr>
<td class="first-column"><span class="key">{modifier}</span> + <span class="key">Shift</span> + <span class="key">S</span></td>
<td>Save current sheet to local file with a new filename instead of replacing existing file </td>
</tr>
<tr>
<td class="first-column"><span class="key">{modifier}</span> + <span class="key">L</span></td>
<td>Save current sheet to database to get a shareable link</td>
</tr>
<tr>
Expand Down
14 changes: 14 additions & 0 deletions src/Updates.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
}
</style>

<em>February 27, 2024</em>
<h4>Save As Shortcut Added and Shareable Link Shortcut Changed</h4>
<p>
When using Chrome, or a Chrome based browser such as Edge, hitting {modifier}-S
will automatically re-save the file using the same name, if it has already been
saved. The {modifier}-Shift-S keyboard shortcut can now be used to perform a Save As
operation to allow you to choose a different file name. Additionally, the Save Document
menu now includes a Save As checkbox to serve the same purpose. The {modifier}-Shift-S
keyboard shortcut was previously used to save your document as a shareable link. The
{modifier}-L keyboard shortcut can now be used the create a shareable link.
</p>

<br>

<em>February 26, 2024</em>
<h4>File Saving Improvements</h4>
<p>
Expand Down

0 comments on commit ead873e

Please sign in to comment.