fix: support all characters for suggestion char, fix #2385

This commit is contained in:
Philipp Kühn
2022-01-13 13:57:33 +01:00
parent 1dcbefd08b
commit 42d3ee8fc9
3 changed files with 7 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { Range } from '@tiptap/core'
import { Range, escapeForRegEx } from '@tiptap/core'
import { ResolvedPos } from 'prosemirror-model'
export interface Trigger {
@@ -24,11 +24,7 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch {
$position,
} = config
// Matching expressions used for later
const escapedChar = char
.split('')
.map(c => `\\${c}`)
.join('')
const escapedChar = escapeForRegEx(char)
const suffix = new RegExp(`\\s${escapedChar}$`)
const prefix = startOfLine ? '^' : ''
const regexp = allowSpaces