1

I'm trying to get my editor to autocomplete after the user types "custom."

What I've done so far is to change the identifierRegexps to [/[a-zA-Z_0-9\.\-\u00A2-\uFFFF]/] which allows me to determine the full prefix after the ".".

I can see that the code is going into the editor.commands.on section, but the autocomplete popup is not being shown when "custom." is typed.

A way I found I could do it was to add "custom." to all words in the wordList array but I would prefer the autocomplete popup to only show "Method1" rather than "custom.Method1".

componentDidMount() {
        addCompleter({
            identifierRegexps: [/[a-zA-Z_0-9\.\-\u00A2-\uFFFF]/],
            getCompletions: function(editor, session, pos, prefix, callback) {
                var completions: any[] = [];
                var wordList
                
                if (prefix == "custom."){
                    wordList = [Method1, Date, Method2];
                    wordList.forEach(function (w) {
                        completions.push({
                            value: w,
                        });
                    });
                    editor.commands.on("afterExec", function (e: { command: { name: string; }; args: string; editor: { completers: any[]; execCommand: (arg0: string) => void; }; }, t: any) {
                        if (e.command.name == "insertstring" && e.args == ".") {
                            e.editor.execCommand("startAutocomplete");
                            e.editor.execCommand("showPopup");
                        }
                    })
                }
                callback(null, completions);               
            }
        })
    }
Daniel Lawton
  • 416
  • 3
  • 9
  • 30

0 Answers0