Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show caret when dragging an element in text editor #142

Open
martinhonza opened this issue Oct 17, 2024 · 1 comment
Open

Show caret when dragging an element in text editor #142

martinhonza opened this issue Oct 17, 2024 · 1 comment

Comments

@martinhonza
Copy link

Hi,
https://codesandbox.io/p/sandbox/slate-reproductions-forked-hlvpjh
i am trying to implement drag and drop with slatejs where I wanna drag elements and drop them inside the editor itself, problem is that when I am dragging an element the caret is not showing at the destination.
In the example I have draggable elements, text in contenteditable and image, text and image do show an caret but draggable element no. I am thinking that it's because of the type of dataTransfer ?
Is it possible to somehow resolve this, maybe change the type of dataTransfer to plain text where I would drag an json or something like that ? implementing drop indicator instead of browser caret seems difficult, as it would need to be correctly positioned on line, move by the width of letter, etc...

@martinhonza
Copy link
Author

Maybe a bit of progress, I tried to put getInitialDataForExternal: (args) => ({ 'text/plain': 'hello' }) which makes the caret work at the beginning/end of line or in my app it works even if I am slightly under or on top of the line, I can then position the caret inside text. But If I hover directly over the line/text then it doesnt register, onDrag/onDrop event doesn't fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant