I want to restrict the editing of a RadEditor, but I don't want to set its server-side Enabled property to false.
Using client-side JavaScript, I'm using editor.enableEditing(false), but this still allows the user to delete or backspace to remove content. It does not allow adding new content, nor respond to any other key.
I've tried to add an event listener for the onkeydown and keydown event to prohibit the delete and backspace keys, but that doesn't stop the user from deleting content, either.
While debugging, I noticed that the content gets deleted prior to hitting the e.preventDefault() that is intended to stop it.
How can I accomplish this task?
editor.enableEditing(false);
editor.get_contentArea().onkeydown = e => {
if (e.keyCode === 8 || e.keyCode === 46) { // Prevent Backspace (8) and Delete (46)
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
}
};