TinyMCE: wptextpattern: fix for fast typing
Props jnylen0, iseulde. Fixes #36585. git-svn-id: https://develop.svn.wordpress.org/trunk@37668 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
363533d9b3
commit
644795a9dc
@ -62,15 +62,14 @@
|
||||
if ( event.keyCode === VK.ENTER && ! VK.modifierPressed( event ) ) {
|
||||
enter();
|
||||
}
|
||||
}, true );
|
||||
|
||||
editor.on( 'keyup', function( event ) {
|
||||
// Wait for the browser to insert the character.
|
||||
if ( event.keyCode === VK.SPACEBAR && ! event.ctrlKey && ! event.metaKey && ! event.altKey ) {
|
||||
space();
|
||||
setTimeout( space );
|
||||
} else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) {
|
||||
inline();
|
||||
setTimeout( inline );
|
||||
}
|
||||
} );
|
||||
}, true );
|
||||
|
||||
function inline() {
|
||||
var rng = editor.selection.getRng();
|
||||
|
@ -6,7 +6,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function mceType(chr) {
|
||||
function mceType( chr, noKeyUp ) {
|
||||
var editor = tinymce.activeEditor, keyCode, charCode, evt, startElm, rng, startContainer, startOffset, textNode;
|
||||
|
||||
function charCodeToKeyCode(charCode) {
|
||||
@ -109,12 +109,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
fakeEvent(startElm, 'keyup', evt);
|
||||
if ( ! noKeyUp ) {
|
||||
fakeEvent(startElm, 'keyup', evt);
|
||||
}
|
||||
}
|
||||
|
||||
function type() {
|
||||
var args = arguments;
|
||||
|
||||
// Wait once for conversions to be triggered,
|
||||
// and once for the `canUndo` flag to be set.
|
||||
setTimeout( function() {
|
||||
setTimeout( function() {
|
||||
if ( typeof args[0] === 'string' ) {
|
||||
args[0] = args[0].split( '' );
|
||||
@ -134,6 +139,7 @@
|
||||
type.apply( null, args );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit.module( 'tinymce.plugins.wptextpattern', {
|
||||
@ -177,6 +183,14 @@
|
||||
}, assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Unordered list. (fast)', function( assert ) {
|
||||
type( '*', function() {
|
||||
mceType( ' ', true );
|
||||
}, 'a', function() {
|
||||
assert.equal( editor.getContent(), '<ul>\n<li>a</li>\n</ul>' );
|
||||
}, assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Ordered list.', function( assert ) {
|
||||
type( '1. a', function() {
|
||||
assert.equal( editor.getContent(), '<ol>\n<li>a</li>\n</ol>' );
|
||||
|
Loading…
Reference in New Issue
Block a user