feat: Add option to replace existing file attachment in editor

This commit is contained in:
Tom Moor
2024-01-21 11:52:20 -05:00
parent cbb00c4871
commit 4ddb5c3eed
8 changed files with 157 additions and 39 deletions

View File

@@ -0,0 +1,34 @@
import { TrashIcon, DownloadIcon, ReplaceIcon } from "outline-icons";
import { EditorState } from "prosemirror-state";
import * as React from "react";
import { MenuItem } from "@shared/editor/types";
import { Dictionary } from "~/hooks/useDictionary";
export default function attachmentMenuItems(
state: EditorState,
dictionary: Dictionary
): MenuItem[] {
return [
{
name: "replaceAttachment",
tooltip: dictionary.replaceAttachment,
icon: <ReplaceIcon />,
visible: true,
},
{
name: "deleteAttachment",
tooltip: dictionary.deleteAttachment,
icon: <TrashIcon />,
visible: true,
},
{
name: "separator",
},
{
name: "downloadAttachment",
label: dictionary.download,
icon: <DownloadIcon />,
visible: !!fetch,
},
];
}