@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/README.md +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/emoji-picker.feature +2 -2
- package/src/use-emoji-picker.ts +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/plugin-emoji-picker",
|
|
3
|
-
"version": "1.0.
|
|
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": {
|
package/src/emoji-picker.feature
CHANGED
|
@@ -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 "
|
|
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 ":
|
|
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
|
package/src/use-emoji-picker.ts
CHANGED
|
@@ -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
|
|
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 <
|
|
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
|
-
|
|
150
|
-
|
|
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>,
|