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 334 forks source link

got undefined when exportFile version:0.2.1.1 #277

Closed teamrun closed 11 years ago

teamrun commented 11 years ago

this happens occasionally: invoke exportFile method, and it returns undefined。

And then i try this method many times, appears that it return undefined every other time.

epiceditor_exportfile_undefined

is it a bug?

waiting for your reply。

OscarGodson commented 11 years ago

Could you show me some of your code that is causing the undefined to appear so I can reproduce it?

teamrun commented 11 years ago

here, i init epiceditor in html file:

seajs.use("writer.js");
var editor = new EpicEditor().load();

then, i try to get editor's content after i write something in the it in writer.js.

newBlog = editor.exportFile('html');

and the newBlog could be undefined...

teamrun commented 11 years ago

sorry to reply so late

OscarGodson commented 11 years ago

Hmm, well, exportFile('html') will try to export a file named html as plain text. Is that what you have have and want or did you want the current file to be exported as html? I assume that's what you wanted.

If you don't have a file named html it'll return undefined because there's no localStorage file with that name. If you just want the current file do:

editor.exportFile('myFileName', 'html');

You can do null if you don't know or care about the filename:

editor.exportFile(null, 'html');

I'm closing it for now since I assume this isn't a bug, you just were missing a param. If you're still having trouble reopen with more details :)