Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying new style to entire selection if partially present #1056

Merged
merged 6 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/font/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
if ( previousStyle ) {
editor.removeStyle( previousStyle );
}
} else if ( value !== previousValue ) {
} else {
editor.applyStyle( style );
}

Expand Down
30 changes: 28 additions & 2 deletions tests/plugins/font/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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, '<h1><span style="' + ffCourierNew + '">[Hello</span> world!]</h1>' );

bot.combo( 'Font', function( combo ) {
combo.onClick( 'Courier New' );
this.wait( function() {
assert.isInnerHtmlMatching( '<h1><span style="' + ffCourierNew + '">Hello world!</span>@</h1>', 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, '<h1><span style="' + ffCourierNew + '">[Hel]lo</span> world!</h1>' );

bot.combo( 'Font', function( combo ) {
combo.onClick( 'Courier New' );
this.wait( function() {
assert.isInnerHtmlMatching( '<h1><span style="' + ffCourierNew + '">Hello</span> world!@</h1>', bot.editor.editable().getHtml(), htmlMatchingOpts );
}, 0 );
} );
}
} );
} )();
8 changes: 8 additions & 0 deletions tests/plugins/font/manual/partialstyles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="editor">
<p>Hello world!</p>
<p>Hello again!</p>
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
25 changes: 25 additions & 0 deletions tests/plugins/font/manual/partialstyles.md
Original file line number Diff line number Diff line change
@@ -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.