Browse Source

fix: trim unnecessary spaces from copy output

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5847/head
mertmit 2 years ago
parent
commit
cf64048304
  1. 11
      packages/nc-gui/composables/useMultiSelect/copyValue.ts

11
packages/nc-gui/composables/useMultiSelect/copyValue.ts

@ -5,21 +5,22 @@ export const copyTable = async (rows: Row[], cols: ColumnType[]) => {
let copyHTML = '<table>' let copyHTML = '<table>'
let copyPlainText = '' let copyPlainText = ''
rows.forEach((row) => { rows.forEach((row, i) => {
let copyRow = '<tr>' let copyRow = '<tr>'
cols.forEach((col) => { cols.forEach((col, i) => {
let value = (col.title && row.row[col.title]) ?? '' let value = (col.title && row.row[col.title]) ?? ''
if (typeof value === 'object') { if (typeof value === 'object') {
value = JSON.stringify(value) value = JSON.stringify(value)
} }
copyRow += `<td>${value}</td>` copyRow += `<td>${value}</td>`
copyPlainText = `${copyPlainText} ${value} \t` copyPlainText = `${copyPlainText}${value}${cols.length - 1 !== i ? '\t' : ''}`
}) })
copyHTML += `${copyRow}</tr>` copyHTML += `${copyRow}</tr>`
copyPlainText = `${copyPlainText.trim()}\n` if (rows.length - 1 !== i) {
copyPlainText = `${copyPlainText}\n`
}
}) })
copyHTML += '</table>' copyHTML += '</table>'
copyPlainText.trim()
const blobHTML = new Blob([copyHTML], { type: 'text/html' }) const blobHTML = new Blob([copyHTML], { type: 'text/html' })
const blobPlainText = new Blob([copyPlainText], { type: 'text/plain' }) const blobPlainText = new Blob([copyPlainText], { type: 'text/plain' })

Loading…
Cancel
Save