WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 years ago

#29571 closed enhancement (fixed)

Quicktag end tags appear after newline characters in text editor

Reported by: JoshuaGoodwin Owned by: azaozz
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.9
Component: Editor Keywords: has-patch
Focuses: javascript, administration Cc:

Description

In order to select a whole line of text in a textarea, it's often convenient to use the triple-click shortcut. In WebKit/Blink browsers, if the selected line of text is not the last line, the selection includes the newline character at the end. So when I click an editor quicktag button, the closing tag appears on the next line.

This is perhaps best illustrated with a screencast: https://mediacru.sh/d6KyDiACDuri

Instead, perhaps the closing tag should be inserted before the newline character.

I've tested on using Chrome 37 on Windows and Linux, but it's a long-standing thing.

Attachments (2)

29571.patch (585 bytes) - added by JoshuaGoodwin 5 years ago.
A patch for qt.TagButton. wpLink and qt.insertContent() probably need changing too.
29571.2.patch (630 bytes) - added by JoshuaGoodwin 5 years ago.
A patch for qt.TagButton (with the correct index, sorry)

Download all attachments as: .zip

Change History (8)

@JoshuaGoodwin
5 years ago

A patch for qt.TagButton. wpLink and qt.insertContent() probably need changing too.

@JoshuaGoodwin
5 years ago

A patch for qt.TagButton (with the correct index, sorry)

#1 @JoshuaGoodwin
5 years ago

  • Keywords has-patch added

#2 @iseulde
4 years ago

  • Type changed from defect (bug) to enhancement

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.


3 years ago

#4 @iseulde
3 years ago

  • Milestone changed from Awaiting Review to 4.6

Looks good! Thanks for the patch and apologies for the long wait.

#5 @azaozz
3 years ago

Thinking it's better to adjust endPos when the last char before it is \n. Pretty similar but perhaps a bit cleaner :)

#6 @azaozz
3 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 37661:

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.

Note: See TracTickets for help on using tickets.