@portabletext/plugin-emoji-picker 0.0.15 → 1.0.0
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/LICENSE +21 -0
- package/README.md +96 -1
- package/dist/index.cjs +61 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -81
- package/dist/index.js.map +1 -1
- package/package.json +30 -30
- package/src/emoji-picker-machine.tsx +84 -99
- package/src/emoji-picker.feature +50 -1
- package/src/emoji-picker.test.tsx +42 -5
package/dist/index.js
CHANGED
|
@@ -2039,7 +2039,7 @@ function createKeywordFoundEvent(payload) {
|
|
|
2039
2039
|
...payload
|
|
2040
2040
|
};
|
|
2041
2041
|
}
|
|
2042
|
-
const
|
|
2042
|
+
const triggerListenerCallback = ({
|
|
2043
2043
|
sendBack,
|
|
2044
2044
|
input
|
|
2045
2045
|
}) => {
|
|
@@ -2062,10 +2062,7 @@ const colonListenerCallback = ({
|
|
|
2062
2062
|
actions: [({
|
|
2063
2063
|
event
|
|
2064
2064
|
}) => [effect(() => {
|
|
2065
|
-
sendBack(
|
|
2066
|
-
...event,
|
|
2067
|
-
type: "colon inserted"
|
|
2068
|
-
});
|
|
2065
|
+
sendBack(event);
|
|
2069
2066
|
})]]
|
|
2070
2067
|
})
|
|
2071
2068
|
}), input.editor.registerBehavior({
|
|
@@ -2074,10 +2071,7 @@ const colonListenerCallback = ({
|
|
|
2074
2071
|
actions: [({
|
|
2075
2072
|
event
|
|
2076
2073
|
}) => [effect(() => {
|
|
2077
|
-
sendBack(
|
|
2078
|
-
...event,
|
|
2079
|
-
type: "colon inserted"
|
|
2080
|
-
});
|
|
2074
|
+
sendBack(event);
|
|
2081
2075
|
})]]
|
|
2082
2076
|
})
|
|
2083
2077
|
})];
|
|
@@ -2135,65 +2129,28 @@ const colonListenerCallback = ({
|
|
|
2135
2129
|
};
|
|
2136
2130
|
}, emojiInsertListener = ({
|
|
2137
2131
|
sendBack,
|
|
2138
|
-
input
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
}), raise({
|
|
2161
|
-
type: "insert.text",
|
|
2162
|
-
text: event.emoji
|
|
2163
|
-
})]]
|
|
2164
|
-
})
|
|
2165
|
-
}), input.context.editor.registerBehavior({
|
|
2166
|
-
behavior: defineBehavior({
|
|
2167
|
-
on: "insert.text",
|
|
2168
|
-
guard: ({
|
|
2169
|
-
event
|
|
2170
|
-
}) => {
|
|
2171
|
-
if (event.text !== ":")
|
|
2172
|
-
return !1;
|
|
2173
|
-
const anchor = context.keywordAnchor?.blockOffset, focus = context.keywordFocus, match = context.matches[context.selectedIndex];
|
|
2174
|
-
return match && match.type === "exact" && anchor && focus ? {
|
|
2175
|
-
anchor,
|
|
2176
|
-
focus,
|
|
2177
|
-
emoji: match.emoji
|
|
2178
|
-
} : !1;
|
|
2179
|
-
},
|
|
2180
|
-
actions: [(_, {
|
|
2181
|
-
anchor,
|
|
2182
|
-
focus,
|
|
2183
|
-
emoji
|
|
2184
|
-
}) => [raise({
|
|
2185
|
-
type: "custom.insert emoji",
|
|
2186
|
-
emoji,
|
|
2187
|
-
anchor,
|
|
2188
|
-
focus
|
|
2189
|
-
})]]
|
|
2190
|
-
})
|
|
2191
|
-
})];
|
|
2192
|
-
return () => {
|
|
2193
|
-
for (const unregister of unregisterBehaviors)
|
|
2194
|
-
unregister();
|
|
2195
|
-
};
|
|
2196
|
-
}, submitListenerCallback = ({
|
|
2132
|
+
input
|
|
2133
|
+
}) => input.context.editor.registerBehavior({
|
|
2134
|
+
behavior: defineBehavior({
|
|
2135
|
+
on: "custom.insert emoji",
|
|
2136
|
+
actions: [({
|
|
2137
|
+
event
|
|
2138
|
+
}) => [effect(() => {
|
|
2139
|
+
sendBack({
|
|
2140
|
+
type: "dismiss"
|
|
2141
|
+
});
|
|
2142
|
+
}), raise({
|
|
2143
|
+
type: "delete.text",
|
|
2144
|
+
at: {
|
|
2145
|
+
anchor: event.anchor,
|
|
2146
|
+
focus: event.focus
|
|
2147
|
+
}
|
|
2148
|
+
}), raise({
|
|
2149
|
+
type: "insert.text",
|
|
2150
|
+
text: event.emoji
|
|
2151
|
+
})]]
|
|
2152
|
+
})
|
|
2153
|
+
}), submitListenerCallback = ({
|
|
2197
2154
|
sendBack,
|
|
2198
2155
|
input,
|
|
2199
2156
|
receive
|
|
@@ -2240,6 +2197,19 @@ const colonListenerCallback = ({
|
|
|
2240
2197
|
});
|
|
2241
2198
|
})]]
|
|
2242
2199
|
})
|
|
2200
|
+
}), input.context.editor.registerBehavior({
|
|
2201
|
+
behavior: defineInputRuleBehavior({
|
|
2202
|
+
rules: [keywordRule]
|
|
2203
|
+
})
|
|
2204
|
+
}), input.context.editor.registerBehavior({
|
|
2205
|
+
behavior: defineBehavior({
|
|
2206
|
+
on: "custom.keyword found",
|
|
2207
|
+
actions: [({
|
|
2208
|
+
event
|
|
2209
|
+
}) => [effect(() => {
|
|
2210
|
+
sendBack(event);
|
|
2211
|
+
})]]
|
|
2212
|
+
})
|
|
2243
2213
|
})];
|
|
2244
2214
|
return () => {
|
|
2245
2215
|
for (const unregister of unregisterBehaviors)
|
|
@@ -2332,7 +2302,7 @@ const colonListenerCallback = ({
|
|
|
2332
2302
|
"emoji insert listener": fromCallback(emojiInsertListener),
|
|
2333
2303
|
"submit listener": fromCallback(submitListenerCallback),
|
|
2334
2304
|
"arrow listener": fromCallback(arrowListenerCallback),
|
|
2335
|
-
"
|
|
2305
|
+
"trigger listener": fromCallback(triggerListenerCallback),
|
|
2336
2306
|
"escape listener": fromCallback(escapeListenerCallback),
|
|
2337
2307
|
"selection listener": fromCallback(selectionListenerCallback),
|
|
2338
2308
|
"text change listener": fromCallback(textChangeListener)
|
|
@@ -2342,19 +2312,19 @@ const colonListenerCallback = ({
|
|
|
2342
2312
|
keyword: ({
|
|
2343
2313
|
context,
|
|
2344
2314
|
event
|
|
2345
|
-
}) => event.type !== "
|
|
2315
|
+
}) => event.type !== "custom.trigger found" && event.type !== "custom.partial keyword found" && event.type !== "custom.keyword found" ? context.keyword : event.keyword
|
|
2346
2316
|
}),
|
|
2347
2317
|
"set keyword anchor": assign({
|
|
2348
2318
|
keywordAnchor: ({
|
|
2349
2319
|
context,
|
|
2350
2320
|
event
|
|
2351
|
-
}) => event.type !== "
|
|
2321
|
+
}) => event.type !== "custom.trigger found" && event.type !== "custom.partial keyword found" && event.type !== "custom.keyword found" ? context.keywordAnchor : event.keywordAnchor
|
|
2352
2322
|
}),
|
|
2353
2323
|
"set keyword focus": assign({
|
|
2354
2324
|
keywordFocus: ({
|
|
2355
2325
|
context,
|
|
2356
2326
|
event
|
|
2357
|
-
}) => event.type !== "
|
|
2327
|
+
}) => event.type !== "custom.trigger found" && event.type !== "custom.partial keyword found" && event.type !== "custom.keyword found" ? context.keywordFocus : event.keywordFocus
|
|
2358
2328
|
}),
|
|
2359
2329
|
"update keyword focus": assign({
|
|
2360
2330
|
keywordFocus: ({
|
|
@@ -2430,10 +2400,11 @@ const colonListenerCallback = ({
|
|
|
2430
2400
|
context
|
|
2431
2401
|
})),
|
|
2432
2402
|
"insert selected match": ({
|
|
2433
|
-
context
|
|
2403
|
+
context,
|
|
2404
|
+
event
|
|
2434
2405
|
}) => {
|
|
2435
2406
|
const match = context.matches[context.selectedIndex];
|
|
2436
|
-
!match || !context.keywordAnchor || !context.keywordFocus || context.editor.send({
|
|
2407
|
+
!match || !context.keywordAnchor || !context.keywordFocus || event.type === "custom.keyword found" && match.type !== "exact" || context.editor.send({
|
|
2437
2408
|
type: "custom.insert emoji",
|
|
2438
2409
|
emoji: match.emoji,
|
|
2439
2410
|
anchor: context.keywordAnchor.blockOffset,
|
|
@@ -2526,7 +2497,7 @@ const colonListenerCallback = ({
|
|
|
2526
2497
|
idle: {
|
|
2527
2498
|
entry: ["reset"],
|
|
2528
2499
|
invoke: {
|
|
2529
|
-
src: "
|
|
2500
|
+
src: "trigger listener",
|
|
2530
2501
|
input: ({
|
|
2531
2502
|
context
|
|
2532
2503
|
}) => ({
|
|
@@ -2534,12 +2505,18 @@ const colonListenerCallback = ({
|
|
|
2534
2505
|
})
|
|
2535
2506
|
},
|
|
2536
2507
|
on: {
|
|
2537
|
-
"
|
|
2508
|
+
"custom.trigger found": {
|
|
2509
|
+
target: "searching",
|
|
2510
|
+
actions: ["set keyword anchor", "set keyword focus", "init keyword"]
|
|
2511
|
+
},
|
|
2512
|
+
"custom.partial keyword found": {
|
|
2538
2513
|
target: "searching",
|
|
2539
2514
|
actions: ["set keyword anchor", "set keyword focus", "init keyword"]
|
|
2540
2515
|
},
|
|
2541
2516
|
"custom.keyword found": {
|
|
2542
|
-
actions: ["set keyword anchor", "set keyword focus", "init keyword", "update matches", "insert selected match"]
|
|
2517
|
+
actions: ["set keyword anchor", "set keyword focus", "init keyword", "update matches", "insert selected match"],
|
|
2518
|
+
target: "idle",
|
|
2519
|
+
reenter: !0
|
|
2543
2520
|
}
|
|
2544
2521
|
}
|
|
2545
2522
|
},
|
|
@@ -2575,6 +2552,9 @@ const colonListenerCallback = ({
|
|
|
2575
2552
|
})
|
|
2576
2553
|
}],
|
|
2577
2554
|
on: {
|
|
2555
|
+
"custom.keyword found": {
|
|
2556
|
+
actions: ["set keyword anchor", "set keyword focus", "init keyword", "update matches", "insert selected match"]
|
|
2557
|
+
},
|
|
2578
2558
|
"insert.text": [{
|
|
2579
2559
|
guard: "unexpected text insertion",
|
|
2580
2560
|
target: "idle"
|
|
@@ -2594,7 +2574,7 @@ const colonListenerCallback = ({
|
|
|
2594
2574
|
guard: "selection moved unexpectedly",
|
|
2595
2575
|
target: "idle"
|
|
2596
2576
|
}, {
|
|
2597
|
-
actions: ["update keyword", "update matches", "reset selected index", "update
|
|
2577
|
+
actions: ["update keyword", "update matches", "reset selected index", "update submit listener context"]
|
|
2598
2578
|
}]
|
|
2599
2579
|
},
|
|
2600
2580
|
always: [{
|
|
@@ -2625,13 +2605,13 @@ const colonListenerCallback = ({
|
|
|
2625
2605
|
}],
|
|
2626
2606
|
on: {
|
|
2627
2607
|
"navigate down": {
|
|
2628
|
-
actions: ["increment selected index", "update
|
|
2608
|
+
actions: ["increment selected index", "update submit listener context"]
|
|
2629
2609
|
},
|
|
2630
2610
|
"navigate up": {
|
|
2631
|
-
actions: ["decrement selected index", "update
|
|
2611
|
+
actions: ["decrement selected index", "update submit listener context"]
|
|
2632
2612
|
},
|
|
2633
2613
|
"navigate to": {
|
|
2634
|
-
actions: ["set selected index", "update
|
|
2614
|
+
actions: ["set selected index", "update submit listener context"]
|
|
2635
2615
|
},
|
|
2636
2616
|
"insert selected match": {
|
|
2637
2617
|
actions: ["insert selected match"]
|