문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top