Skip to content

Conversation

@fisherZW
Copy link

No description provided.

@ocavue
Copy link
Collaborator

ocavue commented Mar 25, 2025

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.

@fisherZW
Copy link
Author

fisherZW commented Apr 1, 2025

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.mp4

rectangular selection:

2025-04-01.14-32-32.mp4

Maybe it is useful for some scenarios。

@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 63.4% 1781 / 2809
🔵 Statements 63.4% 1781 / 2809
🔵 Functions 59.85% 82 / 137
🔵 Branches 86.29% 510 / 591
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/index.ts 89.09% 50% 66.66% 89.09% 106, 116, 120-123
src/input.ts 25.48% 60.71% 36.36% 25.48% 78-83, 98-100, 108-126, 130-135, 139-172, 176-197, 203-244, 247-341, 354, 362-384
Unchanged Files
demo/demo.ts 0% 0% 0% 0% 1-115
src/cellselection.ts 69.33% 86.56% 50% 69.33% 71-72, 129-130, 150-153, 182-198, 201-202, 262-264, 310-311, 321-322, 328-333, 336-337, 348-349, 361-363, 366-367, 370-381, 385-437, 461-464
src/columnresizing.ts 6.99% 50% 6.66% 6.99% 58-112, 119-121, 125-139, 142-387, 399-432
src/commands.ts 85.13% 85.56% 84% 85.13% 189, 192-193, 353, 356-357, 442-443, 514-515, 621, 713, 732, 743, 787-819, 828-842, 850-865, 873-893
src/copypaste.ts 98.71% 90.36% 100% 98.71% 330-331, 342-343
src/fixtables.ts 78.94% 88.57% 75% 78.94% 24-47
src/schema.ts 73.33% 61.53% 50% 73.33% 13-37, 148-149, 180-181
src/tablemap.ts 93.07% 95.16% 87.5% 93.07% 61-74, 140, 150, 355-356
src/tableview.ts 7.59% 100% 0% 7.59% 15-28, 31-40, 43-47, 54-101
src/util.ts 74.57% 88.37% 71.42% 74.57% 36-37, 45-46, 78-79, 85-102, 115-116, 133-134, 140-141
Generated in workflow #7 for commit fe01640 by the Vitest Coverage Report Action


type Axis = 'horiz' | 'vert';

interface Rect {
Copy link
Collaborator

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'.

Comment on lines +306 to +310
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,
);
Copy link
Collaborator

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) {
Copy link
Collaborator

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));
Copy link
Collaborator

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.

Copy link
Collaborator

@ocavue ocavue left a 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

@jjongsu
Copy link

jjongsu commented Jun 11, 2025

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!

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.

3 participants