diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
index 4f69ef090..a28e4d98a 100644
--- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
+++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
@@ -1,4 +1,6 @@
+import copy from "copy-to-clipboard";
import { useContext, useEffect } from "react";
+import toast from "react-hot-toast";
import { Link } from "react-router-dom";
import Icon from "@/components/Icon";
import MemoResourceListView from "@/components/MemoResourceListView";
@@ -30,45 +32,56 @@ const EmbeddedMemo = ({ resourceId: uid, params: paramsStr }: Props) => {
if (!memo) {
return ;
}
- if (memo.name === context.memoName || context.embeddedMemos.has(resourceName)) {
+
+ const params = new URLSearchParams(paramsStr);
+ const useSnippet = params.has("snippet");
+ const inlineMode = params.has("inline");
+ if (!useSnippet && (memo.name === context.memoName || context.embeddedMemos.has(resourceName))) {
return ;
}
// Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
context.embeddedMemos.add(resourceName);
- const params = new URLSearchParams(paramsStr);
- const inlineMode = params.has("inline");
+ const contentNode = useSnippet ? (
+
{memo.snippet}
+ ) : (
+
+ );
if (inlineMode) {
return (
-
+ {contentNode}
);
}
+ const copyMemoUid = (uid: string) => {
+ copy(uid);
+ toast.success("Copied memo UID to clipboard");
+ };
+
return (
-
-
-
+
+ copyMemoUid(memo.uid)}>
+ {memo.uid.slice(0, 8)}
+
+
+
+
+
-
+ {contentNode}
);
diff --git a/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx b/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx
index 5d14c9eb2..8534ebdbd 100644
--- a/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx
+++ b/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx
@@ -28,7 +28,7 @@ const ReferencedMemo = ({ resourceId: uid, params: paramsStr }: Props) => {
}
const paramsText = params.has("text") ? params.get("text") : undefined;
- const displayContent = paramsText || (memo.content.length > 12 ? `${memo.content.slice(0, 12)}...` : memo.content);
+ const displayContent = paramsText || (memo.snippet.length > 12 ? `${memo.snippet.slice(0, 12)}...` : memo.snippet);
const handleGotoMemoDetailPage = () => {
navigateTo(`/m/${memo.uid}`);
diff --git a/web/src/components/MemoEditor/RelationListView.tsx b/web/src/components/MemoEditor/RelationListView.tsx
index 1033715b8..b57fdbc63 100644
--- a/web/src/components/MemoEditor/RelationListView.tsx
+++ b/web/src/components/MemoEditor/RelationListView.tsx
@@ -42,7 +42,7 @@ const RelationListView = (props: Props) => {
onClick={() => handleDeleteRelation(memo)}
>
- {memo.content}
+ {memo.snippet}
);
diff --git a/web/src/components/MemoRelationListView.tsx b/web/src/components/MemoRelationListView.tsx
index 87c76b77a..7ad6b60eb 100644
--- a/web/src/components/MemoRelationListView.tsx
+++ b/web/src/components/MemoRelationListView.tsx
@@ -1,10 +1,8 @@
-import { Tooltip } from "@mui/joy";
import { memo, useEffect, useState } from "react";
-import { Link } from "react-router-dom";
import { useMemoStore } from "@/store/v1";
import { MemoRelation } from "@/types/proto/api/v1/memo_relation_service";
import { Memo } from "@/types/proto/api/v1/memo_service";
-import Icon from "./Icon";
+import EmbeddedContent from "./MemoContent/EmbeddedContent";
interface Props {
memo: Memo;
@@ -15,7 +13,6 @@ const MemoRelationListView = (props: Props) => {
const { memo, relations: relationList } = props;
const memoStore = useMemoStore();
const [referencingMemoList, setReferencingMemoList] = useState([]);
- const [referencedMemoList, setReferencedMemoList] = useState([]);
useEffect(() => {
(async () => {
@@ -25,58 +22,17 @@ const MemoRelationListView = (props: Props) => {
.map((relation) => memoStore.getOrFetchMemoByName(relation.relatedMemo, { skipStore: true })),
);
setReferencingMemoList(referencingMemoList);
- const referencedMemoList = await Promise.all(
- relationList
- .filter((relation) => relation.memo !== memo.name && relation.relatedMemo === memo.name)
- .map((relation) => memoStore.getOrFetchMemoByName(relation.memo, { skipStore: true })),
- );
- setReferencedMemoList(referencedMemoList);
})();
}, [memo, relationList]);
return (
- <>
- {referencingMemoList.length > 0 && (
-
- {referencingMemoList.map((memo) => {
- return (
-
-
-
-
-
- {memo.content}
-
-
- );
- })}
-
- )}
- {referencedMemoList.length > 0 && (
-
- {referencedMemoList.map((memo) => {
- return (
-
-
-
-
-
- {memo.content}
-
-
- );
- })}
-
- )}
- >
+ referencingMemoList.length > 0 && (
+
+ {referencingMemoList.map((memo) => {
+ return ;
+ })}
+
+ )
);
};