The built in behavior of inserting quotes and lists seems unintuitive to me #4632
Replies: 2 comments 6 replies
-
I understand your points, since I also gave them a thought a while ago. I arrived to the conclusion that this behaviour is the correct one. The key point is that, as an analogy of the DOM, Lexical is modeled with hierarchical data models in the form of
The same behaviour is observed in other elements such as
|
Beta Was this translation helpful? Give feedback.
-
Got this issue that requireing paragraphs inside quote, too |
Beta Was this translation helpful? Give feedback.
-
I'm currently working on a project with an existing editor solution, but we are trying to move over to Lexical for various reasons. One of the biggest sticking points so far has been the treatment of lists and quotes by the built in commands
INSERT_ORDERED_LIST
,INSERT_UNORDERED_LIST
and the code the playground uses to insert a quote:Here's some examples of what I mean, all experiments done in the playground:
Entering the following content:
Has what seems like intuitive interactions with lists:
Quotes though are a different story, the behavior here is internally consistent its just not what I would expect:
The second point is as I would expect, but in the first I expected to get one quote with the content of all three line separate into paragraphs as they had already been. As for my reasoning for why this seems unintuitive, is that if I highlight what is seemingly one large block consisting of multiple paragraphs of text in order to format it as a quote, I am not thinking, "I want a separate quote for each paragraph" I am thinking that I want all of the selected text in one big quote.
Now lets look at if I did that same thing but with
SHIFT + ENTER
instead ofENTER
.Lists now get a little weird:
I can kind of understand the first point, this is now just one large string separated by line breaks, but I'd still usually expect these to have come out as separate list items delimited by the line breaks. The second result is really visually confusing, the reason its happening is for the same reason as the first point but you end up with a list item including content you had not selected.
Quotes now behave how I expected in one instance but not the other:
Now the first point behaves exactly as I would expect, but the second, similar to lists, is formatting content I would not expect it to format.
The way quotes and lists interact is strange as well, highlighting any part of a quote and formatting as list will format the entire quote as a list, and formatting a list as a quote has a very similar interaction.
I opened this as a discussion because maybe its my thinking that is off, and if so I'd like to know. If there is interest in changing any of this behavior in the packages themselves, I would be willing to contribute changes. Either way I have to implement the behavior for us to use this package in our project, which we want to. These behaviors might apply to other elements as well, these have just been the ones that I have been interacting with the most.
Beta Was this translation helpful? Give feedback.
All reactions