Skip to content

Commit

Permalink
Support TinyMCE (v3 tested, probably v4 also).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaylett committed May 1, 2015
1 parent 3a61303 commit 70b0af5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ changes, continuing will abandon them and start creating new save points.
The contents of a form are autosaved by examining input and textarea value fields. Some javascript-heavy custom
form widgets only write to the input field they replace when the form is submitted (instead of every time the data changes).
As a result, when autosave serializes the form data, the values can be out of date.

There is support for TinyMCE which will ask it to "save" (serialize)
the contents of its editors back to their sources (we only really care
about TEXTAREA elements) before we create the autosave backup.
7 changes: 7 additions & 0 deletions autosave/static/autosave/js/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ var DjangoAutosave = (window.DjangoAutosave) ? DjangoAutosave : {};

DjangoAutosave.save = function() {
var existingData = DjangoAutosave.retrieve();
// If TinyMCE is running, ask it to save its editors' contents
// back to the places they came from.
if (typeof(tinymce) !== "undefined") {
tinymce.editors.forEach(function(editor) {
editor.save();
});
}
var data = {
formValues: DjangoAutosave.captureForm(),
timestamp: Math.round((new Date()).getTime()/1000, 0),
Expand Down

0 comments on commit 70b0af5

Please sign in to comment.