mirror of
https://github.com/fastmail/Squire.git
synced 2025-03-23 04:51:22 -05:00
Use default block config when inserting plain text
This commit is contained in:
parent
4e7e290fbc
commit
aa3857ab77
3 changed files with 50 additions and 16 deletions
|
@ -3868,18 +3868,35 @@ proto.insertHTML = function ( html, isPaste ) {
|
|||
return this;
|
||||
};
|
||||
|
||||
var escapeHTMLFragement = function ( text ) {
|
||||
return text.split( '&' ).join( '&' )
|
||||
.split( '<' ).join( '<' )
|
||||
.split( '>' ).join( '>' )
|
||||
.split( '"' ).join( '"' );
|
||||
};
|
||||
|
||||
proto.insertPlainText = function ( plainText, isPaste ) {
|
||||
var lines = plainText.split( '\n' ),
|
||||
i, l, line;
|
||||
var lines = plainText.split( '\n' );
|
||||
var config = this._config;
|
||||
var tag = config.blockTag;
|
||||
var attributes = config.blockAttributes;
|
||||
var closeBlock = '</' + tag + '>';
|
||||
var openBlock = '<' + tag;
|
||||
var attr, i, l, line;
|
||||
|
||||
for ( attr in attributes ) {
|
||||
openBlock += ' ' + attr + '="' +
|
||||
escapeHTMLFragement( attributes[ attr ] ) +
|
||||
'"';
|
||||
}
|
||||
openBlock += '>';
|
||||
|
||||
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
||||
line = lines[i];
|
||||
line = line.split( '&' ).join( '&' )
|
||||
.split( '<' ).join( '<' )
|
||||
.split( '>' ).join( '>' )
|
||||
.replace( / (?= )/g, ' ' );
|
||||
line = escapeHTMLFragement( line ).replace( / (?= )/g, ' ' );
|
||||
// Wrap all but first/last lines in <div></div>
|
||||
if ( i && i + 1 < l ) {
|
||||
line = '<DIV>' + ( line || '<BR>' ) + '</DIV>';
|
||||
line = openBlock + ( line || '<BR>' ) + closeBlock;
|
||||
}
|
||||
lines[i] = line;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1650,18 +1650,35 @@ proto.insertHTML = function ( html, isPaste ) {
|
|||
return this;
|
||||
};
|
||||
|
||||
var escapeHTMLFragement = function ( text ) {
|
||||
return text.split( '&' ).join( '&' )
|
||||
.split( '<' ).join( '<' )
|
||||
.split( '>' ).join( '>' )
|
||||
.split( '"' ).join( '"' );
|
||||
};
|
||||
|
||||
proto.insertPlainText = function ( plainText, isPaste ) {
|
||||
var lines = plainText.split( '\n' ),
|
||||
i, l, line;
|
||||
var lines = plainText.split( '\n' );
|
||||
var config = this._config;
|
||||
var tag = config.blockTag;
|
||||
var attributes = config.blockAttributes;
|
||||
var closeBlock = '</' + tag + '>';
|
||||
var openBlock = '<' + tag;
|
||||
var attr, i, l, line;
|
||||
|
||||
for ( attr in attributes ) {
|
||||
openBlock += ' ' + attr + '="' +
|
||||
escapeHTMLFragement( attributes[ attr ] ) +
|
||||
'"';
|
||||
}
|
||||
openBlock += '>';
|
||||
|
||||
for ( i = 0, l = lines.length; i < l; i += 1 ) {
|
||||
line = lines[i];
|
||||
line = line.split( '&' ).join( '&' )
|
||||
.split( '<' ).join( '<' )
|
||||
.split( '>' ).join( '>' )
|
||||
.replace( / (?= )/g, ' ' );
|
||||
line = escapeHTMLFragement( line ).replace( / (?= )/g, ' ' );
|
||||
// Wrap all but first/last lines in <div></div>
|
||||
if ( i && i + 1 < l ) {
|
||||
line = '<DIV>' + ( line || '<BR>' ) + '</DIV>';
|
||||
line = openBlock + ( line || '<BR>' ) + closeBlock;
|
||||
}
|
||||
lines[i] = line;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue