feat: support rectangular selection when selecting a merged cell#271
feat: support rectangular selection when selecting a merged cell#271fisherZW wants to merge 3 commits intoProseMirror:masterfrom
Conversation
|
Sorry for the late reply. I don't understand rectangular selection from your PR. Could you describe it more? A video would be helpful for example. |
normal sleection: 2025-04-01.14-31-17.mp4rectangular selection: 2025-04-01.14-32-32.mp4Maybe it is useful for some scenarios。 |
Coverage Report
File Coverage |
|
|
||
| type Axis = 'horiz' | 'vert'; | ||
|
|
||
| interface Rect { |
There was a problem hiding this comment.
You can just import type {Rect} from './tablemap'.
| const { tr } = view.state; | ||
| const $anchorCell = tr.doc.resolve(map[top * width + left] + tableStart); | ||
| const $headCell = tr.doc.resolve( | ||
| map[(bottom - 1) * width + right - 1] + tableStart, | ||
| ); |
There was a problem hiding this comment.
I guess you don't need tr to the doc. You can use const doc = $anchor.doc
| } | ||
|
|
||
| // get Rectangular cell Selection | ||
| function getRectangularSelection($anchor: ResolvedPos, $head: ResolvedPos) { |
There was a problem hiding this comment.
Let's move this function out of handleMouseDown so that we can write test for it.
| // get rectangular | ||
| export function getRectangularRect(rect: Rect, tableMap: TableMap) { | ||
| let mergedCellsIndices = []; | ||
| const rectangle = JSON.parse(JSON.stringify(rect)); |
There was a problem hiding this comment.
Let's copy the properties directly.
ocavue
left a comment
There was a problem hiding this comment.
Thanks for your contribution. This feature would be good. I left some review comments. Could you also add some tests to those functions you added? Thanks
|
Hi, thank you for the great work on this library. I've noticed that CellSelection works well when using mouse events. However, when navigating with the keyboard using Shift + arrow keys, it still behaves as it did previously. I was wondering if it might make sense for the CellSelection class to accept an option related to supportRectangularSelection in its constructor to handle this case more consistently. Would love to hear your thoughts on this! |
No description provided.