Skip to content

Build your personal knowledge base with Trilium Notes

feat(revisions): display video preview for revisions

Elian Doran29b70a12bd67
diff --git a/apps/client/src/widgets/dialogs/revisions.css b/apps/client/src/widgets/dialogs/revisions.css
index dc94f18e7f..777470e3d2 100644
--- a/apps/client/src/widgets/dialogs/revisions.css
+++ b/apps/client/src/widgets/dialogs/revisions.css
@@ -69,4 +69,30 @@ body.mobile .revisions-dialog {
padding: 0.25em 0;
}
}
+
+ .revision-content.type-file {
+ display: flex;
+ min-width: 0;
+ min-height: 0;
+
+ .revision-file-preview {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ min-height: 0;
+ flex-grow: 1;
+ }
+
+ .revision-file-preview-content {
+ flex-grow: 1;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+
+ video {
+ height: 100%;
+ }
+ }
+ }
+
}
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsx
index 2f10b62334..06a1e0b9d3 100644
--- a/apps/client/src/widgets/dialogs/revisions.tsx
+++ b/apps/client/src/widgets/dialogs/revisions.tsx
@@ -1,6 +1,7 @@
import "./revisions.css";
import type { RevisionItem,RevisionPojo } from "@triliumnext/commons";
+import clsx from "clsx";
import { diffWords } from "diff";
import type { CSSProperties } from "preact/compat";
import { Dispatch, StateUpdater, useEffect, useRef, useState } from "preact/hooks";
@@ -213,7 +214,10 @@ function RevisionPreview({noteContent, revisionItem, showDiff, setShown, onRevis
}
</div>)}
</div>
- <div className="revision-content use-tn-links selectable-text" style={{ overflow: "auto", wordBreak: "break-word" }}>
+ <div
+ className={clsx("revision-content use-tn-links selectable-text", `type-${revisionItem?.type}`)}
+ style={{ overflow: "auto", wordBreak: "break-word" }}
+ >
<RevisionContent noteContent={noteContent} revisionItem={revisionItem} fullRevision={fullRevision} showDiff={showDiff}/>
</div>
</>
@@ -359,26 +363,29 @@ function RevisionFooter({ note }: { note?: FNote }) {
function FilePreview({ revisionItem, fullRevision }: { revisionItem: RevisionItem, fullRevision: RevisionPojo }) {
return (
- <table className="file-preview-table">
- <tbody>
- <tr>
- <th>{t("revisions.mime")}</th>
- <td>{revisionItem.mime}</td>
- </tr>
- <tr>
- <th>{t("revisions.file_size")}</th>
- <td>{revisionItem.contentLength && utils.formatSize(revisionItem.contentLength)}</td>
- </tr>
- <tr>
- <td colspan={2}>
- <strong>{t("revisions.preview")}</strong>
- <div>
- <FilePreviewInner revisionItem={revisionItem} fullRevision={fullRevision} />
- </div>
- </td>
- </tr>
- </tbody>
- </table>
+ <div className="revision-file-preview">
+ <table className="file-preview-table">
+ <tbody>
+ <tr>
+ <th>{t("revisions.mime")}</th>
+ <td>{revisionItem.mime}</td>
+ </tr>
+ <tr>
+ <th>{t("revisions.file_size")}</th>
+ <td>{revisionItem.contentLength && utils.formatSize(revisionItem.contentLength)}</td>
+ </tr>
+ <tr>
+ <td colspan={2}>
+ <strong>{t("revisions.preview")}</strong>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <div class="revision-file-preview-content">
+ <FilePreviewInner revisionItem={revisionItem} fullRevision={fullRevision} />
+ </div>
+ </div>
);
}
@@ -392,6 +399,15 @@ function FilePreviewInner({ revisionItem, fullRevision }: { revisionItem: Revisi
);
}
+ if (revisionItem.mime.startsWith("video/")) {
+ return (
+ <video
+ src={`api/revisions/${revisionItem.revisionId}/download`}
+ controls
+ />
+ );
+ }
+
if (fullRevision.content) {
return <pre className="file-preview-content" style={CODE_STYLE}>{fullRevision.content}</pre>;
}