FIX: paste table with multiline cell (#12194)
When a cell is multiline, it is wrapped with quotes. It can be used to determine if it is a "real" new line or not. Meta: https://meta.discourse.org/t/pasting-google-sheets-table-with-a-cell-that-contain-a-line-break/173106
This commit is contained in:
parent
362dd798ae
commit
57bfc398d4
|
@ -883,7 +883,19 @@ export default Component.extend({
|
|||
text = text.substring(0, text.length - 1);
|
||||
}
|
||||
|
||||
let rows = text.split("\n");
|
||||
text = text.split("");
|
||||
let cell = false;
|
||||
text.forEach((char, index) => {
|
||||
if (char === "\n" && cell) {
|
||||
text[index] = "\r";
|
||||
}
|
||||
if (char === '"') {
|
||||
text[index] = "";
|
||||
cell = !cell;
|
||||
}
|
||||
});
|
||||
|
||||
let rows = text.join("").replace(/\r/g, "<br>").split("\n");
|
||||
|
||||
if (rows.length > 1) {
|
||||
const columns = rows.map((r) => r.split("\t").length);
|
||||
|
|
|
@ -721,6 +721,11 @@ third line`
|
|||
let element = queryAll(".d-editor")[0];
|
||||
await paste(element, "\ta\tb\n1\t2\t3");
|
||||
assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2|3|\n");
|
||||
|
||||
this.set("value", "");
|
||||
|
||||
await paste(element, '\ta\tb\n1\t"2\n2.5"\t3');
|
||||
assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2<br>2.5|3|\n");
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue