From 43dae50c0d9ee4fb957bf88d2bed67dd976b2fb6 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 12 Feb 2016 04:22:03 +0000 Subject: [PATCH] TinyMCE: fix removing a space before inline tags when applying formatting shortcuts. Fixes #35798. git-svn-id: https://develop.svn.wordpress.org/trunk@36513 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wptextpattern/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js b/src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js index 6c894237d8..22e6dd2da5 100644 --- a/src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js @@ -156,13 +156,21 @@ refPattern = pattern; } + function ltrim( text ) { + if ( text ) { + return text.replace( /^\s+/, '' ); + } + + return ''; + } + function enter() { if ( refNode ) { editor.undoManager.add(); editor.undoManager.transact( function() { editor.formatter.apply( refPattern.format, {}, refNode ); - refNode.replaceData( 0, refNode.data.length, tinymce.trim( refNode.data.slice( refPattern.start.length ) ) ); + refNode.replaceData( 0, refNode.data.length, ltrim( refNode.data.slice( refPattern.start.length ) ) ); } ); // We need to wait for native events to be triggered.