mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: remove mark memo (#476)
This commit is contained in:
@ -5,7 +5,6 @@ import { memo, useEffect, useRef, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import "dayjs/locale/zh";
|
import "dayjs/locale/zh";
|
||||||
import { UNKNOWN_ID } from "../helpers/consts";
|
|
||||||
import { editorStateService, locationService, memoService, userService } from "../services";
|
import { editorStateService, locationService, memoService, userService } from "../services";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
import toastHelper from "./Toast";
|
import toastHelper from "./Toast";
|
||||||
@ -71,10 +70,6 @@ const Memo: React.FC<Props> = (props: Props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMarkMemoClick = () => {
|
|
||||||
editorStateService.setMarkMemoWithId(memo.id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEditMemoClick = () => {
|
const handleEditMemoClick = () => {
|
||||||
editorStateService.setEditMemoWithId(memo.id);
|
editorStateService.setEditMemoWithId(memo.id);
|
||||||
};
|
};
|
||||||
@ -102,17 +97,7 @@ const Memo: React.FC<Props> = (props: Props) => {
|
|||||||
const handleMemoContentClick = async (e: React.MouseEvent) => {
|
const handleMemoContentClick = async (e: React.MouseEvent) => {
|
||||||
const targetEl = e.target as HTMLElement;
|
const targetEl = e.target as HTMLElement;
|
||||||
|
|
||||||
if (targetEl.className === "memo-link-text") {
|
if (targetEl.className === "tag-span") {
|
||||||
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") {
|
|
||||||
const tagName = targetEl.innerText.slice(1);
|
const tagName = targetEl.innerText.slice(1);
|
||||||
const currTagQuery = locationService.getState().query?.tag;
|
const currTagQuery = locationService.getState().query?.tag;
|
||||||
if (currTagQuery === tagName) {
|
if (currTagQuery === tagName) {
|
||||||
@ -231,9 +216,6 @@ const Memo: React.FC<Props> = (props: Props) => {
|
|||||||
<span className="tip-text">{t("common.share")}</span>
|
<span className="tip-text">{t("common.share")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span className="btn" onClick={handleMarkMemoClick}>
|
|
||||||
{t("common.mark")}
|
|
||||||
</span>
|
|
||||||
<span className="btn" onClick={handleCopyContent}>
|
<span className="btn" onClick={handleCopyContent}>
|
||||||
{t("memo.copy")}
|
{t("memo.copy")}
|
||||||
</span>
|
</span>
|
||||||
|
@ -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(() => {
|
useEffect(() => {
|
||||||
if (editorState.editMemoId) {
|
if (editorState.editMemoId) {
|
||||||
memoService.getMemoById(editorState.editMemoId ?? UNKNOWN_ID).then((memo) => {
|
memoService.getMemoById(editorState.editMemoId ?? UNKNOWN_ID).then((memo) => {
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import { escape } from "lodash-es";
|
|
||||||
|
|
||||||
export const MARK_REG = /@\[(.+?)\]\((\S+?)\)/;
|
|
||||||
|
|
||||||
const renderer = (rawStr: string): string => {
|
|
||||||
const matchResult = rawStr.match(MARK_REG);
|
|
||||||
if (!matchResult) {
|
|
||||||
return rawStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `<span class='memo-link-text' data-value='${escape(matchResult[2])}'>${escape(matchResult[1])}</span>`;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "mark",
|
|
||||||
regex: MARK_REG,
|
|
||||||
renderer,
|
|
||||||
};
|
|
@ -7,7 +7,6 @@ import Paragraph from "./Paragraph";
|
|||||||
import Tag from "./Tag";
|
import Tag from "./Tag";
|
||||||
import Image from "./Image";
|
import Image from "./Image";
|
||||||
import Link from "./Link";
|
import Link from "./Link";
|
||||||
import Mark from "./Mark";
|
|
||||||
import Bold from "./Bold";
|
import Bold from "./Bold";
|
||||||
import Emphasis from "./Emphasis";
|
import Emphasis from "./Emphasis";
|
||||||
import PlainLink from "./PlainLink";
|
import PlainLink from "./PlainLink";
|
||||||
@ -23,10 +22,9 @@ export { DONE_LIST_REG } from "./DoneList";
|
|||||||
export { TAG_REG } from "./Tag";
|
export { TAG_REG } from "./Tag";
|
||||||
export { IMAGE_REG } from "./Image";
|
export { IMAGE_REG } from "./Image";
|
||||||
export { LINK_REG } from "./Link";
|
export { LINK_REG } from "./Link";
|
||||||
export { MARK_REG } from "./Mark";
|
|
||||||
export { TABLE_REG } from "./Table";
|
export { TABLE_REG } from "./Table";
|
||||||
|
|
||||||
// The order determines the order of execution.
|
// The order determines the order of execution.
|
||||||
export const blockElementParserList = [Table, CodeBlock, Blockquote, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];
|
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];
|
export const parserList = [...blockElementParserList, ...inlineElementParserList];
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"null": "Null",
|
"null": "Null",
|
||||||
"share": "Share",
|
"share": "Share",
|
||||||
"mark": "Mark",
|
|
||||||
"archive": "Archive",
|
"archive": "Archive",
|
||||||
"basic": "Basic",
|
"basic": "Basic",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"delete": "Xóa",
|
"delete": "Xóa",
|
||||||
"null": "Null",
|
"null": "Null",
|
||||||
"share": "Chia sẻ",
|
"share": "Chia sẻ",
|
||||||
"mark": "Đánh dấu",
|
|
||||||
"archive": "Lưu trữ",
|
"archive": "Lưu trữ",
|
||||||
"basic": "Cơ bản",
|
"basic": "Cơ bản",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
"null": "空",
|
"null": "空",
|
||||||
"share": "分享",
|
"share": "分享",
|
||||||
"mark": "标注",
|
|
||||||
"archive": "归档",
|
"archive": "归档",
|
||||||
"basic": "基础",
|
"basic": "基础",
|
||||||
"admin": "管理员",
|
"admin": "管理员",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import store from "../store";
|
import store from "../store";
|
||||||
import { setEditMemoId, setMarkMemoId, setMemoVisibility } from "../store/modules/editor";
|
import { setEditMemoId, setMemoVisibility } from "../store/modules/editor";
|
||||||
|
|
||||||
const editorStateService = {
|
const editorStateService = {
|
||||||
getState: () => {
|
getState: () => {
|
||||||
@ -14,14 +14,6 @@ const editorStateService = {
|
|||||||
store.dispatch(setEditMemoId());
|
store.dispatch(setEditMemoId());
|
||||||
},
|
},
|
||||||
|
|
||||||
setMarkMemoWithId: (markMemoId: MemoId) => {
|
|
||||||
store.dispatch(setMarkMemoId(markMemoId));
|
|
||||||
},
|
|
||||||
|
|
||||||
clearMarkMemo: () => {
|
|
||||||
store.dispatch(setMarkMemoId());
|
|
||||||
},
|
|
||||||
|
|
||||||
setMemoVisibility: (memoVisibility: Visibility) => {
|
setMemoVisibility: (memoVisibility: Visibility) => {
|
||||||
store.dispatch(setMemoVisibility(memoVisibility));
|
store.dispatch(setMemoVisibility(memoVisibility));
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
markMemoId?: MemoId;
|
|
||||||
editMemoId?: MemoId;
|
editMemoId?: MemoId;
|
||||||
memoVisibility: Visibility;
|
memoVisibility: Visibility;
|
||||||
}
|
}
|
||||||
@ -10,12 +9,6 @@ const editorSlice = createSlice({
|
|||||||
name: "editor",
|
name: "editor",
|
||||||
initialState: {} as State,
|
initialState: {} as State,
|
||||||
reducers: {
|
reducers: {
|
||||||
setMarkMemoId: (state, action: PayloadAction<Option<MemoId>>) => {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
markMemoId: action.payload,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
setEditMemoId: (state, action: PayloadAction<Option<MemoId>>) => {
|
setEditMemoId: (state, action: PayloadAction<Option<MemoId>>) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -31,6 +24,6 @@ const editorSlice = createSlice({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setEditMemoId, setMarkMemoId, setMemoVisibility } = editorSlice.actions;
|
export const { setEditMemoId, setMemoVisibility } = editorSlice.actions;
|
||||||
|
|
||||||
export default editorSlice.reducer;
|
export default editorSlice.reducer;
|
||||||
|
Reference in New Issue
Block a user