facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.58k stars 2.64k forks source link

Indenting list block of one type inside the other #443

Open jpuri opened 8 years ago

jpuri commented 8 years ago

If I create a OL of 2 items and change depth of 2nd item to 2, like this:

1. ITEM1
      2. ITEM2

If I change type of 2nd item to UL it looses it depth:

1. ITEM1

2. ITEM2

But now if I try to indent second item, it works

1. ITEM1

    2. ITEM2

While indenting its checked that block above is list, but its not checked if its list of same type. Also, please find gif attached. I can create a PR for the fix.

jpuri commented 8 years ago

indenting

hellendag commented 8 years ago

Thanks for the GIF -- very helpful. :)

I don't recall whether this was intentional, but block depth is always reset when setting type: https://github.com/facebook/draft-js/blob/master/src/model/transaction/setBlockTypeForContentState.js#L35

I'd be open to a PR to change this, since it seems reasonable to preserve depth on list items.

ericbiewener commented 8 years ago

I'm not sure how the OP created that GIF -- Draft doesn't create true nested lists. All nesting is an illusion accomplished purely via CSS:

image

And the corresponding DOM:

image

Perhaps this is a newer approach that was not in play when the OP posted?

thibaudcolas commented 6 years ago

This is reproducible in any editor that has the two list types, and that has a way to increase depth, https://draftjs.org/ shows the issue. There are two separate behaviours:

GIF for the first behavior:

draftjs-list-indent-types

Second behaviour, the depth reset bug:

draftjs-depth-reset-bug

cappuccino6 commented 5 years ago

Is there anybody teach me how to do this issue, thx very much