1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: basicstyles,toolbar */
bender.editor = {
config: {
autoParagraph: false
}
};
bender.test( {
'test apply range style across input element': function() {
var bot = this.editorBot;
bot.editor.filter.allow( 'input[type]' );
bot.setHtmlWithSelection( 'te[xt<input type="button" />te]xt' );
bot.execCommand( 'bold' );
assert.areSame( 'te<strong>xt<input type="button" />te</strong>xt', bot.getData( false, true ) );
},
// (#2294)
'test apply bold to content with HTML comments': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'html-comments-bold', function( inputHtml, expectedHtml ) {
bot.setHtmlWithSelection( inputHtml );
bot.execCommand( 'bold' );
assert.beautified.html( expectedHtml, bot.editor.getData() );
} );
},
'test applying subscript to the selected content': function() {
var bot = this.editorBot;
bot.setHtmlWithSelection( '<p>foo[bar]</p>' );
bot.execCommand( 'subscript' );
assert.beautified.html( '<p>foo<sub>bar</sub></p>', bot.editor.getData() );
},
'test applying superscript to the selected content': function() {
var bot = this.editorBot;
bot.setHtmlWithSelection( '<p>foo[bar]</p>' );
bot.execCommand( 'superscript' );
assert.beautified.html( '<p>foo<sup>bar</sup></p>', bot.editor.getData() );
},
// (#5215)
'test toggle subscript and superscript on selected text': function() {
bender.editorBot.create( {
name: 'editor-subsup1',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[foo] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'There both subscript and superscript elements' );
} );
},
// (#5215)
'test properly toggle subscript and superscript on selected text with other basic styles': function() {
bender.editorBot.create( {
name: 'editor-subsup2',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[<strong>foo</strong>] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub><strong>foo</strong></sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup><strong>foo</strong></sup> bar</p>',
editor.editable().getData(),
'There both subscript and superscript elements' );
} );
},
// (#5215)
'test toggle subscript and superscript on selected text create proper undo and redo step': function() {
bender.editorBot.create( {
name: 'editor-subsup3',
config: {
coreStyles_toggleSubSup: true,
extraPlugins: 'undo'
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[foo] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'There both subscript and superscript elements' );
editor.execCommand( 'undo' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'Undo step is incorrect' );
editor.execCommand( 'redo' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'Redo step is incorrect' );
} );
},
// (#5215)
'test toggle subscript and superscript not disappear selection': function() {
bender.editorBot.create( {
name: 'editor-subsup4',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[foo] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'There both subscript and superscript elements' );
var selection = editor.getSelection(),
range = selection.getRanges()[ 0 ],
selectedContent = range.extractContents();
assert.areSame( 'foo', selectedContent.getHtml(), 'Selected content is incorrect' );
} );
},
// (#5215)
'test toggle subscript and superscript contain only one active UI button': function() {
bender.editorBot.create( {
name: 'editor-subsup5',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[foo] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'There both subscript and superscript elements' );
var subscriptButtonState = editor.ui.get( 'Subscript' ).getState(),
superscriptButtonState = editor.ui.get( 'Superscript' ).getState();
assert.areSame( subscriptButtonState, CKEDITOR.TRISTATE_OFF, 'Subscript button is not active' );
assert.areSame( superscriptButtonState, CKEDITOR.TRISTATE_ON, 'Superscript button is active' );
} );
},
'test allow add subscript and superscript at the same time when config.coreStyles_toggleSubSup is OFF': function() {
bender.editorBot.create( {
name: 'editor-subsup6',
config: {
coreStyles_toggleSubSup: false
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p>[foo] bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'There is no added subscript element' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sup><sub>foo</sub></sup> bar</p>',
editor.editable().getData(),
'There is no subscript and superscript element' );
} );
},
'test remove subscript from content which contain subscript and superscript elements': function() {
bender.editorBot.create( {
name: 'editor-subsup7',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p><sup><sub>[foo]</sub></sup> bar</p>' );
editor.execCommand( 'subscript' );
assert.areSame(
'<p><sup>foo</sup> bar</p>',
editor.editable().getData(),
'Subscript element is not removed' );
} );
},
'test remove superscript from content which contain subscript and superscript elements': function() {
bender.editorBot.create( {
name: 'editor-subsup8',
config: {
coreStyles_toggleSubSup: true
}
}, function( bot ) {
var editor = bot.editor;
bot.setHtmlWithSelection( '<p><sup><sub>[foo]</sub></sup> bar</p>' );
editor.execCommand( 'superscript' );
assert.areSame(
'<p><sub>foo</sub> bar</p>',
editor.editable().getData(),
'Superscript element is not removed' );
} );
}
} );
|