flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Rearrange Texts and embeds on selection and dragging

Open manandharsudhir opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

Use case

I am trying to add a feature in my application where the user can add custom embeds in the text editor and on selecting the embed user must be able to move the embed from one location to another.

Proposal

https://github.com/user-attachments/assets/486406e1-4aac-48cf-8bb3-ce1d61f9b68e

manandharsudhir avatar Jan 13 '25 06:01 manandharsudhir

By now, we cannot focus on this type features (since, we have too much things to organize, move, and fix). I gonna add it to my TODOs.

Edit: This is probably easier to do than we expect, but we'll need to do some fine-tuning. Using a package I'm creating would reduce a lot of code (the current problem is that the getEmbedNode function sometimes doesn't work. Maybe that's just because I'm using it wrong though).

CatHood0 avatar Jan 13 '25 07:01 CatHood0

I'll refrain from taking charge of creating this feature since I've been quite inactive for various reasons. If you want, you can try to create this functionality, although, instead of only allowing this for Embeds we can do it for all Flutter Quill Nodes.

The tricky part would be creating the drag and drop, the easy part is removing the selected text (or the Embed) and then inserting it at the Offset where the Node was dropped. Although thinking about it, we would really need key functions of RenderEditor since it transforms a global Offset to a local one where we can simply get the respective Node and then get the offset of the document of said node.

We're still in theory, though, so probably none of this is easy...

CatHood0 avatar Jan 13 '25 07:01 CatHood0

Now that I think about it, it really wouldn't be that complicated, it would be more about adding a listener that listens while the selected text is being dragged to another part, and that, when it is released, then looks for the child at offset (that's what the childAtOffset function is for).

Another thing would be to verify if the drag that the user is doing is within the selected text (it's not that difficult considering that there are already functions that do something similar).

Maybe in the future, I'll take the time to add this feature.

CatHood0 avatar Feb 21 '25 05:02 CatHood0