This commit is contained in:
@@ -4,6 +4,7 @@ import { ResolvedPos } from 'prosemirror-model'
|
|||||||
export interface Trigger {
|
export interface Trigger {
|
||||||
char: string,
|
char: string,
|
||||||
allowSpaces: boolean,
|
allowSpaces: boolean,
|
||||||
|
prefixSpace: boolean,
|
||||||
startOfLine: boolean,
|
startOfLine: boolean,
|
||||||
$position: ResolvedPos,
|
$position: ResolvedPos,
|
||||||
}
|
}
|
||||||
@@ -18,6 +19,7 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch {
|
|||||||
const {
|
const {
|
||||||
char,
|
char,
|
||||||
allowSpaces,
|
allowSpaces,
|
||||||
|
prefixSpace,
|
||||||
startOfLine,
|
startOfLine,
|
||||||
$position,
|
$position,
|
||||||
} = config
|
} = config
|
||||||
@@ -49,7 +51,7 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch {
|
|||||||
// or the line beginning
|
// or the line beginning
|
||||||
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index)
|
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index)
|
||||||
|
|
||||||
if (!/^[\s\0]?$/.test(matchPrefix)) {
|
if (prefixSpace && !/^[\s\0]?$/.test(matchPrefix)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface SuggestionOptions {
|
|||||||
char?: string,
|
char?: string,
|
||||||
allowSpaces?: boolean,
|
allowSpaces?: boolean,
|
||||||
startOfLine?: boolean,
|
startOfLine?: boolean,
|
||||||
|
prefixSpace?: boolean,
|
||||||
decorationTag?: string,
|
decorationTag?: string,
|
||||||
decorationClass?: string,
|
decorationClass?: string,
|
||||||
command?: (props: {
|
command?: (props: {
|
||||||
@@ -53,6 +54,7 @@ export function Suggestion({
|
|||||||
editor,
|
editor,
|
||||||
char = '@',
|
char = '@',
|
||||||
allowSpaces = false,
|
allowSpaces = false,
|
||||||
|
prefixSpace = true,
|
||||||
startOfLine = false,
|
startOfLine = false,
|
||||||
decorationTag = 'span',
|
decorationTag = 'span',
|
||||||
decorationClass = 'suggestion',
|
decorationClass = 'suggestion',
|
||||||
@@ -173,6 +175,7 @@ export function Suggestion({
|
|||||||
const match = findSuggestionMatch({
|
const match = findSuggestionMatch({
|
||||||
char,
|
char,
|
||||||
allowSpaces,
|
allowSpaces,
|
||||||
|
prefixSpace,
|
||||||
startOfLine,
|
startOfLine,
|
||||||
$position: selection.$from,
|
$position: selection.$from,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user