Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: filter support plain link (#1657)

CorrectRoadHd72b4e9a980d
diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx
index 2262925de..eed8b1c52 100644
--- a/web/src/components/MemoList.tsx
+++ b/web/src/components/MemoList.tsx
@@ -8,6 +8,7 @@ import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
import Memo from "./Memo";
import "@/less/memo-list.less";
+import { PLAIN_LINK_REG } from "@/labs/marked/parser";
import copy from "copy-to-clipboard";
const MemoList = () => {
@@ -62,7 +63,7 @@ const MemoList = () => {
if (memoType) {
if (memoType === "NOT_TAGGED" && memo.content.match(TAG_REG) !== null) {
shouldShow = false;
- } else if (memoType === "LINKED" && memo.content.match(LINK_REG) === null) {
+ } else if (memoType === "LINKED" && (memo.content.match(LINK_REG) === null || memo.content.match(PLAIN_LINK_REG) === null)) {
shouldShow = false;
}
}
diff --git a/web/src/helpers/filter.ts b/web/src/helpers/filter.ts
index 5bfd69f09..2c97498c0 100644
--- a/web/src/helpers/filter.ts
+++ b/web/src/helpers/filter.ts
@@ -1,5 +1,5 @@
import { getUnixTimeMillis } from "./datetime";
-import { TAG_REG, LINK_REG } from "@/labs/marked/parser";
+import { TAG_REG, LINK_REG, PLAIN_LINK_REG } from "@/labs/marked/parser";
export const relationConsts = [
{ text: "filter.and", value: "AND" },
@@ -181,7 +181,7 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
let matched = false;
if (value === "NOT_TAGGED" && memo.content.match(TAG_REG) === null) {
matched = true;
- } else if (value === "LINKED" && memo.content.match(LINK_REG) !== null) {
+ } else if (value === "LINKED" && (memo.content.match(LINK_REG) !== null || memo.content.match(PLAIN_LINK_REG)) !== null) {
matched = true;
} else if (value === "HAS_ATTACHMENT" && memo.resourceList.length > 0) {
matched = true;
diff --git a/web/src/labs/marked/parser/index.ts b/web/src/labs/marked/parser/index.ts
index eea083292..7a1eeb7f3 100644
--- a/web/src/labs/marked/parser/index.ts
+++ b/web/src/labs/marked/parser/index.ts
@@ -21,6 +21,7 @@ import Heading from "./Heading";
export { TAG_REG } from "./Tag";
export { LINK_REG } from "./Link";
+export { PLAIN_LINK_REG } from "./PlainLink";
// The order determines the order of execution.
export const blockElementParserList = [