Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Improve name of variables used in code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Jul 1, 2019
1 parent d297880 commit 661e550
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/entercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ function enterBlock( model, writer, selection, schema ) {
}

if ( isSelectionEmpty ) {
// List of text attributes copied to new line/block.
const filteredAttr = getAllowedAttributes( writer.model.schema, selection.getAttributes() );
const attributesToCopy = getCopyOnEnterAttributes( writer.model.schema, selection.getAttributes() );
splitBlock( writer, range.start );
writer.setSelectionAttribute( filteredAttr );
writer.setSelectionAttribute( attributesToCopy );
} else {
const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd );
const isContainedWithinOneElement = ( startElement == endElement );
Expand Down Expand Up @@ -88,10 +87,10 @@ function splitBlock( writer, splitPos ) {
writer.setSelection( splitPos.parent.nextSibling, 0 );
}

function* getAllowedAttributes( schema, allAttributes ) {
for ( const attr of allAttributes ) {
if ( attr && schema.getAttributeProperties( attr[ 0 ] ).copyOnEnter ) {
yield attr;
function* getCopyOnEnterAttributes( schema, allAttributes ) {
for ( const attribute of allAttributes ) {
if ( attribute && schema.getAttributeProperties( attribute[ 0 ] ).copyOnEnter ) {
yield attribute;
}
}
}
2 changes: 1 addition & 1 deletion tests/entercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe( 'EnterCommand', () => {

describe( 'copyOnEnter', () => {
beforeEach( () => {
schema.extend( '$text', { allowAttributes: 'foo' } );
schema.extend( '$text', { allowAttributes: [ 'foo', 'bar' ] } );
schema.setAttributeProperties( 'foo', { copyOnEnter: true } );
} );

Expand Down

0 comments on commit 661e550

Please sign in to comment.