Skip to content

Build your personal knowledge base with Trilium Notes

client/image compression tool: integrate into the note menu

Adorian Dorana43b75528eb3
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4b5b2720e7..537cfcb45a 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1117,6 +1117,7 @@
"convert_format_warning_risky": "You are converting between two formats that don't have identical capabilities, so some formatting may be lost and some unsupported elements may be dropped.<br><br>Do you fully assume this risk and want to proceed with the conversion?<br><br>A revision of the current note will be saved beforehand, so you can revert to the original format.",
"convert_to_markdown_successful": "Note has been converted to Markdown.",
"convert_to_text_successful": "Note has been converted to a text note.",
+ "compress_images": "Compress images",
"print_pdf": "Export as PDF...",
"export_as_image": "Export as image",
"export_as_image_png": "PNG (raster)",
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index 4b50eb2efa..7f0ec362d4 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -27,6 +27,7 @@ import Dropdown from "../react/Dropdown";
import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem, FormListToggleableItem } from "../react/FormList";
import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteLabelOptionalBool, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks";
import { ParentComponent } from "../react/react_utils";
+import { showImageCompressionDialog } from "../type_widgets/options/content_manager/space_usage/image_compression_dialog";
import { NoteTypeDropdownContent, useNoteBookmarkState, useShareState } from "./BasicPropertiesTab";
import NoteActionsCustom from "./NoteActionsCustom";
@@ -193,6 +194,11 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
<CommandItem command="showNoteSource" icon="bx bx-code" disabled={!hasSource} text={t("note_actions.note_source")} />
{(note.type === "text" || note.isMarkdown()) && isContentAvailable && !isInOptionsOrHelp &&
<ConvertNoteFormat note={note} />}
+ {/* Always the note-level dialog, an image note included: it has children of its
+ own, and reaching them is what makes this "images" and not "image". */}
+ <CommandItem icon="bx bx-collapse-alt" text={t("note_actions.compress_images")}
+ disabled={isInOptionsOrHelp}
+ command={() => void showImageCompressionDialog({ type: "note", noteId: note.noteId })} />
<CommandItem command="showNoteOCRText" icon="bx bx-text" disabled={!["image", "file"].includes(noteType)} text={t("note_actions.view_ocr_text")} />
{(syncServerHost && isElectron) &&
<CommandItem command="openNoteOnServer" icon="bx bx-world" disabled={!syncServerHost} text={t("note_actions.open_note_on_server")} />