add decorationTag and decorationClass option

This commit is contained in:
Philipp Kühn
2021-01-20 10:47:31 +01:00
parent 5d1a2d6695
commit 8f95eb6aed

View File

@@ -8,7 +8,8 @@ export interface SuggestionOptions {
char?: string, char?: string,
allowSpaces?: boolean, allowSpaces?: boolean,
startOfLine?: boolean, startOfLine?: boolean,
suggestionClass?: string, decorationTag?: string,
decorationClass?: string,
command?: (props: { command?: (props: {
editor: Editor, editor: Editor,
range: Range, range: Range,
@@ -45,7 +46,8 @@ export function Suggestion({
char = '@', char = '@',
allowSpaces = false, allowSpaces = false,
startOfLine = false, startOfLine = false,
suggestionClass = 'suggestion', decorationTag = 'span',
decorationClass = 'suggestion',
command = () => null, command = () => null,
items = () => [], items = () => [],
render = () => ({}), render = () => ({}),
@@ -194,8 +196,8 @@ export function Suggestion({
return DecorationSet.create(state.doc, [ return DecorationSet.create(state.doc, [
Decoration.inline(range.from, range.to, { Decoration.inline(range.from, range.to, {
nodeName: 'span', nodeName: decorationTag,
class: suggestionClass, class: decorationClass,
'data-decoration-id': decorationId, 'data-decoration-id': decorationId,
}), }),
]) ])