diff --git src/wp-includes/js/mce-view.js src/wp-includes/js/mce-view.js
index d3af61e..27135cf 100644
|
|
|
window.wp = window.wp || {}; |
| 41 | 41 | doc = editor.getDoc(); |
| 42 | 42 | $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { |
| 43 | 43 | var node = $( elem ); |
| 44 | | node.html( html ); |
| | 44 | node.html( html ).append( '<span data-wp-view-end class="wp-view-end"></span>' ); |
| 45 | 45 | $( self ).trigger( 'ready', elem ); |
| 46 | 46 | }); |
| 47 | 47 | } |
diff --git src/wp-includes/js/tinymce/plugins/wpview/plugin.js src/wp-includes/js/tinymce/plugins/wpview/plugin.js
index 75f7047..e2ff4fa 100644
|
|
|
tinymce.PluginManager.add( 'wpview', function( editor ) { |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | editor.on( 'BeforeAddUndo', function( event ) { |
| 144 | | if ( selected && ! toRemove ) { |
| 145 | | event.preventDefault(); |
| | 144 | var lastLevel = editor.undoManager.data[ editor.undoManager.data.length - 1 ], |
| | 145 | replace, |
| | 146 | previousContent, |
| | 147 | content; |
| | 148 | |
| | 149 | replace = function( content ) { |
| | 150 | return content.replace(/(<div[^>]+wpview-wrap[^>]+>)([^]+)(<span[^>]+data-wp-view-end[^>]+><\/span><\/div>)/mg, '$`$1 $3$\'' ); |
| | 151 | }; |
| | 152 | |
| | 153 | if ( lastLevel ) { |
| | 154 | previousContent = replace( lastLevel.content ); |
| | 155 | content = replace( event.level.content ); |
| | 156 | |
| | 157 | if ( content === previousContent ) { |
| | 158 | event.preventDefault(); |
| | 159 | } |
| 146 | 160 | } |
| 147 | 161 | }); |
| 148 | 162 | |
| … |
… |
tinymce.PluginManager.add( 'wpview', function( editor ) { |
| 157 | 171 | e.content = wp.mce.views.toViews( e.content ); |
| 158 | 172 | }); |
| 159 | 173 | |
| | 174 | editor.on( 'VisualAid', function() { |
| | 175 | wp.mce.views.render(); |
| | 176 | }); |
| | 177 | |
| 160 | 178 | // When the editor's content has been updated and the DOM has been |
| 161 | 179 | // processed, render the views in the document. |
| 162 | 180 | editor.on( 'SetContent', function( event ) { |
| 163 | 181 | var body, padNode; |
| 164 | 182 | |
| 165 | | // don't (re-)render views if the format of the content is raw |
| 166 | | // to avoid adding additional undo levels on undo/redo |
| 167 | | if ( event.format !== 'raw' ) { |
| 168 | | wp.mce.views.render(); |
| 169 | | } |
| 170 | 183 | |
| 171 | 184 | // Add padding <p> if the noneditable node is last |
| 172 | 185 | if ( event.load || ! event.set ) { |