@portabletext/plugin-emoji-picker 1.0.1 → 1.0.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/plugin-emoji-picker",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Easily configure an Emoji Picker for the Portable Text Editor",
5
5
  "keywords": [
6
6
  "portabletext",
@@ -56,8 +56,8 @@
56
56
  "typescript": "5.9.3",
57
57
  "typescript-eslint": "^8.46.1",
58
58
  "vitest": "^3.2.4",
59
- "racejar": "1.3.2",
60
59
  "@portabletext/schema": "1.2.0",
60
+ "racejar": "1.3.2",
61
61
  "@portabletext/editor": "2.15.5"
62
62
  },
63
63
  "peerDependencies": {
@@ -32,14 +32,14 @@ Feature: Emoji Picker
32
32
  Scenario: Picking wrong direct hit
33
33
  When ":jo:" is typed
34
34
  Then the text is ":jo:"
35
- And the keyword is ":jo:"
35
+ And the keyword is "jo"
36
36
  And the matches are "😂, 😹"
37
37
 
38
38
  Scenario: Colon after wrong direct hit
39
39
  When ":jo:" is typed
40
40
  And ":" is typed
41
41
  Then the text is ":jo::"
42
- And the keyword is ":jo::"
42
+ And the keyword is "jo:"
43
43
  And the matches are ""
44
44
 
45
45
  Scenario: Picking wrong direct hit after undoing direct hit
@@ -9,14 +9,14 @@ import type {BaseEmojiMatch, MatchEmojis} from './match-emojis'
9
9
  */
10
10
  export type EmojiPicker<TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch> = {
11
11
  /**
12
- * The matched keyword, including colons.
12
+ * The matched keyword.
13
13
  *
14
14
  * Can be used to display the keyword in the UI or conditionally render the
15
15
  * list of matches.
16
16
  *
17
17
  * @example
18
18
  * ```tsx
19
- * if (keyword.length < 2) {
19
+ * if (keyword.length < 1) {
20
20
  * return null
21
21
  * }
22
22
  * ```
@@ -145,10 +145,12 @@ export function useEmojiPicker<
145
145
  const emojiPickerActor = useActorRef(emojiPickerMachine, {
146
146
  input: {editor, matchEmojis: props.matchEmojis},
147
147
  })
148
- const keyword = useSelector(
149
- emojiPickerActor,
150
- (snapshot) => snapshot.context.keyword,
151
- )
148
+ const keyword = useSelector(emojiPickerActor, (snapshot) => {
149
+ const rawKeyword = snapshot.context.keyword.startsWith(':')
150
+ ? snapshot.context.keyword.slice(1)
151
+ : snapshot.context.keyword
152
+ return rawKeyword.endsWith(':') ? rawKeyword.slice(0, -1) : rawKeyword
153
+ })
152
154
  const matches = useSelector(
153
155
  emojiPickerActor,
154
156
  (snapshot) => snapshot.context.matches as ReadonlyArray<TEmojiMatch>,