#299 Centralized file handling mechanism and .txt support#317
Closed
Ayuyyae wants to merge 4 commits intocodexu:devfrom
Ayuyyae:dev
Closed
#299 Centralized file handling mechanism and .txt support#317Ayuyyae wants to merge 4 commits intocodexu:devfrom Ayuyyae:dev
Ayuyyae wants to merge 4 commits intocodexu:devfrom
Ayuyyae:dev
Conversation
This commit introduces a new extensible file format support system, allowing for easier integration of various file types (e.g., .txt, .json) into the NoteGen application. Key changes include: - Introduced a `FileHandler` interface for modular file type handling. - Implemented `markdown.tsx` and `text.tsx` handlers for Markdown and plain text files. - Refactored `src/stores/article.ts` to use the new `FileHandler` for reading and saving content. - Created `VditorEditorWrapper.tsx` to encapsulate Vditor's lifecycle and logic. - Updated `src/app/core/article/md-editor.tsx` to dynamically render editors based on file type. - Cleaned up unused imports and variables across the codebase. - Fixed various linting and TypeScript compilation errors. - Added a PRD document in `guide/file_format_support.md` detailing the new architecture.
Updated project version in package.json and src-tauri/tauri.conf.json to 0.20.0 to reflect new features and align with upstream versioning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature #299: Centralized File Handling and Enhanced .txt Support
This pull request introduces a new centralized file handling mechanism and significantly enhances support for plain text (
.txt) files, addressing feature request #299.Description of Change
This update refactors how different file types are handled within the editor. A new centralized file handler system has been implemented, allowing the application to dynamically select the appropriate editor component based on the file's extension.
Specifically for
.txtfiles, dedicated support has been added:src/lib/fileHandlers/text.tsx) is introduced to specifically manage.txtfiles..txtfiles now utilizes the sameVditorEditorWrappercomponent used for Markdown files. Crucially, the previous filtering logic that removed certain toolbar options for.txtfiles has been eliminated. This ensures that.txtfiles now display the full set of editor toolbar options, identical to those available for.mdfiles, providing a consistent and rich editing experience.Implementation Details
src/app/core/article/md-editor.tsx: Modified to use agetFileHandlerfunction to dynamically load the correct editor component based on theactiveFilePath. This establishes the centralized file handling.src/lib/fileHandlers/text.tsx: New file handler specifically for.txtfiles, defining how they are loaded, saved, and which editor component (VditorEditorWrapperintextmode) should be used.src/lib/fileHandlers/markdown.tsx: Updated to align with the new file handler structure.src/components/VditorEditorWrapper.tsx: The conditional logic that previously filtered toolbar items formode='text'was removed, ensuring a unified toolbar for both.mdand.txtfiles.src/stores/article.ts: Minor adjustments to support the new file handling flow.No new UI visuals or styles were altered. The modifications are primarily functional, enhancing the application's architecture and user experience.
Impact
.txtfiles, including a full-featured toolbar.Testing Notes
This feature has been verified by testing both
.mdand.txtfiles in the application. The following was confirmed:.txtfiles, applying the correct formatting..txtfiles persists changes correctly.