Skip to content

Commit fa93bdb

Browse files
committed
[MS] Use Cryptpad instead of viewers when possible
1 parent 92e2932 commit fa93bdb

26 files changed

+638
-750
lines changed

client/src/common/fileTypes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum FileContentType {
1111
Document = 'document',
1212
Text = 'text',
1313
PdfDocument = 'pdf-document',
14+
Presentation = 'presentation',
1415
Unknown = 'unknown',
1516
}
1617

@@ -25,6 +26,7 @@ const DOCUMENTS = ['docx'];
2526
const PDF_DOCUMENTS = ['pdf'];
2627
const AUDIOS = ['wav', 'mp3', 'ogg'];
2728
const VIDEOS = ['mp4', 'mpeg', 'webm'];
29+
const PRESENTATIONS = ['pptx'];
2830

2931
// For generic text/plain
3032
const TEXTS = [
@@ -80,7 +82,7 @@ async function getMimeTypeFromBuffer(data: Uint8Array): Promise<string | undefin
8082
}
8183
}
8284

83-
function detectFileContentType(name: EntryName): DetectedFileType | undefined {
85+
function detectFileContentType(name: EntryName): DetectedFileType {
8486
const ext = Path.getFileExtension(name);
8587

8688
if (IMAGES.includes(ext)) {
@@ -104,6 +106,9 @@ function detectFileContentType(name: EntryName): DetectedFileType | undefined {
104106
if (TEXTS.includes(ext)) {
105107
return { type: FileContentType.Text, extension: ext };
106108
}
109+
if (PRESENTATIONS.includes(ext)) {
110+
return { type: FileContentType.Presentation, extension: ext };
111+
}
107112
return { type: FileContentType.Unknown, extension: ext };
108113
}
109114

client/src/parsec/mock_files/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export enum MockFileType {
1010
XLSX = 'XLSX',
1111
MP4 = 'MP4',
1212
MP3 = 'MP3',
13+
PPTX = 'PPTX',
1314
}
1415

1516
// Import content dynamically so it's not loaded if not needed
@@ -33,5 +34,7 @@ export async function getMockFileContent(type: MockFileType): Promise<Uint8Array
3334
return (await import('@/parsec/mock_files/mp4')).default;
3435
case MockFileType.MP3:
3536
return (await import('@/parsec/mock_files/mp3')).default;
37+
case MockFileType.PPTX:
38+
return (await import('@/parsec/mock_files/pptx')).default;
3639
}
3740
}

client/src/parsec/mock_files/pptx.ts

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

client/src/services/cryptpad.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ export class Cryptpad {
213213
// Tried to monkeypatch pushState, nop. There's no way to detect that
214214
// the iframe navigated, changing the main history enough that
215215
// history.back() is required, but not enough that `history.state` changes.
216-
window.history.back();
216+
if (window.history) {
217+
window.history.back();
218+
}
217219
} finally {
218220
window.clearTimeout(loadingTimeoutId);
219221
// Clean up global config reference

0 commit comments

Comments
 (0)