From b3a658edbcc1eb5cc4bb02de1d4a50b8df1075ac Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 18 Jan 2019 16:32:46 +0000 Subject: [PATCH] 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 --- src/js/_enqueues/wp/editor/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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