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:
For administrators using the editor, the rel=”dofollow” attribute is added to all links.
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!
I haven’t tried it yet, I want to know the best way to do it
choise media is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.