我在我的网站中使用jquery-textcomplete。它适用于默认的textarea,但不适用于tinymce。可以将jquery-textcomplete与tinymce集成吗?
在official website jquery-textcomplete帖子或示例中与wysiwyg editor
集成未说明。
感谢您的回答!
$('#textcomplete').textcomplete([{
words: ['stackoverflow', 'ҳайрат', 'english', 'маҳорат'],
match: /(^|\S*)([^\u0000-\u007f]{2,}|\w{2,})$/,
search: function(term, callback) {
callback($.map(this.words, function(word) {
if (word.indexOf(term.toLocaleLowerCase()) !== 0)
return null;
if (term[term.length-1] === term[term.length-1].toLocaleUpperCase())
return word.toLocaleUpperCase(); // last char is upper = uppercase
if (term[0] === term[0].toLocaleUpperCase())
return word.charAt(0).toLocaleUpperCase() + word.slice(1); // first char is upper = capitalized
return word; // default; is lowercase
}));
},
index: 2,
replace: function(word) {
return word + ' ';
}
}]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.textcomplete/1.8.4/jquery.textcomplete.min.js"></script>
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
<h3>Testing jquery textcomplete in input</h3>
<p><input id="textcomplete" type="text"></p>
<h3>Testing jquery textcomplete in textarea with TinyMCE</h3>
<p><textarea></textarea></p>