mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-18 04:32:28 -05:00
Fix first line of plain text paste not HTML escaped
This commit is contained in:
parent
f6d6ac8ca0
commit
2d307ba54a
3 changed files with 15 additions and 9 deletions
|
@ -4579,13 +4579,16 @@ proto.insertPlainText = function ( plainText, isPaste ) {
|
||||||
}
|
}
|
||||||
openBlock += '>';
|
openBlock += '>';
|
||||||
|
|
||||||
// We don't wrap the first line in the block, so if it gets inserted into
|
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
||||||
// 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, ' ' );
|
||||||
|
// 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.
|
||||||
// Wrap each line in <div></div>
|
// Wrap each line in <div></div>
|
||||||
lines[i] = openBlock + ( line || '<BR>' ) + closeBlock;
|
if ( i ) {
|
||||||
|
line = openBlock + ( line || '<BR>' ) + closeBlock;
|
||||||
|
}
|
||||||
|
lines[i] = line;
|
||||||
}
|
}
|
||||||
return this.insertHTML( lines.join( '' ), isPaste );
|
return this.insertHTML( lines.join( '' ), isPaste );
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2020,13 +2020,16 @@ proto.insertPlainText = function ( plainText, isPaste ) {
|
||||||
}
|
}
|
||||||
openBlock += '>';
|
openBlock += '>';
|
||||||
|
|
||||||
// We don't wrap the first line in the block, so if it gets inserted into
|
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
||||||
// 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, ' ' );
|
||||||
|
// 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.
|
||||||
// Wrap each line in <div></div>
|
// Wrap each line in <div></div>
|
||||||
lines[i] = openBlock + ( line || '<BR>' ) + closeBlock;
|
if ( i ) {
|
||||||
|
line = openBlock + ( line || '<BR>' ) + closeBlock;
|
||||||
|
}
|
||||||
|
lines[i] = line;
|
||||||
}
|
}
|
||||||
return this.insertHTML( lines.join( '' ), isPaste );
|
return this.insertHTML( lines.join( '' ), isPaste );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue