mirror of
https://github.com/usememos/memos.git
synced 2024-12-26 23:22:47 +08:00
feat: export Memos as Markdown FIles (#2716)
This commit is contained in:
parent
cafa7c5adc
commit
43e42079a4
5 changed files with 22 additions and 5 deletions
|
@ -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")}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
"fold": "Fold",
|
||||
"expand": "Expand",
|
||||
"image": "Image",
|
||||
"file": "File",
|
||||
"link": "Link",
|
||||
"vacuum": "Vacuum",
|
||||
"select": "Select",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"common": {
|
||||
"about": "Acerca de",
|
||||
"home": "Inicio",
|
||||
"email": "Email",
|
||||
"password": "Contraseña",
|
||||
"username": "Usuario",
|
||||
|
@ -37,6 +38,7 @@
|
|||
"fold": "Plegar",
|
||||
"expand": "Expandir",
|
||||
"image": "Imagen",
|
||||
"file": "Archivo",
|
||||
"link": "Enlace",
|
||||
"vacuum": "Vaciar",
|
||||
"select": "Seleccionar",
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
"email": "Email",
|
||||
"expand": "Agrandir",
|
||||
"explore": "Explorer",
|
||||
"file": "Fichier",
|
||||
"filter": "Filtre",
|
||||
"filter-period": "{{from}} à {{to}}",
|
||||
"fold": "Rétracter",
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"email": "Email",
|
||||
"expand": "Espandi",
|
||||
"explore": "Esplora",
|
||||
"file": "File",
|
||||
"filter": "Filtro",
|
||||
"filter-period": "{{from}} a {{to}}",
|
||||
"fold": "Riduci",
|
||||
|
|
Loading…
Reference in a new issue