@@ -2,7 +2,7 @@ import AbstractSearchOption from "./abstract_search_option.js";
2
2
import SpacedUpdate from "../../services/spaced_update.js" ;
3
3
import server from "../../services/server.js" ;
4
4
import shortcutService from "../../services/shortcuts.js" ;
5
- import appContext from "../../components/app_context.js" ;
5
+ import appContext , { type EventData } from "../../components/app_context.js" ;
6
6
import { t } from "../../services/i18n.js" ;
7
7
import { Tooltip } from "bootstrap" ;
8
8
@@ -29,20 +29,24 @@ const TPL = `
29
29
</ul>
30
30
</div>
31
31
</div>
32
-
32
+
33
33
<span class="bx bx-x icon-action search-option-del"></span>
34
34
</td>
35
35
</tr>` ;
36
36
37
37
export default class SearchString extends AbstractSearchOption {
38
+
39
+ private $searchString ! : JQuery < HTMLElement > ;
40
+ private spacedUpdate ! : SpacedUpdate ;
41
+
38
42
static get optionName ( ) {
39
43
return "searchString" ;
40
44
}
41
45
static get attributeType ( ) {
42
46
return "label" ;
43
47
}
44
48
45
- static async create ( noteId ) {
49
+ static async create ( noteId : string ) {
46
50
await AbstractSearchOption . setAttribute ( noteId , "label" , "searchString" ) ;
47
51
}
48
52
@@ -61,7 +65,7 @@ export default class SearchString extends AbstractSearchOption {
61
65
} ) ;
62
66
63
67
this . spacedUpdate = new SpacedUpdate ( async ( ) => {
64
- const searchString = this . $searchString . val ( ) ;
68
+ const searchString = String ( this . $searchString . val ( ) ) ;
65
69
appContext . lastSearchString = searchString ;
66
70
67
71
await this . setAttribute ( "label" , "searchString" , searchString ) ;
@@ -73,13 +77,13 @@ export default class SearchString extends AbstractSearchOption {
73
77
}
74
78
} , 1000 ) ;
75
79
76
- this . $searchString . val ( this . note . getLabelValue ( "searchString" ) ) ;
80
+ this . $searchString . val ( this . note . getLabelValue ( "searchString" ) ?? "" ) ;
77
81
78
82
return $option ;
79
83
}
80
84
81
- showSearchErrorEvent ( { error } ) {
82
- let tooltip = new Tooltip ( this . $searchString , {
85
+ showSearchErrorEvent ( { error } : EventData < "showSearchError" > ) {
86
+ let tooltip = new Tooltip ( this . $searchString [ 0 ] , {
83
87
trigger : "manual" ,
84
88
title : `${ t ( "search_string.error" , { error } ) } ` ,
85
89
placement : "bottom"
@@ -92,7 +96,7 @@ export default class SearchString extends AbstractSearchOption {
92
96
93
97
focusOnSearchDefinitionEvent ( ) {
94
98
this . $searchString
95
- . val ( this . $searchString . val ( ) . trim ( ) || appContext . lastSearchString )
99
+ . val ( String ( this . $searchString . val ( ) ) . trim ( ) ?? appContext . lastSearchString )
96
100
. focus ( )
97
101
. select ( ) ;
98
102
this . spacedUpdate . scheduleUpdate ( ) ;
0 commit comments