@portabletext/editor 1.17.0 → 1.17.1
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/lib/behaviors/index.cjs +38 -39
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.js +38 -39
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +223 -282
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +223 -282
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
- package/src/behaviors/behavior.emoji-picker.ts +47 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"src"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@portabletext/patches": "1.1.
|
|
58
|
+
"@portabletext/patches": "1.1.1",
|
|
59
59
|
"@xstate/react": "^5.0.0",
|
|
60
60
|
"debug": "^4.3.4",
|
|
61
61
|
"get-random-values-esm": "^1.0.2",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@portabletext/toolkit": "^2.0.16",
|
|
73
|
-
"@sanity/block-tools": "^3.
|
|
74
|
-
"@sanity/diff-match-patch": "^3.1.
|
|
73
|
+
"@sanity/block-tools": "^3.68.0",
|
|
74
|
+
"@sanity/diff-match-patch": "^3.1.2",
|
|
75
75
|
"@sanity/pkg-utils": "^6.12.0",
|
|
76
|
-
"@sanity/schema": "^3.
|
|
77
|
-
"@sanity/types": "^3.
|
|
76
|
+
"@sanity/schema": "^3.68.0",
|
|
77
|
+
"@sanity/types": "^3.68.0",
|
|
78
78
|
"@testing-library/jest-dom": "^6.6.3",
|
|
79
79
|
"@testing-library/react": "^16.1.0",
|
|
80
80
|
"@types/debug": "^4.1.5",
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
"racejar": "1.1.1"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@sanity/block-tools": "^3.
|
|
107
|
-
"@sanity/schema": "^3.
|
|
108
|
-
"@sanity/types": "^3.
|
|
106
|
+
"@sanity/block-tools": "^3.68.0",
|
|
107
|
+
"@sanity/schema": "^3.68.0",
|
|
108
|
+
"@sanity/types": "^3.68.0",
|
|
109
109
|
"react": "^16.9 || ^17 || ^18 || ^19",
|
|
110
110
|
"rxjs": "^7.8.1",
|
|
111
111
|
"styled-components": "^6.1.13"
|
|
@@ -37,6 +37,43 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
return [
|
|
40
|
+
defineBehavior({
|
|
41
|
+
on: 'insert.text',
|
|
42
|
+
guard: ({context, event}) => {
|
|
43
|
+
const isEmojiChar = emojiCharRegEx.test(event.text)
|
|
44
|
+
|
|
45
|
+
if (!isEmojiChar) {
|
|
46
|
+
return {emojis: []}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const focusBlock = selectors.getFocusTextBlock({context})
|
|
50
|
+
const textBefore = selectors.getBlockTextBefore({context})
|
|
51
|
+
const emojiKeyword = `${textBefore}${event.text}`.match(
|
|
52
|
+
incompleteEmojiRegEx,
|
|
53
|
+
)?.[1]
|
|
54
|
+
|
|
55
|
+
if (!focusBlock || emojiKeyword === undefined) {
|
|
56
|
+
return {emojis: []}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const emojis = config.matchEmojis({keyword: emojiKeyword})
|
|
60
|
+
|
|
61
|
+
return {emojis}
|
|
62
|
+
},
|
|
63
|
+
actions: [
|
|
64
|
+
(_, params) => [
|
|
65
|
+
{
|
|
66
|
+
type: 'effect',
|
|
67
|
+
effect: () => {
|
|
68
|
+
emojiPickerActor.send({
|
|
69
|
+
type: 'emojis found',
|
|
70
|
+
matches: params.emojis,
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
],
|
|
76
|
+
}),
|
|
40
77
|
defineBehavior({
|
|
41
78
|
on: 'insert.text',
|
|
42
79
|
guard: ({context, event}) => {
|
|
@@ -106,43 +143,6 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
106
143
|
],
|
|
107
144
|
],
|
|
108
145
|
}),
|
|
109
|
-
defineBehavior({
|
|
110
|
-
on: 'insert.text',
|
|
111
|
-
guard: ({context, event}) => {
|
|
112
|
-
const isEmojiChar = emojiCharRegEx.test(event.text)
|
|
113
|
-
|
|
114
|
-
if (!isEmojiChar) {
|
|
115
|
-
return {emojis: []}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const focusBlock = selectors.getFocusTextBlock({context})
|
|
119
|
-
const textBefore = selectors.getBlockTextBefore({context})
|
|
120
|
-
const emojiKeyword = `${textBefore}${event.text}`.match(
|
|
121
|
-
incompleteEmojiRegEx,
|
|
122
|
-
)?.[1]
|
|
123
|
-
|
|
124
|
-
if (!focusBlock || emojiKeyword === undefined) {
|
|
125
|
-
return {emojis: []}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const emojis = config.matchEmojis({keyword: emojiKeyword})
|
|
129
|
-
|
|
130
|
-
return {emojis}
|
|
131
|
-
},
|
|
132
|
-
actions: [
|
|
133
|
-
(_, params) => [
|
|
134
|
-
{
|
|
135
|
-
type: 'effect',
|
|
136
|
-
effect: () => {
|
|
137
|
-
emojiPickerActor.send({
|
|
138
|
-
type: 'emojis found',
|
|
139
|
-
matches: params.emojis,
|
|
140
|
-
})
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
],
|
|
145
|
-
}),
|
|
146
146
|
defineBehavior({
|
|
147
147
|
on: 'key.down',
|
|
148
148
|
guard: ({context, event}) => {
|
|
@@ -158,9 +158,9 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
158
158
|
const isArrowUp = isHotkey('ArrowUp', event.keyboardEvent)
|
|
159
159
|
const isEnter = isHotkey('Enter', event.keyboardEvent)
|
|
160
160
|
const isTab = isHotkey('Tab', event.keyboardEvent)
|
|
161
|
+
const matches = emojiPickerActor.getSnapshot().context.matches
|
|
161
162
|
|
|
162
163
|
if (isEnter || isTab) {
|
|
163
|
-
const matches = emojiPickerActor.getSnapshot().context.matches
|
|
164
164
|
const selectedIndex =
|
|
165
165
|
emojiPickerActor.getSnapshot().context.selectedIndex
|
|
166
166
|
|
|
@@ -195,11 +195,11 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
195
195
|
return false
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
if (isArrowDown) {
|
|
198
|
+
if (isArrowDown && matches.length > 0) {
|
|
199
199
|
return {action: 'navigate down' as const}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
if (isArrowUp) {
|
|
202
|
+
if (isArrowUp && matches.length > 0) {
|
|
203
203
|
return {action: 'navigate up' as const}
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -283,6 +283,12 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
283
283
|
return false
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
const matches = emojiPickerActor.getSnapshot().context.matches
|
|
287
|
+
|
|
288
|
+
if (matches.length === 0) {
|
|
289
|
+
return false
|
|
290
|
+
}
|
|
291
|
+
|
|
286
292
|
const focusBlock = selectors.getFocusTextBlock({context})
|
|
287
293
|
const textBefore = selectors.getBlockTextBefore({context})
|
|
288
294
|
const emojiKeyword = textBefore
|
|
@@ -290,7 +296,7 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
290
296
|
.match(incompleteEmojiRegEx)?.[1]
|
|
291
297
|
|
|
292
298
|
if (!focusBlock || emojiKeyword === undefined) {
|
|
293
|
-
return {emojis: []
|
|
299
|
+
return {emojis: []}
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
const emojis = config.matchEmojis({keyword: emojiKeyword})
|