lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Discussion: Making list-items draggable instead of list-nodes

Open aquarius-wing opened this issue 2 years ago • 8 comments

At present, we treat each list node as an entire block, similar to this. CleanShot 2023-05-30 at 18 58 29@2x However, a more refined approach would be to consider each indented list node as an individual block, akin to how it is done in Notion. CleanShot 2023-05-30 at 18 59 20@2x

aquarius-wing avatar May 30 '23 11:05 aquarius-wing

If my suggestion is accepted, I would be more than happy to contribute to the code.

aquarius-wing avatar May 30 '23 11:05 aquarius-wing

If my suggestion is accepted, I would be more than happy to contribute to the code.

Awesome, thank you!

I think one thing we'd need to think about here is what exactly makes this more "refined"? I know that block-based editors are trendy right now, and I do see some benefits, but I'd like to understand what specific advantages adding the concept of more granular block to Lexical might confer?

If we can get past that to a place where we can see clear advantages that are worth the implementation trade-offs, I'm not opposed to this.

acywatson avatar May 30 '23 21:05 acywatson

The only advantage I can think of is that such a function is essential for a Notion-like editor. If Lexical aims to create a general editing framework, then this kind of modification will only enhance Lexical's versatility and applicability.

aquarius-wing avatar May 31 '23 05:05 aquarius-wing

I think the concept of "block" may evoke in many a rigid architecture with little flexibility, which is used by other editors like https://editorjs.io/

It is difficult in these editors to achieve an arbitrary HTML structure. Also, I think many make the mistake of reinventing arbitrary selection with CSS.

I think this is not what @aquarius-wing is proposing or what @acywatson is concerned about.

I suggest changing the title of this discussion to something like: "Making list-items draggable instead of list-nodes".

That's plausible without sacrificing anything in Lexical, just modify "DraggableBlockPlugin".

In fact, I've almost done it by using a function to split lists. The problem is that after dragging and dropping several list-items they start to fragment into contiguous lists. The only thing I would be missing is a way to combine lists. I'm experimenting with different strategies, meanwhile I've opened a thread here: https://github.com/facebook/lexical/issues/4618

GermanJablo avatar Jun 07 '23 19:06 GermanJablo

I think the concept of "block" may evoke in many a rigid architecture with little flexibility, which is used by other editors like https://editorjs.io/

It is difficult in these editors to achieve an arbitrary HTML structure. Also, I think many make the mistake of reinventing arbitrary selection with CSS.

I think this is not what @aquarius-wing is proposing or what @acywatson is concerned about.

I suggest changing the title of this discussion to something like: "Making list-items draggable instead of list-nodes".

That's plausible without sacrificing anything in Lexical, just modify "DraggableBlockPlugin".

In fact, I've almost done it by using a function to split lists. The problem is that after dragging and dropping several list-items they start to fragment into contiguous lists. The only thing I would be missing is a way to combine lists. I'm experimenting with different strategies, meanwhile I've opened a thread here: #4618

I cann't agree with you any more. May be we don't need to take such big steps, just modify the list-node is fine.

aquarius-wing avatar Jun 10 '23 15:06 aquarius-wing

Hi @GermanJablo Have you solved this problem yet? I want to drag and drop list-item instead of a list but I don't know how to handle it

Tai-Ku avatar Sep 10 '24 06:09 Tai-Ku

What I did was not use @lexical/list and use my own list nodes which follows a flat model using indentation

GermanJablo avatar Sep 10 '24 12:09 GermanJablo

Can you share in more detail how you handled it? It would be great if you could show me your code

Tai-Ku avatar Sep 10 '24 12:09 Tai-Ku

Did somebody figure it out and can share pseudo code or code? Or even just details on how to implement this.

alterhuman avatar Apr 11 '25 11:04 alterhuman

Frankly, I need this feature. It would also be great to establish a child-parent relationship by moving the list elements left-right

meftunca avatar Apr 14 '25 19:04 meftunca