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
feat(revisions): improve display of diff when note content is identical
Elian Doran3e6ec67e7b1e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex f329ed38b3..416ed8c24e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -324,6 +324,7 @@"diff_on_hint": "Click to show note source diff","diff_off_hint": "Click to show note content","diff_not_available": "Diff isn't available.",+ "diff_identical": "This revision is identical to the current note content.","confirm_restore": "Do you want to restore this revision? This will overwrite the current title and content of the note with this revision.","delete_button": "Delete","confirm_delete": "Do you want to delete this revision?",diff --git a/apps/client/src/widgets/dialogs/revisions.css b/apps/client/src/widgets/dialogs/revisions.cssindex 0985839c04..71767f8c0e 100644--- a/apps/client/src/widgets/dialogs/revisions.css+++ b/apps/client/src/widgets/dialogs/revisions.css@@ -86,7 +86,8 @@ body.desktop .revisions-dialog {}.no-items {- padding-block: 3em;+ padding-block: 0;+ height: calc(100% - 2.5em);}.revision-list {diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsxindex 5ffe400fa9..89a3769596 100644--- a/apps/client/src/widgets/dialogs/revisions.tsx+++ b/apps/client/src/widgets/dialogs/revisions.tsx@@ -612,6 +612,11 @@ function RevisionContentDiff({ noteContent, itemContent, itemType }: {}).join("");}+ // Diff returned no results, meaning that they are identical.+ if (!diffHtml) {+ return <NoItems className="revision-diff-content" icon="bx bx-copy" text={t("revisions.diff_identical")} />;+ }+return <SanitizedHtmlclassName={clsx("revision-diff-content", itemType === "text" ? "ck-content" : "revision-diff-code")}html={diffHtml}diff --git a/apps/client/src/widgets/react/NoItems.tsx b/apps/client/src/widgets/react/NoItems.tsxindex d7a5a6270f..d2be7781f6 100644--- a/apps/client/src/widgets/react/NoItems.tsx+++ b/apps/client/src/widgets/react/NoItems.tsx@@ -1,5 +1,6 @@import "./NoItems.css";+import clsx from "clsx";import { ComponentChildren } from "preact";import Icon from "./Icon";@@ -8,11 +9,12 @@ interface NoItemsProps {icon: string;text: string;children?: ComponentChildren;+ className?: string;}-export default function NoItems({ icon, text, children }: NoItemsProps) {+export default function NoItems({ icon, text, children, className }: NoItemsProps) {return (- <div className="no-items">+ <div className={clsx("no-items", className)}><Icon icon={icon} />{text}{children}