jQuery-textcomplete does not work on contenteditable div from Chrome extension

我与影子孤独终老i 提交于 2019-12-24 04:13:08

问题


I am working on simple auto complete chrome extension using jQuery-textcomplete script.

It is working well on most of traditional sites, because they use textarea. It is not working on Google+ comment box, Facebook comment box and even gmail.

Because they only use div tag with HTML5 'contenteditable' option to get user's text, and also use react in facebook.

So jquery selector not working. How can I solve this problem? Here is my selector.

$("textarea, .editable, textbox, text").textcomplete([{
    match: /(^|\S*)([^\u0000-\u007f]{2,}|\w{2,})$/,
    search: function (term, callback) {
    callback($.map(EnDict, function (word) {
        return word.indexOf(uni_word) === 0 ? word : null;
    }));
    },
    replace: function (word) {
     return word + ' ';
   }
}]);

There is Github Repository

来源:https://stackoverflow.com/questions/30221748/jquery-textcomplete-does-not-work-on-contenteditable-div-from-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!