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

The supportAllValues for font-size doesn't work with nested elements #8454

Merged
merged 1 commit into from
Nov 16, 2020
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
5 changes: 4 additions & 1 deletion packages/ckeditor5-font/src/fontsize/fontsizeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ export default class FontSizeEditing extends Plugin {
value: viewElement => viewElement.getStyle( 'font-size' )
},
view: {
name: 'span'
name: 'span',
styles: {
'font-size': /.*/
}
}
} );
}
Expand Down
10 changes: 10 additions & 0 deletions packages/ckeditor5-font/tests/fontfamily/fontfamilyediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ describe( 'FontFamilyEditing', () => {

expect( editor.getData() ).to.equal( data );
} );

it( 'should convert from a nested element', () => {
const data = '<p>f<span><span><span><span style="font-family: Arial, sans-serif">o</span></span></span></span>o</p>';

editor.setData( data );

expect( getModelData( doc ) ).to.equal( '<paragraph>[]f<$text fontFamily="Arial, sans-serif">o</$text>o</paragraph>' );

expect( editor.getData() ).to.equal( '<p>f<span style="font-family:Arial, sans-serif;">o</span>o</p>' );
} );
} );
} );
} );
Expand Down
10 changes: 10 additions & 0 deletions packages/ckeditor5-font/tests/fontsize/fontsizeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ describe( 'FontSizeEditing', () => {

expect( editor.getData() ).to.equal( '<p>f<span style="font-size:18px;">o</span>o</p>' );
} );

it( 'should convert from a nested element', () => {
const data = '<p>f<span><span><span><span style="font-size: 18px">o</span></span></span></span>o</p>';

editor.setData( data );

expect( getModelData( doc ) ).to.equal( '<paragraph>[]f<$text fontSize="18px">o</$text>o</paragraph>' );

expect( editor.getData() ).to.equal( '<p>f<span style="font-size:18px;">o</span>o</p>' );
} );
} );

it( 'should throw an error if used with default configuration of the plugin', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/ckeditor5-font/tests/manual/tickets/8233/1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="editor">
<p>
<span style="font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><span style="font-size: 28px">LUCIDA, 28px</span></span>
</p>
</div>
34 changes: 34 additions & 0 deletions packages/ckeditor5-font/tests/manual/tickets/8233/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals window, document, console */

import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
import FontSize from '../../../../src/fontsize';
import FontFamily from '../../../../src/fontfamily';

const config = {
plugins: [ ArticlePluginSet, FontSize, FontFamily ],
toolbar: [
'heading', '|', 'fontFamily', 'fontSize', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo'
],
fontSize: {
options: [ 10, 12, 14, 'default', 18, 20, 22 ],
supportAllValues: true
},
fontFamily: {
supportAllValues: true
}
};

ClassicEditor
.create( document.querySelector( '#editor' ), config )
.then( editor => {
window.editor = editor;
} )
.catch( error => {
console.error( error.stack );
} );
7 changes: 7 additions & 0 deletions packages/ckeditor5-font/tests/manual/tickets/8233/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## The supportAllValues doesn't work with nested elements [#8233](https://github.com/ckeditor/ckeditor5/issues/8233)

1. Open CKEditor Inspector (if not already opened) and go to `View` tab.

**Expected result**: the `<span>` element has both `font-family` **and** `font-size` styles.

**Unexpected result**: the `<span>` element lost nested `font-size` style.