-
Notifications
You must be signed in to change notification settings - Fork 52
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
Using a quill editor inside a react-flow is somehow causing cursors to render at strange places. #82
Comments
ah, just seconds after posting this I found something important! On load we are calling |
Okay, so the issue is definitely related to zooming in/out on the react flow :) |
So it looks like I need some way for whatever handles the cursors to be aware that the container's dimensions have changed, or something along those lines. Any ideas? |
This looks relevant slab/quill#635 |
How exactly is the container being resized? An MWE would be needed to debug this. |
Hey there :) Sorry for the vague issue, but I've pinned it down. I had to copy this lib into my own code any way due to something strange with the global This is probably not the most elegant solution, but it worked. I pass a const scale = {
x: containerBounds.width / this.quill.container.offsetWidth,
y: containerBounds.height / this.quill.container.offsetHeight,
}; This gets threaded down to the places where the position calculations are handled, and used like this: private _selectionBlock(selection: ClientRect, container: ClientRect, scale: Scale): HTMLElement {
const element = document.createElement(Cursor.SELECTION_ELEMENT_TAG);
element.classList.add(Cursor.SELECTION_BLOCK_CLASS);
element.style.top = `${(selection.top - container.top) / scale.y}px`;
element.style.left = `${(selection.left - container.left) / scale.x}px`;
element.style.width = `${selection.width / scale.x}px`;
element.style.height = `${selection.height / scale.y}px`;
element.style.backgroundColor = tinycolor(this.color).setAlpha(0.3).toString();
return element;
} |
Good sleuthing! I've not got a vast amount of time to work on this right now, but will try to take a look over the coming weeks. Alternatively, @fyvfyv do you want to pick this one up? |
@alecgibson Sure, I'll try to take a look soon |
For anyone who needs a quick-and-dirty fix for this, I have a fork here: https://github.com/lukebrody/quill-cursors Ideally this would happen automatically based on how the Quill editor is scaled, but I'm not familiar enough with getting this layout information out of the DOM to implement a PR that does this. |
I've been trying tons of things to make this work, and if it comes to it I can try to reproduce with a fiddle, but I was wondering if perhaps anyone would have a pointer on what to look for here, if there is some kind of issue using quill in this context w/ a resizing/absolute container (I think that is how react-flow works?).
Happy to provide additional info as needed, but hopefully there is just a lead I've failed to track down somewhere here :)
The text was updated successfully, but these errors were encountered: