Skip to content

Build your personal knowledge base with Trilium Notes

feat(file): display videos in full width

Elian Dorane330d91df2ab
diff --git a/src/public/app/widgets/note_wrapper.ts b/src/public/app/widgets/note_wrapper.ts
index b7df269fe5..dd108f9c32 100644
--- a/src/public/app/widgets/note_wrapper.ts
+++ b/src/public/app/widgets/note_wrapper.ts
@@ -63,7 +63,7 @@ export default class NoteWrapperWidget extends FlexContainer<BasicWidget> {
return true;
}
- if (note.type === "file" && note.mime === "application/pdf") {
+ if (note.type === "file" && (note.mime === "application/pdf" || note.mime.startsWith("video/"))) {
return true;
}
diff --git a/src/public/app/widgets/type_widgets/file.ts b/src/public/app/widgets/type_widgets/file.ts
index 0d10783a0b..38f1738e76 100644
--- a/src/public/app/widgets/type_widgets/file.ts
+++ b/src/public/app/widgets/type_widgets/file.ts
@@ -22,6 +22,10 @@ const TPL = `
padding: 0;
}
+ .note-split.full-content-width .note-detail-file[data-preview-type="video"] {
+ overflow: hidden;
+ }
+
.file-preview-content {
background-color: var(--accented-background-color);
padding: 15px;
@@ -90,6 +94,8 @@ export default class FileTypeWidget extends TypeWidget {
this.$videoPreview.hide();
this.$audioPreview.hide();
+ let previewType: string;
+
if (blob?.content) {
this.$previewContent.show().scrollTop(0);
const trimmedContent = blob.content.substring(0, TEXT_MAX_NUM_CHARS);
@@ -97,23 +103,30 @@ export default class FileTypeWidget extends TypeWidget {
this.$previewTooBig.removeClass("hidden-ext");
}
this.$previewContent.text(trimmedContent);
+ previewType = "text";
} else if (note.mime === "application/pdf") {
this.$pdfPreview.show().attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open`));
+ previewType = "pdf";
} else if (note.mime.startsWith("video/")) {
this.$videoPreview
.show()
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
.attr("type", this.note?.mime ?? "")
.css("width", this.$widget.width() ?? 0);
+ previewType = "video";
} else if (note.mime.startsWith("audio/")) {
this.$audioPreview
.show()
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
.attr("type", this.note?.mime ?? "")
.css("width", this.$widget.width() ?? 0);
+ previewType = "audio";
} else {
this.$previewNotAvailable.show();
+ previewType = "not-available";
}
+
+ this.$widget.attr("data-preview-type", previewType ?? "");
}
async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {