Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(client): remove the ribbon's image properties tab
Elian Doran4acebd86bfc7
diff --git a/apps/client/src/stylesheets/theme-next/ribbon.css b/apps/client/src/stylesheets/theme-next/ribbon.cssindex 905891d486..c46c5da75d 100644--- a/apps/client/src/stylesheets/theme-next/ribbon.css+++ b/apps/client/src/stylesheets/theme-next/ribbon.css@@ -37,33 +37,6 @@ div.promoted-attributes-container {margin-inline-start: 12px;}-/*- * Image Properties- */-- /* The property label */-.image-properties > div:first-child > span > strong {- opacity: 0.65;- font-weight: 500;- vertical-align: top;-}--/* The button bar */-.image-properties > div:last-of-type {- padding: 0;- margin: 0;- justify-content: flex-start !important;- flex-wrap: wrap;- gap: 12px;-}--/* The properties row for images */-.image-properties > div:first-child {- justify-content: flex-start !important;- flex-wrap: wrap;- gap: 10px 40px;-}-/** Owned attributes*/diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 35af67769f..6b087ac8a4 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1322,16 +1322,10 @@"upload_failed": "Upload of a new file revision failed."},"image_properties": {- "original_file_name": "Original file name",- "file_type": "File type",- "file_size": "File size",- "download": "Download",- "open": "Open","copy_reference_to_clipboard": "Copy reference to clipboard","upload_new_revision": "Upload new revision","upload_success": "New image revision has been uploaded.",- "upload_failed": "Upload of a new image revision failed: {{message}}",- "title": "Image"+ "upload_failed": "Upload of a new image revision failed: {{message}}"},"inherited_attribute_list": {"title": "Inherited Attributes",diff --git a/apps/client/src/widgets/ribbon/ImagePropertiesTab.tsx b/apps/client/src/widgets/ribbon/ImagePropertiesTab.tsxdeleted file mode 100644index 8f9b021a75..0000000000--- a/apps/client/src/widgets/ribbon/ImagePropertiesTab.tsx+++ /dev/null@@ -1,95 +0,0 @@-import { useContext } from "preact/hooks";--import FNote from "../../entities/fnote";-import { t } from "../../services/i18n";-import { downloadFileNote, openNoteExternally } from "../../services/open";-import server from "../../services/server";-import toast from "../../services/toast";-import { clearBrowserCache, formatSize } from "../../services/utils";-import { showImageCompressionDialog } from "../dialogs/image_compression/image_compression_dialog";-import Button from "../react/Button";-import { FormFileUploadButton } from "../react/FormFileUpload";-import { useNoteBlob, useNoteLabel } from "../react/hooks";-import { ParentComponent } from "../react/react_utils";-import { TabContext } from "./ribbon-interface";--export default function ImagePropertiesTab({ note, ntxId }: TabContext) {- const [ originalFileName ] = useNoteLabel(note, "originalFileName");- const blob = useNoteBlob(note);-- const parentComponent = useContext(ParentComponent);-- return (- <div className="image-properties">- {note && (- <>- <div style={{ display: "flex", justifyContent: "space-evenly", margin: "10px" }}>- <span>- <strong>{t("image_properties.original_file_name")}:</strong>{" "}- <span className="selectable-text">{originalFileName ?? "?"}</span>- </span>-- <span>- <strong>{t("image_properties.file_type")}:</strong>{" "}- <span className="selectable-text">{note.mime}</span>- </span>-- <span>- <strong>{t("image_properties.file_size")}:</strong>{" "}- <span className="selectable-text">{formatSize(blob?.contentLength)}</span>- </span>- </div>-- <div style={{ display: "flex", justifyContent: "space-evenly", margin: "10px" }}>- <Button- text={t("image_properties.download")}- icon="bx bx-download"- kind="primary"- onClick={() => downloadFileNote(note, parentComponent, ntxId)}- />-- <Button- text={t("image_properties.open")}- icon="bx bx-link-external"- onClick={() => openNoteExternally(note.noteId, note.mime)}- />-- <Button- text={t("compress-image")}- icon="bx bx-collapse-alt"- onClick={() => void showImageCompressionDialog({ type: "note", noteId: note.noteId, mime: note.mime })}- />-- <Button- text={t("image_properties.copy_reference_to_clipboard")}- icon="bx bx-copy"- onClick={() => parentComponent?.triggerEvent("copyImageReferenceToClipboard", { ntxId })}- />-- <FormFileUploadButton- text={t("image_properties.upload_new_revision")}- icon="bx bx-folder-open"- onChange={buildUploadNewImageRevisionListener(note)}- />- </div>- </>- )}- </div>- );-}--export function buildUploadNewImageRevisionListener(note: FNote) {- return async (files: FileList | null) => {- if (!files) return;- const fileToUpload = files[0]; // copy to allow reset below-- const result = await server.upload(`images/${note.noteId}`, fileToUpload);-- if (result.uploaded) {- toast.showMessage(t("image_properties.upload_success"));- await clearBrowserCache();- } else {- toast.showError(t("image_properties.upload_failed", { message: result.message }));- }- };-}diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsxindex e343e0cdd2..db4684ca00 100644--- a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx@@ -12,7 +12,7 @@ import { getHelpUrlForNote } from "../../services/in_app_help";import { downloadFileNote, openNoteExternally } from "../../services/open";import server from "../../services/server";import toast from "../../services/toast";-import { createImageSrcUrl, isMobile, openInAppHelpFromUrl } from "../../services/utils";+import { clearBrowserCache, createImageSrcUrl, isMobile, openInAppHelpFromUrl } from "../../services/utils";import { ViewTypeOptions } from "../collections/interface";import { buildSaveSqlToNoteHandler } from "../FloatingButtonsDefinitions";import { showImageCompressionDialog } from "../dialogs/image_compression/image_compression_dialog";@@ -23,7 +23,6 @@ import { FormListItem } from "../react/FormList";import { useEffectiveReadOnly, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent, useTriliumEvents, useTriliumOption } from "../react/hooks";import { isSplitEditorForcedReadOnly, resolveDisplayMode } from "../type_widgets/helpers/split_editor_mode";import { ParentComponent } from "../react/react_utils";-import { buildUploadNewImageRevisionListener } from "./ImagePropertiesTab";interface NoteActionsCustomProps {note: FNote;@@ -123,6 +122,22 @@ function ImageActions(props: NoteActionsCustomInnerProps) {);}+function buildUploadNewImageRevisionListener(note: FNote) {+ return async (files: FileList | null) => {+ if (!files) return;+ const fileToUpload = files[0]; // copy to allow reset below++ const result = await server.upload(`images/${note.noteId}`, fileToUpload);++ if (result.uploaded) {+ toast.showMessage(t("image_properties.upload_success"));+ await clearBrowserCache();+ } else {+ toast.showError(t("image_properties.upload_failed", { message: result.message }));+ }+ };+}+function buildUploadNewFileRevisionListener(note: FNote) {return (fileToUpload: FileList | null) => {if (!fileToUpload) {diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.tsindex a297cb77b5..35b57ff167 100644--- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts+++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts@@ -1,14 +1,3 @@-import { t } from "../../services/i18n";-import ImagePropertiesTab from "./ImagePropertiesTab";import { TabConfiguration } from "./ribbon-interface";-export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [- {- title: t("image_properties.title"),- icon: "bx bx-image",- content: ImagePropertiesTab,- show: ({ note }) => note?.type === "image",- toggleCommand: "toggleRibbonTabImageProperties",- activate: true,- },-];+export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [];