diff --git a/plugins/font/plugin.js b/plugins/font/plugin.js index f255488eeef..4d100257603 100644 --- a/plugins/font/plugin.js +++ b/plugins/font/plugin.js @@ -174,7 +174,7 @@ if ( previousStyle ) { editor.removeStyle( previousStyle ); } - } else if ( value !== previousValue ) { + } else { editor.applyStyle( style ); } diff --git a/tests/plugins/font/font.js b/tests/plugins/font/font.js index c281b773975..fff6a59e71e 100644 --- a/tests/plugins/font/font.js +++ b/tests/plugins/font/font.js @@ -13,7 +13,8 @@ fixStyles: true }, ffArial = 'font-family:Arial,Helvetica,sans-serif', - ffCS = 'font-family:Comic Sans MS,cursive'; + ffCS = 'font-family:Comic Sans MS,cursive', + ffCourierNew = 'font-family:Courier New,Courier,monospace'; bender.test( { _should: { @@ -251,7 +252,32 @@ }, 0 ); }, 0 ); } ); - } + }, + // (#1040) + 'test apply new style to entire selection if partially present': function() { + var bot = this.editorBot; + bender.tools.selection.setWithHtml( bot.editor, '

[Hello world!]

' ); + + bot.combo( 'Font', function( combo ) { + combo.onClick( 'Courier New' ); + this.wait( function() { + assert.isInnerHtmlMatching( '

Hello world!@

', bot.editor.editable().getHtml(), htmlMatchingOpts ); + }, 0 ); + } ); + }, + + // (#1040) + 'test if styles are not changed if applied second time on the part of already styled element': function() { + var bot = this.editorBot; + bender.tools.selection.setWithHtml( bot.editor, '

[Hel]lo world!

' ); + + bot.combo( 'Font', function( combo ) { + combo.onClick( 'Courier New' ); + this.wait( function() { + assert.isInnerHtmlMatching( '

Hello world!@

', bot.editor.editable().getHtml(), htmlMatchingOpts ); + }, 0 ); + } ); + } } ); } )(); diff --git a/tests/plugins/font/manual/partialstyles.html b/tests/plugins/font/manual/partialstyles.html new file mode 100644 index 00000000000..6d1b2ed66ca --- /dev/null +++ b/tests/plugins/font/manual/partialstyles.html @@ -0,0 +1,8 @@ +
+

Hello world!

+

Hello again!

+
+ + diff --git a/tests/plugins/font/manual/partialstyles.md b/tests/plugins/font/manual/partialstyles.md new file mode 100644 index 00000000000..9531027a8ac --- /dev/null +++ b/tests/plugins/font/manual/partialstyles.md @@ -0,0 +1,25 @@ +@bender-tags: 4.8.0, bug, 1040 +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, font, elementspath, sourcearea + +## Scenario 1: + +1. Select `Hello` word. +2. Apply **Courier New** font. +3. Expand selection to contain whole text line. +4. Apply **Courier New** font. + +### Expected result + +Font has been applied to whole `Hello world!` text. + +## Scenario 2: + +1. Select `again` word. +2. Apply **36** size. +3. Expand selection to contain whole text line. +4. Apply **36** size. + +### Expected result + +Size has been applied to whole `Hello again!` text.