Issue with Setting rel Attribute for Links in Quill Editor

Hi everyone!

I’m facing a problem with configuring the Quill editor on my website choise media and hope someone can help.

I have a website built with PHP and Bootstrap. The site uses the Quill editor for content editing. I need the links inserted into the editor to have the rel="dofollow" attribute for administrators, while for regular users, the attribute should remain as is (e.g., rel="noreferrer noopener").

Current Code:
Here’s the code I’m using to initialize the Quill editor and handle links:

function quillINT(ct) {
    var quill = new Quill('#editor' + ct, {
        theme: 'snow',
        modules: {
            toolbar: toolbarOptions,
        },
    });

    // This section handles link processing
    quill.getModule('toolbar').addHandler('link', function(value) {
        if (value) {
            const href = prompt('Enter the URL');
            quill.format('link', href);
        } else {
            quill.format('link', false);
        }
    });
}

Problem: I need to modify this code so that:

  1. For administrators using the editor, the rel="dofollow" attribute is added to all links.
  2. For regular users, nothing changes and links remain with their default attributes (rel="noreferrer noopener").

Challenges I’m Facing:

  • How to properly implement a check to determine if the current user is an administrator or a regular user.
  • How to correctly add the rel="dofollow" attribute to links in Quill.

Additional Information:

  • My code uses the quillINT(ct) function to initialize the editor.
  • I also use the isAdmin variable to determine if the user is an administrator.

I would appreciate any help or advice on this issue! Thanks in advance!

Hi, and welcome. This is a forum for Rust the programming language. The Quill Editor is written in JavaScript. You would be better off asking in https://stackoverflow.com/

1 Like

Hi and welcome to URLO, the Rust users forum for the Rust programming language. Your question seems to be unrelated to the Rust language, if your website is written in PHP and Bootstrap. I'd say the odds of you getting a satisfying answer to your PHP and JS related questions is slimmer here than in some other places on the internet that have a bigger community of devs specialising in those technologies, like Stack Overflow, for example, just to make you aware of that.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.