Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Preview: Support for text files and PDFs #467

Merged
merged 8 commits into from
May 27, 2024

Conversation

Innders
Copy link
Member

@Innders Innders commented May 27, 2024

Description of changes

  • Support all text/ mime formats and some custom text formats.
  • Use code editor in read only mode for syntax highlighting
  • Markdown files preview as rendered markdown.
  • PDF files now open in a new tab for previewing.
  • UploadFileCard now has a consistent UX for pre-viewing and downloading files.

Technical details

It is now a lot easier to add support for new file types using the object expandableMimeTypes in FileUploadPreview.jsx

// define expandable mime types and their components
export const expandableMimeTypes = {
  image: {
    component: ImageMime,
    mimeTypes: ['image/'],
    fullPreviews: ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'],
    id: 'image',
  },
  text: {
    component: TextMime,
    mimeTypes: ['text/', 'application/json', 'scss', 'jsx'],
    id: 'text',
  },
  pdf: {
    component: null,
    mimeTypes: ['pdf'],
    id: 'pdf',
    callback: (file) => window.open(getFileURL(file.id, file.projectName), '_blank'),
  },
// add new file support and their custom rendering component here
}

Adding a new file value to the object will also automatically show the expand icon when hovering over a file card.

Additional context

CONTRUBTING_markdown
FileUploadPReview_jsx
lorem_ipsom

@Innders Innders requested a review from martastain May 27, 2024 09:23
@Innders Innders self-assigned this May 27, 2024
@Innders Innders linked an issue May 27, 2024 that may be closed by this pull request
@Innders Innders added the type: feature Adding something new and exciting to the product label May 27, 2024
Copy link
Member

@martastain martastain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works like a charm!

@Innders Innders merged commit 5591f44 into develop May 27, 2024
@Innders Innders deleted the 463-Activity-feed-Text-file-preview branch May 27, 2024 17:42
@BigRoy
Copy link
Contributor

BigRoy commented May 27, 2024

Really lovely work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Adding something new and exciting to the product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Activity feed: Text file preview
3 participants