diff --git a/CHANGELOG.md b/CHANGELOG.md index b0ec738..7feec93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Added + +- Added `commands` array to `CustomElementDeclaration` and `CustomElementMixinDeclaration` to document [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) that a custom element responds to. ([#144](https://github.com/webcomponents/custom-elements-manifest/issues/144)) + ## [2.1.0] - 2024-05-16 ### Added diff --git a/examples/simple-element.json b/examples/simple-element.json index fbd23e5..22eb983 100644 --- a/examples/simple-element.json +++ b/examples/simple-element.json @@ -35,6 +35,12 @@ "name": "disabled" } ], + "commands": [ + { + "name": "--show-modal", + "description": "Calls `showModal()` on the `` element when invoked." + } + ], "superclass": { "name": "HTMLElement" } diff --git a/schema.d.ts b/schema.d.ts index edf3a21..81867b9 100644 --- a/schema.d.ts +++ b/schema.d.ts @@ -252,6 +252,12 @@ export interface CustomElement extends ClassLike { cssStates?: CssCustomState[]; + /** + * The commands this element responds to. + * https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API + */ + commands?: Command[]; + demos?: Demo[]; /** @@ -402,6 +408,35 @@ export interface CssCustomState { deprecated?: boolean | string; } +/** + * The description of a command that a custom element responds to. + * https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API + */ +export interface Command { + /** + * The name of the command, e.g. `--show-modal`. + */ + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description what the command does when invoked. + */ + description?: string; + + inheritedFrom?: Reference; + + /** + * Whether the command is deprecated. + * If the value is a string, it's the reason for the deprecation. + */ + deprecated?: boolean | string; +} + export interface CssCustomProperty { /** * The name of the property, including leading `--`. diff --git a/schema.json b/schema.json index 59ad67c..8a8a3dc 100644 --- a/schema.json +++ b/schema.json @@ -224,6 +224,37 @@ ], "type": "object" }, + "Command": { + "description": "The description of a command that a custom element responds to.\nhttps://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API", + "properties": { + "deprecated": { + "description": "Whether the command is deprecated.\nIf the value is a string, it's the reason for the deprecation.", + "type": [ + "string", + "boolean" + ] + }, + "description": { + "description": "A markdown description what the command does when invoked.", + "type": "string" + }, + "inheritedFrom": { + "$ref": "#/definitions/Reference" + }, + "name": { + "description": "The name of the command, e.g. `--show-modal`.", + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, "CssCustomProperty": { "properties": { "default": { @@ -323,6 +354,13 @@ }, "type": "array" }, + "commands": { + "description": "The commands this element responds to.\nhttps://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API", + "items": { + "$ref": "#/definitions/Command" + }, + "type": "array" + }, "cssParts": { "items": { "$ref": "#/definitions/CssPart" @@ -473,6 +511,13 @@ }, "type": "array" }, + "commands": { + "description": "The commands this element responds to.\nhttps://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API", + "items": { + "$ref": "#/definitions/Command" + }, + "type": "array" + }, "cssParts": { "items": { "$ref": "#/definitions/CssPart"