|
|
|
@ -6,6 +6,7 @@ import useLocalStorage from "react-use/lib/useLocalStorage";
|
|
|
|
|
import { memoServiceClient } from "@/grpcweb";
|
|
|
|
|
import { TAB_SPACE_WIDTH, UNKNOWN_ID } from "@/helpers/consts";
|
|
|
|
|
import { isValidUrl } from "@/helpers/utils";
|
|
|
|
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
|
|
|
|
import { useGlobalStore, useResourceStore, useTagStore } from "@/store/module";
|
|
|
|
|
import { useMemoStore, useUserStore } from "@/store/v1";
|
|
|
|
|
import { MemoRelation, MemoRelation_Type } from "@/types/proto/api/v2/memo_relation_service";
|
|
|
|
@ -50,8 +51,6 @@ const MemoEditor = (props: Props) => {
|
|
|
|
|
const { className, editorClassName, cacheKey, memoId, parentMemoId, autoFocus, onConfirm } = props;
|
|
|
|
|
const { i18n } = useTranslation();
|
|
|
|
|
const t = useTranslate();
|
|
|
|
|
const contentCacheKey = `memo-editor-${cacheKey}`;
|
|
|
|
|
const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
|
|
|
|
|
const {
|
|
|
|
|
state: { systemStatus },
|
|
|
|
|
} = useGlobalStore();
|
|
|
|
@ -59,6 +58,7 @@ const MemoEditor = (props: Props) => {
|
|
|
|
|
const memoStore = useMemoStore();
|
|
|
|
|
const resourceStore = useResourceStore();
|
|
|
|
|
const tagStore = useTagStore();
|
|
|
|
|
const currentUser = useCurrentUser();
|
|
|
|
|
const [state, setState] = useState<State>({
|
|
|
|
|
memoVisibility: Visibility.PRIVATE,
|
|
|
|
|
resourceList: [],
|
|
|
|
@ -69,6 +69,8 @@ const MemoEditor = (props: Props) => {
|
|
|
|
|
const [hasContent, setHasContent] = useState<boolean>(false);
|
|
|
|
|
const editorRef = useRef<EditorRefActions>(null);
|
|
|
|
|
const userSetting = userStore.userSetting as UserSetting;
|
|
|
|
|
const contentCacheKey = `${currentUser.name}-${cacheKey || ""}`;
|
|
|
|
|
const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
|
|
|
|
|
const referenceRelations = memoId
|
|
|
|
|
? state.relationList.filter(
|
|
|
|
|
(relation) => relation.memoId === memoId && relation.relatedMemoId !== memoId && relation.type === MemoRelation_Type.REFERENCE,
|
|
|
|
|