Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
61b8cee3
Commit
61b8cee3
authored
Aug 07, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: retire preview markdown dialog
parent
4ad60286
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
75 deletions
+0
-75
MarkdownMenu.tsx
web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
+0
-16
PreviewMarkdownDialog.tsx
web/src/components/PreviewMarkdownDialog.tsx
+0
-59
No files found.
web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
View file @
61b8cee3
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
...
...
web/src/components/PreviewMarkdownDialog.tsx
deleted
100644 → 0
View file @
4ad60286
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
,
},
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment