feat(Clipboard): exclude empty table cells at edges of selection from copied content#945
feat(Clipboard): exclude empty table cells at edges of selection from copied content#945
Conversation
| /** @internal */ | ||
| export function trimTableEdgeCell($pos: ResolvedPos, dir: 'backward' | 'forward'): number { | ||
| let depth = $pos.depth; | ||
| let isAtEdgeOfInlineBlocks = true; |
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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. tableCell → blockquote/list → p), 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--; | ||
| } |
There was a problem hiding this comment.
nit
If there is another table inside tableCell, tableRole will start to appear at several levels.
No description provided.