udecode / plate

A rich-text editor powered by AI
https://platejs.org
Other
11.9k stars 727 forks source link

Table attributes disappear during copying #3549

Closed oleg-orlov-quantori closed 1 month ago

oleg-orlov-quantori commented 2 months ago

Description

Table attributes disappear during copying

Add an attribute to a table:

const tableElement = getBlockAbove(editor, {
  match: { type: TablePlugin.key },
})?.[0];

if (tableElement == null) {
  return;
}

if (tableElement.attributes == null) {
  tableElement.attributes = {};
}

(tableElement.attributes as { [key: string]: string | undefined })['data-custom-attribute'] = 'value';

You can see this attribute:

image

But when you copy this table to clipboard - attribute will disappear:

<table>
  <tr>
    <td colspan="1" rowspan="1">
      <span></span>
    </td>
  </tr>
</table>

Reproduction URL

No response

Reproduction steps

1. Add an attribute to a table.
2. Copy this table to clipboard.
3. Look at clipboard data.

Actual result: table tag without attribute.
Expected result: table tag has data-custom-attribute.

Plate version

38.0.4

Slate React version

0.110.1

Screenshots

No response

Logs

No response

Browsers

No response

Funding

Fund with Polar