@@ -27,10 +27,28 @@ const customTextLongLS = new LocalStorageWithSchema({
2727 fallback : { } ,
2828} ) ;
2929
30+ const userEditedSettingsText = new LocalStorageWithSchema ( {
31+ key : "customTextSettingsUserEdited" ,
32+ schema : z . boolean ( ) ,
33+ fallback : false ,
34+ } ) ;
35+
3036type CustomTextLimit = z . infer < typeof CustomTextSettingsSchema > [ "limit" ] ;
3137
38+ const defaultCustomText = [
39+ "The" ,
40+ "quick" ,
41+ "brown" ,
42+ "fox" ,
43+ "jumps" ,
44+ "over" ,
45+ "the" ,
46+ "lazy" ,
47+ "dog" ,
48+ ] ;
49+
3250const defaultCustomTextSettings : CustomTextSettings = {
33- text : [ "The" , "quick" , "brown" , "fox" , "jumps" , "over" , "the" , "lazy" , "dog" ] ,
51+ text : defaultCustomText ,
3452 mode : "repeat" ,
3553 limit : { value : 9 , mode : "word" } ,
3654 pipeDelimiter : false ,
@@ -57,12 +75,28 @@ const customTextSettings = new LocalStorageWithSchema({
5775 } ,
5876} ) ;
5977
60- export function getText ( ) : string [ ] {
78+ function isDefaultCustomText ( text : string [ ] ) : boolean {
79+ return (
80+ text . length === defaultCustomText . length &&
81+ text . every ( ( word , index ) => word === defaultCustomText [ index ] )
82+ ) ;
83+ }
84+
85+ export function getStoredText ( ) : string [ ] {
6186 return customTextSettings . get ( ) . text ;
6287}
6388
89+ export function getEffectiveText ( languageWords : string [ ] ) : string [ ] {
90+ const text = customTextSettings . get ( ) . text ;
91+ if ( ! userEditedSettingsText . get ( ) && isDefaultCustomText ( text ) ) {
92+ return languageWords . slice ( 0 , text . length ) ;
93+ }
94+ return text ;
95+ }
96+
6497export function setText ( txt : string [ ] ) : void {
6598 const currentSettings = customTextSettings . get ( ) ;
99+ userEditedSettingsText . set ( true ) ;
66100 customTextSettings . set ( {
67101 ...currentSettings ,
68102 text : txt ,
0 commit comments