mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: export Memos as Markdown FIles (#2716)
This commit is contained in:
@ -49,11 +49,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
||||
pixelRatio: window.devicePixelRatio * 2,
|
||||
})
|
||||
.then((url) => {
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `memos-${getDateTimeString(Date.now())}.png`;
|
||||
a.click();
|
||||
|
||||
downloadFileFromUrl(url, `memos-${getDateTimeString(Date.now())}.png`);
|
||||
downloadingImageState.setFinish();
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -61,6 +57,18 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleDownloadTextFileBtnClick = () => {
|
||||
const blob = new Blob([memo.content], { type: "text/plain;charset=utf-8" });
|
||||
downloadFileFromUrl(URL.createObjectURL(blob), `memos-${getDateTimeString(Date.now())}.md`);
|
||||
};
|
||||
|
||||
const downloadFileFromUrl = (url: string, filename: string) => {
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
};
|
||||
|
||||
const handleCopyLinkBtnClick = () => {
|
||||
copy(`${window.location.origin}/m/${memo.id}`);
|
||||
toast.success(t("message.succeed-copy-link"));
|
||||
@ -88,6 +96,10 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
||||
)}
|
||||
{t("common.image")}
|
||||
</Button>
|
||||
<Button color="neutral" variant="outlined" onClick={handleDownloadTextFileBtnClick}>
|
||||
<Icon.File className="w-4 h-auto mr-1" />
|
||||
{t("common.file")}
|
||||
</Button>
|
||||
<Button color="neutral" variant="outlined" onClick={handleCopyLinkBtnClick}>
|
||||
<Icon.Link className="w-4 h-auto mr-1" />
|
||||
{t("common.link")}
|
||||
|
Reference in New Issue
Block a user