mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Pasting plain text on a blank line should keep line's formatting
This commit is contained in:
parent
ede1991931
commit
f6d6ac8ca0
3 changed files with 13 additions and 9 deletions
|
@ -4524,11 +4524,11 @@ proto.insertHTML = function ( html, isPaste ) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
var escapeHTMLFragement = function ( text ) {
|
var escapeHTML = function ( text ) {
|
||||||
return text.split( '&' ).join( '&' )
|
return text.split( '&' ).join( '&' )
|
||||||
.split( '<' ).join( '<' )
|
.split( '<' ).join( '<' )
|
||||||
.split( '>' ).join( '>' )
|
.split( '>' ).join( '>' )
|
||||||
.split( '"' ).join( '"' );
|
.split( '"' ).join( '"' );
|
||||||
};
|
};
|
||||||
|
|
||||||
proto.insertPlainText = function ( plainText, isPaste ) {
|
proto.insertPlainText = function ( plainText, isPaste ) {
|
||||||
|
@ -4574,14 +4574,16 @@ proto.insertPlainText = function ( plainText, isPaste ) {
|
||||||
|
|
||||||
for ( attr in attributes ) {
|
for ( attr in attributes ) {
|
||||||
openBlock += ' ' + attr + '="' +
|
openBlock += ' ' + attr + '="' +
|
||||||
escapeHTMLFragement( attributes[ attr ] ) +
|
escapeHTML( attributes[ attr ] ) +
|
||||||
'"';
|
'"';
|
||||||
}
|
}
|
||||||
openBlock += '>';
|
openBlock += '>';
|
||||||
|
|
||||||
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
// We don't wrap the first line in the block, so if it gets inserted into
|
||||||
|
// a blank line it keeps that line's formatting.
|
||||||
|
for ( i = 1, l = lines.length; i < l; i += 1 ) {
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
line = escapeHTMLFragement( line ).replace( / (?= )/g, ' ' );
|
line = escapeHTML( line ).replace( / (?= )/g, ' ' );
|
||||||
// Wrap each line in <div></div>
|
// Wrap each line in <div></div>
|
||||||
lines[i] = openBlock + ( line || '<BR>' ) + closeBlock;
|
lines[i] = openBlock + ( line || '<BR>' ) + closeBlock;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2020,7 +2020,9 @@ proto.insertPlainText = function ( plainText, isPaste ) {
|
||||||
}
|
}
|
||||||
openBlock += '>';
|
openBlock += '>';
|
||||||
|
|
||||||
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
// We don't wrap the first line in the block, so if it gets inserted into
|
||||||
|
// a blank line it keeps that line's formatting.
|
||||||
|
for ( i = 1, l = lines.length; i < l; i += 1 ) {
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
line = escapeHTML( line ).replace( / (?= )/g, ' ' );
|
line = escapeHTML( line ).replace( / (?= )/g, ' ' );
|
||||||
// Wrap each line in <div></div>
|
// Wrap each line in <div></div>
|
||||||
|
|
Loading…
Reference in a new issue