* Fix typing for Suggestion `command` with new MentionAttrs generic
As of
7cae9673f0,
new generics were added for Suggestion options and props. However,
there is a subtle bug in the current typing: the object selected with
the suggestion `command` need not have the same types as the `items` in
the suggestion options. For instance, in Tiptap's official demo
https://tiptap.dev/api/nodes/mention, the suggestion `items` are all
`string`s, but the selected Mention is of type `{id: string}` (which are
the attributes of the Mention node, as the Mention extension requires):
```ts
const selectItem = index => {
const item = props.items[index]
if (item) {
props.command({ id: item })
}
}
```
i.e., there should be no restriction that when you select something with
the suggestion `command`, it must use the identical structure as the
suggested items. When using the suggestion plugin with the Mention
extension, for instance, the value passed to the SuggestionProps
`props.command()` function must be a `Record<string, any>`, as it's
directly/exclusively used to set the `attrs` of a `Node` via
`insertContentAt` (and you need not use that shape for suggestion
options, as in the Tiptap example above):
44996d60be/packages/extension-mention/src/mention.ts (L42)f869507396/packages/core/src/types.ts (L79)
This fixes the typing so that suggestions can correctly refer separately
to their own items (of any type), while ensuring the `command`ed item be
of whatever type is necessary (and so in the Mention context, could be
restricted further).
* Add generics to override selected suggestion type
---------
Co-authored-by: Steven DeMartini <sjdemartini@users.noreply.github.com>
* added JSDocs for almost all extensions
* start adding commands jsdocs
* add jsdocs for rest of extensions
* add jsdocs for Extensions
* add js docs for all extensions
* add more jsdocs
* add js docs for node spec definitions
* refactor: upgrade prosemirror packages to new typescript versions
* refactor: migrate to new typings from prosemirror
* style: fix linting issues
* style: fix linting issues
* style: fix linting issues
* fix(ci): fix build process by reimplement filterTransaction
* fix(extension-test): fix broken build because of wrong output file names
* fix: fix prosemirror-tables not being bundled correctly for ES6
* fix: move to prosemirror-tables-contently until es6 build is working
* fix: fix tests for youtube
* fix: fix youtube test
* fix(demos): fix demos build
This commit makes the clientRect prop optional - this means that this value can be null. This allows developers using the suggestion extension to know that they have to implement a check for the clientRect before using it.
#2795