Commit Graph

324 Commits

Author SHA1 Message Date
Steven DeMartini
f55171fb43
fix: types for Suggestion command, allowing generic overrides (#4136)
* 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>
2024-05-17 05:12:04 +02:00
bdbch
6a581153d8 v2.4.0 2024-05-14 14:45:38 +02:00
bdbch
b941eea6da
feat: added jsdocs (#4356)
* 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
2024-05-11 14:30:44 +02:00
Dominik Biedebach
ca4f13461e v2.3.2 2024-05-08 17:43:53 +02:00
bdbch
dfd5ff5c6b v2.3.1 2024-04-30 17:27:07 +02:00
svenadlung
b132d9207d v2.3.0 2024-04-09 13:17:27 +02:00
Pontus Lundin
677642eda8
return invokation of command (#4882)
Co-authored-by: Pontus Lundin <pontus.lundin@klarna.com>
2024-04-06 19:02:55 +02:00
bdbch
e79523fb8b v2.2.6 2024-04-06 17:46:17 +02:00
bdbch
0e5af53778 v2.2.5 2024-04-06 00:09:00 +02:00
Dominik Biedebach
9a615643ac v2.2.4 2024-02-23 13:01:19 +01:00
Dominik Biedebach
f8baf792cf v2.2.3 2024-02-15 16:41:48 +01:00
svenadlung
d308d7c31f v2.2.2 2024-02-07 13:47:00 +01:00
bdbch
1c5c087641 v2.2.1 2024-01-31 09:04:52 +01:00
bdbch
6ad92fbd28 v2.2.0 2024-01-29 13:25:37 +01:00
bdbch
731109b566 merge main 2024-01-10 13:57:46 +01:00
bdbch
23b32f805f v2.1.16 2024-01-10 13:45:34 +01:00
bdbch
46e391aa9d merge main 2024-01-08 22:30:06 +01:00
bdbch
412b0b92f0 v2.1.15 2024-01-08 20:25:21 +01:00
bdbch
c2232e74a4 v2.2.0-rc.8 2024-01-08 20:22:38 +01:00
Dominik Biedebach
8c99685545 sync with main 2024-01-08 12:54:37 +01:00
Dominik Biedebach
6c7b27f39b v2.1.14 2024-01-08 12:49:20 +01:00
Dominik Biedebach
e128f6cac0 merge main 2023-12-14 13:00:09 +01:00
Dominik Biedebach
b18d729101 v2.1.13 2023-11-30 18:04:49 +01:00
Dominik Biedebach
fab5e963ce v2.2.0-rc.7 2023-11-27 14:14:28 +01:00
Dominik Biedebach
e2ac6003fb v2.2.0-rc.6 2023-11-23 14:42:38 +01:00
Dominik Biedebach
2bb371126e merge main 2023-11-23 09:28:26 +01:00
Dominik Biedebach
b62c87a07e v2.2.0-rc.5 2023-11-23 09:24:24 +01:00
Eric Bailey
ad47c49298 allow users to pass a custom findSuggestionMatch 2023-11-17 12:25:44 +01:00
Dominik Biedebach
01135be60c v2.1.12 2023-10-11 15:55:10 +02:00
bdbch
42039c05f0 v2.2.0-rc.4 2023-10-10 12:34:15 +02:00
bdbch
b5cb36058b merge main into develop 2023-09-20 17:36:56 +02:00
bdbch
634cb68f6c v2.1.11 2023-09-20 17:31:41 +02:00
bdbch
6aa755a04b Revert "v2.2.11"
This reverts commit 99a5f2d77f.
2023-09-20 17:30:40 +02:00
bdbch
99a5f2d77f v2.2.11 2023-09-20 17:29:31 +02:00
Dominik Biedebach
39cf6979c4 merge main with develop 2023-09-15 17:04:38 +02:00
Dominik Biedebach
8b89b97d5b v2.1.10 2023-09-15 15:43:55 +02:00
Dominik Biedebach
b2f74f209c sync with main 2023-09-14 17:40:39 +02:00
Dominik Biedebach
a7156b347b v.2.1.9 2023-09-14 17:35:24 +02:00
Dominik Biedebach
a5f7fe0a89 Sync develop with main
Sync develop branch with main – develop (RC) releases won't generate CHANGELOG.md entries anymore.
2023-09-14 17:33:32 +02:00
bdbch
6f218be6e4 v2.1.8 2023-09-04 21:40:25 +02:00
bdbch
5437814920 v2.1.7 2023-09-04 21:39:38 +02:00
Dominik Biedebach
9dc6b8f1ab v2.2.0-rc.3 2023-08-18 12:37:06 -07:00
Dominik Biedebach
d5ce8e5b7b v2.2.0-rc.2 2023-08-18 11:54:37 -07:00
Dominik Biedebach
f99c4f64dd merge main 2023-08-18 11:53:44 -07:00
Dominik Biedebach
028411e735 v2.1.6 2023-08-18 11:08:52 -07:00
Dominik Biedebach
3cefcf12f9 v2.2.0-rc.1 2023-08-18 11:02:41 -07:00
Dominik Biedebach
f315706af1 v2.2.0-rc.0 2023-08-18 10:55:25 -07:00
Dominik Biedebach
92be1e8cb0 v2.1.5 2023-08-18 09:25:35 -07:00
Dominik Biedebach
571bea436c v2.1.4 2023-08-18 09:09:17 -07:00
Dominik Biedebach
c09d9e9e42 v2.1.3 2023-08-17 23:28:54 -07:00