How ytssamuel/md_editor works
Project Type and Purpose
• This is a single‐page, front-end only Markdown editor (“md_editor”).
• It consists of static assets (HTML/CSS) and a set of JavaScript modules that handle file I/O, markdown parsing, UI updates, and modal dialogs.
High-Level Components
a. Presentation Layer
• index.html – the container for the editor and preview panes
• styles/*.css – styling rules (variables, layout, components, markdown theme)
b. Application Logic (JavaScript Modules)
• scripts/main.js – bootstrapper; wires together UI events and core modules
• scripts/uiManager.js – orchestrates DOM updates (editor ↔ preview pane)
• scripts/markdownRenderer.js – parses Markdown to HTML (via in-browser library)
• scripts/fileHandler.js – handles “Open File” (FileReader API) and “Save File” (Blob + download link)
• scripts/modalManager.js – manages modals/prompts (e.g., “Unsaved changes?”)
Relationships & Interactions
• User → Browser UI (index.html)
• Typing in the editor triggers uiManager events
• Click “Open”/“Save” buttons invoke fileHandler
• “Settings” or warnings invoke modalManager
• uiManager → markdownRenderer
• On editor input or “Render” action, uiManager passes raw markdown text to markdownRenderer
• markdownRenderer returns HTML, uiManager injects it into the preview pane
• uiManager & modalManager
• Before destructive actions, uiManager asks modalManager to display confirmation
• fileHandler ↔ Browser File API
• fileHandler uses FileReader to load .md files and Blob + anchor download to save
Architectural Patterns & Principles
• Modular separation: each JavaScript file is a focused component (single responsibility)
• Event-driven flow: user actions trigger events that bubble through main → uiManager → other modules
• Layered presentation: HTML/CSS layers separated from business logic (JS)
Technologies & Frameworks
• Vanilla JavaScript (ES modules or namespace objects)
• In-browser Markdown library (e.g., marked.js or markdown-it)
• HTML5 File API (FileReader, Blob)
• CSS for styling; no front-end framework (React/Angular) detected