-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save Paste
button should save to .md extension if paste format is markdown
#1293
Comments
Hey there, can I take up this issue ? Would appreciate it if someone could lend a few pointers on where to begin. |
Sure thing, go for it. It should not be too complicated, the filename is the first thing generated in the TopNav.downloadText method: Lines 3825 to 3834 in 28f3e54
You could look up the current format using the PasteViewer.getFormat method - you would look for it to be |
Thanks for the pointers, will keep you posted of the progress here. |
Hello, sorry wasn't able to get back in the last couple of weeks. I have made the changes to the Modified function downloadText()
{
var fileFormat = PasteViewer.getFormat() === 'markdown' ? '.md' : '.txt';
var filename = 'paste-' + Model.getPasteId() + fileFormat;
var text = PasteViewer.getText();
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
Unit Test Log:
Screenshot to show that file is downloaded as .md: Is this good to go ? |
Sure, if it is good create a pull request and we can review it and suggest changes, if needed. |
Will create a pull request from my feature branch of the forked repo to the master branch of the official repo. Hope that works ? |
Sure, it should, just do it. |
The problem
I recently opened a paste that was marked markdown, like this one.
When clicking on save paste button, I found it cool that it downloaded a file automatically with the pastes id as name. But the extension was .txt.
The solution
For regular plaintext pastes the above makes sense, but since the paste format was Markdown, and is also being displayed as markdown, maybe it'd be more intuitive and seamless if the download is also with extension .md ?
The text was updated successfully, but these errors were encountered: