Fixed automatically added new lines for inserted text
parent
4526d6b6bf
commit
fe54eb409d
|
@ -3,6 +3,7 @@
|
|||
- Updated the `setup_windows.md` tutorial
|
||||
- Correct redirecting to `index.php` when using the serve mode
|
||||
- Added correct hostname resolving for the web client.
|
||||
- Fixed automatically added new lines for inserted text
|
||||
|
||||
* **02.02.20**
|
||||
- Added a music bot GUI
|
||||
|
|
|
@ -133,7 +133,6 @@ namespace chat {
|
|||
return message.replace(/ /g, ' ');
|
||||
}
|
||||
private _callback_paste(event: ClipboardEvent) {
|
||||
|
||||
const _event = (<any>event).originalEvent as ClipboardEvent || event;
|
||||
const clipboard = _event.clipboardData || (<any>window).clipboardData;
|
||||
if(!clipboard) return;
|
||||
|
@ -151,7 +150,27 @@ namespace chat {
|
|||
const parser = new DOMParser();
|
||||
const nodes = parser.parseFromString(html_xml, "text/html");
|
||||
|
||||
const data = this._text(nodes.body);
|
||||
let data = this._text(nodes.body);
|
||||
|
||||
/* fix prefix & suffix new lines */
|
||||
{
|
||||
let prefix_length = 0, suffix_length = 0;
|
||||
{
|
||||
for(let i = 0; i < raw_text.length; i++)
|
||||
if(raw_text.charAt(i) === '\n')
|
||||
prefix_length++;
|
||||
else if(raw_text.charAt(i) !== '\r')
|
||||
break;
|
||||
for(let i = raw_text.length - 1; i >= 0; i++)
|
||||
if(raw_text.charAt(i) === '\n')
|
||||
suffix_length++;
|
||||
else if(raw_text.charAt(i) !== '\r')
|
||||
break;
|
||||
}
|
||||
|
||||
data = data.replace(/^[\n\r]+|[\n\r]+$/g, '');
|
||||
data = "\n".repeat(prefix_length) + data + "\n".repeat(suffix_length);
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
selection.deleteFromDocument();
|
||||
|
|
Loading…
Reference in New Issue