mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-03 16:38:50 -04:00
Fix autocompletion (#1736)
* Add visibility check for codemirror autocompletion Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Move autocompletion trigger to extended-codemirror Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
20d9a15cff
commit
98040cbdaa
3 changed files with 38 additions and 27 deletions
|
@ -20,24 +20,8 @@ import { useApplyScrollState } from './hooks/use-apply-scroll-state'
|
|||
import { MaxLengthWarning } from './max-length-warning/max-length-warning'
|
||||
import { useCreateStatusBarInfo } from './hooks/use-create-status-bar-info'
|
||||
import { useOnImageUploadFromRenderer } from './hooks/use-on-image-upload-from-renderer'
|
||||
import { allHinters, findWordAtCursor } from './autocompletion'
|
||||
import { ExtendedCodemirror } from './extended-codemirror/extended-codemirror'
|
||||
|
||||
const onChange = (editor: Editor) => {
|
||||
const searchTerm = findWordAtCursor(editor)
|
||||
for (const hinter of allHinters) {
|
||||
if (hinter.wordRegExp.test(searchTerm.text)) {
|
||||
editor.showHint({
|
||||
hint: hinter.hint,
|
||||
completeSingle: false,
|
||||
completeOnSingleClick: false,
|
||||
alignWithWord: true
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const EditorPane: React.FC<ScrollProps> = ({ scrollState, onScroll, onMakeScrollSource }) => {
|
||||
const markdownContent = useNoteMarkdownContent()
|
||||
|
||||
|
@ -76,7 +60,6 @@ export const EditorPane: React.FC<ScrollProps> = ({ scrollState, onScroll, onMak
|
|||
value={markdownContent}
|
||||
options={codeMirrorOptions}
|
||||
onPaste={onPaste}
|
||||
onChange={onChange}
|
||||
onDrop={onDrop}
|
||||
onCursorActivity={updateStatusBarInfo}
|
||||
editorDidMount={onEditorDidMount}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue