Question

I'm searching for a javascript solution for the following problem. I'm using CKEditor on my website, but i think that this is irrelavant. Because i think that this is a native functionality and not a functionality of the CKEditor.

I would like to disable moving selected text within the editor. The user needs to be able to move select text within the editor, this may not be disabled.

The only thing that i would like to disable is the moving of a selection. Or better the drop of a selection.

Was it helpful?

Solution

Use the ondrop event.

myEditor.ondrop = function preventDrop (e) {
    e.preventDefault();
};

jsfiddle.net/PHgdZ

But, if change tracking is what you are actually after, there's no need to prevent drag and drop. Just use the ondrop event to track the change. And for newer browsers, just use oninput. That will detect changes regardless of the input method.

jsfiddle.net/PHgdZ/1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top