ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.71k stars 3.24k forks source link

Can't delete blocks at first line #1031

Closed ezakto closed 7 years ago

ezakto commented 7 years ago

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

Can't delete block nodes in first line.

  1. Go to http://slatejs.org/#/rich-text
  2. Add a list or a blockquote
  3. Remove the previous content so the block is in the first line
  4. Press backspace like crazy

slatelist

slatequote

What's the expected behavior?

It should remove the block (probably defaulting to paragraph?)

ianstormtaylor commented 7 years ago

Hey @ezakto thanks for this. The rich-text example is just an example of what's possible, in your editor you can choose how you want to handle backspacing at the beginning of a document like this, but it's not something core will handle for it, since it doesn't make assumptions about your schema.

ezakto commented 7 years ago

@ianstormtaylor that seems odd as it assumes you want to delete block nodes in other lines?

ianstormtaylor commented 7 years ago

@ezakto in other cases it's not forced to come up with the node type you want to insert by itself because it's actually just collapsing the content into the previous node, whatever its type may be. In the case of deleting at the start of a single quote block, it would actually need to create a new node (or change the node's type), and that is a schema-specific decision.

Basically anything where the decision is schema-specific, Slate's core won't handle it. In general this sacrifices a bit smartness in certain cases, like this one, but reduces complexity a lot overall. But I do feel for you that this specific case is an unfortunate casualty of that design decision.