feat:search ignore case

pr675
黄云飞 4 years ago
parent a4abaca5a7
commit 6f375e928e

@ -145,6 +145,7 @@ export class Search {
} }
public compute(payload: string) { public compute(payload: string) {
const keyword = payload.toLocaleLowerCase()
const searchMatchList: ISearchResult[] = [] const searchMatchList: ISearchResult[] = []
// 分组 // 分组
const elementListGroup: { type: EditorContext, elementList: IElement[], index: number }[] = [] const elementListGroup: { type: EditorContext, elementList: IElement[], index: number }[] = []
@ -190,6 +191,7 @@ export class Search {
: ZERO) : ZERO)
.filter(Boolean) .filter(Boolean)
.join('') .join('')
.toLocaleLowerCase()
const matchStartIndexList = [] const matchStartIndexList = []
let index = text.indexOf(payload) let index = text.indexOf(payload)
while (index !== -1) { while (index !== -1) {
@ -224,11 +226,11 @@ export class Search {
tdIndex: d, tdIndex: d,
tdId: td.id tdId: td.id
} }
searchClosure(payload, group.type, td.value, restArgs) searchClosure(keyword, group.type, td.value, restArgs)
} }
} }
} else { } else {
searchClosure(payload, group.type, group.elementList, { searchClosure(keyword, group.type, group.elementList, {
startIndex: group.index startIndex: group.index
}) })
} }

Loading…
Cancel
Save