Skip to content

Commit

Permalink
BK-2174 Turn off autosave by default in editor to avoid saving revisi…
Browse files Browse the repository at this point in the history
…on issues

I moved the place where we enable the editor autosave function. It now
can be easily customised from instances
  • Loading branch information
eos87 committed Mar 2, 2017
1 parent 77314d5 commit 511ac27
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/booktype/apps/edit/static/edit/js/booktype/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@
});

// Autosave chapter
if (win.booktype.editor.data.settings.config.edit.autosave.enabled) {
if (win.booktype.editor.autosave.enabled) {
setInterval(function () {
var $editor = Aloha.getEditableById('contenteditor');
if (!_.isUndefined($editor) && $editor && $editor.isModified()) {
win.booktype.editor.edit.saveContent({minor: true})
}
}, win.booktype.editor.data.settings.config.edit.autosave.delay * 1000);
}, win.booktype.editor.autosave.delay * 1000);
}

// Tabs
Expand Down
4 changes: 0 additions & 4 deletions lib/booktype/apps/edit/static/edit/js/booktype/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@
'TABLE': ['horizontalline', 'pbreak', 'indent-left', 'indent-right'],
'PRE': ['insertImage', 'insertLink', 'horizontalline', 'pbreak', 'indent-left', 'indent-right'],
'ALL': ['insertImage', 'insertLink', 'horizontalline', 'pbreak', 'indent-left', 'indent-right']
},
'autosave': {
'enabled': true,
'delay': 10
}
},
'media': {
Expand Down
1 change: 1 addition & 0 deletions lib/booktype/apps/edit/templates/edit/edit_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
window.booktype.sputnikDispatcherURL = "{% url 'sputnik_dispatcher' %}";
window.booktype.activeProfile = "{{ ACTIVE_PROFILE }}";
window.booktype.editor.historyURL = "{% url 'edit:history' book.url_title %}";
window.booktype.editor.autosave = {{ autosave|safe }}
window.booktype.bookSettingsURL = "{% url 'edit:settings' book.url_title %}";

var settings = {
Expand Down
5 changes: 5 additions & 0 deletions lib/booktype/apps/edit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ def get_context_data(self, **kwargs):
context['is_owner'] = book.owner == self.request.user
context['publish_options'] = config.get_configuration('PUBLISH_OPTIONS')

context['autosave'] = json.dumps({
'enabled': config.get_configuration('EDITOR_AUTOSAVE_ENABLED'),
'delay': config.get_configuration('EDITOR_AUTOSAVE_DELAY')
})

return context

def get_login_url(self):
Expand Down
6 changes: 6 additions & 0 deletions lib/booktype/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
MOBI_DOCUMENT_WIDTH = 2480
EPUB_DOCUMENT_WIDTH = 2480

# editor stuff here
EDITOR_AUTOSAVE_ENABLED = False # disabled by default
EDITOR_AUTOSAVE_DELAY = 60 # time in seconds

# end editor stuff

EPUB_NOT_ALLOWED_TAGS = (
# 'strip' - drop tag, leave content
# 'drop' - drop tag, drop content
Expand Down

0 comments on commit 511ac27

Please sign in to comment.