Преглед на файлове

Allow convert font background color from CSS background shorthand property.

Maciej Gołaszewski преди 5 години
родител
ревизия
c219c29610

+ 2 - 0
packages/ckeditor5-font/src/fontbackgroundcolor/fontbackgroundcolorediting.js

@@ -10,6 +10,7 @@
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import FontBackgroundColorCommand from './fontbackgroundcolorcommand';
 import { FONT_BACKGROUND_COLOR, renderDowncastElement, renderUpcastAttribute } from '../utils';
+import { addBackgroundRules } from '@ckeditor/ckeditor5-engine/src/view/styles/background';
 
 /**
  * The font background color editing feature.
@@ -102,6 +103,7 @@ export default class FontBackgroundColorEditing extends Plugin {
 			columns: 5
 		} );
 
+		editor.data.addStyleProcessorRules( addBackgroundRules );
 		editor.conversion.for( 'upcast' ).elementToAttribute( {
 			view: {
 				name: 'span',

+ 11 - 1
packages/ckeditor5-font/tests/fontbackgroundcolor/fontbackgroundcoloreditng.js

@@ -211,7 +211,17 @@ describe( 'FontBackgroundColorEditing', () => {
 				} );
 		} );
 
-		it( 'should convert from element with defined style when with other styles', () => {
+		it( 'should convert from element with defined style when with other styles (using background-color style)', () => {
+			const data = '<p>f<span style="font-size: 18px;background: rgb(10, 20, 30);">o</span>o</p>';
+
+			editor.setData( data );
+
+			expect( getModelData( doc ) ).to.equal( '<paragraph>[]f<$text fontBackgroundColor="rgb(10,20,30)">o</$text>o</paragraph>' );
+
+			expect( editor.getData() ).to.equal( '<p>f<span style="background-color:rgb(10,20,30);">o</span>o</p>' );
+		} );
+
+		it( 'should convert from element with defined style when with other styles (using background style)', () => {
 			const data = '<p>f<span style="font-size: 18px;background-color: rgb(10, 20, 30);">o</span>o</p>';
 
 			editor.setData( data );