Reputation: 1
I have problem with get element which I pasted element in ckeditor. In ck iframe I have two boxes ex.
<div class="box"> content1 </div>
<div class="box"> content2 </div>
Plugin looks like
CKEDITOR.plugins.add('containers', {
requires: 'widget',
init: function(editor) {
editor.addFeature(editor.widgets.registered.containers);
editor.on('paste', function(evt) {
var contact = evt.data.dataTransfer.getData('contact');
if (!contact) {
return;
}
evt.data.dataValue = contact.html;
});
} });
Before add new html I would like to know classes of destinations element to prevent drop element to other boxes ex. without class "box".
Maybe someone have some suggest to resolve this poblem
Upvotes: 0
Views: 241
Reputation: 62536
If you want to prevent the paste
event you can use the cancel
function of the evt
variable.
To check if the dropped place and see if that element contain a specific class you should use the Ranges feature:
evt.editor.getSelection().getRanges()
Here is a combined example:
sc = evt.editor.getSelection().getRanges()[0].startContainer
if (!sc.getParent().hasClass('box')) {
evt.cancel()
return;
}
Upvotes: 1