Skip to content

feat(Clipboard): exclude empty table cells at edges of selection from copied content#945

Open
d3m1d0v wants to merge 1 commit intomainfrom
trim-empty-cells
Open

feat(Clipboard): exclude empty table cells at edges of selection from copied content#945
d3m1d0v wants to merge 1 commit intomainfrom
trim-empty-cells

Conversation

@d3m1d0v
Copy link
Member

@d3m1d0v d3m1d0v commented Feb 3, 2026

No description provided.

@d3m1d0v d3m1d0v requested a review from makhnatkin as a code owner February 3, 2026 15:58
@gravity-ui
Copy link

gravity-ui bot commented Feb 3, 2026

Storybook Deployed

@gravity-ui
Copy link

gravity-ui bot commented Feb 3, 2026

🎭 Playwright Report

/** @internal */
export function trimTableEdgeCell($pos: ResolvedPos, dir: 'backward' | 'forward'): number {
let depth = $pos.depth;
let isAtEdgeOfInlineBlocks = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit
The variable doesn’t check “inline”; it checks the edge along the document tree. Let’s name it isAtContentEdge or isAtTextblockEdge.

const isInTable = node.type.spec.tableRole || parentNode.type.spec.tableRole;
if (!isInTable || !node.isTextblock) {
return $pos.pos;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand code correctly we only detect “in table” when the textblock or its direct parent has tableRole. If a cell content is wrapped (e.g. tableCellblockquote/listp), isInTable becomes false and we return early, so edge navigation/trim doesn’t work. We should walk up to the nearest ancestor with tableRole (cell) and then check whether the selection is at the edge of that cell (possibly via wrappers).

Let's add tests for

  • yfmTd(blockquote(p('text'))):
  • yfmTd(list(li(p('text')))):

if (node !== edgeNode) break;

depth--;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit
If there is another table inside tableCell, tableRole will start to appear at several levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants