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

Add Document Export Functionality #238

Merged
merged 20 commits into from
Jul 23, 2024

Conversation

minai621
Copy link
Contributor

@minai621 minai621 commented Jul 19, 2024

What this PR does / why we need it:

This pull request introduces a new document export feature for CodePair. Currently, users can write Markdown documents in CodePair, but there was no functionality to export these documents into various file formats. With this update, users can now export their Markdown documents as PDF, TXT, and DOCX files.

Which issue(s) this PR fixes:

Fixes #191

Special notes for your reviewer:

The implementation uses local storage to save the document title for file naming purposes. I would appreciate your feedback on whether there are better alternatives for this approach.

Does this PR introduce a user-facing change?:

Added document export functionality to CodePair. 
Users can now export their Markdown documents to PDF, TXT, and DOCX formats. 
This feature allows users to save and share their Markdown documents in multiple formats.

Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Introduced a DownloadMenu component for exporting files in PDF, HTML, and Markdown formats.
    • Added functionality for exporting Markdown files through a new endpoint in the backend.
    • Integrated the DownloadMenu component into the DocumentHeader for easier access to download options.
  • Improvements

    • Enhanced the FilesService to support versatile content export capabilities (PDF, HTML, Markdown).
    • Improved organization and clarity of import statements across various components.
    • Added new dependencies to facilitate document generation and file saving capabilities.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

The recent changes introduce a comprehensive document export functionality to the CodePair platform, enabling users to save Markdown documents as PDF, HTML, and Markdown files. This update enhances the user interface with a new download menu for seamless file exports, while adding supporting hooks and utilities for managing exports effectively. Overall, these enhancements significantly improve user experience and collaboration flexibility.

Changes

Files Change Summary
frontend/package.json Added dependencies for document generation and file saving: docx, file-saver, jspdf-html2canvas, and related TypeScript types.
frontend/src/components/common/DownloadMenu.tsx, frontend/src/components/headers/DocumentHeader.tsx Introduced DownloadMenu component for exporting files in different formats and integrated it into the DocumentHeader.
frontend/src/hooks/useFileExport.ts Implemented useFileExport hook for handling exports to PDF, HTML, and Markdown formats.
backend/package.json Added new dependencies for backend functionality: fs-extra, html-pdf-node, and markdown-it.
backend/src/files/files.controller.ts, backend/src/files/files.service.ts Added endpoints and methods for exporting Markdown files and improved existing service methods.
backend/src/files/types/export-file.type.ts Created type definitions for exporting files, including request and response structures.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DocumentHeader
    participant DownloadMenu
    participant useFileExport
    participant FilesController

    User->>DocumentHeader: Clicks save icon
    DocumentHeader->>DownloadMenu: Opens download options
    DownloadMenu->>User: Displays formats (PDF, HTML, Markdown)
    User->>DownloadMenu: Selects format
    DownloadMenu->>useFileExport: Triggers export function
    useFileExport->>FilesController: Requests file export
    FilesController->>User: Initiates file download
Loading

Assessment against linked issues

