|
2 | 2 |
|
3 | 3 | ## High-Level Components |
4 | 4 |
|
5 | | -- UI Layer (React-based) |
6 | | -- Spreadsheet core logic |
7 | | -- Canvas renderer |
8 | | -- Formula evaluation |
9 | | -- Import/export subsystem |
10 | | -- PWA integration |
| 5 | +- React UI layer under `src/app`, `src/features`, and `src/shared`. |
| 6 | +- Spreadsheet core logic under `src/lib/core`. |
| 7 | +- Canvas rendering under `src/lib/rendering`. |
| 8 | +- UI-to-core adapter logic under `src/lib/UI.ts` and `src/features/sheet`. |
| 9 | +- Formula evaluation under `src/lib/core/formula`. |
| 10 | +- Native `.ows` document import/export helpers under `src/features/document-io`. |
| 11 | +- PWA integration through `src/registerServiceWorker.ts` and generated static assets. |
11 | 12 |
|
12 | 13 | ## Design Principles |
13 | 14 |
|
14 | 15 | - Keep spreadsheet logic independent from UI frameworks. |
15 | 16 | - Minimize coupling between rendering and business logic. |
16 | 17 | - Allow future UI migrations without rewriting the spreadsheet engine. |
| 18 | +- Keep React components small and composed by feature area. |
| 19 | +- Keep reusable UI primitives in `src/shared/ui`. |
| 20 | +- Keep Tailwind class composition in `src/app/styles.css`. |
| 21 | + |
| 22 | +## Runtime Flow |
| 23 | + |
| 24 | +1. `src/main.ts` mounts the React app. |
| 25 | +2. `src/app/App.tsx` owns top-level UI state for file mode, selection, formula bar value, and active appearance. |
| 26 | +3. `SpreadsheetSurface` creates the existing `UI` adapter with a DOM element. |
| 27 | +4. `UI` creates the canvas renderer and a `UIHandlerController`. |
| 28 | +5. Ribbon and formula bar actions call `UI.execCmd`, which forwards commands to the spreadsheet core. |
| 29 | +6. The core document emits changes back through `UI.addOnChangeEventListener`, and React updates the ribbon/formula state. |
17 | 30 |
|
18 | 31 | ## Future Direction |
19 | 32 |
|
20 | | -A future React migration should focus on the UI layer only while preserving the existing spreadsheet core. |
| 33 | +Advanced formula support, OpenDocument import/export, and richer spreadsheet interactions should extend the core APIs first, then expose those capabilities through the React features. |
0 commit comments