feat(revisions): display audio preview for revisions

This commit is contained in:
Elian Doran 2026-01-02 19:21:51 +02:00
parent 2b2ef4251f
commit d84150e97b
No known key found for this signature in database

View File

@ -285,7 +285,7 @@ function RevisionContentText({ content }: { content: string | Buffer<ArrayBuffer
renderMathInElement(contentRef.current, { trust: true }); renderMathInElement(contentRef.current, { trust: true });
} }
}, [content]); }, [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 }: { function RevisionContentDiff({ noteContent, itemContent, itemType }: {
@ -372,9 +372,9 @@ function FilePreview({ revisionItem, fullRevision }: { revisionItem: RevisionIte
<tr> <tr>
<td colspan={2}> <td colspan={2}>
<strong>{t("revisions.preview")}</strong> <strong>{t("revisions.preview")}</strong>
{fullRevision.content <div>
? <pre className="file-preview-content" style={CODE_STYLE}>{fullRevision.content}</pre> <FilePreviewInner revisionItem={revisionItem} fullRevision={fullRevision} />
: <div>{t("revisions.preview_not_available")}</div>} </div>
</td> </td>
</tr> </tr>
</tbody> </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) { async function getNote(noteId?: string | null) {
if (noteId) { if (noteId) {
return await froca.getNote(noteId); return await froca.getNote(noteId);