I have used react-quill and quill-mention. In that when i type or click in mention list at that time facing this error in console “Uncaught ParchmentError: [Parchment] Unable to create mention blot error”
I have implement this code for that
i have used version of
"quill": "^2.0.0", "quill-delta": "^5.1.0", "quill-mention": "^4.1.0", "react": "^18.2.0", "react-quill": "^2.0.0",
` mention: {
allowedChars: /^[A-Za-zsÅÄÖåäö]*$/,
isolateCharacter: true,
mentionDenotationChars: [“@”],
positioningStrategy: “fixed”,
dataAttributes: [
“id”,
“value”,
“denotationChar”,
“link”,
“target”,
“disabled”,
“color”,
],
source: async function (searchTerm, renderList, mentionChar) {
let values;
console.log(atValues.length, “atValues.length”);
if (atValues.length > 0) {
if (mentionChar === “@”) {
values = atValues;
}
// if (searchTerm.length === 0) {
// renderList(values, searchTerm);
// } else {
// const matches = [];
// for (let i = 0; i < values.length; i++)
// if (
// ~values[i].value
// .toLowerCase()
// .indexOf(searchTerm.toLowerCase())
// )
// matches.push(values[i]);
// renderList(matches, searchTerm);
// }
if (searchTerm.length === 0) {
renderList(values, searchTerm);
} else {
const matches = [];
const exactMatches = [];
const mentionMatches = [];
// Loop through values to find matches
for (let i = 0; i < values.length; i++) {
const valueLowerCase = values[i].value.toLowerCase();
const searchTermLowerCase = searchTerm.toLowerCase();
// Check for exact match
if (valueLowerCase.startsWith(searchTermLowerCase)) {
exactMatches.push(values[i]);
}
// Check for mention match
else if (valueLowerCase.includes(searchTermLowerCase)) {
mentionMatches.push(values[i]);
}
}
// Push mention matches first
matches.push(
...mentionMatches.filter(
(match) => !exactMatches.includes(match)
)
);
// Push exact matches to the top
matches.unshift(...exactMatches);
// Render the list
renderList(matches, searchTerm);
}
}
},
renderItem: (item) => {
var mentionItem = document.createElement("div");
mentionItem.className = "mention-user";
mentionItem.innerHTML = item?.profileImg
? '<img src="' +
item?.profileImg +
'" class="profile-image" alt="" width="20px" height="20px">' +
item?.value
: "<span class='rounded-user-text'>" +
item?.value?.charAt(0) +
"</span>" +
item.value;
return mentionItem;
},
mentionContainer: document.querySelector(".mention-container"),
defaultMenuOrientation: "top",
onSelect: function (item, insertItem) {
insertItem(item);
mentionSelectRef.current = true;
handleSelectionChange();
},
onOpen: function (data) {
// mentionSelectRef.current = true;
},
onClose: function (data) {
setTimeout(() => {
mentionSelectRef.current = false;
}, 200);
},
},`
I have trying to mention any user but when i type or select any user from list at that time error occure “Uncaught ParchmentError: [Parchment] Unable to create mention blot”
Kavita is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.