@@ -27,6 +27,36 @@ export class App {
2727 if ( key === "useTab" ) return false ;
2828 return null ;
2929 } ,
30+ // Event system for vault
31+ _events : { } as Record < string , Function [ ] > ,
32+ on : function ( eventName : string , callback : Function ) {
33+ if ( ! this . _events [ eventName ] ) {
34+ this . _events [ eventName ] = [ ] ;
35+ }
36+ this . _events [ eventName ] . push ( callback ) ;
37+ return { unload : ( ) => this . off ( eventName , callback ) } ;
38+ } ,
39+ off : function ( eventName : string , callback : Function ) {
40+ if ( this . _events [ eventName ] ) {
41+ const index = this . _events [ eventName ] . indexOf ( callback ) ;
42+ if ( index > - 1 ) {
43+ this . _events [ eventName ] . splice ( index , 1 ) ;
44+ }
45+ }
46+ } ,
47+ trigger : function ( eventName : string , ...args : any [ ] ) {
48+ if ( this . _events [ eventName ] ) {
49+ this . _events [ eventName ] . forEach ( ( callback : any ) => callback ( ...args ) ) ;
50+ }
51+ } ,
52+ getFileByPath : function ( path : string ) {
53+ // Mock implementation for getFileByPath
54+ return {
55+ path : path ,
56+ name : path . split ( '/' ) . pop ( ) || path ,
57+ children : [ ] , // For directory-like behavior
58+ } ;
59+ } ,
3060 } ;
3161
3262 workspace = {
@@ -298,9 +328,16 @@ function momentFn(input?: any) {
298328} ;
299329
300330( momentFn as any ) . locale = function ( locale ?: string ) {
301- return locale || "en" ;
331+ if ( locale ) {
332+ ( momentFn as any ) . _currentLocale = locale ;
333+ return locale ;
334+ }
335+ return ( momentFn as any ) . _currentLocale || "en" ;
302336} ;
303337
338+ // Initialize default locale
339+ ( momentFn as any ) . _currentLocale = "en" ;
340+
304341( momentFn as any ) . weekdaysShort = function ( localeData ?: boolean ) {
305342 return [ "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" ] ;
306343} ;
@@ -309,6 +346,16 @@ function momentFn(input?: any) {
309346 return [ "Su" , "Mo" , "Tu" , "We" , "Th" , "Fr" , "Sa" ] ;
310347} ;
311348
349+ ( momentFn as any ) . months = function ( ) {
350+ return [ "January" , "February" , "March" , "April" , "May" , "June" ,
351+ "July" , "August" , "September" , "October" , "November" , "December" ] ;
352+ } ;
353+
354+ ( momentFn as any ) . monthsShort = function ( ) {
355+ return [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" ,
356+ "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ] ;
357+ } ;
358+
312359export const moment = momentFn as any ;
313360
314361// Mock Component class
@@ -366,6 +413,12 @@ export class Component {
366413 // Mock implementation
367414 return id ;
368415 }
416+
417+ private _events : Array < { unload : ( ) => void } > = [ ] ;
418+
419+ registerEvent ( eventRef : { unload : ( ) => void } ) : void {
420+ this . _events . push ( eventRef ) ;
421+ }
369422}
370423
371424// Mock other common Obsidian utilities
@@ -391,4 +444,26 @@ export function debounce<T extends (...args: any[]) => any>(
391444 } ) as T ;
392445}
393446
447+ // Mock EditorSuggest class
448+ export abstract class EditorSuggest < T > extends Component {
449+ app : App ;
450+
451+ constructor ( app : App ) {
452+ super ( ) ;
453+ this . app = app ;
454+ }
455+
456+ abstract getSuggestions ( context : any ) : T [ ] | Promise < T [ ] > ;
457+ abstract renderSuggestion ( suggestion : T , el : HTMLElement ) : void ;
458+ abstract selectSuggestion ( suggestion : T , evt : MouseEvent | KeyboardEvent ) : void ;
459+
460+ onTrigger ( cursor : any , editor : any , file : any ) : any {
461+ return null ;
462+ }
463+
464+ close ( ) : void {
465+ // Mock implementation
466+ }
467+ }
468+
394469// Add any other Obsidian classes or functions needed for tests
0 commit comments