Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion client/src/common/fileTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum FileContentType {
Document = 'document',
Text = 'text',
PdfDocument = 'pdf-document',
Presentation = 'presentation',
Unknown = 'unknown',
}

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

// For generic text/plain
const TEXTS = [
Expand Down Expand Up @@ -80,7 +82,7 @@ async function getMimeTypeFromBuffer(data: Uint8Array): Promise<string | undefin
}
}

function detectFileContentType(name: EntryName): DetectedFileType | undefined {
function detectFileContentType(name: EntryName): DetectedFileType {
const ext = Path.getFileExtension(name);

if (IMAGES.includes(ext)) {
Expand All @@ -104,6 +106,9 @@ function detectFileContentType(name: EntryName): DetectedFileType | undefined {
if (TEXTS.includes(ext)) {
return { type: FileContentType.Text, extension: ext };
}
if (PRESENTATIONS.includes(ext)) {
return { type: FileContentType.Presentation, extension: ext };
}
return { type: FileContentType.Unknown, extension: ext };
}

Expand Down
3 changes: 3 additions & 0 deletions client/src/parsec/mock_files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum MockFileType {
XLSX = 'XLSX',
MP4 = 'MP4',
MP3 = 'MP3',
PPTX = 'PPTX',
}

// Import content dynamically so it's not loaded if not needed
Expand All @@ -33,5 +34,7 @@ export async function getMockFileContent(type: MockFileType): Promise<Uint8Array
return (await import('@/parsec/mock_files/mp4')).default;
case MockFileType.MP3:
return (await import('@/parsec/mock_files/mp3')).default;
case MockFileType.PPTX:
return (await import('@/parsec/mock_files/pptx')).default;
}
}
9 changes: 9 additions & 0 deletions client/src/parsec/mock_files/pptx.ts

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions client/src/services/cryptpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ export class Cryptpad {

// Race between successful loading (onReady callback) and timeout
await Promise.race([loadingComplete, timeoutPromise]);

// No way to know if the history really changed.
// Something changes about it, window.history.length` gets incremented
// but the state doesn't change. Tried the navigation API, same things.
// Tried to monkeypatch pushState, nop. There's no way to detect that
// the iframe navigated, changing the main history enough that
// history.back() is required, but not enough that `history.state` changes.
if (window.history) {
window.history.back();
}
} finally {
window.clearTimeout(loadingTimeoutId);
// Clean up global config reference
Expand All @@ -224,12 +234,17 @@ export function getCryptpadDocumentType(contentType: FileContentType): CryptpadD
return CryptpadDocumentType.Sheet;
case FileContentType.Document:
return CryptpadDocumentType.Doc;
case FileContentType.Presentation:
return CryptpadDocumentType.Presentation;
default:
return CryptpadDocumentType.Unsupported;
}
}

export function isEnabledCryptpadDocumentType(contentType: FileContentType): boolean {
if (!Env.isEditicsEnabled()) {
return false;
}
return ENABLED_DOCUMENT_TYPES.includes(getCryptpadDocumentType(contentType));
}

Expand Down
Loading
Loading