fastmail / Squire

The rich text editor for arbitrary HTML.
MIT License
4.77k stars 406 forks source link

Setting linkRegExp to null breaks insertHTML #437

Closed mYstar closed 1 year ago

mYstar commented 1 year ago

I tried to turn off link detection as mentioned in the docs: https://github.com/fastmail/Squire#linkregexp like this:

this._editor = new Squire($element[0]);
this._editor.linkRegExp = null;

Then I noticed, that paste is broken. After debugging it turns out, that insertHTML() fails due to an exception. My solution, let linkRegExp always return null or false:

this._editor.linkRegExp = {
    exec: function () {
        return null;
    },
    test: function () {
        return false;
    }
};

Is there a cleaner solution? Did I misinterpret the docs?

Thanks for this great project.

neilj commented 1 year ago

Looks like the docs are slightly wrong. It needs to be a regex, but to turn off link detect just make it match nothing. I would just do:

this._editor.linkRegExp = /[]/;