question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] use react-quil,Cannot read property 'imports' of undefined

See original GitHub issue

webpack config

  chainWebpack: (config, { env, webpack }) => {
    new webpack.ProvidePlugin({
      'window.Quill': 'quill/dist/quill.js',
      'Quill': 'quill/dist/quill.js'
    }),
    config.module
        .rule('quill-image-resize')
        .test(/\.js$/)
        .exclude
        .add(/node_modules(?!\/quill-image-drop-module|quill-image-resize-module)/)
        .end()
        .use('loader')
        .loader('babel-loader')
  }

code

import ReactQuill, { Quill } from 'react-quill';
import ImageResize from 'quill-image-resize-module';

Quill.register('modules/imageResize', ImageResize);

 const modules = {
    imageResize: {   //添加
      displayStyles: {   //添加
        backgroundColor: 'black',
        border: 'none',
        color: 'white'
      },
      modules: ['Resize', 'DisplaySize', 'Toolbar'] 
    },
    toolbar: {
      container: [
        ['bold', 'italic', 'underline', 'strike'],
        ['blockquote', 'code-block'],
        [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }],
        [{ script: 'sub' }, { script: 'super' }],
        [{ direction: 'rtl' }],

        [{ 'size': ['10px', '12px', '14px', '16px', '18px', '20px', '22px', '24px', '26px', '32px', '48px'] }],
        [{ header: [1, 2, 3, 4, 5, 6, false] }],

        [{ color: [] }, { background: [] }],
        [{ font: [] }],
        [{ align: [] }],
        ['link', 'image', 'video'],
        ['clean'],
      ],
      handlers: {
        image: imageHandler,
      },
    },
    imageUploader: {
      upload: (file: any) => {
        handleUpload(file, (urlData: any) => {
          dropImageRef.current = `${DomainNameOfImg}${urlData}`;
          quillEditor = quillRef.current.getEditor();
          const range = quillEditor.getSelection();
          quillEditor.insertEmbed(range.index, 'image', dropImageRef.current);
          currentContextRef.current = quillEditor.scrollingContainer.innerHTML;
        });
        return dropImageRef.current;
      },
    },
  };

   <ReactQuill
    ref={quillRef}
    value={currentContextRef.current || ''}
    onChange={handleTextChange}
    modules={modules}
    formats={formats}
    style={{ height: '51vh', width: '100%', borderRadius: '12px' }}
   />

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:6

github_iconTop GitHub Comments

3reactions
ikibkilamcommented, Aug 2, 2020

Please help. I have the same problem. Using react.

1reaction
danwellmancommented, Sep 25, 2020

FWIW I fixed this with ngx-quill by installing the BlotFormatter plugin (which also supports image resizing)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'imports' of undefined (react-quill ...
I tried using the require statement, but the error remains the same. These are my dependencies: "quill-image-resize-module": "^3.0.0", ...
Read more >
playlistList - Uncaught TypeError: Cannot read property 'then ...
I'm having trouble with the 'Feature Request' advanced project (building on the Jammming project)n - hope someone can help me out ...
Read more >
[swydo:graphql] Get error, If I have 2 .graphql schemas that ...
I get error when If I have 2 .graphql schemas that import each other ... (STDERR) TypeError: Cannot read property 'filter' of undefined...
Read more >
TypeError: Cannot read property 'imports' of undefined
computer: Environment Visual Studio with juanblanco.solidity extension Truffle v5.1.66 (core: 5.1.66) Node v14.15.0 Using the latest ...
Read more >
TypeError: Cannot read property 'document' of undefined
I am using it in a fairly large project at the moment and all of a sudden I'm getting the below errors. My...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found