@portabletext/plugin-typeahead-picker 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +2 -32
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -355,27 +355,9 @@ The error is cleared when the picker returns to idle (e.g., via Escape or cursor
355
355
 
356
356
  ## onDismiss
357
357
 
358
- The optional `onDismiss` callback runs when the picker is dismissed via Escape. This is useful for cleaning up the typed trigger and keyword text.
358
+ The optional `onDismiss` callback runs when the picker is dismissed (Escape, Enter/Tab with no matches, or programmatically). Without `onDismiss`, dismissing simply closes the picker and leaves the typed text in place.
359
359
 
360
- ```ts
361
- const mentionPicker = defineTypeaheadPicker<MentionMatch>({
362
- trigger: /@/,
363
- keyword: /\w*/,
364
- getMatches: ({keyword}) => searchUsers(keyword),
365
- onSelect: [
366
- ({event}) => [
367
- raise({type: 'delete', at: event.patternSelection}),
368
- raise({type: 'insert.text', text: `@${event.match.name}`}),
369
- ],
370
- ],
371
- // Delete the typed text when user presses Escape
372
- onDismiss: [
373
- ({event}) => [raise({type: 'delete', at: event.patternSelection})],
374
- ],
375
- })
376
- ```
377
-
378
- Without `onDismiss`, pressing Escape leaves the typed text in place (e.g., `@john` remains in the editor). With `onDismiss` configured to delete the pattern, the text is removed.
360
+ For most pickers, you should **not** use `onDismiss` to delete text. If a user types `@` and dismisses, they likely wanted to type a literal `@`.
379
361
 
380
362
  **onDismiss payload:**
381
363
 
@@ -384,18 +366,6 @@ Without `onDismiss`, pressing Escape leaves the typed text in place (e.g., `@joh
384
366
  | `event.patternSelection` | Selection range covering the trigger + keyword (e.g., `@john`) |
385
367
  | `snapshot` | Current editor snapshot |
386
368
 
387
- Note: `onDismiss` is called when the user actively dismisses the picker:
388
-
389
- - Pressing Escape
390
- - Pressing Enter/Tab when there are no matches
391
- - Programmatically via `picker.send({type: 'dismiss'})`
392
-
393
- It is NOT called when:
394
-
395
- - The user selects a match (Enter/Tab/click with a match selected)
396
- - The picker is dismissed due to cursor movement
397
- - The picker is dismissed due to invalid pattern (e.g., typing a space)
398
-
399
369
  ## Advanced onSelect
400
370
 
401
371
  The `onSelect` callback receives more than just the event. The full payload includes access to the editor snapshot, which is useful for generating keys, accessing the schema, or reading the current editor state.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/plugin-typeahead-picker",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Generic typeahead picker infrastructure for the Portable Text Editor",
5
5
  "keywords": [
6
6
  "portabletext",
@@ -35,7 +35,7 @@
35
35
  "@xstate/react": "^6.0.0",
36
36
  "xstate": "^5.25.0",
37
37
  "@portabletext/keyboard-shortcuts": "^2.1.2",
38
- "@portabletext/plugin-input-rule": "^2.0.22"
38
+ "@portabletext/plugin-input-rule": "^2.0.23"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@sanity/pkg-utils": "^10.2.1",
@@ -52,12 +52,12 @@
52
52
  "typescript": "5.9.3",
53
53
  "typescript-eslint": "^8.48.0",
54
54
  "vitest": "^4.0.16",
55
- "@portabletext/editor": "^4.3.7",
55
+ "@portabletext/editor": "^4.3.8",
56
56
  "@portabletext/schema": "2.1.1",
57
57
  "racejar": "2.0.2"
58
58
  },
59
59
  "peerDependencies": {
60
- "@portabletext/editor": "^4.3.7",
60
+ "@portabletext/editor": "^4.3.8",
61
61
  "react": "^19.2"
62
62
  },
63
63
  "engines": {