Hi,
I'm trying to get the text that a user has pasted. What I have so far is this:
editor.on('paste', function (e) {
var selectionRange = editor.getSelection().getRanges()[0];
var range = editor.createRange(selectionRange.startContainer);
range.setStartAt(selectionRange.startContainer, selectionRange.startOffset);
range.setEndAt(selectionRange.startContainer, selectionRange.startOffset);
editor.bookmarkBeforePaste = range.createBookmark();
setTimeout(function () { //TODO: Use DOM inspectors instead of waiting
editor.focus();
var bookmarksAfterPaste = editor.getSelection().createBookmarks();
var pastedTextRange = editor.createRange(editor.document);
pastedTextRange.setStartAt(editor.bookmarkBeforePaste.endNode, 0);
pastedTextRange.setEndAt(bookmarksAfterPaste.startNode, 0);
debugger;
}, 100);
});
This almost works. It adds a bookmark before and after the text but I can't work out how to actually get the text that was pasted. If someone has a better way of doing this then I'd be glad to use their approach instead.
Thanks,
Joe
Just check the e.data object
Just check the e.data object and you'll find there the data that you want.