mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 13:16:31 -05:00
Style pass
This commit is contained in:
parent
29fffdccd0
commit
b4d47775b9
4 changed files with 17 additions and 15 deletions
|
@ -1326,7 +1326,7 @@ var keyHandlers = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( /^PRE|CODE|SAMP$/.test( block.nodeName ) ) {
|
if ( block.nodeName === 'PRE' ) {
|
||||||
if ( !getNodeAfter( range.endContainer, range.endOffset ).nodeValue[ range.endOffset ] ) {
|
if ( !getNodeAfter( range.endContainer, range.endOffset ).nodeValue[ range.endOffset ] ) {
|
||||||
insertNodeInRange( range, self._doc.createTextNode( '\n\n' ) );
|
insertNodeInRange( range, self._doc.createTextNode( '\n\n' ) );
|
||||||
} else {
|
} else {
|
||||||
|
@ -3554,12 +3554,13 @@ var getTextFromHTMLFragment = function ( self, frag ) {
|
||||||
|
|
||||||
var makePreformatted = function ( frag ) {
|
var makePreformatted = function ( frag ) {
|
||||||
return this.createElement( 'PRE',
|
return this.createElement( 'PRE',
|
||||||
this._config.tagAttributes.pre, [
|
this._config.tagAttributes.pre,
|
||||||
|
[
|
||||||
this.createElement( 'INPUT', { id: startSelectionId, type: 'hidden' } ),
|
this.createElement( 'INPUT', { id: startSelectionId, type: 'hidden' } ),
|
||||||
getTextFromHTMLFragment( this, frag ),
|
getTextFromHTMLFragment( this, frag ),
|
||||||
this.createElement( 'INPUT', { id: endSelectionId, type: 'hidden' } ),
|
this.createElement( 'INPUT', { id: endSelectionId, type: 'hidden' } ),
|
||||||
this._doc.createTextNode( '\n' )
|
this._doc.createTextNode( '\n' )
|
||||||
] );
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
var removePreformatted = function ( frag ) {
|
var removePreformatted = function ( frag ) {
|
||||||
|
@ -3573,12 +3574,12 @@ var removePreformatted = function ( frag ) {
|
||||||
range.setStartBefore( startRangeMarker );
|
range.setStartBefore( startRangeMarker );
|
||||||
range.setEndAfter( endRangeMarker );
|
range.setEndAfter( endRangeMarker );
|
||||||
|
|
||||||
var preElems = frag.querySelectorAll('pre');
|
var preElems = frag.querySelectorAll( 'pre' );
|
||||||
if ( preElems.length === 0 ) {
|
if ( preElems.length === 0 ) {
|
||||||
return frag;
|
return frag;
|
||||||
} else {
|
} else {
|
||||||
var firstPre = preElems[0],
|
var firstPre = preElems[0],
|
||||||
lastPre = preElems[preElems.length - 1],
|
lastPre = preElems[ preElems.length - 1 ],
|
||||||
startContainer = range.startContainer,
|
startContainer = range.startContainer,
|
||||||
startOffset = range.startOffset,
|
startOffset = range.startOffset,
|
||||||
endContainer = range.endContainer,
|
endContainer = range.endContainer,
|
||||||
|
@ -3628,7 +3629,7 @@ var removePreformatted = function ( frag ) {
|
||||||
split( startContainer, startOffset, firstPre.parentNode );
|
split( startContainer, startOffset, firstPre.parentNode );
|
||||||
splitElems.push( startContainer );
|
splitElems.push( startContainer );
|
||||||
}
|
}
|
||||||
preElems = frag.querySelectorAll('pre');
|
preElems = frag.querySelectorAll( 'pre' );
|
||||||
range.setStartBefore( startRangeMarker );
|
range.setStartBefore( startRangeMarker );
|
||||||
range.setEndAfter( endRangeMarker );
|
range.setEndAfter( endRangeMarker );
|
||||||
var self = this,
|
var self = this,
|
||||||
|
@ -3643,7 +3644,7 @@ var removePreformatted = function ( frag ) {
|
||||||
// replace all text nodes with HTMLified version of text content (1 DIV per line)
|
// replace all text nodes with HTMLified version of text content (1 DIV per line)
|
||||||
var nodeLines = childNode.nodeValue.split( '\n' );
|
var nodeLines = childNode.nodeValue.split( '\n' );
|
||||||
/*jshint loopfunc: true*/
|
/*jshint loopfunc: true*/
|
||||||
nodeLines.forEach( function (line) {
|
nodeLines.forEach( function ( line ) {
|
||||||
if ( !line ) { return; }
|
if ( !line ) { return; }
|
||||||
var div = self.createDefaultBlock( [ self._doc.createTextNode ( line ) ] );
|
var div = self.createDefaultBlock( [ self._doc.createTextNode ( line ) ] );
|
||||||
replacement.appendChild( div );
|
replacement.appendChild( div );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1351,12 +1351,13 @@ var getTextFromHTMLFragment = function ( self, frag ) {
|
||||||
|
|
||||||
var makePreformatted = function ( frag ) {
|
var makePreformatted = function ( frag ) {
|
||||||
return this.createElement( 'PRE',
|
return this.createElement( 'PRE',
|
||||||
this._config.tagAttributes.pre, [
|
this._config.tagAttributes.pre,
|
||||||
|
[
|
||||||
this.createElement( 'INPUT', { id: startSelectionId, type: 'hidden' } ),
|
this.createElement( 'INPUT', { id: startSelectionId, type: 'hidden' } ),
|
||||||
getTextFromHTMLFragment( this, frag ),
|
getTextFromHTMLFragment( this, frag ),
|
||||||
this.createElement( 'INPUT', { id: endSelectionId, type: 'hidden' } ),
|
this.createElement( 'INPUT', { id: endSelectionId, type: 'hidden' } ),
|
||||||
this._doc.createTextNode( '\n' )
|
this._doc.createTextNode( '\n' )
|
||||||
] );
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
var removePreformatted = function ( frag ) {
|
var removePreformatted = function ( frag ) {
|
||||||
|
@ -1370,12 +1371,12 @@ var removePreformatted = function ( frag ) {
|
||||||
range.setStartBefore( startRangeMarker );
|
range.setStartBefore( startRangeMarker );
|
||||||
range.setEndAfter( endRangeMarker );
|
range.setEndAfter( endRangeMarker );
|
||||||
|
|
||||||
var preElems = frag.querySelectorAll('pre');
|
var preElems = frag.querySelectorAll( 'pre' );
|
||||||
if ( preElems.length === 0 ) {
|
if ( preElems.length === 0 ) {
|
||||||
return frag;
|
return frag;
|
||||||
} else {
|
} else {
|
||||||
var firstPre = preElems[0],
|
var firstPre = preElems[0],
|
||||||
lastPre = preElems[preElems.length - 1],
|
lastPre = preElems[ preElems.length - 1 ],
|
||||||
startContainer = range.startContainer,
|
startContainer = range.startContainer,
|
||||||
startOffset = range.startOffset,
|
startOffset = range.startOffset,
|
||||||
endContainer = range.endContainer,
|
endContainer = range.endContainer,
|
||||||
|
@ -1425,7 +1426,7 @@ var removePreformatted = function ( frag ) {
|
||||||
split( startContainer, startOffset, firstPre.parentNode );
|
split( startContainer, startOffset, firstPre.parentNode );
|
||||||
splitElems.push( startContainer );
|
splitElems.push( startContainer );
|
||||||
}
|
}
|
||||||
preElems = frag.querySelectorAll('pre');
|
preElems = frag.querySelectorAll( 'pre' );
|
||||||
range.setStartBefore( startRangeMarker );
|
range.setStartBefore( startRangeMarker );
|
||||||
range.setEndAfter( endRangeMarker );
|
range.setEndAfter( endRangeMarker );
|
||||||
var self = this,
|
var self = this,
|
||||||
|
@ -1440,7 +1441,7 @@ var removePreformatted = function ( frag ) {
|
||||||
// replace all text nodes with HTMLified version of text content (1 DIV per line)
|
// replace all text nodes with HTMLified version of text content (1 DIV per line)
|
||||||
var nodeLines = childNode.nodeValue.split( '\n' );
|
var nodeLines = childNode.nodeValue.split( '\n' );
|
||||||
/*jshint loopfunc: true*/
|
/*jshint loopfunc: true*/
|
||||||
nodeLines.forEach( function (line) {
|
nodeLines.forEach( function ( line ) {
|
||||||
if ( !line ) { return; }
|
if ( !line ) { return; }
|
||||||
var div = self.createDefaultBlock( [ self._doc.createTextNode ( line ) ] );
|
var div = self.createDefaultBlock( [ self._doc.createTextNode ( line ) ] );
|
||||||
replacement.appendChild( div );
|
replacement.appendChild( div );
|
||||||
|
|
|
@ -175,7 +175,7 @@ var keyHandlers = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( /^PRE|CODE|SAMP$/.test( block.nodeName ) ) {
|
if ( block.nodeName === 'PRE' ) {
|
||||||
if ( !getNodeAfter( range.endContainer, range.endOffset ).nodeValue[ range.endOffset ] ) {
|
if ( !getNodeAfter( range.endContainer, range.endOffset ).nodeValue[ range.endOffset ] ) {
|
||||||
insertNodeInRange( range, self._doc.createTextNode( '\n\n' ) );
|
insertNodeInRange( range, self._doc.createTextNode( '\n\n' ) );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue