Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove mark memo #476

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 1 addition & 19 deletions web/src/components/Memo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { memo, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import "dayjs/locale/zh";
import { UNKNOWN_ID } from "../helpers/consts";
import { editorStateService, locationService, memoService, userService } from "../services";
import Icon from "./Icon";
import toastHelper from "./Toast";
Expand Down Expand Up @@ -71,10 +70,6 @@ const Memo: React.FC<Props> = (props: Props) => {
}
};

const handleMarkMemoClick = () => {
editorStateService.setMarkMemoWithId(memo.id);
};

const handleEditMemoClick = () => {
editorStateService.setEditMemoWithId(memo.id);
};
Expand Down Expand Up @@ -102,17 +97,7 @@ const Memo: React.FC<Props> = (props: Props) => {
const handleMemoContentClick = async (e: React.MouseEvent) => {
const targetEl = e.target as HTMLElement;

if (targetEl.className === "memo-link-text") {
const memoId = targetEl.dataset?.value;
const memoTemp = await memoService.getMemoById(Number(memoId) ?? UNKNOWN_ID);

if (memoTemp) {
navigate(`/m/${memoTemp.id}`);
} else {
toastHelper.error(t("message.memo-not-found"));
targetEl.classList.remove("memo-link-text");
}
} else if (targetEl.className === "tag-span") {
if (targetEl.className === "tag-span") {
const tagName = targetEl.innerText.slice(1);
const currTagQuery = locationService.getState().query?.tag;
if (currTagQuery === tagName) {
Expand Down Expand Up @@ -231,9 +216,6 @@ const Memo: React.FC<Props> = (props: Props) => {
<span className="tip-text">{t("common.share")}</span>
</div>
</div>
<span className="btn" onClick={handleMarkMemoClick}>
{t("common.mark")}
</span>
<span className="btn" onClick={handleCopyContent}>
{t("memo.copy")}
</span>
Expand Down
9 changes: 0 additions & 9 deletions web/src/components/MemoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ const MemoEditor = () => {
}
}, []);

useEffect(() => {
if (editorState.markMemoId && editorState.markMemoId !== UNKNOWN_ID) {
const editorCurrentValue = editorRef.current?.getContent();
const memoLinkText = `${editorCurrentValue ? "\n" : ""}Mark: @[MEMO](${editorState.markMemoId})`;
editorRef.current?.insertText(memoLinkText);
editorStateService.clearMarkMemo();
}
}, [editorState.markMemoId]);

useEffect(() => {
if (editorState.editMemoId) {
memoService.getMemoById(editorState.editMemoId ?? UNKNOWN_ID).then((memo) => {
Expand Down
18 changes: 0 additions & 18 deletions web/src/labs/marked/parser/Mark.ts

This file was deleted.

4 changes: 1 addition & 3 deletions web/src/labs/marked/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Paragraph from "./Paragraph";
import Tag from "./Tag";
import Image from "./Image";
import Link from "./Link";
import Mark from "./Mark";
import Bold from "./Bold";
import Emphasis from "./Emphasis";
import PlainLink from "./PlainLink";
Expand All @@ -23,10 +22,9 @@ export { DONE_LIST_REG } from "./DoneList";
export { TAG_REG } from "./Tag";
export { IMAGE_REG } from "./Image";
export { LINK_REG } from "./Link";
export { MARK_REG } from "./Mark";
export { TABLE_REG } from "./Table";

// The order determines the order of execution.
export const blockElementParserList = [Table, CodeBlock, Blockquote, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];
export const inlineElementParserList = [Image, Mark, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Tag, PlainText];
export const inlineElementParserList = [Image, BoldEmphasis, Bold, Emphasis, Link, InlineCode, PlainLink, Tag, PlainText];
export const parserList = [...blockElementParserList, ...inlineElementParserList];
1 change: 0 additions & 1 deletion web/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"delete": "Delete",
"null": "Null",
"share": "Share",
"mark": "Mark",
"archive": "Archive",
"basic": "Basic",
"admin": "Admin",
Expand Down
1 change: 0 additions & 1 deletion web/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"delete": "Xóa",
"null": "Null",
"share": "Chia sẻ",
"mark": "Đánh dấu",
"archive": "Lưu trữ",
"basic": "Cơ bản",
"admin": "Admin",
Expand Down
1 change: 0 additions & 1 deletion web/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"delete": "删除",
"null": "空",
"share": "分享",
"mark": "标注",
"archive": "归档",
"basic": "基础",
"admin": "管理员",
Expand Down
10 changes: 1 addition & 9 deletions web/src/services/editorStateService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import store from "../store";
import { setEditMemoId, setMarkMemoId, setMemoVisibility } from "../store/modules/editor";
import { setEditMemoId, setMemoVisibility } from "../store/modules/editor";

const editorStateService = {
getState: () => {
Expand All @@ -14,14 +14,6 @@ const editorStateService = {
store.dispatch(setEditMemoId());
},

setMarkMemoWithId: (markMemoId: MemoId) => {
store.dispatch(setMarkMemoId(markMemoId));
},

clearMarkMemo: () => {
store.dispatch(setMarkMemoId());
},

setMemoVisibility: (memoVisibility: Visibility) => {
store.dispatch(setMemoVisibility(memoVisibility));
},
Expand Down
9 changes: 1 addition & 8 deletions web/src/store/modules/editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface State {
markMemoId?: MemoId;
editMemoId?: MemoId;
memoVisibility: Visibility;
}
Expand All @@ -10,12 +9,6 @@ const editorSlice = createSlice({
name: "editor",
initialState: {} as State,
reducers: {
setMarkMemoId: (state, action: PayloadAction<Option<MemoId>>) => {
return {
...state,
markMemoId: action.payload,
};
},
setEditMemoId: (state, action: PayloadAction<Option<MemoId>>) => {
return {
...state,
Expand All @@ -31,6 +24,6 @@ const editorSlice = createSlice({
},
});

export const { setEditMemoId, setMarkMemoId, setMemoVisibility } = editorSlice.actions;
export const { setEditMemoId, setMemoVisibility } = editorSlice.actions;

export default editorSlice.reducer;