@@ -7,7 +7,20 @@ import {getIssueColor, getIssueIcon} from '../issue.ts';
77import { debounce } from 'perfect-debounce' ;
88import type TextExpanderElement from '@github/text-expander-element' ;
99
10- const debouncedSuggestIssues = debounce ( ( key : string , text : string ) => new Promise < { matched :boolean ; fragment ?: HTMLElement } > ( async ( resolve ) => {
10+ type TextExpanderProvideResult = {
11+ matched : boolean ,
12+ fragment ?: HTMLElement ,
13+ }
14+
15+ type TextExpanderChangeEvent = Event & {
16+ detail ?: {
17+ key : string ,
18+ text : string ,
19+ provide : ( result : TextExpanderProvideResult | Promise < TextExpanderProvideResult > ) => void ,
20+ }
21+ }
22+
23+ const debouncedSuggestIssues = debounce ( ( key : string , text : string ) => new Promise < TextExpanderProvideResult > ( async ( resolve ) => {
1124 const issuePathInfo = parseIssueHref ( window . location . href ) ;
1225 if ( ! issuePathInfo . ownerName ) {
1326 const repoOwnerPathInfo = parseRepoOwnerPathInfo ( window . location . pathname ) ;
@@ -34,7 +47,8 @@ const debouncedSuggestIssues = debounce((key: string, text: string) => new Promi
3447} ) , 100 ) ;
3548
3649export function initTextExpander ( expander : TextExpanderElement ) {
37- expander ?. addEventListener ( 'text-expander-change' , ( { detail : { key, provide, text} } : Record < string , any > ) => {
50+ expander ?. addEventListener ( 'text-expander-change' , ( e : TextExpanderChangeEvent ) => {
51+ const { key, text, provide} = e . detail ;
3852 if ( key === ':' ) {
3953 const matches = matchEmoji ( text ) ;
4054 if ( ! matches . length ) return provide ( { matched : false } ) ;
0 commit comments