replace allowedChars with not-whitespace (#617)

This commit is contained in:
mrdrogdrog 2020-09-30 23:58:31 +02:00 committed by GitHub
parent 1ab9b58031
commit 733df9b94a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 29 deletions

View file

@ -1,14 +1,13 @@
import { Editor, Hint, Hints, Pos } from 'codemirror'
import { findWordAtCursor, Hinter, search } from './index'
const allowedChars = /[`\w-_+]/
const wordRegExp = /^```((\w|-|_|\+)*)$/
let allSupportedLanguages: string[] = []
const codeBlockHint = (editor: Editor): Promise< Hints| null > => {
return import(/* webpackChunkName: "highlight.js" */ 'highlight.js').then(hljs =>
new Promise((resolve) => {
const searchTerm = findWordAtCursor(editor, allowedChars)
const searchTerm = findWordAtCursor(editor)
const searchResult = wordRegExp.exec(searchTerm.text)
if (searchResult === null) {
resolve(null)
@ -36,7 +35,6 @@ const codeBlockHint = (editor: Editor): Promise< Hints| null > => {
}
export const CodeBlockHinter: Hinter = {
allowedChars,
wordRegExp,
hint: codeBlockHint
}