mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
paste multicell
This commit is contained in:
parent
fd3308e05a
commit
d578a8f011
@ -359,22 +359,24 @@ export default function DataGridCore(props) {
|
|||||||
pastedText = event.clipboardData.getData('text/plain');
|
pastedText = event.clipboardData.getData('text/plain');
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const rows = pastedText.replace(/\r/g, '').split('\n');
|
const pasteRows = pastedText
|
||||||
|
.replace(/\r/g, '')
|
||||||
|
.split('\n')
|
||||||
|
.map(row => row.split('\t'));
|
||||||
let chs = changeSet;
|
let chs = changeSet;
|
||||||
let allRows = loadedAndInsertedRows;
|
let allRows = loadedAndInsertedRows;
|
||||||
|
|
||||||
if (selectedCells.length <= 1) {
|
if (selectedCells.length <= 1) {
|
||||||
if (isRegularCell(currentCell)) {
|
if (isRegularCell(currentCell)) {
|
||||||
let rowIndex = currentCell[0];
|
let rowIndex = currentCell[0];
|
||||||
for (const rowData of rows) {
|
for (const rowData of pasteRows) {
|
||||||
if (rowIndex >= allRows.length) {
|
if (rowIndex >= allRows.length) {
|
||||||
chs = changeSetInsertNewRow(chs, display.baseTable);
|
chs = changeSetInsertNewRow(chs, display.baseTable);
|
||||||
allRows = [...loadedRows, ...getChangeSetInsertedRows(chs, display.baseTable)];
|
allRows = [...loadedRows, ...getChangeSetInsertedRows(chs, display.baseTable)];
|
||||||
}
|
}
|
||||||
let colIndex = currentCell[1];
|
let colIndex = currentCell[1];
|
||||||
const cells = rowData.split('\t');
|
|
||||||
const row = allRows[rowIndex];
|
const row = allRows[rowIndex];
|
||||||
for (const cell of cells) {
|
for (const cell of rowData) {
|
||||||
chs = setChangeSetValue(
|
chs = setChangeSetValue(
|
||||||
chs,
|
chs,
|
||||||
display.getChangeSetField(
|
display.getChangeSetField(
|
||||||
@ -390,6 +392,28 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selectedCells.length > 1) {
|
||||||
|
const regularSelected = selectedCells.filter(isRegularCell);
|
||||||
|
const startRow = _.min(regularSelected.map(x => x[0]));
|
||||||
|
const startCol = _.min(regularSelected.map(x => x[1]));
|
||||||
|
for (const cell of regularSelected) {
|
||||||
|
const [rowIndex, colIndex] = cell;
|
||||||
|
const selectionRow = rowIndex - startRow;
|
||||||
|
const selectionCol = colIndex - startCol;
|
||||||
|
const row = allRows[rowIndex];
|
||||||
|
const pasteRow = pasteRows[selectionRow % pasteRows.length];
|
||||||
|
const pasteCell = pasteRow[selectionCol % pasteRow.length];
|
||||||
|
chs = setChangeSetValue(
|
||||||
|
chs,
|
||||||
|
display.getChangeSetField(
|
||||||
|
row,
|
||||||
|
realColumnUniqueNames[colIndex],
|
||||||
|
rowIndex >= loadedRows.length ? rowIndex - loadedRows.length : null
|
||||||
|
),
|
||||||
|
pasteCell
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setChangeSet(chs);
|
setChangeSet(chs);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user