From 7592ee11bd83846984d81a39b04af894c510c10b Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 15 Jan 2017 02:40:30 +0000 Subject: [PATCH] TinyMCE: when inserting a wpview, place the caret after is so the user can continue typing without interruption. Props iseulde. Fixes #39337. git-svn-id: https://develop.svn.wordpress.org/trunk@39903 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 8c8de56a0e..16d860d470 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -428,6 +428,7 @@ */ replaceMarkers: function() { this.getMarkers( function( editor, node ) { + var selected = node === editor.selection.getNode(); var $viewNode; if ( ! this.loader && $( node ).text() !== this.text ) { @@ -440,6 +441,13 @@ ); editor.$( node ).replaceWith( $viewNode ); + + if ( selected ) { + setTimeout( function() { + editor.selection.select( $viewNode[0] ); + editor.selection.collapse(); + } ); + } } ); },