How to remove trigger character on autocomplete in tinyMCE? Let's assume that the trigger character is @.
Once I select an autocomplete item, I wish to remove the preceding @ character.
How to remove trigger character on autocomplete in tinyMCE? Let's assume that the trigger character is @.
Once I select an autocomplete item, I wish to remove the preceding @ character.
Here is an example of using the autocompleter and not including the trigger character:
https://fiddle.tiny.cloud/u7haab/12
The fetch function determines what is returned:
fetch: function (pattern) {
return new tinymce.util.Promise(function (resolve) {
var results = getMatchedNames(pattern).map(function (char) {
return {
type: 'autocompleteitem',
value: char.value, //This VALUE is what is inserted into the content via the onAction method
text: char.value,
}
});
resolve(results);
});
}
...and the onAction method takes the value and inserts it into the editor:
var onAction = function (autocompleteApi, rng, value) {
editor.selection.setRng(rng);
editor.insertContent(value);
autocompleteApi.hide();
};
Unless you explicitly choose to include the trigger character it won't be included if you follow this pattern.