Javascript 在summernote中添加提示词

Javascript 在summernote中添加提示词,javascript,html,summernote,Javascript,Html,Summernote,我可以在服务器上找到的Summernote字典中添加单词吗?默认情况下,Summernote支持一个名为“”的选项,您可以在“单词”中预定义提示单词的字典,如下所示: $(".hint2basic").summernote({ height: 100, toolbar: false, placeholder: 'type with apple, orange, watermelon and lemon', hint: { words: ['apple', 'orange', 'watermel

我可以在服务器上找到的Summernote字典中添加单词吗?默认情况下,Summernote支持一个名为“”的选项,您可以在“单词”中预定义提示单词的字典,如下所示:

$(".hint2basic").summernote({
height: 100,
toolbar: false,
placeholder: 'type with apple, orange, watermelon and lemon',
hint: {
 words: ['apple', 'orange', 'watermelon', 'lemon'],
 match: /\b(\w{1,})$/,
 search: function (keyword, callback) {
  callback($.grep(this.words, function (item) {
    return item.indexOf(keyword) === 0;
  }));
 }
}
});
但是如果我想添加从服务器上获得的其他单词,该怎么办

$.ajax({
            beforeSend: function(request) {
            request.setRequestHeader("Accept", "application/ld+json");},
            url:'MY URL', 
            type:'POST',
            data:JSON.stringify(jsonld),
            success: function(response)
            {
                //here must be something, e.g.
                var arrayWithWords = response;
            }
      });
在“arrayWithWords”中,我现在有一个字符串,例如“car”、“house”、“bag”


我现在应该怎么做才能将这个“arrayWithWords”添加到Summernote的“words”中,或者用“arrayWithWords”的值替换“words”的值?主要问题是,在用户可以使用Summernote之前,您必须为Summernote中的提示词预定义一个字典,我看不到任何更新“单词”的方法。

我只是在寻找其他内容时偶然发现了这个问题,因此,很抱歉这里的necro帖子。如果您还没有弄明白这一点,您可以在回调函数中使用arrayWithWords变量进行提示搜索,而不是使用初始化时定义的单词列表。任何时候搜索都会使用arrayWithWords的当前值

$(".hint2basic").summernote({
height: 100,
toolbar: false,
placeholder: 'type with apple, orange, watermelon and lemon',
hint: {
 match: /\b(\w{1,})$/,
 search: function (keyword, callback) {
  callback($.grep(arrayWithWords, function (item) {
    return item.indexOf(keyword) === 0;
  }));
 }
}
});