Objective Addressed Explanation
Add document export functionality (Issue #191)
Improve usability by enabling file formats
Enhance user experience with export options

Poem

In a world of docs and files so bright,
A rabbit hops with joy and delight.
Exporting dreams in formats galore,
PDF, HTML, Markdown—oh, what a score!
With each click, a new tale to unfold,
A bunny's heart sings, "Let your stories be told!" 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e1cebe0 and 508f830.

Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (10)
  • frontend/package.json (2 hunks)
  • frontend/src/components/cards/DocumentCard.tsx (2 hunks)
  • frontend/src/components/common/DownloadMenu.tsx (1 hunks)
  • frontend/src/components/editor/Preview.tsx (3 hunks)
  • frontend/src/components/headers/DocumentHeader.tsx (3 hunks)
  • frontend/src/contexts/PreviewRefContext.ts (1 hunks)
  • frontend/src/hooks/useFileExport.ts (1 hunks)
  • frontend/src/providers/PreviewRefProvider.tsx (1 hunks)
  • frontend/src/routes.tsx (2 hunks)
  • frontend/src/utils/localStorage.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • frontend/src/utils/localStorage.ts
Additional comments not posted (42)
frontend/src/contexts/PreviewRefContext.ts (3)

1-2: Good practice: Import statements.

The import statements are clear and concise.


4-6: Interface definition looks good.

The PreviewRefContextValue interface is well-defined.


8-10: Context initialization looks good.

The PreviewRefContext is correctly initialized with a default value.

frontend/src/providers/PreviewRefProvider.tsx (3)

1-3: Good practice: Import statements.

The import statements are clear and concise.


5-7: Provider component definition looks good.

The PreviewRefProvider component is well-defined and uses the useRef hook appropriately.


9-11: Context provider implementation looks good.

The PreviewRefContext.Provider is correctly implemented to pass down the previewRef.

frontend/src/components/cards/DocumentCard.tsx (3)

2-3: Reordered import statements.

The import statements are reordered for better organization.


6-6: New import statement added.

The import of documentNameStorage is correctly added.


18-18: Functionality enhancement: Storing document title in local storage.

The call to documentNameStorage.setDocumentName(document.title); enhances the functionality by storing the document's title in local storage.

frontend/src/components/common/DownloadMenu.tsx (6)

1-4: LGTM! Imports are relevant and necessary.

The import statements are appropriate for the functionality described in the file.


6-15: LGTM! State management and handlers are well-implemented.

The state management and event handlers for opening and closing the menu are correctly implemented.


17-17: LGTM! Custom hook usage is appropriate.

The useFileExport hook is correctly used to handle file export functionality.


19-32: LGTM! Export handlers are well-implemented.

The export handlers use useCallback for performance optimization and correctly call the respective export functions.


34-52: LGTM! JSX structure and accessibility considerations are well-implemented.

The JSX structure is clear and follows Material-UI best practices. The aria attributes are correctly used for accessibility.


54-54: LGTM! Export statement is correctly implemented.

The DownloadMenu component is correctly exported as the default export.

frontend/src/hooks/useFileExport.ts (7)

1-9: LGTM! Imports are relevant and necessary.

The import statements are appropriate for the functionality described in the file.


11-15: LGTM! Interface definition is correct.

The useFileExportReturn interface is correctly defined to ensure type safety for the hook's return values.


17-20: LGTM! Hook initialization is correct.

The useFileExport hook is correctly initialized and retrieves necessary data from the Redux store and context.


27-50: LGTM! exportToPDF function is well-implemented.

The exportToPDF function uses jspdf-html2canvas to convert HTML content to a PDF file and handles potential errors gracefully.


52-55: LGTM! exportToTXT function is well-implemented.

The exportToTXT function creates a text file from the Markdown content and uses file-saver to save the file.


57-74: LGTM! exportToDOCX function is well-implemented.

The exportToDOCX function creates a DOCX file from the Markdown content using the docx library and saves the file using file-saver.


76-77: LGTM! Return statement is correctly implemented.

The useFileExport hook correctly returns the three export functions.

frontend/src/routes.tsx (4)

1-14: LGTM! Imports are relevant and necessary.

The import statements are appropriate for the functionality described in the file.


63-67: LGTM! Routing structure and enhancement are well-implemented.

The routing structure is well-implemented. Wrapping the DocumentLayout component with PreviewRefProvider is a logical enhancement for managing document previews.


Line range hint 96-126:
LGTM! injectProtectedRoute function is correctly implemented.

The injectProtectedRoute function ensures that routes are protected based on their access type.


Line range hint 128-128:
LGTM! Export statement is correctly implemented.

The routes are correctly exported using the injectProtectedRoute function.

frontend/package.json (4)

40-40: Dependency Addition: docx

The docx library is added to handle DOCX file generation. Ensure it is necessary and used securely.


41-41: Dependency Addition: file-saver

The file-saver library is added for saving files on the client side. Ensure it is necessary and used securely.


43-43: Dependency Addition: jspdf-html2canvas

The jspdf-html2canvas library is added for PDF generation from HTML content. Ensure it is necessary and used securely.


74-74: DevDependency Addition: @types/file-saver

The @types/file-saver type declaration is added to support TypeScript development. Ensure it is necessary and used correctly.

frontend/src/components/editor/Preview.tsx (8)

2-2: Import Addition: MarkdownPreview

The MarkdownPreview component is imported for rendering Markdown content. Ensure it is necessary and used correctly.


4-4: Import Addition: katex

The katex library is imported for rendering LaTeX math in Markdown. Ensure it is necessary and used correctly.


5-5: Import Addition: useContext and useEffect

The useContext and useEffect hooks are imported for managing context and side effects. Ensure they are necessary and used correctly.


11-11: Import Addition: PreviewRefContext

The PreviewRefContext is imported to manage the preview reference context. Ensure it is necessary and used correctly.


15-15: Import Addition: documentNameStorage

The documentNameStorage utility is imported for managing document names in local storage. Ensure it is necessary and used correctly.


23-23: Context Usage: PreviewRefContext

The previewRef is obtained from the PreviewRefContext. Ensure it is necessary and used correctly.


46-48: useEffect Hook: Local Storage Cleanup

The useEffect hook is added to clean up document names from local storage when the component unmounts. This prevents potential data retention issues.


59-59: Prop Addition: ref

The previewRef is passed to the MarkdownPreview component. Ensure it is necessary and used correctly.

frontend/src/components/headers/DocumentHeader.tsx (4)

1-4: Import Consolidation: MUI Icons

The MUI icons are consolidated into individual import statements for better clarity and organization.


18-18: Import Addition: useDispatch and useSelector

The useDispatch and useSelector hooks are imported for managing Redux state. Ensure they are necessary and used correctly.


25-25: Import Addition: DownloadMenu

The DownloadMenu component is imported for providing download options in the document header. Ensure it is necessary and used correctly.


129-129: Component Addition: DownloadMenu

The DownloadMenu component is added to the document header to provide download options. Ensure it is necessary and used correctly.

@minai621
Copy link
Contributor Author

minai621 commented Jul 19, 2024

Notify

This is a problem I learned from the additional modification.
If the client creates a markdown and extracts it as a PDF, there is a problem that the image cannot be rendered.
I can solve it if I make a PDF on the server, but can I modify the backend code together and solve it in the pull request now?

@devleejb
Copy link
Member

devleejb commented Jul 20, 2024

Please check formatting and lint rules.
image

You can check it by,

Frontend

  • Formatter: npm run format (It also perform auto formatting.)
  • Linter: npm run lint
    Backend
  • Formatter: npm run format(It also perform auto formatting.)
  • Linter: npm run lint

Copy link
Member

Choose a reason for hiding this comment

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

This is redundant data saving functions.

You can get this data in redux store.
(Refer to frontend/src/store/documentSlice.ts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in this commit and resolved using documentStore in this commit

frontend/src/components/cards/DocumentCard.tsx Outdated Show resolved Hide resolved

const { exportToPDF, exportToTXT, exportToDOCX } = useFileExport();

const handleExportToPDF = useCallback(() => {
Copy link
Member

Choose a reason for hiding this comment

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

It seems necessary to standardize either wrapping or not wrapping handlers in the Component with useCallback.

frontend/src/components/common/DownloadMenu.tsx Outdated Show resolved Hide resolved
frontend/src/routes.tsx Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/providers/PreviewRefProvider.tsx Outdated Show resolved Hide resolved
@devleejb
Copy link
Member

Notify

This is a problem I learned from the additional modification. If the client creates a markdown and extracts it as a PDF, there is a problem that the image cannot be rendered. I can solve it if I make a PDF on the server, but can I modify the backend code together and solve it in the pull request now?

While modifying to convert Markdown text to PDF, it is necessary to check if there is an option to render images. If it is determined to be impossible on the frontend, backend code modifications are possible. However, the first option to consider should be to make changes on the frontend alone, as this seems optimal.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Outside diff range, codebase verification and nitpick comments (2)
backend/src/files/types/export-file.type.ts (1)

3-5: Enhance property descriptions and consider extending export types.

The descriptions in the @ApiProperty decorators could be more descriptive to provide better API documentation. Additionally, consider if other export types (e.g., DOCX, TXT) should be supported.

-  @ApiProperty({ type: String, description: "export_type" })
+  @ApiProperty({ type: String, description: "The format to export the file (e.g., pdf, html, markdown)" })
frontend/src/hooks/useFileExport.ts (1)

31-33: Internationalize snackbar messages.

The enqueueSnackbar messages should be internationalized for better localization support.

- enqueueSnackbar(`${exportType.toUpperCase()} 파일 내보내기 시작...`, {
+ enqueueSnackbar(t(`${exportType.toUpperCase()} file export started...`), {
- enqueueSnackbar(`${exportType.toUpperCase()} 파일이 성공적으로 내보내졌습니다.`, {
+ enqueueSnackbar(t(`${exportType.toUpperCase()} file exported successfully.`), {
- enqueueSnackbar(`${exportType.toUpperCase()} 파일 내보내기에 실패했습니다.`, {
+ enqueueSnackbar(t(`${exportType.toUpperCase()} file export failed.`), {

Also applies to: 66-68, 71-73

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 508f830 and 1d6e835.

Files ignored due to path filters (1)
  • backend/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (9)
  • backend/package.json (1 hunks)
  • backend/src/files/files.controller.ts (3 hunks)
  • backend/src/files/files.service.ts (2 hunks)
  • backend/src/files/types/export-file.type.ts (1 hunks)
  • frontend/src/components/cards/DocumentCard.tsx (1 hunks)
  • frontend/src/components/common/DownloadMenu.tsx (1 hunks)
  • frontend/src/components/editor/Preview.tsx (1 hunks)
  • frontend/src/hooks/useFileExport.ts (1 hunks)
  • frontend/src/routes.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • frontend/src/components/cards/DocumentCard.tsx
  • frontend/src/routes.tsx
Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/common/DownloadMenu.tsx
  • frontend/src/components/editor/Preview.tsx
Additional context used
Biome
frontend/src/hooks/useFileExport.ts

[error] 8-12: The enum declaration should not be const

Const enums are not supported by bundlers and are incompatible with the 'isolatedModules' mode. Their use can lead to import inexistent values.
See TypeScript Docs for more details.
Safe fix: Turn the const enum into a regular enum.

(lint/suspicious/noConstEnum)


[error] 52-53: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (6)
backend/src/files/types/export-file.type.ts (1)

14-17: LGTM!

The interface ExportFileResponseDto is well-defined and straightforward.

backend/src/files/files.controller.ts (1)

45-46: LGTM!

The correction in the description improves clarity in the API documentation.

backend/package.json (3)

38-38: LGTM!

The addition of fs-extra is appropriate for handling file system operations more efficiently.


39-39: LGTM!

The addition of html-pdf-node is appropriate for generating PDF files from HTML content.


41-41: LGTM!

The addition of markdown-it is appropriate for processing markdown content.

backend/src/files/files.service.ts (1)

1-18: LGTM!

The imports and constructor initialization are appropriate.

Also applies to: 23-26

backend/src/files/files.controller.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
backend/src/files/files.service.ts Outdated Show resolved Hide resolved
backend/src/files/files.service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d6e835 and 8bbdd51.

Files selected for processing (1)
  • frontend/src/components/headers/DocumentHeader.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/headers/DocumentHeader.tsx

@devleejb
Copy link
Member

image

May I proceed with the code review?
If you are ready, please click the 'Re-request review' button.

@devleejb devleejb changed the title [Feat] Add Document Export Functionality Add Document Export Functionality Jul 21, 2024
@minai621 minai621 requested a review from devleejb July 21, 2024 17:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8bbdd51 and 2734a4c.

Files selected for processing (1)
  • backend/src/files/files.controller.ts (3 hunks)
Additional context used
Biome
backend/src/files/files.controller.ts

[error] 75-75: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Additional comments not posted (3)
backend/src/files/files.controller.ts (3)

1-16: Imports look good.

The new imports are necessary for the added export functionality.


45-45: Documentation correction approved.

The correction from "Create rresigned URL for download" to "Create Presigned URL for download" improves clarity.


56-77: Function implementation approved.

The exportMarkdown function is correctly implemented and follows best practices.

Tools
Biome

[error] 75-75: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

backend/src/files/files.controller.ts Outdated Show resolved Hide resolved
backend/src/files/files.controller.ts Outdated Show resolved Hide resolved
backend/package.json Outdated Show resolved Hide resolved
backend/src/files/types/export-file.type.ts Outdated Show resolved Hide resolved
backend/src/files/files.service.ts Outdated Show resolved Hide resolved
backend/src/files/files.service.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2734a4c and 1040b83.

Files selected for processing (8)
  • backend/package.json (1 hunks)
  • backend/src/files/files.controller.ts (3 hunks)
  • backend/src/files/files.service.ts (2 hunks)
  • backend/src/files/types/export-file.type.ts (1 hunks)
  • frontend/src/components/common/DownloadMenu.tsx (1 hunks)
  • frontend/src/hooks/api/file.ts (2 hunks)
  • frontend/src/hooks/api/types/file.d.ts (1 hunks)
  • frontend/src/hooks/useFileExport.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • backend/package.json
  • backend/src/files/files.service.ts
  • backend/src/files/types/export-file.type.ts
  • frontend/src/components/common/DownloadMenu.tsx
Additional context used
Biome
frontend/src/hooks/useFileExport.ts

[error] 8-12: The enum declaration should not be const

Const enums are not supported by bundlers and are incompatible with the 'isolatedModules' mode. Their use can lead to import inexistent values.
See TypeScript Docs for more details.
Safe fix: Turn the const enum into a regular enum.

(lint/suspicious/noConstEnum)


[error] 46-46: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (6)
frontend/src/hooks/api/types/file.d.ts (1)

17-21: Ensure consistency in property naming.

The class ExportFileRequest is well-defined, but ensure that the property names are consistent with any existing naming conventions in the project.

frontend/src/hooks/api/file.ts (1)

3-8: LGTM! Ensure the import is necessary.

The import statement for ExportFileRequest is correct. Ensure that it is necessary and used appropriately in the file.

frontend/src/hooks/useFileExport.ts (4)

1-6: Imports look good.

The imported modules and functions are necessary for the functionality of the hook.


14-20: Type and interface declarations look good.

The type alias and interface improve type safety and readability.


73-75: Export functions look good.

The functions correctly call handleExportFile with the appropriate file extension.


77-78: Return statement looks good.

The return statement correctly provides the export functions to the caller.

frontend/src/hooks/useFileExport.ts Show resolved Hide resolved
frontend/src/hooks/api/file.ts Show resolved Hide resolved
backend/src/files/files.controller.ts Show resolved Hide resolved
frontend/src/hooks/useFileExport.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1040b83 and 7af17ef.

Files selected for processing (1)
  • frontend/src/components/common/DownloadMenu.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/common/DownloadMenu.tsx

@minai621 minai621 requested a review from devleejb July 22, 2024 16:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7af17ef and af14534.

Files ignored due to path filters (1)
  • backend/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (1)
  • frontend/src/hooks/useFileExport.ts (1 hunks)
Additional context used
Biome
frontend/src/hooks/useFileExport.ts

[error] 8-12: The enum declaration should not be const

Const enums are not supported by bundlers and are incompatible with the 'isolatedModules' mode. Their use can lead to import inexistent values.
See TypeScript Docs for more details.
Safe fix: Turn the const enum into a regular enum.

(lint/suspicious/noConstEnum)

Additional comments not posted (5)
frontend/src/hooks/useFileExport.ts (5)

1-6: Imports look good.

The import statements are necessary and correctly used in the file.


23-27: Hooks usage looks good.

The hooks are used correctly and the dependency arrays are accurate.


29-70: Functionality looks good, but ensure useCallback dependency array includes editorStore and documentStore.

The handleExportFile function is well-implemented, handling errors and optimizing performance. However, ensure that the useCallback dependency array includes editorStore and documentStore to use the latest state.


44-46: Simplify content-disposition header parsing using optional chaining.

Use optional chaining to simplify the content-disposition header parsing.


72-77: Return statement looks good.

The return statement correctly includes the export functions for PDF, HTML, and Markdown.

frontend/src/hooks/useFileExport.ts Show resolved Hide resolved
Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

@devleejb devleejb merged commit a2d8e69 into yorkie-team:main Jul 23, 2024
3 checks passed
@devleejb
Copy link
Member

@minai621
Since html-pdf-node has Puppeteer as a dependency, it requires the installation of Chromium. For now, we will add this to the installation script, but we should consider implementing an alternative solution in the future.

@coderabbitai coderabbitai bot mentioned this pull request Oct 1, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Document Export Functionality
2 participants