web: update memo editor and about me

This commit is contained in:
steven
2021-12-09 10:23:20 +08:00
parent 06bffd0ba5
commit b8c01524c5
8 changed files with 83 additions and 93 deletions

View File

@ -16,26 +16,27 @@ const MemoEditor: React.FC<Props> = (props: Props) => {
const { className, editMemoId } = props;
const { globalState } = useContext(appContext);
const editorRef = useRef<EditorRefActions>(null);
const prevGlobalStateRef = useRef(globalState);
useEffect(() => {
if (globalState.markMemoId) {
const editorCurrentValue = editorRef.current?.getContent();
const memoLinkText = `${editorCurrentValue ? "\n" : ""}Mark: [@MEMO](${globalState.markMemoId})`;
editorRef.current?.insertText(memoLinkText);
globalStateService.setMarkMemoId("");
if (editMemoId === globalState.editMemoId || (!editMemoId && !globalState.editMemoId)) {
const editorCurrentValue = editorRef.current?.getContent();
const memoLinkText = `${editorCurrentValue ? "\n" : ""}Mark: [@MEMO](${globalState.markMemoId})`;
editorRef.current?.insertText(memoLinkText);
globalStateService.setMarkMemoId("");
}
}
}, [globalState.markMemoId]);
if (editMemoId && globalState.editMemoId) {
const editMemo = memoService.getMemoById(globalState.editMemoId);
useEffect(() => {
if (editMemoId) {
const editMemo = memoService.getMemoById(editMemoId);
if (editMemo) {
editorRef.current?.setContent(editMemo.content ?? "");
editorRef.current?.focus();
}
}
prevGlobalStateRef.current = globalState;
}, [globalState.markMemoId, globalState.editMemoId]);
}, [editMemoId]);
const handleSaveBtnClick = useCallback(async (content: string) => {
if (content === "") {