0

Question: How I can copy some text in drop event, inside the Aloha Editor on the final cursor position (drop).

With this code I have strange behavior, I can copy the text, but in the drag div not in the drop div

I guess is a problem with Aloha environment, but I need help to fix the problem.

Code:

$('.draggable').draggable({
   cursor: 'move',
   containment: 'document',
   helper: 'clone',
   stop: insertTextAtCursor ("HELLO WORLD")
});


function insertTextAtCursor(text) {
    var sel, range, html;

    if (window.getSelection) {
        sel = window.getSelection();

        if (sel.getRangeAt && sel.rangeCount) {
            range = sel.getRangeAt(0);
            range.deleteContents();
            range.insertNode(document.createTextNode(text));
        }
    } else if (document.selection && document.selection.createRange) {
        document.selection.createRange().text = text;
    }
}
4

0 回答 0