@@ -26,6 +26,7 @@ type SearchEntry = {
2626 block : string ;
2727 category : string ;
2828 tags ?: string [ ] ;
29+ notes ?: string [ ] ;
2930} ;
3031
3132type SearchData = {
@@ -139,7 +140,10 @@ function filterName(
139140) {
140141 if ( ! headerValue ) return true ;
141142
142- const rowValue = rowData . name ;
143+ const rowValues = [ rowData . name ] ;
144+ if ( rowData . notes ) {
145+ rowValues . push ( ...rowData . notes ) ;
146+ }
143147
144148 if ( headerValue . length == 1 ) {
145149 if ( headerValue == "^" ) {
@@ -154,15 +158,25 @@ function filterName(
154158 return true ;
155159 }
156160 const search = headerValue . substring ( 1 ) . toLowerCase ( ) ;
157- return rowValue . toLowerCase ( ) . startsWith ( search ) ;
161+ for ( const rowValue of rowValues ) {
162+ if ( rowValue . toLowerCase ( ) . startsWith ( search ) ) {
163+ return true ;
164+ }
165+ }
166+ return false ;
158167 }
159168
160169 if ( headerValue . startsWith ( "/" ) && headerValue . endsWith ( "/" ) ) {
161170 // regex
162171 const pattern = headerValue . substring ( 1 , headerValue . length - 1 ) ;
163172 try {
164173 const re = new RegExp ( pattern , "i" ) ;
165- return re . test ( rowValue ) ;
174+ for ( const rowValue of rowValues ) {
175+ if ( re . test ( rowValue ) ) {
176+ return true ;
177+ }
178+ }
179+ return false ;
166180 } catch ( e ) {
167181 // bad regex
168182 return false ;
@@ -171,7 +185,12 @@ function filterName(
171185
172186 // contains
173187 const search = headerValue . toLowerCase ( ) ;
174- return rowValue . toLowerCase ( ) . includes ( search ) ;
188+ for ( const rowValue of rowValues ) {
189+ if ( rowValue . toLowerCase ( ) . includes ( search ) ) {
190+ return true ;
191+ }
192+ }
193+ return false ;
175194}
176195
177196function filterTags (
@@ -226,26 +245,33 @@ function fmtExample(cell: CellComponent) {
226245
227246function fmtTags ( cell : CellComponent ) {
228247 const tags = cell . getValue ( ) as string [ ] ;
229- if ( ! tags || tags . length === 0 ) {
248+ const notes = cell . getRow ( ) . getData ( ) . notes as string [ ] | undefined ;
249+ if ( ! tags && ! notes ) {
230250 return "" ;
231251 }
232252
233253 const container = document . createElement ( "div" ) ;
234254
235- const keys = tags . sort ( ) ;
236-
237- for ( const key of keys ) {
238- var el = document . createElement ( "span" ) ;
239- el . className =
240- "badge border border-primary text-primary me-1 mb-1 text-decoration-none" ;
241- el . textContent = key . replace ( / _ / g, " " ) ;
242- el . style . cursor = "pointer" ;
243- el . onclick = ( e ) => {
244- e . preventDefault ( ) ;
245- e . stopPropagation ( ) ;
246- toggleTagFilter ( cell , key ) ;
255+ if ( notes ) {
256+ container . textContent = notes . join ( ", " ) + " " ;
257+ }
258+
259+ if ( tags ) {
260+ const keys = tags . sort ( ) ;
261+
262+ for ( const key of keys ) {
263+ var el = document . createElement ( "span" ) ;
264+ el . className =
265+ "badge border border-primary text-primary me-1 mb-1 text-decoration-none" ;
266+ el . textContent = key . replace ( / _ / g, " " ) ;
267+ el . style . cursor = "pointer" ;
268+ el . onclick = ( e ) => {
269+ e . preventDefault ( ) ;
270+ e . stopPropagation ( ) ;
271+ toggleTagFilter ( cell , key ) ;
272+ }
273+ container . appendChild ( el ) ;
247274 }
248- container . appendChild ( el ) ;
249275 }
250276
251277 return container ;
@@ -421,6 +447,7 @@ async function main() {
421447 }
422448 if ( key == "dir" ) {
423449 sort [ 0 ] . dir = ( value == "desc" ) ? "desc" : "asc" ;
450+ continue ;
424451 }
425452 if ( key && value ) {
426453 filters . push ( { field : key , type : "=" , value : value } ) ;
@@ -570,7 +597,9 @@ async function main() {
570597 formatter : fmtTags ,
571598 headerFilter : "input" ,
572599 headerFilterFunc : filterTags ,
573- headerPopup : `Separate multiple tags with space or comma.<br/>Prefix a tag with <code>!</code> to exclude it.` ,
600+ headerPopup : `Separate multiple tags with space or comma.<br/>
601+ Prefix a tag with <code>!</code> to exclude it.<br/>
602+ Notes are searched under Name.` ,
574603 headerPopupIcon :
575604 '<span class="badge rounded-pill text-bg-primary">?</span>' ,
576605 headerSort : false ,
0 commit comments