Skip to content

Commit

Permalink
fix(deps): update tiptap to v2.2.4 (#2398)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: userquin <userquin@gmail.com>
  • Loading branch information
renovate[bot] and userquin authored Feb 24, 2024
1 parent efb6967 commit 3584151
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 319 deletions.
28 changes: 15 additions & 13 deletions composables/tiptap/emoji.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ExtendedRegExpMatchArray } from '@tiptap/core'
import {
Node,
mergeAttributes,
Expand All @@ -6,31 +7,32 @@ import {
} from '@tiptap/core'
import { emojiRegEx, getEmojiAttributes } from '~/config/emojis'

function wrapHandler<T extends (...args: any[]) => any>(handler: T): T {
return <T>((...args: any[]) => {
try {
return handler(...args)
}
catch (e) {
return null
}
})
}

function createEmojiRule<NR extends typeof nodeInputRule | typeof nodePasteRule>(nodeRule: NR,
type: Parameters<NR>[0]['type']): ReturnType<NR>[] {
const rule = nodeRule({
find: emojiRegEx as RegExp,
type,
getAttributes: (match) => {
getAttributes: (match: ExtendedRegExpMatchArray) => {
const [native] = match
return getEmojiAttributes(native)
},
}) as ReturnType<NR>

// Error catch for unsupported emoji
const handler = rule.handler.bind(rule)
rule.handler = (...args) => {
try {
return handler(...args)
}
catch (e) {
return null
}
}
rule.handler = wrapHandler(rule.handler.bind(rule))

return [
rule,
]
return [rule]
}

export const TiptapPluginEmoji = Node.create({
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
"@nuxtjs/color-mode": "^3.3.2",
"@nuxtjs/i18n": "^8.1.1",
"@pinia/nuxt": "^0.5.1",
"@tiptap/core": "2.1.8",
"@tiptap/extension-bold": "2.1.8",
"@tiptap/extension-character-count": "2.1.8",
"@tiptap/extension-code-block": "2.1.8",
"@tiptap/extension-history": "2.1.8",
"@tiptap/extension-italic": "2.1.8",
"@tiptap/extension-mention": "2.1.8",
"@tiptap/extension-paragraph": "2.1.8",
"@tiptap/extension-placeholder": "2.1.8",
"@tiptap/extension-text": "2.1.8",
"@tiptap/pm": "^2.0.3",
"@tiptap/starter-kit": "2.1.8",
"@tiptap/suggestion": "2.1.8",
"@tiptap/vue-3": "2.1.8",
"@tiptap/core": "2.2.4",
"@tiptap/extension-bold": "2.2.4",
"@tiptap/extension-character-count": "2.2.4",
"@tiptap/extension-code-block": "2.2.4",
"@tiptap/extension-history": "2.2.4",
"@tiptap/extension-italic": "2.2.4",
"@tiptap/extension-mention": "2.2.4",
"@tiptap/extension-paragraph": "2.2.4",
"@tiptap/extension-placeholder": "2.2.4",
"@tiptap/extension-text": "2.2.4",
"@tiptap/pm": "^2.2.4",
"@tiptap/starter-kit": "2.2.4",
"@tiptap/suggestion": "2.2.4",
"@tiptap/vue-3": "2.2.4",
"@unocss/nuxt": "^0.58.5",
"@upstash/redis": "^1.27.1",
"@vercel/kv": "^1.0.1",
Expand Down
Loading

0 comments on commit 3584151

Please sign in to comment.