fix: emoji replacement error handling
parent
dc94d707b0
commit
2d2dc64efc
|
@ -49,8 +49,7 @@ export const Emoji = Node.create({
|
|||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
nodeInputRule({
|
||||
const inputRule = nodeInputRule({
|
||||
find: EMOJI_REGEX,
|
||||
type: this.type,
|
||||
getAttributes: (match) => {
|
||||
|
@ -60,7 +59,19 @@ export const Emoji = Node.create({
|
|||
fallback: native,
|
||||
}
|
||||
},
|
||||
}),
|
||||
})
|
||||
// Error catch for unsupported emoji
|
||||
const handler = inputRule.handler.bind(inputRule)
|
||||
inputRule.handler = (...args) => {
|
||||
try {
|
||||
return handler(...args)
|
||||
}
|
||||
catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return [
|
||||
inputRule,
|
||||
]
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue