Skip to content

Build your personal knowledge base with Trilium Notes

feat(revisions): display audio preview for revisions

Elian Dorand84150e97bde
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsx
index e0d82ed47b..2f10b62334 100644
--- a/apps/client/src/widgets/dialogs/revisions.tsx
+++ b/apps/client/src/widgets/dialogs/revisions.tsx
@@ -285,7 +285,7 @@ function RevisionContentText({ content }: { content: string | Buffer<ArrayBuffer
renderMathInElement(contentRef.current, { trust: true });
}
}, [content]);
- return <RawHtmlBlock containerRef={contentRef} className="ck-content" html={content as string} />;;
+ return <RawHtmlBlock containerRef={contentRef} className="ck-content" html={content as string} />;
}
function RevisionContentDiff({ noteContent, itemContent, itemType }: {
@@ -372,9 +372,9 @@ function FilePreview({ revisionItem, fullRevision }: { revisionItem: RevisionIte
<tr>
<td colspan={2}>
<strong>{t("revisions.preview")}</strong>
- {fullRevision.content
- ? <pre className="file-preview-content" style={CODE_STYLE}>{fullRevision.content}</pre>
- : <div>{t("revisions.preview_not_available")}</div>}
+ <div>
+ <FilePreviewInner revisionItem={revisionItem} fullRevision={fullRevision} />
+ </div>
</td>
</tr>
</tbody>
@@ -382,6 +382,23 @@ function FilePreview({ revisionItem, fullRevision }: { revisionItem: RevisionIte
);
}
+function FilePreviewInner({ revisionItem, fullRevision }: { revisionItem: RevisionItem, fullRevision: RevisionPojo }) {
+ if (revisionItem.mime.startsWith("audio/")) {
+ return (
+ <audio
+ src={`api/revisions/${revisionItem.revisionId}/download`}
+ controls
+ />
+ );
+ }
+
+ if (fullRevision.content) {
+ return <pre className="file-preview-content" style={CODE_STYLE}>{fullRevision.content}</pre>;
+ }
+
+ return t("revisions.preview_not_available");
+}
+
async function getNote(noteId?: string | null) {
if (noteId) {
return await froca.getNote(noteId);