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
This commit is contained in:
CorrectRoadH 2023-05-14 23:17:18 +08:00 committed by GitHub
parent 2cc5691efd
commit d72b4e9a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import { checkShouldShowMemoWithFilters } from "@/helpers/filter"; import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
import Memo from "./Memo"; import Memo from "./Memo";
import "@/less/memo-list.less"; import "@/less/memo-list.less";
import { PLAIN_LINK_REG } from "@/labs/marked/parser";
import copy from "copy-to-clipboard"; import copy from "copy-to-clipboard";
const MemoList = () => { const MemoList = () => {
@ -62,7 +63,7 @@ const MemoList = () => {
if (memoType) { if (memoType) {
if (memoType === "NOT_TAGGED" && memo.content.match(TAG_REG) !== null) { if (memoType === "NOT_TAGGED" && memo.content.match(TAG_REG) !== null) {
shouldShow = false; 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; shouldShow = false;
} }
} }

View File

@ -1,5 +1,5 @@
import { getUnixTimeMillis } from "./datetime"; 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 = [ export const relationConsts = [
{ text: "filter.and", value: "AND" }, { text: "filter.and", value: "AND" },
@ -181,7 +181,7 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
let matched = false; let matched = false;
if (value === "NOT_TAGGED" && memo.content.match(TAG_REG) === null) { if (value === "NOT_TAGGED" && memo.content.match(TAG_REG) === null) {
matched = true; 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; matched = true;
} else if (value === "HAS_ATTACHMENT" && memo.resourceList.length > 0) { } else if (value === "HAS_ATTACHMENT" && memo.resourceList.length > 0) {
matched = true; matched = true;

View File

@ -21,6 +21,7 @@ import Heading from "./Heading";
export { TAG_REG } from "./Tag"; export { TAG_REG } from "./Tag";
export { LINK_REG } from "./Link"; export { LINK_REG } from "./Link";
export { PLAIN_LINK_REG } from "./PlainLink";
// The order determines the order of execution. // The order determines the order of execution.
export const blockElementParserList = [ export const blockElementParserList = [