[PR #317] [CLOSED] #299 Centralized file handling mechanism and .txt support #721

Closed
opened 2026-03-02 03:41:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/codexu/note-gen/pull/317
Author: @Ayuyyae
Created: 6/30/2025
Status: Closed

Base: devHead: dev


📝 Commits (4)

  • 73e9515 feat: Implement extensible file format support
  • 93c23ac Merge branch 'codexu:dev' into dev
  • e0da571 chore: Update version to 0.20.0
  • dbc9df1 docs: Update guide documentation for file format support

📊 Changes

16 files changed (+837 additions, -482 deletions)

View changed files

📝 .eslintrc.json (+5 -1)
.git_commit_message.txt (+4 -0)
guide/feature_299_txt_toolbar_support.md (+37 -0)
guide/file_format_support.md (+234 -0)
📝 package.json (+1 -1)
📝 src-tauri/tauri.conf.json (+1 -1)
📝 src/app/core/article/custom-footer/index.tsx (+4 -4)
📝 src/app/core/article/custom-toolbar/index.tsx (+8 -8)
📝 src/app/core/article/md-editor.tsx (+17 -458)
src/components/VditorEditorWrapper.tsx (+431 -0)
src/lib/fileHandlers/index.ts (+13 -0)
src/lib/fileHandlers/markdown.tsx (+17 -0)
src/lib/fileHandlers/text.tsx (+26 -0)
src/lib/fileHandlers/types.ts (+16 -0)
📝 src/stores/article.ts (+22 -9)
📝 tsconfig.json (+1 -0)

📄 Description

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 .txt files, dedicated support has been added:

  1. Dedicated File Handler: A new file handler (src/lib/fileHandlers/text.tsx) is introduced to specifically manage .txt files.
  2. Unified Editor Experience: The editor for .txt files now utilizes the same VditorEditorWrapper component used for Markdown files. Crucially, the previous filtering logic that removed certain toolbar options for .txt files has been eliminated. This ensures that .txt files now display the full set of editor toolbar options, identical to those available for .md files, providing a consistent and rich editing experience.

Implementation Details

  • src/app/core/article/md-editor.tsx: Modified to use a getFileHandler function to dynamically load the correct editor component based on the activeFilePath. This establishes the centralized file handling.
  • src/lib/fileHandlers/text.tsx: New file handler specifically for .txt files, defining how they are loaded, saved, and which editor component (VditorEditorWrapper in text mode) 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 for mode='text' was removed, ensuring a unified toolbar for both .md and .txt files.
  • 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

  • Improved Architecture: The introduction of a centralized file handler makes the system more modular and extensible for future file types.
  • Enhanced .txt Support: Users will now have a comprehensive and consistent editing experience for .txt files, including a full-featured toolbar.
  • Unified User Experience: Provides a seamless editing environment across different text-based file formats.
  • No Visual Changes: The aesthetic and layout of the editor and toolbar remain unchanged.
  • Robustness: The changes are targeted and designed to integrate smoothly with existing components.

Testing Notes

This feature has been verified by testing both .md and .txt files in the application. The following was confirmed:

  1. Both file types open correctly within the editor.
  2. Their respective editor toolbars display the same set of options.
  3. All toolbar functions (e.g., bold, italic, headings, lists) work as expected on .txt files, applying the correct formatting.
  4. Saving and reopening .txt files persists changes correctly.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/codexu/note-gen/pull/317 **Author:** [@Ayuyyae](https://github.com/Ayuyyae) **Created:** 6/30/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (4) - [`73e9515`](https://github.com/codexu/note-gen/commit/73e951527be7cb89171f6a21c6d211928fdc131f) feat: Implement extensible file format support - [`93c23ac`](https://github.com/codexu/note-gen/commit/93c23ac95592fe4cf1bc5f1d006b273c15791153) Merge branch 'codexu:dev' into dev - [`e0da571`](https://github.com/codexu/note-gen/commit/e0da571b9291d7e9edc30f40bce4dc27feba527b) chore: Update version to 0.20.0 - [`dbc9df1`](https://github.com/codexu/note-gen/commit/dbc9df1ade7b92391a968f797c99b6690455d884) docs: Update guide documentation for file format support ### 📊 Changes **16 files changed** (+837 additions, -482 deletions) <details> <summary>View changed files</summary> 📝 `.eslintrc.json` (+5 -1) ➕ `.git_commit_message.txt` (+4 -0) ➕ `guide/feature_299_txt_toolbar_support.md` (+37 -0) ➕ `guide/file_format_support.md` (+234 -0) 📝 `package.json` (+1 -1) 📝 `src-tauri/tauri.conf.json` (+1 -1) 📝 `src/app/core/article/custom-footer/index.tsx` (+4 -4) 📝 `src/app/core/article/custom-toolbar/index.tsx` (+8 -8) 📝 `src/app/core/article/md-editor.tsx` (+17 -458) ➕ `src/components/VditorEditorWrapper.tsx` (+431 -0) ➕ `src/lib/fileHandlers/index.ts` (+13 -0) ➕ `src/lib/fileHandlers/markdown.tsx` (+17 -0) ➕ `src/lib/fileHandlers/text.tsx` (+26 -0) ➕ `src/lib/fileHandlers/types.ts` (+16 -0) 📝 `src/stores/article.ts` (+22 -9) 📝 `tsconfig.json` (+1 -0) </details> ### 📄 Description # 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 `.txt` files, dedicated support has been added: 1. **Dedicated File Handler:** A new file handler (`src/lib/fileHandlers/text.tsx`) is introduced to specifically manage `.txt` files. 2. **Unified Editor Experience:** The editor for `.txt` files now utilizes the same `VditorEditorWrapper` component used for Markdown files. Crucially, the previous filtering logic that removed certain toolbar options for `.txt` files has been eliminated. This ensures that `.txt` files now display the full set of editor toolbar options, identical to those available for `.md` files, providing a consistent and rich editing experience. ## Implementation Details * **`src/app/core/article/md-editor.tsx`:** Modified to use a `getFileHandler` function to dynamically load the correct editor component based on the `activeFilePath`. This establishes the centralized file handling. * **`src/lib/fileHandlers/text.tsx`:** New file handler specifically for `.txt` files, defining how they are loaded, saved, and which editor component (`VditorEditorWrapper` in `text` mode) 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 for `mode='text'` was removed, ensuring a unified toolbar for both `.md` and `.txt` files. * **`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 * **Improved Architecture:** The introduction of a centralized file handler makes the system more modular and extensible for future file types. * **Enhanced .txt Support:** Users will now have a comprehensive and consistent editing experience for `.txt` files, including a full-featured toolbar. * **Unified User Experience:** Provides a seamless editing environment across different text-based file formats. * **No Visual Changes:** The aesthetic and layout of the editor and toolbar remain unchanged. * **Robustness:** The changes are targeted and designed to integrate smoothly with existing components. ## Testing Notes This feature has been verified by testing both `.md` and `.txt` files in the application. The following was confirmed: 1. Both file types open correctly within the editor. 2. Their respective editor toolbars display the same set of options. 3. All toolbar functions (e.g., bold, italic, headings, lists) work as expected on `.txt` files, applying the correct formatting. 4. Saving and reopening `.txt` files persists changes correctly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 03:41:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/note-gen#721
No description provided.