quill
quill copied to clipboard
When i Paste it is scrolling to the Top
When I paste any text or image into the Quill editor, the page scrolls to the top. I'm unsure if this is a bug with Quill or if I'm missing something in my implementation. Here's the code I'm using. Could you help me figure out how to prevent the page from scrolling?
import React, { forwardRef, useImperativeHandle, useRef, useEffect } from 'react';
import ReactQuill, { Quill } from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import ImageResize from 'quill-image-resize-module-react';
Quill.register('modules/imageResize', ImageResize);
const QuillWrapper = forwardRef((props, ref) => {
const quillRef = useRef(null);
useImperativeHandle(ref, () => ({
getEditor: () => quillRef.current.getEditor(),
}));
useEffect(() => {
const quill = quillRef.current.getEditor();
const root = quill.root;
root.style.fontSize = '16px';
root.style.fontFamily = 'Spartan, sans-serif';
}, []);
const modules = {
toolbar: [
[{ size: ['small', false, 'large', 'huge'] }],
['bold', 'italic', 'underline', 'strike'],
[{ align: [] }],
[{ list: 'ordered' }, { list: 'bullet' }],
['code-block'],
['image', 'link'],
],
imageResize: {
modules: ['Resize', 'DisplaySize', 'Toolbar'],
},
clipboard: {
matchVisual: false,
},
};
return <ReactQuill ref={quillRef} modules={modules} {...props} />
});
export default QuillWrapper;
I am facing the same issues. Did you happen to figure out this issue?
No then i found out its a Quill Editor Issue itself not working then i changed the library
Hi @Yathish26 @malhardhawle You can do this to prevent unintended scroll by quill
let lastScroll = window.pageYOffset;
window.onscroll = () => {
lastScroll = window.pageYOffset;
}
quill.root.addEventListener('paste', (e) => {
window.scrollTo(0, lastScroll);
});