feat: support brf export in braille mode#419
Conversation
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to export the current braille output as an ASCII BRF (Braille Ready Format) file. Users can trigger this export using Ctrl+S when in braille mode.
Key Changes:
- Added a new keybinding (Ctrl+S) for exporting braille to BRF format
- Implemented braille-to-ASCII conversion logic with proper character mapping
- Created a new command to handle the export functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/state/viewModel/brailleViewModel.ts | Added export functionality and braille-to-ASCII conversion method |
| src/service/keybinding.ts | Added EXPORT_TO_BRF keybinding (Ctrl+S) and reformatted ALLOW_DEFAULT |
| src/command/toggle.ts | Created ToggleExport command to handle the export operation |
| src/command/factory.ts | Registered the new ToggleExport command and reformatted existing code |
| public ExportBraille(braille: string): void { | ||
| // trigger download of current braille | ||
| const ascii = this.brailleToAscii(braille); | ||
| const blob = new Blob([ascii], { type: 'text/plain;charset=utf-8' }); | ||
| const url = URL.createObjectURL(blob); | ||
| const a = document.createElement('a'); | ||
| a.href = url; | ||
| a.download = 'braille.brf'; | ||
| a.click(); | ||
| URL.revokeObjectURL(url); | ||
| } |
There was a problem hiding this comment.
This method contains UI manipulation logic (DOM element creation and triggering downloads) which violates the layered architecture. ViewModels should not directly manipulate the DOM. This functionality should be moved to a service layer or handled through proper UI layer delegation.
Pull Request
Description
Added an exporter to save an ascii brf of the current braille output
Related Issues
Fixes #405