Browse Source

Add explanation about styles conversion in UpcastHelpers.attributeToAttribute().

Maciej Gołaszewski 6 years ago
parent
commit
c5cd820e00
1 changed files with 16 additions and 0 deletions
  1. 16 0
      packages/ckeditor5-engine/src/conversion/upcasthelpers.js

+ 16 - 0
packages/ckeditor5-engine/src/conversion/upcasthelpers.js

@@ -237,6 +237,22 @@ export default class UpcastHelpers extends ConversionHelpers {
 	 *			}
 	 *		} );
 	 *
+	 * Converting styles is a bit different as it requires an object to be set as a `value` and by default
+	 * a model attribute's value will be set to `true`. You can set any value by providing a `value` callback
+	 * that returns a desired value.
+	 *
+	 *		// Default conversion of font-weight style will result in setting bold attribute to true.
+	 *		editor.conversion.for( 'upcast' ).attributeToAttribute( {
+	 *			view: {
+	 *				key: 'style',
+	 *				value: {
+	 *					'font-weight': 'bold'
+	 *				}
+	 *			},
+	 *			model: 'bold'
+	 *		} );
+	 *
+	 *		// This converter will pass any value of a style property define a callback.
 	 *		editor.conversion.for( 'upcast' ).attributeToAttribute( {
 	 *			view: {
 	 *				key: 'style',