-
Notifications
You must be signed in to change notification settings - Fork 174
feat: support rectangular selection when selecting a merged cell #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's copy the properties directly.
ocavue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.