React-quill: Creating a handler for a link popup/modal

Created on 24 May 2017  路  7Comments  路  Source: zenoamaro/react-quill

I'm using [email protected] in my React component, and would like to customize the "link" button so that it displays a popup/modal in which the user can paste the link and the link text.

So far this is what I've got:

var TextEditor = React.createClass({

    getInitialState: function () {
        return {
            text: this.props.initialData
        }
    },

    onTextChange: function (value) {
        this.setState({ text: value });
    },

    modules: {
        handlers: {
            // handlers object will be merged with default handlers object
            'link': function(value) {
                if (value) {
                    var href = prompt('Enter the URL');
                    this.quill.format('link', href);
                } else {
                    this.quill.format('link', false);
                }
            }
        }
    },

    formats: [
        'header',
        'bold', 'italic', 'underline', 'strike', 'blockquote',
        'list', 'bullet', 'indent',
        'link',
    ],

    render: function () {
        return (
            <ReactQuill theme="snow"
                        value={this.state.text}
                        onChange={this.onTextChange}
                        modules={this.modules}
                        formats={this.formats} />
        )
    }

});
export default TextEditor;

The error message I'm getting is that it can't find the "handlers" module. Any ideas anyone on how to get this working?

Most helpful comment

http://quilljs.com/docs/modules/toolbar/#handlers

All 7 comments

I'm running into the same issue attempting to use the handlers property as it is documented

http://quilljs.com/docs/modules/toolbar/#handlers

this works for adding link but how do I get the same behavior for edit link?

afsafsafsaf

Hi I want to create popup on button click in the toolbar which allows user to do search. Does anyone know how to implement in Quill editor

@KiranVH Hi, look at my answer https://github.com/zenoamaro/react-quill/issues/471#issuecomment-579971349, maybe it will helpful for you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LiuChangFreeman picture LiuChangFreeman  路  3Comments

Drejerdk picture Drejerdk  路  4Comments

prosenjitchy picture prosenjitchy  路  3Comments

levous picture levous  路  3Comments

jaimefps picture jaimefps  路  3Comments