Skip to content

Commit

Permalink
fix: preserve Windows newline characters
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed May 20, 2021
1 parent 244dcac commit bbdf13c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/PropertiesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ PropertiesPanel.prototype._bindListeners = function(container) {

function handlePaste(event) {
var text = (event.clipboardData || window.clipboardData).getData('text');

text = normalizeEndOfLineSequences(text);

document.execCommand('insertText', false, text);

event.preventDefault();
Expand Down Expand Up @@ -1233,4 +1236,8 @@ function setContentEditableSelection(node, selection) {
domSelection = window.getSelection();
domSelection.removeAllRanges();
domSelection.addRange(domRange);
}

function normalizeEndOfLineSequences(string) {
return string.replace(/\r\n|\r|\n/g, '\n');
}

0 comments on commit bbdf13c

Please sign in to comment.