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) => {
|
onChange={(event) => {
|
||||||
handleValueChange(event.target.value);
|
handleValueChange(event.target.value);
|
||||||
}}
|
}}
|
||||||
|
placeholder={t("filter.text-placeholder")}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Selector className="value-selector" dataSource={valueDataSource} value={value} handleValueChanged={handleValueChange} />
|
<Selector className="value-selector" dataSource={valueDataSource} value={value} handleValueChanged={handleValueChange} />
|
||||||
|
@ -142,11 +142,16 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
|
|||||||
}
|
}
|
||||||
shouldShow = matched;
|
shouldShow = matched;
|
||||||
} else if (type === "TEXT") {
|
} else if (type === "TEXT") {
|
||||||
let contained = memo.content.toLowerCase().includes(value.toLowerCase());
|
if (value.startsWith("^")) {
|
||||||
if (operator === "NOT_CONTAIN") {
|
const reg = new RegExp(value.slice(1));
|
||||||
contained = !contained;
|
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;
|
return shouldShow;
|
||||||
|
@ -116,7 +116,8 @@
|
|||||||
"value": {
|
"value": {
|
||||||
"not-tagged": "No tags",
|
"not-tagged": "No tags",
|
||||||
"linked": "Has links"
|
"linked": "Has links"
|
||||||
}
|
},
|
||||||
|
"text-placeholder": "Starts with ^ to use regex"
|
||||||
},
|
},
|
||||||
"tag-list": {
|
"tag-list": {
|
||||||
"tip-text": "Enter `#tag ` to create"
|
"tip-text": "Enter `#tag ` to create"
|
||||||
|
@ -116,7 +116,8 @@
|
|||||||
"value": {
|
"value": {
|
||||||
"not-tagged": "无标签",
|
"not-tagged": "无标签",
|
||||||
"linked": "包含链接"
|
"linked": "包含链接"
|
||||||
}
|
},
|
||||||
|
"text-placeholder": "以 ^ 开头使用正则表达式"
|
||||||
},
|
},
|
||||||
"tag-list": {
|
"tag-list": {
|
||||||
"tip-text": "输入`#tag `来创建标签"
|
"tip-text": "输入`#tag `来创建标签"
|
||||||
|
Loading…
Reference in New Issue
Block a user