Browse Source

fix: long text to single text paste

pull/6586/head
mertmit 1 year ago
parent
commit
a7a634fd40
  1. 8
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  2. 4
      packages/nc-gui/composables/useMultiSelect/index.ts

8
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -17,6 +17,14 @@ export default function convertCellData(
if (value === '') return null if (value === '') return null
switch (to) { switch (to) {
case UITypes.SingleLineText:
case UITypes.LongText:
// This is to remove the quotes added from LongText
// TODO (refactor): remove this when we have a better way to handle this
if (value.match(/^".*"$/)) {
return value.slice(1, -1)
}
return value
case UITypes.Number: { case UITypes.Number: {
const parsedNumber = Number(value) const parsedNumber = Number(value)
if (isNaN(parsedNumber)) { if (isNaN(parsedNumber)) {

4
packages/nc-gui/composables/useMultiSelect/index.ts

@ -184,7 +184,7 @@ export function useMultiSelect(
} }
if (columnObj.uidt === UITypes.LongText) { if (columnObj.uidt === UITypes.LongText) {
textToCopy = `"${textToCopy.replace(/\"/g, '""')}"` textToCopy = `"${textToCopy.replace(/"/g, '\\"')}"`
} }
return textToCopy return textToCopy
@ -202,7 +202,7 @@ export function useMultiSelect(
const value = valueToCopy(row, col) const value = valueToCopy(row, col)
copyRow += `<td>${value}</td>` copyRow += `<td>${value}</td>`
text = `${text}${value}${cols.length - 1 !== i ? '\t' : ''}` text = `${text}${value}${cols.length - 1 !== i ? '\t' : ''}`
jsonRow.push(col.uidt === UITypes.LongText ? value.replace(/^"/, '').replace(/"$/, '').replace(/""/g, '"') : value) jsonRow.push(value)
}) })
html += `${copyRow}</tr>` html += `${copyRow}</tr>`
if (rows.length - 1 !== i) { if (rows.length - 1 !== i) {

Loading…
Cancel
Save