0
Fork 0
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:
Neil Jenkins 2020-03-02 10:23:24 +11:00
parent ede1991931
commit f6d6ac8ca0
3 changed files with 13 additions and 9 deletions

View file

@ -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( '&lt;' )
.split( '>' ).join( '&gt;' )
@ -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, '&nbsp;' );
line = escapeHTML( line ).replace( / (?= )/g, '&nbsp;' );
// Wrap each line in <div></div>
lines[i] = openBlock + ( line || '<BR>' ) + closeBlock;
}

File diff suppressed because one or more lines are too long

View file

@ -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, '&nbsp;' );
// Wrap each line in <div></div>