src/lib/components/Editor.svelte is carrying too many responsibilities in one component. On my checkout it is about 9,700 lines and includes TipTap setup/extensions, markdown conversion, source-mode behavior, file paste/drop handling, context menus, history UI, AI actions, embedded renderers, and a large style block.
This is worth refactoring because it would make editor changes safer, reviews smaller, and future features easier to land without accidental regressions. The goal should not be a rewrite. It should be a gradual extraction of stable responsibilities while keeping behavior unchanged.
Suggested approach:
- Keep
Editor.svelte as the orchestration layer for now.
- Extract one responsibility per PR: pure helpers first, then TipTap extensions, then focused UI pieces such as context menus.
- Add focused tests around extracted logic where practical.
- Treat each PR as behavior-preserving unless maintainers explicitly agree to a behavior change.
To avoid breaking functionality, each refactor PR should verify the relevant editor paths, especially:
- rich text and source mode save/reload behavior
- switching between rich text and source mode
- title/H1 handling
- links, images, PDFs, attachments, tables, task lists, code blocks, math, mermaid, details, and secret blocks
- slash commands, context menus, paste/drop, history restore, and AI apply flows
Would you be open to this direction if it comes as small, reviewable PRs rather than one large editor rewrite? I can start with the lowest-risk extraction and include the relevant checks with it.
`src/lib/components/Editor.svelte` is carrying too many responsibilities in one component. On my checkout it is about 9,700 lines and includes TipTap setup/extensions, markdown conversion, source-mode behavior, file paste/drop handling, context menus, history UI, AI actions, embedded renderers, and a large style block.
This is worth refactoring because it would make editor changes safer, reviews smaller, and future features easier to land without accidental regressions. The goal should not be a rewrite. It should be a gradual extraction of stable responsibilities while keeping behavior unchanged.
Suggested approach:
1. Keep `Editor.svelte` as the orchestration layer for now.
2. Extract one responsibility per PR: pure helpers first, then TipTap extensions, then focused UI pieces such as context menus.
3. Add focused tests around extracted logic where practical.
4. Treat each PR as behavior-preserving unless maintainers explicitly agree to a behavior change.
To avoid breaking functionality, each refactor PR should verify the relevant editor paths, especially:
- rich text and source mode save/reload behavior
- switching between rich text and source mode
- title/H1 handling
- links, images, PDFs, attachments, tables, task lists, code blocks, math, mermaid, details, and secret blocks
- slash commands, context menus, paste/drop, history restore, and AI apply flows
Would you be open to this direction if it comes as small, reviewable PRs rather than one large editor rewrite? I can start with the lowest-risk extraction and include the relevant checks with it.