-
-
Notifications
You must be signed in to change notification settings - Fork 206
Description
When pasting data with empty cells (e.g., Name\t\t\tCategory\t\tGrade), revogrid's HTML parser or clipboard conversion removes the empty cells, resulting in misaligned data. Manual text/plain parsing via beforepasteapply event preserves empty cells correctly.
Taking a look at the code and the body of the event.. I noticed that when copied right out of excel, empty fields were getting skipped. Even looking at the event data as html the field is missing. So this is browser level.
Sample data
The html that gets pasted has two rows
<td height=21 width=52 style='height:16.0pt;width:39pt'>Alex</td>
<td width=75 style='width:56pt'>Example</td>
<td width=87 style='width:65pt'>Alphabet</td>
<td width=87 style='width:65pt'>K</td>
<td align=right width=87 style='width:65pt'>123456</td>
</tr>
<tr height=21 style='height:16.0pt'>
<td height=21 colspan=2 style='height:16.0pt;mso-ignore:colspan'>Sam Example</td>
<td>Spelling</td>
<td align=right>3</td>
<td></td>
</tr>
So the parse builds out
My fix..
I added
const clipboardText = event.detail.event.clipboardData?.getData('text/plain')
if (clipboardText) {
event.detail.parsed = clipboardText
.split('\n')
.map(row => row.split('\t').map(cell => cell || ''))
}
into the handleBeforePasteApply function..
IN here
revogrid/src/components/clipboard/revogr-clipboard.tsx
@listen('paste',
It picks the html...
suggestion..
return dataText (which you already have) through to the event, so my code can pick parsed or dataText and I could parse it myself. Would save me reaching into the clipboard.