import { UITypes } from '../../../nocodb-sdk' import type { ColumnType } from '../../../nocodb-sdk' import type { Row } from '~/lib' export const copyTable = async (rows: Row[], cols: ColumnType[]) => { let copyHTML = '' let copyPlainText = '' rows.forEach((row) => { let copyRow = '' cols.forEach((col) => { let value = (col.title && row.row[col.title]) ?? '' if (typeof value === 'object') { value = JSON.stringify(value) } copyRow += `` copyPlainText = `${copyPlainText} ${value} \t` }) copyHTML += `${copyRow}` copyPlainText = `${copyPlainText.trim()}\n` }) copyHTML += '
${value}
' copyPlainText.trim() const blobHTML = new Blob([copyHTML], { type: 'text/html' }) const blobPlainText = new Blob([copyPlainText], { type: 'text/plain' }) return navigator.clipboard.write([new ClipboardItem({ [blobHTML.type]: blobHTML, [blobPlainText.type]: blobPlainText })]) }