mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
replace allowedChars with not-whitespace (#617)
This commit is contained in:
parent
1ab9b58031
commit
733df9b94a
10 changed files with 14 additions and 29 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue