Skip to content

Commit

Permalink
refactor: Allow to pass custom items/emit to mentions plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Dec 30, 2022
1 parent 6043016 commit d476e5c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/Mention/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const emitMention = ({ session, props }) => {
})
}

export default ({ session }) => ({
export default ({ session, params }) => ({
items: async ({ query }) => {
const params = {
documentId: session.documentId,
Expand All @@ -36,7 +36,14 @@ export default ({ session }) => ({
},

command: ({ editor, range, props }) => {
emitMention({ session, props })
if (params.emitMention) {
params.emitMention({ props })
} else {
emitMention({
session,
props,
})
}

// Insert mention
// from https://github.com/ueberdosis/tiptap/blob/9a254bf9daf6d839bd02c968e14837098b903b38/packages/extension-mention/src/mention.ts
Expand Down Expand Up @@ -129,4 +136,5 @@ export default ({ session }) => ({
},
}
},
...params,
})

0 comments on commit d476e5c

Please sign in to comment.