Transform this code into an obsidian clone. Keep it in a single file. Again, first time opening the app ask me for selecting a folder / vault… then, each note i create it's stored in that folder as .txt, the saving it's automatically.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Sidebar: Contains buttons to select the vault and create new notes, along with a list of existing notes.
Content Area: Displays the selected note's title and content for editing.
Vault Selection:
On the first launch, the app prompts the user to select a folder that will act as the vault.
The selected vault path is saved in localStorage for future sessions.
Note Management:
Listing Notes: All .txt files in the vault are listed in the sidebar. If no notes are present, a message prompts the user to create one.
Creating Notes: Clicking the "Create New Note" button prompts the user for a note name, sanitizes it, creates a corresponding .txt file, and opens it for editing.
Opening Notes: Clicking on a note in the list opens it in the content area, displaying the title and content. Changes are saved automatically with a debounce mechanism to prevent excessive writes.
Renaming Notes: Changing the title in the input field renames the underlying .txt file accordingly.
Auto-Save Functionality:
The app listens for input events in both the title and content fields.
Changes are saved automatically after 1 second of inactivity, ensuring that user edits are preserved without manual intervention.
File Operations:
Tauri APIs: The app uses Tauri's fs (filesystem) and path modules to interact with the local filesystem, enabling reading, writing, and renaming of files.
Error Handling: Basic error handling is implemented to log any issues during file operations.
Deployment with Tauri
To make this application fully functional as a desktop app using Tauri, follow these steps:
Initialize a new Tauri project and replace the default index.html with the provided code.
Adjust Permissions:
Modify the tauri.conf.json to allow filesystem access, ensuring the app can read and write to user-selected directories.
Build the Application:
Use Tauri's build commands to compile the application for your target operating system.
This implementation provides a foundational structure for a note-taking app similar to Obsidian. You can further enhance it by adding features like markdown support, search functionality, tagging, and more advanced UI components as per your requirements.