diff --git a/src/js/_enqueues/wp/editor/base.js b/src/js/_enqueues/wp/editor/base.js index c3ef2238af..0620b312de 100644 --- a/src/js/_enqueues/wp/editor/base.js +++ b/src/js/_enqueues/wp/editor/base.js @@ -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