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,7 +4524,7 @@ proto.insertHTML = function ( html, isPaste ) {
|
|||
return this;
|
||||
};
|
||||
|
||||
var escapeHTMLFragement = function ( text ) {
|
||||
var escapeHTML = function ( text ) {
|
||||
return text.split( '&' ).join( '&' )
|
||||
.split( '<' ).join( '<' )
|
||||
.split( '>' ).join( '>' )
|
||||
|
@ -4574,14 +4574,16 @@ proto.insertPlainText = function ( plainText, isPaste ) {
|
|||
|
||||
for ( attr in attributes ) {
|
||||
openBlock += ' ' + attr + '="' +
|
||||
escapeHTMLFragement( attributes[ attr ] ) +
|
||||
escapeHTML( attributes[ attr ] ) +
|
||||
'"';
|
||||
}
|
||||
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 = escapeHTMLFragement( line ).replace( / (?= )/g, ' ' );
|
||||
line = escapeHTML( line ).replace( / (?= )/g, ' ' );
|
||||
// Wrap each line in <div></div>
|
||||
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 += '>';
|
||||
|
||||
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 = escapeHTML( line ).replace( / (?= )/g, ' ' );
|
||||
// Wrap each line in <div></div>
|
||||
|
|
Loading…
Reference in a new issue