File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 27
27
"@react-pdf/textkit" : " ^4.2.1" ,
28
28
"@react-pdf/types" : " ^2.3.5" ,
29
29
"cross-fetch" : " ^3.1.5" ,
30
- "emoji-regex" : " ^10.2.1 " ,
30
+ "emoji-regex" : " ^10.3.0 " ,
31
31
"queue" : " ^6.0.1" ,
32
32
"yoga-layout" : " ^2.0.1"
33
33
},
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ export const fetchEmojis = (string, source) => {
67
67
return promises ;
68
68
} ;
69
69
70
+ const specialCases = [ '©️' , '®' ] ; // Do not treat these as emojis if emoji not present
71
+
70
72
export const embedEmojis = fragments => {
71
73
const result = [ ] ;
72
74
@@ -78,6 +80,8 @@ export const embedEmojis = fragments => {
78
80
Array . from ( fragment . string . matchAll ( regex ) ) . forEach ( match => {
79
81
const { index } = match ;
80
82
const emoji = match [ 0 ] ;
83
+ const isSpecialCase = specialCases . includes ( emoji ) ;
84
+
81
85
const emojiSize = fragment . attributes . fontSize ;
82
86
const chunk = fragment . string . slice ( lastIndex , index + match [ 0 ] . length ) ;
83
87
@@ -96,6 +100,8 @@ export const embedEmojis = fragments => {
96
100
} ,
97
101
} ,
98
102
} ) ;
103
+ } else if ( isSpecialCase ) {
104
+ result . push ( { string : emoji , attributes : fragment . attributes } ) ;
99
105
} else {
100
106
// If no emoji data, we just replace the emoji with a nodef char
101
107
result . push ( {
You can’t perform that action at this time.
0 commit comments