facebook / facebook/lexical

Feature: Delete an entire line (all selected lines) all at once

Open
#4,524 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 16h
Merged PRs (30d)
61

Description

I'm trying to implement a keyboard shortcut to delete everything on all selected lines in one single command, but having trouble doing so with lexical's API. Examples would be the following:

Text:
1. Line 1
2. Line 2
3. Line 3

If my cursor was on line 2 (either collapsed or selecting some of the characters on this line), running the command should delete only line 2 and the result would look like:
1. Line 1
2. Line 3

If my cursor was in the middle of line 2 and extended to line 3, running the command should delete all of both line 2 and line 3 and the result would look like:
1. Line 1

This is similar to Jetbrains Ctrl/Cmd + Y/Backspace (delete line) functionality in their IDE.

What I've tried:
1. The DELETE_LINE_COMMAND only deletes in a single direction
5. Using selection to select all of the desired regions and then delete is wonky due to the reliance on the native API

Contributor guide

Open the contributing guide

Research direction

Start by examining Lexical's DELETE_LINE_COMMAND and the selection handling involved in deleting content across multiple lines. Reproduce the collapsed-cursor and multi-line-selection examples from the issue, then determine how the command should behave without relying on the native selection API. Done means all selected lines are removed in one command while unaffected lines remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.