Changeset 33563
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
r33512 r33563 54 54 } ); 55 55 56 function first Node( node ) {56 function firstTextNode( node ) { 57 57 var parent = editor.dom.getParent( node, 'p' ), 58 58 child; … … 75 75 76 76 if ( ! child.data ) { 77 child = child.nextSibling; 77 if ( child.nextSibling && child.nextSibling.nodeType === 3 ) { 78 child = child.nextSibling; 79 } else { 80 child = null; 81 } 78 82 } 79 83 … … 87 91 text; 88 92 89 if ( ! node || first Node( node ) !== node ) {93 if ( ! node || firstTextNode( node ) !== node ) { 90 94 return; 91 95 } … … 124 128 125 129 function watchEnter() { 126 var selection = editor.selection, 127 rng = selection.getRng(), 128 offset = rng.startOffset, 130 var rng = editor.selection.getRng(), 129 131 start = rng.startContainer, 130 node = first Node( start ),132 node = firstTextNode( start ), 131 133 i = enterPatterns.length, 132 134 text, pattern; … … 149 151 } 150 152 151 if ( node === start ) { 152 if ( tinymce.trim( text ) === pattern.start ) { 153 return; 154 } 155 156 offset = Math.max( 0, offset - pattern.start.length ); 153 if ( node === start && tinymce.trim( text ) === pattern.start ) { 154 return; 157 155 } 158 156 … … 167 165 editor.undoManager.transact( function() { 168 166 editor.formatter.apply( refPattern.format, {}, refNode ); 169 refNode. deleteData( 0, refPattern.start.length);167 refNode.replaceData( 0, refNode.data.length, tinymce.trim( refNode.data.slice( refPattern.start.length ) ) ); 170 168 } ); 171 169 -
trunk/tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
r33452 r33563 151 151 152 152 type( '\n', function() { 153 assert.equal( editor.$( 'h3' )[0].firstChild.data, 'test' ); 153 154 assert.equal( editor.getContent(), '<h3>test</h3>\n<p> </p>' ); 154 155 }, assert.async() );
Note: See TracChangeset
for help on using the changeset viewer.