|
51 | 51 | var bot = this.editorBot;
|
52 | 52 |
|
53 | 53 | bender.tools.selection.setWithHtml( bot.editor, '<p>{foo}</p>' );
|
54 |
| - bot.combo( 'FontSize', function( combo ) { |
55 |
| - combo.onClick( 48 ); |
56 |
| - assert.isInnerHtmlMatching( '<p><span style="font-size:48px">foo</span>@</p>', |
57 |
| - bot.editor.editable().getHtml(), htmlMatchingOpts ); |
58 |
| - } ); |
| 54 | + this.assertCombo( 'FontSize', 48, false, bot, '<p><span style="font-size:48px">foo</span>@</p>' ); |
59 | 55 | },
|
60 | 56 |
|
61 | 57 | 'test apply font size over another font size (collapsed selection)': function() {
|
62 |
| - var bot = this.editorBot, |
63 |
| - editor = bot.editor; |
| 58 | + var bot = this.editorBot; |
64 | 59 |
|
65 | 60 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px">f{}oo</span>x</p>' );
|
66 |
| - bot.combo( 'FontSize', function( combo ) { |
67 |
| - combo.onClick( 24 ); |
68 |
| - |
69 |
| - this.wait( function() { |
70 |
| - // We lose (dunno where) the empty span on IE8, so let's insert something. |
71 |
| - editor.insertText( 'bar' ); |
72 |
| - assert.isInnerHtmlMatching( |
73 |
| - '<p>x<span style="font-size:48px">f</span><span style="font-size:24px">bar</span><span style="font-size:48px">oo</span>x@</p>', |
74 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
75 |
| - }, 0 ); |
76 |
| - } ); |
| 61 | + this.assertCombo( 'FontSize', 24, true, bot, |
| 62 | + '<p>x<span style="font-size:48px">f</span><span style="font-size:24px">bar</span><span style="font-size:48px">oo</span>x@</p>' ); |
77 | 63 | },
|
78 | 64 |
|
79 | 65 | 'test apply font size over another font size (collapsed selection in empty span)': function() {
|
80 |
| - var bot = this.editorBot, |
81 |
| - editor = bot.editor; |
| 66 | + var bot = this.editorBot; |
82 | 67 |
|
83 | 68 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px"><em>[]</em></span>x</p>' );
|
84 |
| - bot.combo( 'FontSize', function( combo ) { |
85 |
| - combo.onClick( 24 ); |
86 |
| - |
87 |
| - this.wait( function() { |
88 |
| - // We lose (dunno where) the empty span on IE8, so let's insert something. |
89 |
| - editor.insertText( 'bar' ); |
90 |
| - assert.isInnerHtmlMatching( '<p>x<em><span style="font-size:24px">bar</span></em>x@</p>', editor.editable().getHtml(), htmlMatchingOpts ); |
91 |
| - assert.areSame( 1, editor.editable().find( 'span' ).count(), 'there is only one span in the editable' ); |
92 |
| - }, 0 ); |
93 |
| - } ); |
| 69 | + this.assertCombo( 'FontSize', 24, true, bot, |
| 70 | + '<p>x<em><span style="font-size:24px">bar</span></em>x@</p>', |
| 71 | + function( bot ) { |
| 72 | + assert.areSame( 1, bot.editor.editable().find( 'span' ).count(), 'there is only one span in the editable' ); |
| 73 | + } ); |
94 | 74 | },
|
95 | 75 |
|
96 | 76 | 'test apply font size over another font size (collapsed selection at the existing span boundary)': function() {
|
97 |
| - var bot = this.editorBot, |
98 |
| - editor = bot.editor; |
| 77 | + var bot = this.editorBot; |
99 | 78 |
|
100 | 79 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px">{}foo</span>x</p>' );
|
101 |
| - bot.combo( 'FontSize', function( combo ) { |
102 |
| - combo.onClick( 24 ); |
103 |
| - |
104 |
| - this.wait( function() { |
105 |
| - // We lose (dunno where) the empty span on IE8, so let's insert something. |
106 |
| - editor.insertText( 'bar' ); |
107 |
| - assert.isInnerHtmlMatching( |
108 |
| - '<p>x<span style="font-size:24px">bar</span><span style="font-size:48px">foo</span>x@</p>', |
109 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
110 |
| - }, 0 ); |
111 |
| - } ); |
| 80 | + this.assertCombo( 'FontSize', 24, true, bot, |
| 81 | + '<p>x<span style="font-size:24px">bar</span><span style="font-size:48px">foo</span>x@</p>' ); |
112 | 82 | },
|
113 | 83 |
|
114 | 84 | 'test apply font size over another font size (text selection)': function() {
|
115 |
| - var bot = this.editorBot, |
116 |
| - editor = bot.editor; |
| 85 | + var bot = this.editorBot; |
117 | 86 |
|
118 | 87 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px">f{o}o</span>x</p>' );
|
119 |
| - bot.combo( 'FontSize', function( combo ) { |
120 |
| - combo.onClick( 24 ); |
121 |
| - assert.isInnerHtmlMatching( |
122 |
| - '<p>x<span style="font-size:48px">f</span><span style="font-size:24px">o</span><span style="font-size:48px">o</span>x@</p>', |
123 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
124 |
| - } ); |
| 88 | + this.assertCombo( 'FontSize', 24, false, bot, |
| 89 | + '<p>x<span style="font-size:48px">f</span><span style="font-size:24px">o</span><span style="font-size:48px">o</span>x@</p>' ); |
125 | 90 | },
|
126 | 91 |
|
127 | 92 | 'test apply font size over another font size (the existing span selection)': function() {
|
128 |
| - var bot = this.editorBot, |
129 |
| - editor = bot.editor; |
| 93 | + var bot = this.editorBot; |
130 | 94 |
|
131 | 95 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px">{foo}</span>x</p>' );
|
132 |
| - bot.combo( 'FontSize', function( combo ) { |
133 |
| - combo.onClick( 24 ); |
134 |
| - assert.isInnerHtmlMatching( |
135 |
| - '<p>x<span style="font-size:24px">foo</span>x@</p>', |
136 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
137 |
| - } ); |
| 96 | + this.assertCombo( 'FontSize', 24, false, bot, '<p>x<span style="font-size:24px">foo</span>x@</p>' ); |
138 | 97 | },
|
139 | 98 |
|
140 | 99 | 'test apply font size over another font size (selection containing other span)': function() {
|
141 |
| - var bot = this.editorBot, |
142 |
| - editor = bot.editor; |
| 100 | + var bot = this.editorBot; |
143 | 101 |
|
144 | 102 | bender.tools.selection.setWithHtml( bot.editor, '<p>x{f<span style="font-size:48px">o</span>o}x</p>' );
|
145 |
| - bot.combo( 'FontSize', function( combo ) { |
146 |
| - combo.onClick( 24 ); |
147 |
| - assert.isInnerHtmlMatching( |
148 |
| - '<p>x<span style="font-size:24px">foo</span>x@</p>', |
149 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
150 |
| - } ); |
| 103 | + this.assertCombo( 'FontSize', 24, false, bot, '<p>x<span style="font-size:24px">foo</span>x@</p>' ); |
151 | 104 | },
|
152 | 105 |
|
153 | 106 | 'test apply font size over another font size (deeply nested text selection)': function() {
|
154 |
| - var bot = this.editorBot, |
155 |
| - editor = bot.editor; |
| 107 | + var bot = this.editorBot; |
156 | 108 |
|
157 | 109 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px"><em>f{o}o</em></span>x</p>' );
|
158 |
| - bot.combo( 'FontSize', function( combo ) { |
159 |
| - combo.onClick( 24 ); |
160 |
| - assert.isInnerHtmlMatching( |
161 |
| - '<p>x<span style="font-size:48px"><em>f</em></span><span style="font-size:24px"><em>o</em></span><span style="font-size:48px"><em>o</em></span>x@</p>', |
162 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
163 |
| - } ); |
| 110 | + this.assertCombo( 'FontSize', 24, false, bot, |
| 111 | + '<p>x<span style="font-size:48px"><em>f</em></span><span style="font-size:24px"><em>o</em></span><span style="font-size:48px"><em>o</em></span>x@</p>' ); |
164 | 112 | },
|
165 | 113 |
|
166 | 114 | 'test apply font size over another font size (deeply nested collapsed selection)': function() {
|
|
169 | 117 | assert.ignore();
|
170 | 118 | }
|
171 | 119 |
|
172 |
| - var bot = this.editorBot, |
173 |
| - editor = bot.editor; |
| 120 | + var bot = this.editorBot; |
174 | 121 |
|
175 | 122 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:48px"><em>f<u class="y">{}o</u>o</em></span>x</p>' );
|
176 |
| - bot.combo( 'FontSize', function( combo ) { |
177 |
| - combo.onClick( 24 ); |
178 |
| - |
179 |
| - this.wait( function() { |
180 |
| - editor.insertText( 'bar' ); |
181 |
| - assert.isInnerHtmlMatching( |
182 |
| - '<p>x<span style="font-size:48px"><em>f</em></span>' + |
183 |
| - '<em><u class="y"><span style="font-size:24px">bar</span></u></em>' + |
184 |
| - '<span style="font-size:48px"><em><u class="y">o</u>o</em></span>x@</p>', |
185 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
186 |
| - }, 0 ); |
187 |
| - } ); |
| 123 | + this.assertCombo( 'FontSize', 24, true, bot, |
| 124 | + '<p>x<span style="font-size:48px"><em>f</em></span><em><u class="y"><span style="font-size:24px">bar</span></u></em>' + |
| 125 | + '<span style="font-size:48px"><em><u class="y">o</u>o</em></span>x@</p>' ); |
188 | 126 | },
|
189 | 127 |
|
190 | 128 | 'test apply font size over font family (check possible false positive match)': function() {
|
191 |
| - var bot = this.editorBot, |
192 |
| - editor = bot.editor; |
| 129 | + var bot = this.editorBot; |
193 | 130 |
|
194 | 131 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="' + ffArial + '">f{o}o</span>x</p>' );
|
195 |
| - bot.combo( 'FontSize', function( combo ) { |
196 |
| - combo.onClick( 24 ); |
197 |
| - assert.isInnerHtmlMatching( |
198 |
| - '<p>x<span style="' + ffArial + '">f<span style="font-size:24px">o</span>o</span>x@</p>', |
199 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
200 |
| - } ); |
| 132 | + this.assertCombo( 'FontSize', 24, false, bot, '<p>x<span style="' + ffArial + '">f<span style="font-size:24px">o</span>o</span>x@</p>' ); |
201 | 133 | },
|
202 | 134 |
|
203 | 135 | 'test apply font family over another font family (text selection)': function() {
|
204 |
| - var bot = this.editorBot, |
205 |
| - editor = bot.editor; |
| 136 | + var bot = this.editorBot; |
206 | 137 |
|
207 | 138 | bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="' + ffArial + '">f{o}o</span>x</p>' );
|
208 |
| - bot.combo( 'Font', function( combo ) { |
209 |
| - combo.onClick( 'Comic Sans MS' ); |
210 |
| - assert.isInnerHtmlMatching( |
211 |
| - '<p>x<span style="' + ffArial + '">f</span><span style="' + ffCS + '">o</span><span style="' + ffArial + '">o</span>x@</p>', |
212 |
| - editor.editable().getHtml(), htmlMatchingOpts ); |
| 139 | + this.assertCombo( 'Font', 'Comic Sans MS', false, bot, |
| 140 | + '<p>x<span style="' + ffArial + '">f</span><span style="' + ffCS + '">o</span><span style="' + ffArial + '">o</span>x@</p>' ); |
| 141 | + }, |
| 142 | + |
| 143 | + // #14856 |
| 144 | + 'test reapply font family on the beginning (collapsed selection)': function() { |
| 145 | + if ( CKEDITOR.env.safari ) { |
| 146 | + assert.ignore(); |
| 147 | + } |
| 148 | + |
| 149 | + var bot = this.editorBot; |
| 150 | + |
| 151 | + bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="' + ffArial + '"><em>{}foo</em></span>x</p>' ); |
| 152 | + this.assertCombo( 'Font', 'Comic Sans MS', true, bot, |
| 153 | + '<p>x<em><span style="' + ffCS + '">bar</span></em><span style="' + ffArial + '"><em>foo</em></span>x@</p>' ); |
| 154 | + }, |
| 155 | + |
| 156 | + 'test reapply font family in the middle (collapsed selection)': function() { |
| 157 | + var bot = this.editorBot; |
| 158 | + |
| 159 | + bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="' + ffArial + '"><em>fo{}o</em></span>x</p>' ); |
| 160 | + this.assertCombo( 'Font', 'Comic Sans MS', true, bot, |
| 161 | + '<p>x<span style="' + ffArial + '"><em>fo</em></span><em><span style="' + ffCS + '">bar</span></em>' + |
| 162 | + '<span style="' + ffArial + '"><em>o</em></span>x@</p>' ); |
| 163 | + }, |
| 164 | + |
| 165 | + 'test reapply font size on the end (collapsed selection)': function() { |
| 166 | + var bot = this.editorBot; |
| 167 | + |
| 168 | + bender.tools.selection.setWithHtml( bot.editor, '<p>x<span style="font-size:12px"><em>foo{}</em></span>x</p>' ); |
| 169 | + this.assertCombo( 'FontSize', 24, true, bot, |
| 170 | + '<p>x<span style="font-size:12px"><em>foo</em></span><em><span style="font-size:24px">bar</span></em>x@</p>' ); |
| 171 | + }, |
| 172 | + |
| 173 | + assertCombo: function( comboName, comboValue, collapsed, bot, resultHtml, callback ) { |
| 174 | + bot.combo( comboName, function( combo ) { |
| 175 | + combo.onClick( comboValue ); |
| 176 | + |
| 177 | + this.wait( function() { |
| 178 | + // The empty span from collapsed selection is lost on FF and IE8, insert something to prevent that. |
| 179 | + collapsed && bot.editor.insertText( 'bar' ); |
| 180 | + assert.isInnerHtmlMatching( resultHtml, bot.editor.editable().getHtml(), htmlMatchingOpts ); |
| 181 | + callback && callback( bot ); |
| 182 | + }, 0 ); |
213 | 183 | } );
|
214 | 184 | }
|
215 | 185 | } );
|
|
0 commit comments