Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: add download button on images (#1563)

Muhammad Alifc634f15bb1f
diff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsx
index 43a125c2c..1d25336c3 100644
--- a/packages/editor/src/extensions/image/component.tsx
+++ b/packages/editor/src/extensions/image/component.tsx
@@ -178,11 +178,13 @@ export function ImageComponent(
tools={
float
? [
+ "downloadAttachment",
"imageAlignLeft",
"imageAlignRight",
"imageProperties"
]
: [
+ "downloadAttachment",
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
diff --git a/packages/editor/src/toolbar/tools/attachment.tsx b/packages/editor/src/toolbar/tools/attachment.tsx
index 325943c2d..a480645d7 100644
--- a/packages/editor/src/toolbar/tools/attachment.tsx
+++ b/packages/editor/src/toolbar/tools/attachment.tsx
@@ -47,7 +47,10 @@ export function DownloadAttachment(props: ToolProps) {
{...props}
toggled={false}
onClick={() => {
- const attachmentNode = findSelectedNode(editor, "attachment");
+ const attachmentNode =
+ findSelectedNode(editor, "attachment") ||
+ findSelectedNode(editor, "image");
+
const attachment = (attachmentNode?.attrs || {}) as Attachment;
editor.current?.chain().focus().downloadAttachment(attachment).run();
}}