mirror of
https://github.com/usememos/memos.git
synced 2025-02-16 11:21:02 +01:00
feat: export Memos as Markdown FIles (#2716)
This commit is contained in:
parent
cafa7c5adc
commit
43e42079a4
@ -49,11 +49,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
|||||||
pixelRatio: window.devicePixelRatio * 2,
|
pixelRatio: window.devicePixelRatio * 2,
|
||||||
})
|
})
|
||||||
.then((url) => {
|
.then((url) => {
|
||||||
const a = document.createElement("a");
|
downloadFileFromUrl(url, `memos-${getDateTimeString(Date.now())}.png`);
|
||||||
a.href = url;
|
|
||||||
a.download = `memos-${getDateTimeString(Date.now())}.png`;
|
|
||||||
a.click();
|
|
||||||
|
|
||||||
downloadingImageState.setFinish();
|
downloadingImageState.setFinish();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.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 = () => {
|
const handleCopyLinkBtnClick = () => {
|
||||||
copy(`${window.location.origin}/m/${memo.id}`);
|
copy(`${window.location.origin}/m/${memo.id}`);
|
||||||
toast.success(t("message.succeed-copy-link"));
|
toast.success(t("message.succeed-copy-link"));
|
||||||
@ -88,6 +96,10 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
|
|||||||
)}
|
)}
|
||||||
{t("common.image")}
|
{t("common.image")}
|
||||||
</Button>
|
</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}>
|
<Button color="neutral" variant="outlined" onClick={handleCopyLinkBtnClick}>
|
||||||
<Icon.Link className="w-4 h-auto mr-1" />
|
<Icon.Link className="w-4 h-auto mr-1" />
|
||||||
{t("common.link")}
|
{t("common.link")}
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
"fold": "Fold",
|
"fold": "Fold",
|
||||||
"expand": "Expand",
|
"expand": "Expand",
|
||||||
"image": "Image",
|
"image": "Image",
|
||||||
|
"file": "File",
|
||||||
"link": "Link",
|
"link": "Link",
|
||||||
"vacuum": "Vacuum",
|
"vacuum": "Vacuum",
|
||||||
"select": "Select",
|
"select": "Select",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"common": {
|
"common": {
|
||||||
"about": "Acerca de",
|
"about": "Acerca de",
|
||||||
|
"home": "Inicio",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"password": "Contraseña",
|
"password": "Contraseña",
|
||||||
"username": "Usuario",
|
"username": "Usuario",
|
||||||
@ -37,6 +38,7 @@
|
|||||||
"fold": "Plegar",
|
"fold": "Plegar",
|
||||||
"expand": "Expandir",
|
"expand": "Expandir",
|
||||||
"image": "Imagen",
|
"image": "Imagen",
|
||||||
|
"file": "Archivo",
|
||||||
"link": "Enlace",
|
"link": "Enlace",
|
||||||
"vacuum": "Vaciar",
|
"vacuum": "Vaciar",
|
||||||
"select": "Seleccionar",
|
"select": "Seleccionar",
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
"email": "Email",
|
"email": "Email",
|
||||||
"expand": "Agrandir",
|
"expand": "Agrandir",
|
||||||
"explore": "Explorer",
|
"explore": "Explorer",
|
||||||
|
"file": "Fichier",
|
||||||
"filter": "Filtre",
|
"filter": "Filtre",
|
||||||
"filter-period": "{{from}} à {{to}}",
|
"filter-period": "{{from}} à {{to}}",
|
||||||
"fold": "Rétracter",
|
"fold": "Rétracter",
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
"email": "Email",
|
"email": "Email",
|
||||||
"expand": "Espandi",
|
"expand": "Espandi",
|
||||||
"explore": "Esplora",
|
"explore": "Esplora",
|
||||||
|
"file": "File",
|
||||||
"filter": "Filtro",
|
"filter": "Filtro",
|
||||||
"filter-period": "{{from}} a {{to}}",
|
"filter-period": "{{from}} a {{to}}",
|
||||||
"fold": "Riduci",
|
"fold": "Riduci",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user