Creating a handler for a link popup/modal

See original GitHub issue

I’m using react-quill@1.0.0 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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
alexkrolickcommented, May 25, 2017

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

0reactions
MaxRazencommented, Jan 29, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to open the modal popup using a link, instead of button
As of right now, I have the code as a button to open the modal, and buttons are pre styles, I just want...
Read more >
How to Make an External Link Pop-up Modal
The modals show additional content or opportunities -- both in context of your page's content or out of context depending on your usage...
Read more >
4 Ways to Create a Modal Popup Box with HTML, CSS and ...
We declared a createCustomAlert() function. This is where we create the body of our modal, displayed on the page. Then we created a...
Read more >
How to implement custom URL handler to access JS modal ...
What I would like to achieve, is to make the modal content accessible by url, so that external users can be directed to...
Read more >
Popups and window methods
A popup can navigate (change URL) and send messages to the opener window. ... called outside of user-triggered event handlers like onclick ....
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