Can I somehow add words to the Summernote's dictionary that I get from the server? By default, Summernote supports an option called "hint" and you can predefine a dictionary for hint words in "words" like here:
$(".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;
}));
}
}
});
But what if I want to add some other words that I got from the server:
$.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;
}
});
In "arrayWithWords" I have now a string, e.g. "car", "house", "bag".
What I should do now to add this "arrayWithWords" into Summernote's "words" or just replace the "words" value with the value of "arrayWithWords"? The main problem is that you must predefine a dictionary for hint words in Summernote BEFORE a user can use Summernote and I don't see any way to update "words".