From 510cff5fe627a56f80bf91cc01bd8c5e2743bde2 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 9 Jun 2016 00:24:56 +0000 Subject: [PATCH] Editor quickTags: when the user selects some text by triple-clicking, then wraps it in a tag, and the last selected char is `\n`, insert the closing tag before the line break. Props JoshuaGoodwin azaozz. Fixes #29571. git-svn-id: https://develop.svn.wordpress.org/trunk@37661 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/quicktags.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/js/quicktags.js b/src/wp-includes/js/quicktags.js index 11f8785059..6d00901a78 100644 --- a/src/wp-includes/js/quicktags.js +++ b/src/wp-includes/js/quicktags.js @@ -526,6 +526,11 @@ function edButton(id, display, tagStart, tagEnd, access) { } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera startPos = canvas.selectionStart; endPos = canvas.selectionEnd; + + if ( startPos < endPos && v.charAt( endPos - 1 ) === '\n' ) { + endPos -= 1; + } + cursorPos = endPos; scrollTop = canvas.scrollTop; l = v.substring(0, startPos); // left of the selection