Skip to content

Commit 9cdc4e1

Browse files
committed
Live preview updates; use custom CSS to see. fixes #22
1 parent eb5e2db commit 9cdc4e1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

martor/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'imgur': 'true', # to enable/disable imgur/custom uploader.
88
'mention': 'false', # to enable/disable mention
99
'jquery': 'true', # to include/revoke jquery (require for admin default django)
10+
'living': 'true', # to enable/disable live updates in preview
1011
}
1112
)
1213

martor/static/martor/js/martor.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@
140140
// update the preview if this menu is clicked
141141
var currentTab = $('.tab.segment[data-tab=preview-tab-'+field_name+']');
142142
var previewTabButton = $('.item[data-tab=preview-tab-'+field_name+']');
143-
previewTabButton.click(function(){
144-
// hide the `.martor-toolbar` for this current editor if under preview.
145-
$(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
146-
143+
refreshPreview = function() {
147144
var value = editor.getValue();
148145
var form = new FormData();
149146
form.append('content', value);
@@ -167,7 +164,15 @@
167164
console.log("error", response);
168165
}
169166
});
167+
};
168+
previewTabButton.click(function(){
169+
// hide the `.martor-toolbar` for this current editor if under preview.
170+
$(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
171+
refreshPreview();
170172
});// end click `previewTabButton`
173+
if (editorConfig.living === 'true') {
174+
editor.on('change', refreshPreview);
175+
}
171176

172177
var editorTabButton = $('.item[data-tab=editor-tab-'+field_name+']');
173178
editorTabButton.click(function(){

0 commit comments

Comments
 (0)