@@ -115,6 +115,28 @@ const BooleanGroupFilterFn: FilterFn<RowDataType> = (row: Row<RowDataType>, colu
115115
116116}
117117
118+ const TagsGroupFilterFn : FilterFn < RowDataType > = ( row : Row < RowDataType > , columnId : string , filterValue : string ) => {
119+ const value = row . getValue < Literal > ( columnId ) ;
120+ const wrapLiteral = DataviewService . wrapLiteral ( value ) ;
121+ if ( filterValue === undefined || filterValue === null ) {
122+ return true ;
123+ }
124+
125+ if ( value === undefined || value === null ) {
126+ return false ;
127+ }
128+ const sanitizedFilterValue = filterValue . toLowerCase ( ) ;
129+ if ( wrapLiteral . type === "array" ) {
130+ return wrapLiteral . value . some ( ( tag ) => {
131+ const sanitizedTag = tag . toString ( ) . toLowerCase ( ) ;
132+ return sanitizedTag . includes ( sanitizedFilterValue ) || searchRegex ( sanitizedTag , sanitizedFilterValue ) ;
133+ } ) ;
134+ } else {
135+ const sanitizedTag = wrapLiteral . value . toString ( ) . toLowerCase ( ) ;
136+ return sanitizedTag . includes ( sanitizedFilterValue ) || searchRegex ( sanitizedTag , sanitizedFilterValue ) ;
137+ }
138+ }
139+
118140const TaskGroupFilterFn : FilterFn < RowDataType > = ( row : Row < RowDataType > , columnId : string , selectedOption : string ) => {
119141 const value = row . getValue < Literal > ( columnId ) as STask [ ] ;
120142 if ( selectedOption === undefined || selectedOption === null ) {
@@ -126,16 +148,15 @@ const TaskGroupFilterFn: FilterFn<RowDataType> = (row: Row<RowDataType>, columnI
126148 const sanitized = task . text . toLowerCase ( ) ;
127149 return sanitized . includes ( sanitizedSelectedOption ) || searchRegex ( sanitized , sanitizedSelectedOption ) ;
128150 } ) ;
129-
130-
131151}
132152
133153const customSortingfns : FilterFns = {
134154 markdown : MarkdownFilterFn ,
135155 linksGroup : LinksGroupFilterFn ,
136156 calendar : CalendarGroupFilterFn ,
137157 boolean : BooleanGroupFilterFn ,
138- task : TaskGroupFilterFn
158+ task : TaskGroupFilterFn ,
159+ tags : TagsGroupFilterFn ,
139160} ;
140161
141162export default customSortingfns ;
0 commit comments