Skip to content

Commit 81701d7

Browse files
authored
Merge pull request #24 from topcoder-platform/issues-526
Issues-526: Fixed formatting in Firefox
2 parents 45ada40 + 3bb87ed commit 81701d7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

js/topcodereditor.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,13 @@
646646

647647
editor.codemirror.on('paste', function (cm, event) {
648648
var clipboard = event.clipboardData;
649-
var data = clipboard.getData('text/plain').trim();
650-
var rows = data.split((/[\u0085\u2028\u2029]|\r\n?/g)).map(function(row) {
651-
row = row.replace('\n', ' ')
652-
return row.split("\t")
649+
// trim the trailing newline character, if present.
650+
var data = clipboard.getData('text/plain');
651+
data = data.replace(/(?:[\n\u0085\u2028\u2029]|\r\n?)$/, '');
652+
var rows = data.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(function(row) {
653+
return row.split("\t");
653654
})
655+
654656
var isTableData = looksLikeTable(rows);
655657
if(isTableData) {
656658
event.preventDefault();

0 commit comments

Comments
 (0)