TinyMCE: treat HTML comments same as tags when keeping cursor position. Fixes breaking the More and Nextpage tags when switching from Text to Visual.
Props iCaleb, jeremeylduvall. Fixes #45947. git-svn-id: https://develop.svn.wordpress.org/trunk@44649 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3132f22932
commit
b3a658edbc
@ -188,7 +188,7 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a cursor is inside an HTML tag.
|
||||
* Checks if a cursor is inside an HTML tag or comment.
|
||||
*
|
||||
* In order to prevent breaking HTML tags when selecting text, the cursor
|
||||
* must be moved to either the start or end of the tag.
|
||||
@ -211,7 +211,7 @@ window.wp = window.wp || {};
|
||||
if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) {
|
||||
// find what the tag is
|
||||
var tagContent = content.substr( lastLtPos ),
|
||||
tagMatch = tagContent.match( /<\s*(\/)?(\w+)/ );
|
||||
tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
|
||||
|
||||
if ( ! tagMatch ) {
|
||||
return null;
|
||||
@ -382,7 +382,7 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets adjusted selection cursor positions according to HTML tags/shortcodes
|
||||
* Gets adjusted selection cursor positions according to HTML tags, comments, and shortcodes.
|
||||
*
|
||||
* Shortcodes and HTML codes are a bit of a special case when selecting, since they may render
|
||||
* content in Visual mode. If we insert selection markers somewhere inside them, it's really possible
|
||||
|
Loading…
Reference in New Issue
Block a user