mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add disable filter to renderer context
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import classNames from "classnames";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { useFilterStore } from "@/store/module";
|
import { useFilterStore } from "@/store/module";
|
||||||
import { RendererContext } from "./types";
|
import { RendererContext } from "./types";
|
||||||
@ -11,7 +12,7 @@ const Tag: React.FC<Props> = ({ content }: Props) => {
|
|||||||
const filterStore = useFilterStore();
|
const filterStore = useFilterStore();
|
||||||
|
|
||||||
const handleTagClick = () => {
|
const handleTagClick = () => {
|
||||||
if (context.readonly) {
|
if (context.disableFilter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +25,13 @@ const Tag: React.FC<Props> = ({ content }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="cursor-pointer inline-block w-auto text-blue-600 dark:text-blue-400 hover:opacity-80" onClick={handleTagClick}>
|
<span
|
||||||
|
className={classNames(
|
||||||
|
"inline-block w-auto text-blue-600 dark:text-blue-400",
|
||||||
|
context.disableFilter ? "" : "cursor-pointer hover:opacity-80"
|
||||||
|
)}
|
||||||
|
onClick={handleTagClick}
|
||||||
|
>
|
||||||
#{content}
|
#{content}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
@ -9,6 +9,7 @@ interface Props {
|
|||||||
nodes: Node[];
|
nodes: Node[];
|
||||||
memoId?: number;
|
memoId?: number;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
|
disableFilter?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: (e: React.MouseEvent) => void;
|
onClick?: (e: React.MouseEvent) => void;
|
||||||
}
|
}
|
||||||
@ -35,6 +36,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
|
|||||||
nodes,
|
nodes,
|
||||||
memoId,
|
memoId,
|
||||||
readonly: !allowEdit,
|
readonly: !allowEdit,
|
||||||
|
disableFilter: props.disableFilter,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={`w-full flex flex-col justify-start items-start text-gray-800 dark:text-gray-300 ${className || ""}`}>
|
<div className={`w-full flex flex-col justify-start items-start text-gray-800 dark:text-gray-300 ${className || ""}`}>
|
||||||
|
@ -5,6 +5,7 @@ interface Context {
|
|||||||
nodes: Node[];
|
nodes: Node[];
|
||||||
memoId?: number;
|
memoId?: number;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
|
disableFilter?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RendererContext = createContext<Context>({
|
export const RendererContext = createContext<Context>({
|
||||||
|
@ -32,7 +32,7 @@ interface Props {
|
|||||||
memo: Memo;
|
memo: Memo;
|
||||||
showCreator?: boolean;
|
showCreator?: boolean;
|
||||||
showVisibility?: boolean;
|
showVisibility?: boolean;
|
||||||
showPinnedStyle?: boolean;
|
showPinned?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames("group memo-wrapper", "memos-" + memo.id, memo.pinned && props.showPinnedStyle ? "pinned" : "", className)}
|
className={classNames("group memo-wrapper", "memos-" + memo.id, memo.pinned && props.showPinned ? "pinned" : "", className)}
|
||||||
ref={memoContainerRef}
|
ref={memoContainerRef}
|
||||||
>
|
>
|
||||||
<div className="memo-top-wrapper mb-1">
|
<div className="memo-top-wrapper mb-1">
|
||||||
@ -189,7 +189,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
|
|||||||
<span className="text-sm text-gray-400 select-none" onClick={handleGotoMemoDetailPage}>
|
<span className="text-sm text-gray-400 select-none" onClick={handleGotoMemoDetailPage}>
|
||||||
{displayTime}
|
{displayTime}
|
||||||
</span>
|
</span>
|
||||||
{props.showPinnedStyle && memo.pinned && (
|
{props.showPinned && memo.pinned && (
|
||||||
<>
|
<>
|
||||||
<Icon.Dot className="w-4 h-auto text-gray-400 dark:text-zinc-400" />
|
<Icon.Dot className="w-4 h-auto text-gray-400 dark:text-zinc-400" />
|
||||||
<Tooltip title={"Pinned"} placement="top">
|
<Tooltip title={"Pinned"} placement="top">
|
||||||
@ -217,10 +217,12 @@ const MemoView: React.FC<Props> = (props: Props) => {
|
|||||||
</span>
|
</span>
|
||||||
<div className="more-action-btns-wrapper">
|
<div className="more-action-btns-wrapper">
|
||||||
<div className="more-action-btns-container min-w-[6em]">
|
<div className="more-action-btns-container min-w-[6em]">
|
||||||
<span className="btn" onClick={handleTogglePinMemoBtnClick}>
|
{props.showPinned && (
|
||||||
{memo.pinned ? <Icon.BookmarkMinus className="w-4 h-auto mr-2" /> : <Icon.BookmarkPlus className="w-4 h-auto mr-2" />}
|
<span className="btn" onClick={handleTogglePinMemoBtnClick}>
|
||||||
{memo.pinned ? t("common.unpin") : t("common.pin")}
|
{memo.pinned ? <Icon.BookmarkMinus className="w-4 h-auto mr-2" /> : <Icon.BookmarkPlus className="w-4 h-auto mr-2" />}
|
||||||
</span>
|
{memo.pinned ? t("common.unpin") : t("common.pin")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<span className="btn" onClick={handleEditMemoClick}>
|
<span className="btn" onClick={handleEditMemoClick}>
|
||||||
<Icon.Edit3 className="w-4 h-auto mr-2" />
|
<Icon.Edit3 className="w-4 h-auto mr-2" />
|
||||||
{t("common.edit")}
|
{t("common.edit")}
|
||||||
|
@ -112,7 +112,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
|||||||
>
|
>
|
||||||
<span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{getDateTimeString(memo.displayTime)}</span>
|
<span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{getDateTimeString(memo.displayTime)}</span>
|
||||||
<div className="w-full px-6 text-base pb-4">
|
<div className="w-full px-6 text-base pb-4">
|
||||||
<MemoContent memoId={memo.id} nodes={memo.nodes} readonly={true} />
|
<MemoContent memoId={memo.id} nodes={memo.nodes} readonly={true} disableFilter />
|
||||||
<MemoResourceListView resourceList={memo.resources} />
|
<MemoResourceListView resourceList={memo.resources} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6">
|
<div className="flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6">
|
||||||
|
@ -73,7 +73,7 @@ const Home = () => {
|
|||||||
<div className="flex flex-col justify-start items-start w-full max-w-full pb-28">
|
<div className="flex flex-col justify-start items-start w-full max-w-full pb-28">
|
||||||
<MemoFilter className="px-2 pb-2" />
|
<MemoFilter className="px-2 pb-2" />
|
||||||
{sortedMemos.map((memo) => (
|
{sortedMemos.map((memo) => (
|
||||||
<MemoView key={`${memo.id}-${memo.updateTime}`} memo={memo} showVisibility showPinnedStyle />
|
<MemoView key={`${memo.id}-${memo.updateTime}`} memo={memo} showVisibility showPinned />
|
||||||
))}
|
))}
|
||||||
{isRequesting ? (
|
{isRequesting ? (
|
||||||
<div className="flex flex-col justify-start items-center w-full my-4">
|
<div className="flex flex-col justify-start items-center w-full my-4">
|
||||||
|
@ -107,7 +107,7 @@ const UserProfile = () => {
|
|||||||
</div>
|
</div>
|
||||||
<MemoFilter className="px-2 pb-3" />
|
<MemoFilter className="px-2 pb-3" />
|
||||||
{sortedMemos.map((memo) => (
|
{sortedMemos.map((memo) => (
|
||||||
<MemoView key={memo.id} memo={memo} showVisibility showPinnedStyle />
|
<MemoView key={memo.id} memo={memo} showVisibility showPinned />
|
||||||
))}
|
))}
|
||||||
{isRequesting ? (
|
{isRequesting ? (
|
||||||
<div className="flex flex-col justify-start items-center w-full my-4">
|
<div className="flex flex-col justify-start items-center w-full my-4">
|
||||||
|
Reference in New Issue
Block a user