add some default options for mentions
This commit is contained in:
@@ -8,6 +8,18 @@ export default class MentionNode extends Node {
|
|||||||
return 'mention'
|
return 'mention'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get defaultOptions() {
|
||||||
|
return {
|
||||||
|
matcher: {
|
||||||
|
char: '@',
|
||||||
|
allowSpaces: false,
|
||||||
|
startOfLine: false,
|
||||||
|
},
|
||||||
|
mentionClass: 'mention',
|
||||||
|
suggestionClass: 'mention-suggestion',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get schema() {
|
get schema() {
|
||||||
return {
|
return {
|
||||||
attrs: {
|
attrs: {
|
||||||
@@ -21,7 +33,7 @@ export default class MentionNode extends Node {
|
|||||||
toDOM: node => [
|
toDOM: node => [
|
||||||
'span',
|
'span',
|
||||||
{
|
{
|
||||||
class: 'mention',
|
class: this.options.mentionClass,
|
||||||
'data-mention-id': node.attrs.id,
|
'data-mention-id': node.attrs.id,
|
||||||
},
|
},
|
||||||
`@${node.attrs.label}`,
|
`@${node.attrs.label}`,
|
||||||
@@ -42,21 +54,17 @@ export default class MentionNode extends Node {
|
|||||||
get plugins() {
|
get plugins() {
|
||||||
return [
|
return [
|
||||||
SuggestionsPlugin({
|
SuggestionsPlugin({
|
||||||
suggestionClass: 'mention-suggestion',
|
|
||||||
matcher: {
|
|
||||||
char: '@',
|
|
||||||
allowSpaces: false,
|
|
||||||
startOfLine: false,
|
|
||||||
},
|
|
||||||
command: ({ range, attrs, schema }) => {
|
command: ({ range, attrs, schema }) => {
|
||||||
return replaceText(range, schema.nodes.mention, attrs)
|
return replaceText(range, schema.nodes.mention, attrs)
|
||||||
},
|
},
|
||||||
|
matcher: this.options.matcher,
|
||||||
items: this.options.items,
|
items: this.options.items,
|
||||||
onEnter: this.options.onEnter,
|
onEnter: this.options.onEnter,
|
||||||
onChange: this.options.onChange,
|
onChange: this.options.onChange,
|
||||||
onExit: this.options.onExit,
|
onExit: this.options.onExit,
|
||||||
onKeyDown: this.options.onKeyDown,
|
onKeyDown: this.options.onKeyDown,
|
||||||
onFilter: this.options.onFilter,
|
onFilter: this.options.onFilter,
|
||||||
|
suggestionClass: this.options.suggestionClass,
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user