0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

null arg to setText(Alignment|Direction) should reset value

Resolves #247
This commit is contained in:
Neil Jenkins 2016-12-07 19:22:28 +11:00
parent a899c001eb
commit 65a621abcf
3 changed files with 31 additions and 13 deletions

View file

@ -4353,21 +4353,30 @@ proto.setHighlightColour = function ( colour ) {
proto.setTextAlignment = function ( alignment ) {
this.forEachBlock( function ( block ) {
block.className = ( block.className
var className = block.className
.split( /\s+/ )
.filter( function ( klass ) {
return !( /align/.test( klass ) );
return !!klass && !/^align/.test( klass );
})
.join( ' ' ) +
' align-' + alignment ).trim();
.join( ' ' );
if ( alignment ) {
block.className = className + ' align-' + alignment;
block.style.textAlign = alignment;
} else {
block.className = className;
block.style.textAlign = '';
}
}, true );
return this.focus();
};
proto.setTextDirection = function ( direction ) {
this.forEachBlock( function ( block ) {
if ( direction ) {
block.dir = direction;
} else {
block.removeAttribute( 'dir' );
}
}, true );
return this.focus();
};

File diff suppressed because one or more lines are too long

View file

@ -1959,21 +1959,30 @@ proto.setHighlightColour = function ( colour ) {
proto.setTextAlignment = function ( alignment ) {
this.forEachBlock( function ( block ) {
block.className = ( block.className
var className = block.className
.split( /\s+/ )
.filter( function ( klass ) {
return !( /align/.test( klass ) );
return !!klass && !/^align/.test( klass );
})
.join( ' ' ) +
' align-' + alignment ).trim();
.join( ' ' );
if ( alignment ) {
block.className = className + ' align-' + alignment;
block.style.textAlign = alignment;
} else {
block.className = className;
block.style.textAlign = '';
}
}, true );
return this.focus();
};
proto.setTextDirection = function ( direction ) {
this.forEachBlock( function ( block ) {
if ( direction ) {
block.dir = direction;
} else {
block.removeAttribute( 'dir' );
}
}, true );
return this.focus();
};