[FEATURE] Autocomplete event names for `on` modifier
bertdeblock opened this issue · 3 comments
bertdeblock commented
Might be nice if a list of event names is shown when typing {{on "...
?
lifeart commented
have asked gpt to provide sample of event names, based on tag name:
function suggestEventNames(tagName: string): string[] {
tagName = tagName.toLowerCase();
const eventSuggestions: Record<string, string[]> = {
"a": ["click", "mousedown", "mouseup", "mouseenter", "mouseleave"],
"button": ["click", "mousedown", "mouseup", "mouseenter", "mouseleave"],
"input": ["change", "focus", "blur", "keydown", "keyup"],
"select": ["change", "focus", "blur"],
"textarea": ["change", "focus", "blur", "keydown", "keyup"],
"form": ["submit"],
"img": ["load", "error"],
"video": ["play", "pause", "ended", "timeupdate"],
"audio": ["play", "pause", "ended", "timeupdate"],
"div": ["click", "mousedown", "mouseup", "mouseenter", "mouseleave"],
"span": ["click", "mousedown", "mouseup", "mouseenter", "mouseleave"],
// Add more tag names and their event suggestions here
};
return eventSuggestions[tagName] || [];
}
// Example usage
const tagName = "input";
const eventNames = suggestEventNames(tagName);
console.log(`Suggested events for '${tagName}': ${eventNames.join(", ")}`);
lifeart commented
@bertdeblock thank you for suggestion! Feature available in uELS v3.0.51
("@lifeart/ember-language-server": "2.29.0")
bertdeblock commented
Very helpful! Thanks @lifeart!