import { SuggestModal } from "obsidian" ; import ObsidianGit from "src/main" ; export class CustomMessageModal extends SuggestModal < string > { plugin : ObsidianGit ; resolve : ( ( value : string | PromiseLike < string > ) => void ) | null = null ; constructor ( plugin , private readonly fromAutoBackup ) { super ( plugin . app ) ; this . plugin = plugin ; this . setPlaceholder ( "Type your message and select optional the version with the added date." ) ; } open ( ) { super . open ( ) ; return new Promise ( ( resolve ) => { this . resolve = resolve ; } ) ; } onClose ( ) { if ( this . resolve ) this . resolve ( undefined ) ; } selectSuggestion ( value , evt ) { if ( this . resolve ) this . resolve ( value ) ; super . selectSuggestion ( value , evt ) ; } getSuggestions ( query ) { const date = ( window as any ) . moment ( ) . format ( this . plugin . settings . commitDateFormat ) ; if ( query == "" ) query = "..." ; return [ query , `${ date }: ${ query }` , `${ query }: ${ date }` ] ; } renderSuggestion ( value , el ) { el . innerText = value ; } onChooseSuggestion ( item , _ ) { } }