react-quill icon indicating copy to clipboard operation
react-quill copied to clipboard

When i add the handlers method to the react quill, the edit box always auto blur when i input a letter.

Open z-lionel opened this issue 3 years ago • 9 comments

When i add the handlers method to the react quill, the edit box always auto blur when i input a letter. how can i fix it?

I want to add custom properties for the link like this: < a href=" " data-custom="custom properties">data</ a>

it means i have to custome the handlers link? because i can't find any api to do this thing.

z-lionel avatar Feb 28 '21 03:02 z-lionel

I also experience the same and I was wondering if I am doing something wrong, but it looks like it comes from the ReactQuill component...

@zenoamaro any ideas?

vidimitrov avatar Mar 03 '21 09:03 vidimitrov

I have same issue get an error Error: The given range isn't in document in browser console. And fix this wrapping with useMemo function. reference: https://github.com/quilljs/quill/issues/1940

  const modules = useMemo(() => {
      toolbar: {
        handlers: {
          image: imageHandler,
        },
        container: [
          [{ header: [1, 2, false] }],
          ['bold', 'italic', 'underline', 'strike', 'blockquote'],
          [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }],
          ['link', 'image'],
          ['clean'],
        ],
      },
      clipboard: {
        matchVisual: false,
      },
    };
  }, []);
<ReactQuill
      theme="snow"
      id={'quill'}
      style={{ marginBottom: '10px' }}
      modules={modules}
      value={content}
      onChange={onChangeContent}
      ref={quillRef}
    />

SooJungChae avatar Mar 09 '21 06:03 SooJungChae

Yep running in to this as well - it seems typing the first character into an empty ReactQuill editor with the value/onChange set to use strings (vs deltas) causes it to blur. Trying to work around this, will let y'all know if I come up with anything!

bengotow avatar Mar 31 '21 15:03 bengotow

Also experiencing the same problem will let you know if I find anything out too!

joeyparis avatar Mar 31 '21 19:03 joeyparis

my workaround, although after a couple hours of working with Quill I have concluded that it is intrinsically incompatible with React as the project exists currently. I am abandoning quill in favor of my own equivalent. this work-around I started with was only the tip of the iceberg of much deeper problems with this project. Screenshot from 2021-04-09 13-17-03

codefist avatar Apr 09 '21 17:04 codefist

I have the same problem: I using this library (use-debounce) to resolve it:

const debounced = useDebouncedCallback((value: string) => { setEditorHtml(value) }, 500)

//use the useMemo to prevent rerendering const modules = useMemo( () => ({ toolbar: { container: [...], handlers: { image: imageHandler, }, }, }),[])

<ReactQuill ref={quill} defaultValue={""} onChange={(e) => debounced(e)} modules={modules} />

dieng01 avatar May 14 '21 06:05 dieng01

Same issue. https://github.com/zenoamaro/react-quill/issues/688#issuecomment-793441268 worked for me

pavi2410 avatar Jul 05 '21 09:07 pavi2410

Using useMemo worked for me as well, however the brackets and parentheses in https://github.com/zenoamaro/react-quill/issues/688#issuecomment-793441268 is not correct. This is what worked for me:

const modules = useMemo(() => ({
      toolbar: {
        handlers: { image: imageHandler,},
        container: [
          [{ header: [1, 2, false] }],
          ["bold", "italic", "underline", "strike", "blockquote"],
          [{ list: "ordered" }, { list: "bullet" }, { indent: "-1" }, { indent: "+1" }],
          ["link", "image"],
          ["clean"],
        ],
      },
      clipboard: {
        matchVisual: false,
      },
    }),[]);

SimonProper avatar Aug 28 '22 16:08 SimonProper