Skip to content
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

FHL: Port TableCellSelection plugin #2506

Merged
merged 22 commits into from
Mar 20, 2024
Merged

Conversation

JiuqingSong
Copy link
Collaborator

@JiuqingSong JiuqingSong commented Mar 14, 2024

Port the original TableCellSelection plugin and merge the logic into existing SelectionPlugin. Now the table selection become part of editor core, and no need to add any plugin explicitly for it.

Expose the following new types:

  • TableCellCoordinate: {row, col}
  • TableSelectionInfo: Store current table selection info, can be incomplete since user is still moving mouse
  • ParsedTable: a 2D array for TD or its span state

Create the following internal util functions:

  • findTableCellElement: Try to find a TD/TH element from the given row and col number from the given parsed table
  • findLastedCoInMergedCell: Try to find the last logic cell of a merged table cell
  • findCoordinate: Find coordinate of a given element from a parsed table
  • normalizePos: Find the deepest position of the given position (aka Position.normalize() in old code)

Add a IgnoredPluginNames const in EditorAdapter to aways ignore old TableCellSelection plugin since it will be conflict with the new one

Also handle keyboard event for the following cases:

  • Up/Down in table: move focus into the cell above/below
  • Shift+Up/Down in table: select current cell and the cell above/below. If there is already table selection, adjust the selection according to the key
  • Shift+Left/Right in table: select current cell and the cell left/right. If there is already table selection, adjust the selection according to the key

I didn't handle TAB key in this change since it is not directly related to table selection. We will handle it in future changes.

Fix a bug in getDOMSelection when check isReverted.
Fix #861

@JiuqingSong JiuqingSong marked this pull request as ready for review March 18, 2024 19:08
@Andres-CT98
Copy link
Contributor

This behaviour appears to be missing from the port: #2024

@JiuqingSong
Copy link
Collaborator Author

This behaviour appears to be missing from the port: #2024

Thanks, good catch! Just fixed.

@BryanValverdeU
Copy link
Contributor

If I start a selection in a nested table and mouse move to the parent table, the selection is not updating to the parent table. Not sure if we want to implement in the new plugin:
3192024

@JiuqingSong
Copy link
Collaborator Author

If I start a selection in a nested table and mouse move to the parent table, the selection is not updating to the parent table. Not sure if we want to implement in the new plugin: 3192024 3192024

Thanks, fixed.

@JiuqingSong JiuqingSong merged commit 2d6cae1 into master Mar 20, 2024
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/porttableselection branch March 20, 2024 16:57
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.

TableCellSelection Plugin is not considering the Cell Spans
3 participants