Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: retire preview markdown dialog

Steven61b8cee31d9a
diff --git a/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx b/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
index 479d3eab6..b6612d807 100644
--- a/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
+++ b/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
@@ -1,8 +1,6 @@
import { Dropdown, IconButton, Menu, MenuButton, MenuItem } from "@mui/joy";
import { Link } from "@mui/joy";
-import toast from "react-hot-toast";
import Icon from "@/components/Icon";
-import showPreviewMarkdownDialog from "@/components/PreviewMarkdownDialog";
import { EditorRefActions } from "../Editor";
interface Props {
@@ -59,16 +57,6 @@ const MarkdownMenu = (props: Props) => {
});
};
- const handlePreviewClick = () => {
- const content = editorRef.current?.getContent() ?? "";
- if (content === "") {
- toast.error("Nothing to preview");
- return;
- }
-
- showPreviewMarkdownDialog(editorRef.current?.getContent() ?? "");
- };
-
return (
<Dropdown>
<MenuButton
@@ -90,10 +78,6 @@ const MarkdownMenu = (props: Props) => {
<Icon.CheckSquare className="w-4 h-auto" />
<span>Checkbox</span>
</MenuItem>
- <MenuItem onClick={handlePreviewClick}>
- <Icon.GanttChartSquare className="w-4 h-auto" />
- <span>Preview</span>
- </MenuItem>
<div className="-mt-0.5 pl-2">
<Link fontSize={12} href="https://www.usememos.com/docs/getting-started/content-syntax" target="_blank">
Content syntax
diff --git a/web/src/components/PreviewMarkdownDialog.tsx b/web/src/components/PreviewMarkdownDialog.tsx
deleted file mode 100644
index e2aa56725..000000000
--- a/web/src/components/PreviewMarkdownDialog.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { IconButton } from "@mui/joy";
-import { useEffect, useState } from "react";
-import { markdownServiceClient } from "@/grpcweb";
-import { Node } from "@/types/proto/api/v1/markdown_service";
-import { generateDialog } from "./Dialog";
-import Icon from "./Icon";
-import MemoContent from "./MemoContent";
-
-interface Props extends DialogProps {
- content: string;
-}
-
-const PreviewMarkdownDialog: React.FC<Props> = ({ content, destroy }: Props) => {
- const [nodes, setNodes] = useState<Node[]>([]);
-
- useEffect(() => {
- (async () => {
- try {
- const { nodes } = await markdownServiceClient.parseMarkdown({ markdown: content });
- setNodes(nodes);
- } catch (error) {
- console.error("Error parsing markdown:", error);
- }
- })();
- }, [content]);
-
- const handleCloseBtnClick = () => {
- destroy();
- };
-
- return (
- <>
- <div className="dialog-header-container">
- <div className="flex flex-row justify-start items-center">
- <p className="text-black opacity-80 dark:text-gray-200">Preview</p>
- </div>
- <IconButton size="sm" onClick={handleCloseBtnClick}>
- <Icon.X className="w-5 h-auto" />
- </IconButton>
- </div>
- <div className="flex flex-col justify-start items-start max-w-full w-[32rem]">
- {nodes.length > 0 ? <MemoContent nodes={nodes} /> : <p className="text-gray-400 dark:text-gray-600">Nothing to preview</p>}
- </div>
- </>
- );
-};
-
-export default function showPreviewMarkdownDialog(content: string): void {
- generateDialog(
- {
- className: "preview-markdown-dialog",
- dialogName: "preview-markdown-dialog",
- },
- PreviewMarkdownDialog,
- {
- content,
- },
- );
-}