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

Suggestion: Option to live preview without fullscreen mode #391

Open paulocheque opened 8 years ago

paulocheque commented 8 years ago

Is that possible? I believe the fullscreen mode should be independent of the live_preview mode.

We could have fullscreen only for edition, and non-fullscreen with live_preview.

OscarGodson commented 8 years ago

This should be possible with minimal use of the API. You would just make another empty div and on editor update you update the div contents

https://gist.github.com/OscarGodson/d58ef4994ee703ce6622

paulocheque commented 8 years ago

It worked perfectly! Thanks!

paulocheque commented 8 years ago

Actually this solution is a hack, right? This solution worked for me, but the preview' style does not work because we are not using the preview iframe anymore. So I have to create a new style for that. So all the documentation about themes does not work for this scenario.

paulocheque commented 8 years ago

Well, actually this solution works but it has performance problems when the text is extensive. I will check what is the solution in the fullscreen mode.

paulocheque commented 8 years ago

One of the reasons of the bad performance is the following code:

// Even if autoSave is false, we want to make sure to keep the textarea synced
// with the editor's content. One bad thing about this tho is that we're
// creating two timers now in some configurations. We keep the textarea synced
// by saving and opening the textarea content from the draft file storage.
self._textareaSaveTimer = window.setInterval(function () {
  if (!self._canSave) {
    return;
  }
  self.save(true);
}, 100);
paulocheque commented 8 years ago

Well, actually I was able to solve the performance problems with a debounce strategy during the preview update!