简体   繁体   English

如何使tinymce textarea编辑器可放置?

[英]How to make tinymce textarea editor droppable?

I have this html: 我有这个HTML:

 <ul id="some_words">
   <li>Word 1</li>
   <li>Word 2</li>
   <li>Word 3</li>
 </ul>

I made these words ( word1; word2; word3 ) draggable by this: 我通过以下操作使这些单词(word1; word2; word3) draggable

$("#some_words li").draggable({helper: 'clone'}); $(“#some_words li”)。draggable({helper:'clone'});;

And to make droppable textfield I did: 为了创建droppable文本字段,我做了以下操作:

$("#my-text_field").droppable({ accept: "#some_words li", drop: function(ev, ui) { alert('fired');// } }); $(“#my-text_field”)。droppable({接受:“ #some_words li”,drop:function(ev,ui){alert('fired'); //}}));

There is also an <textarea> where TinyMCE (editor) is applied so how can this Tinymce be droppable as I did for the text field. 还有一个<textarea> ,其中应用了TinyMCE(编辑器),因此该Tinymce如何像我在文本字段中所做的那样droppable被拖放。

Now when I try to drop any word into text field it shows alert box but when try to drop it into a tinyMCE (textarea) then nothing happens. 现在,当我尝试将任何单词放入文本字​​段时,它会显示警告框,但是当尝试将其放入tinyMCE(文本区域)时,则什么也没有发生。

If anybody know how to make 'TinyMCE' droppable? 是否有人知道如何使“ TinyMCE”可滴液?

Thanks 谢谢

TinyMCE hides the textarea to create an iframe just next to it. TinyMCE隐藏文本区域以在其旁边创建iframe。 So you have to get the element of the iframe you want droppable. 因此,您必须获取要拖放的iframe元素。

Basicly, you could reach it with : 基本上,您可以通过:

$('#my-textarea')
    .next('span.mceEditor')
    .find('iframe')
    .contents()
    .find('.mceContentBody')

(found with inspector on TinyMCE demo for jquery) (在TinyMCE演示 jquery中与检查器一起找到)

Make sure you load TinyMCE first, then you can apply your droppable. 确保先加载TinyMCE,然后才能应用可放置对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM