diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 41118ca19d..c0ae668062 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -421,23 +421,29 @@ */ replaceMarkers: function() { this.getMarkers( function( editor, node ) { + var selected = node === editor.selection.getNode(), + $viewNode; + if ( ! this.loader && $( node ).text() !== this.text ) { editor.dom.setAttrib( node, 'data-wpview-marker', null ); return; } - editor.dom.replace( - editor.dom.createFragment( - '
' + - '

\u00a0

' + - '
' + - '
' + - '
' + - '

\u00a0

' + - '
' - ), - node + $viewNode = editor.$( + '
' + + '

\u00a0

' + + '
' + + '
' + + '
' + + '

\u00a0

' + + '
' ); + + editor.$( node ).replaceWith( $viewNode ); + + if ( selected ) { + editor.wp.setViewCursor( false, $viewNode[0] ); + } } ); }, diff --git a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js index 104006a175..44481941ae 100644 --- a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -729,6 +729,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { // Add to editor.wp editor.wp = editor.wp || {}; editor.wp.getView = getView; + editor.wp.setViewCursor = setViewCursor; // Keep for back-compat. return {