mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
editor: enable previewing attachments on desktop/web
This commit is contained in:
committed by
Abdullah Atta
parent
2c9f5df530
commit
09098410a5
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -206,6 +206,7 @@ export function ImageComponent(
|
||||
<ToolbarGroup
|
||||
editor={editor}
|
||||
tools={[
|
||||
hash ? "previewAttachment" : "none",
|
||||
hash ? "downloadAttachment" : "none",
|
||||
"imageAlignLeft",
|
||||
float ? "none" : "imageAlignCenter",
|
||||
|
||||
@@ -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);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user