TinyMCE: inline text patterns

First run.

See #33300.


git-svn-id: https://develop.svn.wordpress.org/trunk@36627 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ella Iseulde Van Dorpe
2016-02-23 08:32:34 +00:00
parent b4f1d6ff55
commit 7040b4d932
2 changed files with 158 additions and 20 deletions
@@ -14,7 +14,8 @@
'0': 48, '1': 49, '2': 50, '3': 51, '4': 52, '5': 53, '6': 54, '7': 55, '8': 56, '9': 57,'a': 65, 'b': 66, 'c': 67,
'd': 68, 'e': 69, 'f': 70, 'g': 71, 'h': 72, 'i': 73, 'j': 74, 'k': 75, 'l': 76, 'm': 77, 'n': 78, 'o': 79, 'p': 80, 'q': 81,
'r': 82, 's': 83, 't': 84, 'u': 85, 'v': 86, 'w': 87, 'x': 88, 'y': 89, ' ': 32, ',': 188, '-': 189, '.': 190, '/': 191, '\\': 220,
'[': 219, ']': 221, '\'': 222, ';': 186, '=': 187, ')': 41
'[': 219, ']': 221, '\'': 222, ';': 186, '=': 187, ')': 41,
'*': 48 // Anything will do.
};
return lookup[String.fromCharCode(charCode)];
@@ -277,4 +278,36 @@
assert.equal( editor.getContent(), '<p>###&nbsp;</p>\n<p>&nbsp;</p>' );
}, assert.async() );
} );
QUnit.test( 'Inline: single.', function( assert ) {
type( '*test*', function() {
assert.equal( editor.getContent(), '<p><em>test</em></p>' );
assert.equal( editor.selection.getRng().startOffset, 1 );
}, assert.async() );
} );
QUnit.test( 'Inline: double.', function( assert ) {
type( '**test**', function() {
assert.equal( editor.getContent(), '<p><strong>test</strong></p>' );
assert.equal( editor.selection.getRng().startOffset, 1 );
}, assert.async() );
} );
QUnit.test( 'Inline: after typing.', function( assert ) {
editor.setContent( '<p>test test test</p>' );
editor.selection.setCursorLocation( editor.$( 'p' )[0].firstChild, 5 );
type( '**', function() {
editor.selection.setCursorLocation( editor.$( 'p' )[0].firstChild, 11 );
}, '**', function() {
assert.equal( editor.getContent(), '<p>test <strong>test</strong> test</p>' );
assert.equal( editor.selection.getRng().startOffset, 1 );
}, assert.async() );
} );
QUnit.test( 'Inline: no change.', function( assert ) {
type( '******', function() {
assert.equal( editor.getContent(), '<p>******</p>' );
}, assert.async() );
} );
} )( window.jQuery, window.QUnit, window.tinymce, window.setTimeout );