With https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API being available in all browsers, we are able to define custom commands for custom elements. However, the custom-elements-manifest schema currently has no support for storing such information.
For example you could have a command jsdoc like this:
/**
* @command --show-modal - Calls `showModal()` on the `<dialog>` element when invoked.
*/
export class Dialog extends LitElement { ... }
To be able to store this information in custom-elements.json, a schema change is necessary.
I propose adding the following property to the CustomElementDeclaration:
"commands": {
"description": "The commands that this element will respond to.",
"items": {
"$ref": "#/definitions/Command"
},
"type": "array"
}
with the following being the Command definition:
"Command": {
"properties": {
"description": {
"description": "A markdown description what the command does when invoked.",
"type": "string"
},
"inheritedFrom": {
"$ref": "#/definitions/Reference"
},
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}
With https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API being available in all browsers, we are able to define custom commands for custom elements. However, the custom-elements-manifest schema currently has no support for storing such information.
For example you could have a
commandjsdoc like this:To be able to store this information in
custom-elements.json, a schema change is necessary.I propose adding the following property to the
CustomElementDeclaration:with the following being the
Commanddefinition: