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

When i Paste it is scrolling to the Top #4528

Open
Yathish26 opened this issue Dec 15, 2024 · 0 comments
Open

When i Paste it is scrolling to the Top #4528

Yathish26 opened this issue Dec 15, 2024 · 0 comments

Comments

@Yathish26
Copy link

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;
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