OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 338 forks source link

saving the markdown input #361

Closed ThomasRoest closed 9 years ago

ThomasRoest commented 9 years ago

Hi,

How can I save the markdown input to the database, along with the generated html? I need the orignal markdown input as the user generated content is editable.

thanks

OscarGodson commented 9 years ago

There's an example in the docs under exportFile([filename],[type])

But to slightly modify it to your use case:

syncWithServerBtn.onclick = function () {
  var theMarkdown = editor.exportFile();
  var theHtml = editor.exportFile(null, 'html');
  saveToServerAjaxCall('/save', {markdown: theMarkdown, html: theHtml}, function () {
    console.log('Markdown and HTML was saved to the database.');
  });
}