Reputation: 57
Is there is any way to disable Copy, Paste and Dropping text in ng2-ace-editor. https://github.com/fxmontigny/ng2-ace-editor This is the one I have used in my angular 5 app.
Upvotes: 1
Views: 1941
Reputation: 1068
Found the answer for RMB right here
editor.container.addEventListener("contextmenu", function(e) {
e.preventDefault();
alert('success!');
return false;
}, false);
Upvotes: 0
Reputation: 24104
to disable clipboard add the following command:
editor.commands.addCommand({
name: "breakTheEditor",
bindKey: "ctrl-c|ctrl-v|ctrl-x|ctrl-shift-v|shift-del|cmd-c|cmd-v|cmd-x",
exec: function() {}
});
to disable dragging use
![
"dragenter", "dragover", "dragend", "dragstart", "dragleave", "drop"
].forEach(function(eventName) {
editor.container.addEventListener(eventName, function(e) {
e.stopPropagation()
}, true)
});
editor.setOption("dragEnabled", false)
Upvotes: 3
Reputation: 2465
You can benefit from this issue on github https://github.com/ajaxorg/ace/issues/266
To hide cursor and line highlights
editor.setOptions({
readOnly: true,
highlightActiveLine: false,
highlightGutterLine: false
})
editor.renderer.$cursorLayer.element.style.opacity=0
to make editor non tabbable
editor.textInput.getElement().tabIndex=-1
or
editor.textInput.getElement().disabled=true
to disable all shortcuts
editor.commands.commmandKeyBinding={}
Upvotes: 0