/** * Initialises Keyword Autocomplete for TinyMCE instances. * * @package WPZincDashboardWidget * @author WP Zinc */ ( function () { // Define key binds. const DOWN_ARROW_KEY = 40; const UP_ARROW_KEY = 38; const ESC_KEY = 27; const ENTER_KEY = 13; const BACKSPACE = 8; // Define key binds to ignore. var keyBindsToIgnore = [ DOWN_ARROW_KEY, UP_ARROW_KEY, ESC_KEY, ENTER_KEY ]; // Define triggers as character codes. var textToOpenAutoComplete = [ // Changing this to 219 i.e. left curly brace wipes an entire paragraph, no idea why. '123' ]; // Iterate through autocompleters. if ( typeof wpzinc_autocomplete !== 'undefined' ) { wpzinc_autocomplete.forEach( function ( autocompleter, i ) { autocompleter.triggers.forEach( function ( trigger, j ) { // Skip remote autocompleters. if ( 'url' in trigger ) { return; } // Create TinyMCE Plugin for this Autocompleter. tinymce.create( 'tinymce.plugins.' + trigger.tinyMCEName, { init: function ( editor ) { var autoCompleteDisplayed = false, autoCompleteContainer = createAutoComplete(); /** * Creates an unordered list comprising of all keywords that can be * searched and displayed as a list. * * @since 2.0.2 */ function createAutoComplete() { // Define