Skip to content

[WIKI-543] fix: unable to delete last cell of a table#7394

Merged
sriramveeraghanta merged 3 commits intopreviewfrom
fix/delete-last-cell
Jul 17, 2025
Merged

[WIKI-543] fix: unable to delete last cell of a table#7394
sriramveeraghanta merged 3 commits intopreviewfrom
fix/delete-last-cell

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jul 11, 2025

Description

This PR fixes the bug where users were unable to delete the last cell of a table on pressing Backspace.

New flow-

  1. When backspace is pressed on the last cell of a table, that cell gets selected.
  2. When backspace is pressed again, the cell gets deleted.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Media

Screen.Recording.2025-07-17.at.17.38.40.mov

Summary by CodeRabbit

  • New Features

    • Added a keyboard shortcut for Backspace in table cells to enhance cell selection when only one cell is present.
  • Refactor

    • Improved parent node detection in tables by updating internal logic to support searching for multiple node types.
    • Updated internal utility functions for better type handling and code clarity.
  • Style

    • Adjusted import order and added comments for improved code organization (no user-facing impact).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

The changes update utility function signatures and usage for finding parent nodes by type, refactor import paths for cell selection helpers, and add a keyboard shortcut to select a single table cell with Backspace. Type annotations and argument expectations are standardized for improved consistency across table-related editor utilities.

Changes

File(s) Change Summary
.../menus/bubble-menu/root.tsx Refactored import paths for isCellSelection and reordered imports for clarity; added a comment separator.
.../extensions/table/table-cell.ts Added a Backspace keyboard shortcut to select a single table cell when appropriate.
.../extensions/table/table/utilities/insert-line-above-table-action.ts
...below-table-action.ts
Updated findParentNodeOfType usage to pass an array of node types instead of a single type.
.../helpers/common.ts Changed findParentNodeOfType to accept an array of type names, updated logic and return type, added typing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Editor
    participant TableCellExtension
    participant TableMap

    User->>Editor: Presses Backspace in a table cell
    Editor->>TableCellExtension: Triggers Backspace shortcut handler
    TableCellExtension->>TableMap: Checks if table has only one cell
    TableMap-->>TableCellExtension: Returns cell count
    alt Table has one cell
        TableCellExtension->>Editor: Sets selection to entire cell
    else Table has more than one cell
        TableCellExtension->>Editor: Allows default Backspace behavior
    end
Loading

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • Palanikannan1437
  • VipinDevelops
  • sriramveeraghanta

Poem

A shortcut hops in with a gentle tap,
Backspace in a cell—now a clever trap!
Helpers refactored, imports in line,
Table logic polished, everything’s fine.
With tidy new types and functions arrayed,
The editor’s garden is neatly displayed.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 071b576 and 6acffb5.

📒 Files selected for processing (4)
  • packages/editor/src/core/extensions/table/table-cell.ts (2 hunks)
  • packages/editor/src/core/extensions/table/table/utilities/insert-line-above-table-action.ts (1 hunks)
  • packages/editor/src/core/extensions/table/table/utilities/insert-line-below-table-action.ts (1 hunks)
  • packages/editor/src/core/helpers/common.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/editor/src/core/extensions/table/table-cell.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/editor/src/core/extensions/table/table/utilities/insert-line-below-table-action.ts (1)
packages/editor/src/core/helpers/common.ts (1)
  • findParentNodeOfType (25-46)
packages/editor/src/core/extensions/table/table/utilities/insert-line-above-table-action.ts (1)
packages/editor/src/core/helpers/common.ts (1)
  • findParentNodeOfType (25-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
packages/editor/src/core/helpers/common.ts (3)

1-1: Good addition of explicit type import.

Adding the ProseMirrorNode type import improves type safety and makes the function signature more explicit.


25-32: Well-designed function signature enhancement.

The refactoring from a single typeName: string to typeName: string[] improves flexibility by allowing searches for multiple node types. The explicit return type annotation with depth property addition is also beneficial.


36-42: findParentNodeOfType: Array-based Calls Verified & No Performance Impact

All existing calls to findParentNodeOfType have been updated to use the new array signature, for example:

• packages/editor/src/core/extensions/table/table-cell.ts
• packages/editor/src/core/extensions/table/table/utilities/insert-line-above-table-action.ts
• packages/editor/src/core/extensions/table/table/utilities/insert-line-below-table-action.ts

Each array contains at most two items, so the cost of typeName.includes(...) remains negligible and depth traversal is unchanged. No further changes are needed.

packages/editor/src/core/extensions/table/table/utilities/insert-line-below-table-action.ts (1)

16-16: Correctly updated function call to match new signature.

The change from CORE_EXTENSIONS.TABLE to [CORE_EXTENSIONS.TABLE] properly adapts to the updated findParentNodeOfType function signature that now accepts an array of type names.

packages/editor/src/core/extensions/table/table/utilities/insert-line-above-table-action.ts (1)

16-16: Correctly updated function call to match new signature.

The change from CORE_EXTENSIONS.TABLE to [CORE_EXTENSIONS.TABLE] properly adapts to the updated findParentNodeOfType function signature, maintaining consistency with the changes in the sibling file.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link

makeplane bot commented Jul 11, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@aaryan610 aaryan610 changed the title [WIKI-543] fix: delete last cell of a table [WIKI-543] fix: unable to delete last cell of a table Jul 11, 2025
@aaryan610 aaryan610 requested a review from iam-vipin July 17, 2025 12:10
Copy link
Member

@iam-vipin iam-vipin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sriramveeraghanta sriramveeraghanta merged commit 7136b31 into preview Jul 17, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix/delete-last-cell branch July 17, 2025 15:49
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: delete last cell of a table

* refactor: last cell selection logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants