fix mention rendering

This commit is contained in:
Philipp Kühn
2021-01-19 12:03:38 +01:00
parent c13d65c842
commit 7712325ba9
5 changed files with 17 additions and 15 deletions

View File

@@ -22,9 +22,11 @@ export const Mention = Node.create({
return {
id: {
default: null,
},
label: {
default: null,
parseHTML: element => {
return {
id: element.getAttribute('data-mention'),
}
},
},
}
},
@@ -38,7 +40,7 @@ export const Mention = Node.create({
},
renderHTML({ node, HTMLAttributes }) {
return ['span', HTMLAttributes, `@${node.attrs.label}`]
return ['span', HTMLAttributes, `@${node.attrs.id}`]
},
addProseMirrorPlugins() {
@@ -46,11 +48,11 @@ export const Mention = Node.create({
Suggestion({
editor: this.editor,
...this.options,
command: ({ range }) => {
command: ({ range, attributes }) => {
this.editor
.chain()
.focus()
.replace(range, 'mention')
.replace(range, 'mention', attributes)
.insertText(' ')
.run()
},