File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 ) ;
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 ( ) {
You can’t perform that action at this time.
0 commit comments