I am using CoderMirror6 to implement an online latex editor, I want to trigger the subcommend after user select the previous. For example, when user select the \usepackage{} commnend, then the cursor will focus in the middle of {} and popup the package name like xcorlor table and so on to let the user select, this is the code I am using right now, it can trigger the first select and make the cursor focus in the middle of {} but could not auto retrigger the next autocomplate selection:
export function texAutoCompletions(context: CompletionContext) {
let word = context.matchBefore(/\\[\w\\]*/);
if (!word) return null;
if (word.from === word.to && !context.explicit) return null;
return {
from: word.from,
options: [
snippetCompletion("\\begin{#{1}}",{
label: "\\begin{}",
type: "text",
detail: "env",
}),
],
};
}
I am trying to define the code like this:
{ label: "\\usepackage{xcolor}", type: "text", apply: "xcolor" },
but I need to know the previous triggered commend to match, how to get the previous user select? or any other clue to do like this? This is the autocomplete config:
autocompletion({
override: [texAutoCompletions],
tooltipClass: ttc,
activateOnCompletion: (com: Completion) => {return true},
}),