Sanitizing Pasted Content in Kendo UI for Vue Editor
Environment
| Product | Kendo UI for Vue Editor |
| Version | Current |
Description
I need to sanitize pasted content in the Kendo UI for Vue Editor. I want to remove styles such as background color and font color from the pasted text. The provided demo in the documentation mentions sanitizing pasted content, but unwanted styles are still preserved. I also need clarification on what "sanitize" means in this context.
This knowledge base article also answers the following questions:
- How can I remove font and background styles when pasting content in Kendo Vue Editor?
- What does sanitizing pasted content mean in Kendo Vue Editor?
- How can I customize the paste settings in Kendo Vue Editor?
Solution
Sanitizing pasted content in the Kendo UI for Vue Editor means removing or modifying specific attributes or styles from the pasted content. To remove styles like background color and font color, customize the pasteSettings by using the removeAttribute function for the style attribute.
Follow these steps to achieve this:
- Define a
pasteSettingsobject and use theremoveAttributefunction for thestyleattribute. - Apply the
pasteSettingsto the Editor.
Example code snippet:
const pasteSettings = {
convertMsLists: true,
attributes: {
class: sanitizeClassAttr, // Example for sanitizing class attributes
style: removeAttribute, // Removes all style attributes
width: () => {} // Example for other attributes
}
};
function removeAttribute() {
return null; // Removes the attribute
}
// Apply the pasteSettings to the Editor
<Editor :paste-html="pasteSettings" />
You can see a demo implementing the suggestions above here: