Instructions & ideas about drag & drop of non inline nodes #2713
Unanswered
oskar-szwajkowski
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
After working time with utilizing Draft.js as main editor, I have achieved there some behavior, that is not out of the box in there, and now wondering how could I do them in lexical, which should be more extendable and flexible, but I cannot figure it out.
What I have now in Draft.js, and how I have done it:
DraftBlockRenderMap
, which I have overriden, passing custom wrapper that wraps eachblock
in element that has drag handle, and can be dragged only by this handle, this works pretty good, as I am savingblock key
on drag start, on drag over I am savingblock key
which let me show drop lines under each block, and then on drop I am moving draggedblock
in content block array to reflect operationTo sum it up, I believe that this wrapper thing was usefull, and I am trying to somehow reflect it in lexical, but without success.
In lexical:
react-beautiful-dnd
and wrap Node in<Draggrable />
Then this drag handle on drag start is saving
node key
intodataTransfer
, and then on drop listener reads it, and reads not that has been dropped into, to figure out where to place dropped block (searching nearest drag handle, as rendered nodes does not contain any HTML attribute withnode key
and selecting during dragging returns null (or previous value)I am mentioning paragraph, but in my mind I see it as all non inline nodes, good example of those behaviors is notion.
I know that there is a task scheduled for future, but I have such requirements now, and as I am hiting limit of Draft.js (would need some collaboration capabilities in future etc.) I am thinking about switching either to
lexical
, orSlate
, and researching capabilitiesI have written some of it there #2115 , but felt like it deserves its own discussion
If you have any idea how to solve this in current stage, I would appreciate any answer, from my point of view overwriting ParagraphNode (and all non inline nodes) with ones that could render custom React components, and then as children rendering original nodes, would do, but I do not see that option in current implementation of lexical.
Beta Was this translation helpful? Give feedback.
All reactions