kensnyder / quill-image-resize-module

A module for Quill rich text editor to allow images to be resized.
MIT License
464 stars 457 forks source link

eslint error #12

Open suziesirena opened 7 years ago

suziesirena commented 7 years ago

Hi,

I try to use quill-image-resize-module with react-quill in a react component but the build fails.

I have an error with eslint module but I don't know what is wrong. The error is:

quill-image-resize-module/node_modules/eslint/lib/api.js didn't return a function

Is it a problem with eslint version in quill-image-resize-module?

Here is my code :

import React from 'react'
import ReactDom from 'react-dom'
import ReactQuill from 'react-quill'
import { ImageResize } from 'quill-image-resize-module'

export default class Test extends React.Component {
  constructor(props) {
    super(props)
    this.state = { text: '' }
  }

  componentWillMount() {
    ReactQuill.Quill.register('modules/imageResize', ImageResize)
  }

  handleChange(value) {
    this.setState({ text: value })
  }

  render() {
    var modules= {
      ImageResize: {
        modules: [ 'Resize', 'DisplaySize', 'Toolbar' ]
      },
      toolbar: [
        // [{SizeStyle : SizeStyle}],
        [{ 'size': ['small', false, 'large', 'huge'] }],
        [{ 'header': [1, 2, false] }],
        ['bold', 'italic', 'underline','strike', 'blockquote'],
        [{'list': 'ordered'}, {'list': 'bullet'}, {'indent': '-1'}, {'indent': '+1'}],
        ['link', 'image'],
        ['clean']
      ]
    }

    var formats= [
      'header',
      'bold', 'italic', 'underline', 'strike', 'blockquote',
      'list', 'bullet', 'indent',
      'link', 'image'
    ]

    return (
      <div className="text-editor">
        <ReactQuill theme="snow"
                    modules={modules}
                    formats={formats}>
        </ReactQuill>
      </div>
    )
  }
}
racc-oo-n commented 7 years ago

Hi,

try to exclude node_modules from your eslint rule. For example for webpack it will look like this

module: {
    rules: [
      {
        test: /\.js$/,
        enforce: 'pre',
        use: 'eslint-loader',
        exclude: /node_modules/
      },
      ...
   ]
}

Maybe, it will help