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.
I've been playing with Epic (inside a plugin to the Pico CMS). I've got it doing some good stuff for me, but one thing that bugs me with my current solution is that it doesn't properly know if a file has been modified.
It seems Epic understands quite well when a file is modified and needs autosaving (or not). The problem I have is that the caller it's wrapped in doesn't - it uses "$(editor.getElement('editor')).on('keyup', function (){" to determine if the file needs saving, but that says the file is unsaved for any keypress (including arrow up/down, etc). As such, it sets internal state to "unsaved", but Epic will never autosave because there's nothing to save.
I'm wondering if there's a way Epic can tell me when it detects a change in the file? I checked out the 'update' event, but that doesn't seem to be it. Is there (or could there be?) an event that says "file modified"?
You could retain the original markdown text, then use the update event and determine it has changed, do a string compare with the original and voila, you know if it really changed.
I've been playing with Epic (inside a plugin to the Pico CMS). I've got it doing some good stuff for me, but one thing that bugs me with my current solution is that it doesn't properly know if a file has been modified.
It seems Epic understands quite well when a file is modified and needs autosaving (or not). The problem I have is that the caller it's wrapped in doesn't - it uses "$(editor.getElement('editor')).on('keyup', function (){" to determine if the file needs saving, but that says the file is unsaved for any keypress (including arrow up/down, etc). As such, it sets internal state to "unsaved", but Epic will never autosave because there's nothing to save.
I'm wondering if there's a way Epic can tell me when it detects a change in the file? I checked out the 'update' event, but that doesn't seem to be it. Is there (or could there be?) an event that says "file modified"?