Copy and paste only from Ace editor #5068
Answered
by
nightwing
krishnagogada
asked this question in
Q&A
-
We want to keep a feature in our platform that users can copy or paste only from the Ace editor. Is that possible? |
Beta Was this translation helpful? Give feedback.
Answered by
nightwing
Feb 21, 2023
Replies: 1 comment
-
You can use paste and copy events var lastCopiedText = ""
editor.on("paste", function(e) {
if (lastCopiedText != e.text) {
alert(`
An attempt to paste text not copied from the editor is detected.
And it will not be tolerated!
Use browser developer tools to circumvent this annoyance.
`)
}
e.text = lastCopiedText
})
editor.on("copy", function(e) {
lastCopiedText = e.text
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
krishnagogada
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use paste and copy events