feat: add label attribute to mention extension (#1322)
This commit is contained in:
@@ -62,6 +62,22 @@ export const Mention = Node.create<MentionOptions>({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
label: {
|
||||||
|
default: null,
|
||||||
|
parseHTML: element => {
|
||||||
|
return {
|
||||||
|
label: element.getAttribute('data-label'),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
renderHTML: attributes => {
|
||||||
|
if (!attributes.label) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'data-label': attributes.label,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -77,12 +93,12 @@ export const Mention = Node.create<MentionOptions>({
|
|||||||
return [
|
return [
|
||||||
'span',
|
'span',
|
||||||
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
||||||
`${this.options.suggestion.char}${node.attrs.id}`,
|
`${this.options.suggestion.char}${node.attrs.label ?? node.attrs.id}`,
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
renderText({ node }) {
|
renderText({ node }) {
|
||||||
return `${this.options.suggestion.char}${node.attrs.id}`
|
return `${this.options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
|
||||||
},
|
},
|
||||||
|
|
||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
|
|||||||
Reference in New Issue
Block a user