Search code examples
javascriptquill

How can I make Quill.js support an additional url scheme for links?


Quill editor only permits http://, https://, and mailto: for links.

Everything else gets replaced with "about:blank"

How can I enable Quill to permit an additional URL scheme?

Update:

The array of permitted values is in Link.PROTOCOL_WHITELIST: ["http", "https", "mailto", "tel"]

Can I change that from outside the library?


Solution

  • Here's how I solved it:

    let Link = window.Quill.import('formats/link');
    
    class CustomLink extends Link {
    
      static sanitize(url) {
        if(url.startsWith("fmp")) {
          return url
        } else {
          let value = super.sanitize(url);
          return value;
        }
      }
    }
    Quill.register(CustomLink);