@@ -15,6 +15,7 @@ import {
1515 type KeyBinding ,
1616 keymap ,
1717 placeholder ,
18+ tooltips ,
1819} from '@codemirror/view' ;
1920
2021import { InputState } from 'src/utils/input-state' ;
@@ -62,6 +63,7 @@ import {type YfmLangOptions, yfmLang} from './yfm';
6263export type { YfmLangOptions } ;
6364
6465type Autocompletion = Parameters < typeof autocompletion > [ 0 ] ;
66+ type Tooltips = Parameters < typeof tooltips > [ 0 ] ;
6567
6668const linkRegex = / \[ [ \s \S ] * ?] \( [ \s \S ] * ?\) / g;
6769
@@ -88,6 +90,7 @@ export type CreateCodemirrorParams = {
8890 receiver ?: Receiver < EventMap > ;
8991 yfmLangOptions ?: YfmLangOptions ;
9092 autocompletion ?: Autocompletion ;
93+ tooltips ?: Tooltips ;
9194 directiveSyntax : DirectiveSyntaxContext ;
9295 preserveEmptyRows : boolean ;
9396 searchPanel ?: boolean ;
@@ -110,6 +113,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
110113 extensions : extraExtensions ,
111114 placeholder : placeholderContent ,
112115 autocompletion : autocompletionConfig ,
116+ tooltips : tooltipsConfig ,
113117 parseHtmlOnPaste,
114118 parseInsertedUrlAsImage,
115119 directiveSyntax,
@@ -317,6 +321,10 @@ export function createCodemirror(params: CreateCodemirrorParams) {
317321 ) ;
318322 }
319323
324+ if ( tooltipsConfig ) {
325+ extensions . push ( tooltips ( tooltipsConfig ) ) ;
326+ }
327+
320328 if ( extraExtensions ) {
321329 extensions . push ( ...extraExtensions ) ;
322330 }
0 commit comments