Skip to content

Build your personal knowledge base with Trilium Notes

feat(revisions): show revision details inline on mobile

Elian Dorana2a8a084563c
diff --git a/apps/client/src/widgets/dialogs/revisions.css b/apps/client/src/widgets/dialogs/revisions.css
index a684e063c6..a9a4fde7d6 100644
--- a/apps/client/src/widgets/dialogs/revisions.css
+++ b/apps/client/src/widgets/dialogs/revisions.css
@@ -118,6 +118,18 @@ body.desktop .revisions-dialog {
min-width: 0;
}
}
+
+ /* On touch devices the items carry the source/size inline (no hover tooltip), so let the
+ description wrap to its full text and give the rows a little more breathing room. */
+ &.detailed {
+ .dropdown-item {
+ padding-block: 6px;
+ }
+
+ .revision-item-description {
+ white-space: normal;
+ }
+ }
}
.revision-item-description {
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsx
index d5c1e63b5f..d94cb97e92 100644
--- a/apps/client/src/widgets/dialogs/revisions.tsx
+++ b/apps/client/src/widgets/dialogs/revisions.tsx
@@ -121,6 +121,7 @@ export default function RevisionsDialog() {
revisions={revisions ?? []}
onSelect={selectRevision}
currentRevision={currentRevision}
+ detailed={utils.isMobile()}
/>
);
@@ -371,16 +372,23 @@ function buildRevisionTooltip(item: RevisionItem): string {
].filter(Boolean).join("\n");
}
-function RevisionsList({ revisions, onSelect, currentRevision }: { revisions: RevisionItem[], onSelect: (val: string) => void, currentRevision?: RevisionItem }) {
+function RevisionsList({ revisions, onSelect, currentRevision, detailed }: { revisions: RevisionItem[], onSelect: (val: string) => void, currentRevision?: RevisionItem, detailed?: boolean }) {
let lastGroup: DateGroup | "" = "";
return (
- <FormList onSelect={onSelect} fullHeight wrapperClassName="revision-list">
+ <FormList onSelect={onSelect} fullHeight wrapperClassName={clsx("revision-list", detailed && "detailed")}>
{revisions.map((item) => {
const group = item.dateCreated ? getDateGroup(item.dateCreated) : "" as DateGroup;
const showHeader = group !== lastGroup;
lastGroup = group;
+ // On touch devices the hover tooltip is unreachable, so the source/size it carries are
+ // surfaced inline as a meta line instead.
+ const meta = detailed && [
+ getRevisionSourceTitle(item.source),
+ item.contentLength && utils.formatSize(item.contentLength)
+ ].filter(Boolean).join(" · ");
+
return (
<Fragment key={item.revisionId}>
{showHeader && (
@@ -390,7 +398,7 @@ function RevisionsList({ revisions, onSelect, currentRevision }: { revisions: Re
key={item.revisionId}
value={item.revisionId}
icon={REVISION_SOURCE_ICONS[item.source ?? ""] ?? DEFAULT_REVISION_ICON}
- title={buildRevisionTooltip(item)}
+ title={detailed ? undefined : buildRevisionTooltip(item)}
active={currentRevision && item.revisionId === currentRevision.revisionId}
>
<div>
@@ -402,6 +410,11 @@ function RevisionsList({ revisions, onSelect, currentRevision }: { revisions: Re
{item.description}
</div>
)}
+ {meta && (
+ <div className="revision-item-meta">
+ {meta}
+ </div>
+ )}
</div>
</FormListItem>
</Fragment>