File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 421421 */
422422 replaceMarkers : function ( ) {
423423 this . getMarkers ( function ( editor , node ) {
424+ var selected = node === editor . selection . getNode ( ) ,
425+ $viewNode ;
426+
424427 if ( ! this . loader && $ ( node ) . text ( ) !== this . text ) {
425428 editor . dom . setAttrib ( node , 'data-wpview-marker' , null ) ;
426429 return ;
427430 }
428431
429- editor . dom . replace (
430- editor . dom . createFragment (
431- '<div class="wpview-wrap" data-wpview-text="' + this . encodedText + '" data-wpview-type="' + this . type + '">' +
432- '<p class="wpview-selection-before">\u00a0</p>' +
433- '<div class="wpview-body" contenteditable="false">' +
434- '<div class="wpview-content wpview-type-' + this . type + '"></div>' +
435- '</div>' +
436- '<p class="wpview-selection-after">\u00a0</p>' +
437- '</div>'
438- ) ,
439- node
432+ $viewNode = editor . $ (
433+ '<div class="wpview-wrap" data-wpview-text="' + this . encodedText + '" data-wpview-type="' + this . type + '">' +
434+ '<p class="wpview-selection-before">\u00a0</p>' +
435+ '<div class="wpview-body" contenteditable="false">' +
436+ '<div class="wpview-content wpview-type-' + this . type + '"></div>' +
437+ '</div>' +
438+ '<p class="wpview-selection-after">\u00a0</p>' +
439+ '</div>'
440440 ) ;
441+
442+ editor . $ ( node ) . replaceWith ( $viewNode ) ;
443+
444+ if ( selected ) {
445+ editor . wp . setViewCursor ( false , $viewNode [ 0 ] ) ;
446+ }
441447 } ) ;
442448 } ,
443449
Original file line number Diff line number Diff line change @@ -729,6 +729,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
729729 // Add to editor.wp
730730 editor . wp = editor . wp || { } ;
731731 editor . wp . getView = getView ;
732+ editor . wp . setViewCursor = setViewCursor ;
732733
733734 // Keep for back-compat.
734735 return {
You can’t perform that action at this time.
0 commit comments