File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
component/src/utils/paste/CSV Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ export class ParseCSVClipboardText {
6
6
public static readonly NEW_LINE_SYMBOL = '\\n' ;
7
7
private static readonly EXPLICIT_TAB_SYMBOL = '\\\\t' ;
8
8
private static readonly EXPLICIT_NEW_LINE_SYMBOL = '\\\\n' ;
9
+ private static readonly WINDOWS_NEW_LINE_SYMBOL = '\\r\\n' ;
10
+ private static readonly EXPLICIT_WINDOWS_NEW_LINE_SYMBOL = '\\\\r\\\\n' ;
9
11
10
12
private static preprocessText ( multiLineString : string ) : string {
11
13
let newString = multiLineString ;
@@ -20,6 +22,17 @@ export class ParseCSVClipboardText {
20
22
21
23
private static getSeparatorSymbols ( multiLineString : string ) : { newLine : string ; tab : string } {
22
24
// occurs when pasting string that contains actual \n or \t symbols
25
+
26
+ // Handle Windows-style line endings (`\r\n`)
27
+ if ( multiLineString . indexOf ( ParseCSVClipboardText . EXPLICIT_WINDOWS_NEW_LINE_SYMBOL ) > - 1 ) {
28
+ return {
29
+ newLine : ParseCSVClipboardText . EXPLICIT_WINDOWS_NEW_LINE_SYMBOL , tab : ParseCSVClipboardText . EXPLICIT_TAB_SYMBOL
30
+ } ;
31
+ }
32
+ if ( multiLineString . indexOf ( ParseCSVClipboardText . WINDOWS_NEW_LINE_SYMBOL ) > - 1 ) {
33
+ return { newLine : ParseCSVClipboardText . WINDOWS_NEW_LINE_SYMBOL , tab : ParseCSVClipboardText . TAB_SYMBOL } ;
34
+ }
35
+ // Handle Unix-style line endings (`\n`)
23
36
if (
24
37
multiLineString . indexOf ( ParseCSVClipboardText . EXPLICIT_NEW_LINE_SYMBOL ) > - 1 ||
25
38
multiLineString . indexOf ( ParseCSVClipboardText . EXPLICIT_TAB_SYMBOL ) > - 1
You can’t perform that action at this time.
0 commit comments