mirror of
https://github.com/usememos/memos.git
synced 2024-09-22 01:07:12 +03:00
feat: text filter regex support (#406)
This commit is contained in:
parent
a1068b6fe3
commit
4ed987229b
@ -258,6 +258,7 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterIn
|
||||
onChange={(event) => {
|
||||
handleValueChange(event.target.value);
|
||||
}}
|
||||
placeholder={t("filter.text-placeholder")}
|
||||
/>
|
||||
) : (
|
||||
<Selector className="value-selector" dataSource={valueDataSource} value={value} handleValueChanged={handleValueChange} />
|
||||
|
@ -142,11 +142,16 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
|
||||
}
|
||||
shouldShow = matched;
|
||||
} else if (type === "TEXT") {
|
||||
let contained = memo.content.toLowerCase().includes(value.toLowerCase());
|
||||
if (operator === "NOT_CONTAIN") {
|
||||
contained = !contained;
|
||||
if (value.startsWith("^")) {
|
||||
const reg = new RegExp(value.slice(1));
|
||||
shouldShow = operator === "NOT_CONTAIN" ? !reg.test(memo.content) : reg.test(memo.content);
|
||||
} else {
|
||||
let contained = memo.content.toLowerCase().includes(value.toLowerCase());
|
||||
if (operator === "NOT_CONTAIN") {
|
||||
contained = !contained;
|
||||
}
|
||||
shouldShow = contained;
|
||||
}
|
||||
shouldShow = contained;
|
||||
}
|
||||
|
||||
return shouldShow;
|
||||
|
@ -116,7 +116,8 @@
|
||||
"value": {
|
||||
"not-tagged": "No tags",
|
||||
"linked": "Has links"
|
||||
}
|
||||
},
|
||||
"text-placeholder": "Starts with ^ to use regex"
|
||||
},
|
||||
"tag-list": {
|
||||
"tip-text": "Enter `#tag ` to create"
|
||||
|
@ -116,7 +116,8 @@
|
||||
"value": {
|
||||
"not-tagged": "无标签",
|
||||
"linked": "包含链接"
|
||||
}
|
||||
},
|
||||
"text-placeholder": "以 ^ 开头使用正则表达式"
|
||||
},
|
||||
"tag-list": {
|
||||
"tip-text": "输入`#tag `来创建标签"
|
||||
|
Loading…
Reference in New Issue
Block a user