8
0
Просмотр исходного кода

Update description. Improve unit test.

Mateusz Samsel 6 лет назад
Родитель
Сommit
b06a7ff4f6

+ 1 - 1
packages/ckeditor5-enter/src/shiftentercommand.js

@@ -84,7 +84,7 @@ function softBreakAction( model, writer, selection ) {
 	if ( isSelectionEmpty ) {
 		const attributesToCopy = getCopyOnEnterAttributes( model.schema, selection.getAttributes() );
 		insertBreak( writer, range.end );
-		// transforms: [ [ key1, value1 ], ... ] => [ key1, ... ]
+
 		writer.removeSelectionAttribute( Array.from( selection.getAttributes() ).map( x => x[ 0 ] ) );
 		writer.setSelectionAttribute( attributesToCopy );
 	} else {

+ 3 - 3
packages/ckeditor5-enter/src/utils.js

@@ -8,13 +8,13 @@
  */
 
 /**
- * Returns iterator which has filtered attributes read from {@link module:engine/model/selection~Selection#getAttributes selection}.
+ * Returns attributes that should be preserved on the enter key.
  * Filtering is realized based on `copyOnEnter` attribute property. Read more about attribute properties
  * {@link module:engine/model/schema~Schema#setAttributeProperties here}.
  *
  * @param {module:engine/model/schema~Schema} schema
- * @param {Iterable.<*>} allAttributes iterator with attributes of current selection.
- * @returns {Iterable.<*>} filtered attributes which has `copyOnEnter` property.
+ * @param {Iterable.<*>} allAttributes attributes to filter.
+ * @returns {Iterable.<*>}
  */
 export function* getCopyOnEnterAttributes( schema, allAttributes ) {
 	for ( const attribute of allAttributes ) {

+ 3 - 3
packages/ckeditor5-enter/tests/utils.js

@@ -13,9 +13,9 @@ describe( 'utils', () => {
 				.then( editor => {
 					const schema = editor.model.schema;
 
-					schema.register( 'foo', { inheritAllFrom: '$block' } );
-					schema.register( 'bar', { inheritAllFrom: '$block' } );
-					schema.register( 'baz', { inheritAllFrom: '$block' } );
+					schema.extend( '$text', {
+						allowAttributes: [ 'foo', 'bar', 'baz' ]
+					} );
 
 					schema.setAttributeProperties( 'foo', { copyOnEnter: true } );
 					schema.setAttributeProperties( 'baz', { copyOnEnter: true } );