-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Allow optional drag event enabling #2579
Conversation
This change allows consumers to enable drag events by configuring Quill with an `enableDragging` flag. This is useful for writing custom modules that want to use drag behaviour.
db93d60
to
935b478
Compare
Preventing dragging in Quill was motivated by some browsers that allow images and other elements (iirc images in Firefox, links in Edge) to be moved natively but such actions would mess up the DOM structure that Quill expects and tries to keep tidy and predictable. What is your use case for dragstart? |
Our use case is allowing dragging of certain custom blots around the DOM. For example, we have a heavily-customised image block blot, which has an associated caption attached to it. Manipulating the image (moving / deleting) will also make sure we correctly move / delete the associated caption. This seems like a much more user-friendly approach to the alternatives, which are:
|
@jhchen if you don't want to add this flag, can we please at least move the listener registration into a module like the |
I don't want to add the flag but not sure how to best let people override it. This guard doesn't really make sense in the uploader as its purpose is unrelated to the uploader. Somewhere in ScrollBlot might be more appropriate. |
@jhchen if you want it in the class Scroll extends ScrollBlot {
constructor(registry, domNode, { emitter }) {
// Do some constructory stuff
this.domNode.addEventListener('dragstart', e => this.preventDrag(e));
}
// Users can now extend this class and override this method
preventDrag(e) {
e.preventDefault();
}
} We could also do the above on the If you're happy with the above proposal, let me know and I'll put together a new PR. |
Yes that works although can you name it handleDrag or handleDragStart? Thanks! |
Superseded by #2596 |
This change allows consumers to enable drag events by configuring Quill
with an
enableDragging
flag.This is useful for writing custom modules that want to use drag
behaviour.