Ticket #31441: 31441.19.patch
File 31441.19.patch, 2.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
14 14 tinymce.PluginManager.add( 'wptextpattern', function( editor ) { 15 15 var $$ = editor.$, 16 16 patterns = [], 17 VK = tinymce.util.VK, 17 18 canUndo = false; 18 19 19 20 /** … … 52 53 } ); 53 54 54 55 editor.on( 'keydown', function( event ) { 55 if ( canUndo && event.keyCode === tinymce.util.VK.BACKSPACE ) {56 if ( canUndo && ( event.keyCode === VK.BACKSPACE || event.keyCode === 27 ) ) { // esc 56 57 editor.undoManager.undo(); 57 58 event.preventDefault(); 58 59 } … … 61 62 editor.on( 'keyup', function( event ) { 62 63 var rng, node, text, parent, child; 63 64 64 if ( event.keyCode !== tinymce.util.VK.SPACEBAR ) {65 if ( event.keyCode !== VK.SPACEBAR ) { 65 66 return; 66 67 } 67 68 … … 87 88 } 88 89 } 89 90 91 if ( ! child.nodeValue ) { 92 child = child.nextSibling; 93 } 94 90 95 if ( child !== node ) { 91 96 return; 92 97 } … … 109 114 editor.undoManager.add(); 110 115 111 116 editor.undoManager.transact( function() { 117 var $$parent; 118 112 119 if ( replace ) { 113 120 $$( node ).replaceWith( document.createTextNode( replace ) ); 114 121 } else { 115 $$( node.parentNode ).empty().append( '<br>' ); 122 $$parent = $$( node.parentNode ); 123 124 $$( node ).remove(); 125 126 if ( ! $$parent.html() ) { 127 $$parent.append( '<br>' ); 128 } 116 129 } 117 130 118 131 editor.selection.setCursorLocation( parent ); -
tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
77 77 }, assert.async() ); 78 78 } ); 79 79 80 QUnit.test( 'Ordered list with content. ', function( assert ) {80 QUnit.test( 'Ordered list with content. (1)', function( assert ) { 81 81 editor.setContent( '<p><strong>test</strong></p>' ); 82 82 editor.selection.setCursorLocation(); 83 83 … … 86 86 }, assert.async() ); 87 87 } ); 88 88 89 QUnit.test( 'Ordered list with content. (2)', function( assert ) { 90 editor.setContent( '<p><strong>test</strong></p>' ); 91 editor.selection.setCursorLocation( editor.$( 'p' )[0], 0 ); 92 93 type( '* ', function() { 94 assert.equal( editor.getContent(), '<ul>\n<li><strong>test</strong></li>\n</ul>' ); 95 }, assert.async() ); 96 } ); 97 89 98 QUnit.test( 'Only transform inside a P tag.', function( assert ) { 90 99 editor.setContent( '<h1>test</h1>' ); 91 100 editor.selection.setCursorLocation();