editor: enable previewing attachments on desktop/web

This commit is contained in:
Abdullah Atta
2023-04-15 16:32:55 +05:00
committed by Abdullah Atta
parent 2c9f5df530
commit 09098410a5
3 changed files with 4 additions and 4 deletions

View File

@@ -166,6 +166,7 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
previewAttachment:
(attachment) =>
({ editor }) => {
if (!this.options.onPreviewAttachment) return false;
return this.options.onPreviewAttachment(editor, attachment);
}
};

View File

@@ -206,6 +206,7 @@ export function ImageComponent(
<ToolbarGroup
editor={editor}
tools={[
hash ? "previewAttachment" : "none",
hash ? "downloadAttachment" : "none",
"imageAlignLeft",
float ? "none" : "imageAlignCenter",

View File

@@ -64,9 +64,7 @@ export function DownloadAttachment(props: ToolProps) {
export function PreviewAttachment(props: ToolProps) {
const { editor } = props;
const isBottom = useToolbarLocation() === "bottom";
if (!editor.isActive("image") || !isBottom) return null;
if (!editor.isActive("image")) return null;
return (
<ToolButton
@@ -78,7 +76,7 @@ export function PreviewAttachment(props: ToolProps) {
findSelectedNode(editor, "image");
const attachment = (attachmentNode?.attrs || {}) as Attachment;
editor.current?.chain().focus().previewAttachment(attachment).run();
editor.current?.commands.previewAttachment(attachment);
}}
/>
);