From d72b4e9a980dc60075926a143e8a04a7187293e3 Mon Sep 17 00:00:00 2001 From: CorrectRoadH Date: Sun, 14 May 2023 23:17:18 +0800 Subject: [PATCH] feat: filter support plain link (#1657) * fix: unexpected empty lines when copying-pasting * add ref * feat: support to filter plain link * eslint * fix the typo * fix the typo * unified the import path --- web/src/components/MemoList.tsx | 3 ++- web/src/helpers/filter.ts | 4 ++-- web/src/labs/marked/parser/index.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx index 2262925d..eed8b1c5 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 5bfd69f0..2c97498c 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 eea08329..7a1eeb7f 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 = [