rename suggestion command argument

This commit is contained in:
Philipp Kühn
2021-01-21 12:28:58 +01:00
parent a2d5eef6b2
commit 319eb83303
3 changed files with 9 additions and 9 deletions

View File

@@ -8,8 +8,8 @@ export default Extension.create({
suggestion: { suggestion: {
char: '/', char: '/',
startOfLine: true, startOfLine: true,
command: ({ editor, range, attributes }) => { command: ({ editor, range, props }) => {
attributes.command({ editor, range }) props.command({ editor, range })
}, },
}, },
}, },

View File

@@ -15,11 +15,11 @@ export const Mention = Node.create({
HTMLAttributes: {}, HTMLAttributes: {},
suggestion: { suggestion: {
char: '@', char: '@',
command: ({ editor, range, attributes }) => { command: ({ editor, range, props }) => {
editor editor
.chain() .chain()
.focus() .focus()
.replaceRange(range, 'mention', attributes) .replaceRange(range, 'mention', props)
.insertText(' ') .insertText(' ')
.run() .run()
}, },

View File

@@ -1,4 +1,4 @@
import { Editor, Range, AnyObject } from '@tiptap/core' import { Editor, Range } from '@tiptap/core'
import { Plugin, PluginKey } from 'prosemirror-state' import { Plugin, PluginKey } from 'prosemirror-state'
import { Decoration, DecorationSet, EditorView } from 'prosemirror-view' import { Decoration, DecorationSet, EditorView } from 'prosemirror-view'
import { findSuggestionMatch } from './findSuggestionMatch' import { findSuggestionMatch } from './findSuggestionMatch'
@@ -13,7 +13,7 @@ export interface SuggestionOptions {
command?: (props: { command?: (props: {
editor: Editor, editor: Editor,
range: Range, range: Range,
attributes: AnyObject props: any,
}) => void, }) => void,
items?: (query: string) => any[], items?: (query: string) => any[],
render?: () => { render?: () => {
@@ -30,7 +30,7 @@ export interface SuggestionProps {
query: string, query: string,
text: string, text: string,
items: any[], items: any[],
command: (attributes: AnyObject) => void, command: (props: any) => void,
decorationNode: Element | null, decorationNode: Element | null,
clientRect: () => (DOMRect | null), clientRect: () => (DOMRect | null),
} }
@@ -88,11 +88,11 @@ export function Suggestion({
items: (handleChange || handleStart) items: (handleChange || handleStart)
? await items(state.query) ? await items(state.query)
: [], : [],
command: attributes => { command: commandProps => {
command({ command({
editor, editor,
range: state.range, range: state.range,
attributes, props: commandProps,
}) })
}, },
decorationNode, decorationNode,