Make WordPress Core

Changeset 44649


Ignore:
Timestamp:
01/18/2019 04:32:46 PM (5 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/editor/base.js

    r43347 r44649  
    189189
    190190        /**
    191          * Checks if a cursor is inside an HTML tag.
     191         * Checks if a cursor is inside an HTML tag or comment.
    192192         *
    193193         * In order to prevent breaking HTML tags when selecting text, the cursor
     
    212212                // find what the tag is
    213213                var tagContent = content.substr( lastLtPos ),
    214                     tagMatch = tagContent.match( /<\s*(\/)?(\w+)/ );
     214                    tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
    215215
    216216                if ( ! tagMatch ) {
     
    383383
    384384        /**
    385          * Gets adjusted selection cursor positions according to HTML tags/shortcodes
     385         * Gets adjusted selection cursor positions according to HTML tags, comments, and shortcodes.
    386386         *
    387387         * Shortcodes and HTML codes are a bit of a special case when selecting, since they may render
Note: See TracChangeset for help on using the changeset viewer.