sparksuite / simplemde-markdown-editor

A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://simplemde.com
MIT License
9.89k stars 1.12k forks source link

Feature Request: "A simple save button to download the markdown file with an md extension" #772

Open lexterror opened 4 years ago

lexterror commented 4 years ago

I would like to have a save button that would download the markdown file with an "md" extension onto my computer.

Thank you!

Ionaru commented 4 years ago

This is possible using custom toolbar actions!

Btw may I suggest https://github.com/Ionaru/easy-markdown-editor, a continuation of SimpleMDE with added features and bugfixes.

For example:

new EasyMDE({
    toolbar: [{
        name: 'save',
        action: function(editor) {

            var element = document.createElement('a');
            element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(editor.value()));
            element.setAttribute('download', 'easymde.md');
            element.style.display = 'none';
            document.body.appendChild(element);
            element.click();
            document.body.removeChild(element);

        },
        className: 'fa fa-save',
        title: 'Save markdown'
    },
});