Skip to content

Commit 1104dd4

Browse files
committed
feat: ECharts chart system with 11 gallery templates + Spaces feature
Charts: - New {{Chart:}} DocGen tag — 7 declarative types + raw ECharts JS code mode - chart-docgen.js (~720 lines): parser, builder, transformer, DOM binding - chart-docgen.css + echarts.css: card layout, dark mode styling - ECharts lazy-loaded from CDN via window.getECharts() - 📊 Chart toolbar button, composer chip, mobile integration - 11 gallery templates: Line, Bar, Pie, Scatter, Sunburst, Treemap, Advanced, Sankey, Parallel, Graph (~4,200 lines) - New Charts template category with bi-bar-chart-line icon Spaces: - Personal document hub with email-based ownership + access key recovery - space-manager.js (~760 lines): CRUD, Firestore sync, hub rendering - spaces.css (~540 lines): glassmorphic modal UI, dark mode - Firestore /spaces/{spaceId} rules: field validation, write-token, 50-item limit - Spaces modal (create/recover/manage), share integration, #space=<slug> routing
1 parent b615a44 commit 1104dd4

25 files changed

+6237
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ TextAgent has undergone significant evolution since its inception. What started
538538

539539
| Date | Commits | Feature / Update |
540540
|------|---------|-----------------:|
541+
| **2026-03-27** | | 📊 **ECharts Chart System** — new `{{Chart:}}` DocGen tag with 7 declarative chart types (bar, line, pie, scatter, radar, gauge, heatmap) and raw ECharts JS code mode; `chart-docgen.js` (~720 lines) parser/builder/transformer; `chart-docgen.css` + `echarts.css` styling; lazy-loaded ECharts CDN via `window.getECharts()`; 📊 Chart toolbar button, composer chip, mobile integration; 11 chart gallery templates (Line, Bar, Pie, Scatter, Sunburst, Treemap, Advanced, Sankey, Parallel, Graph) with ~4,200 lines of copy-paste-ready examples; new Charts template category |
542+
| **2026-03-27** | | 📂 **Spaces** — personal document hub with email-based ownership and access key recovery; `space-manager.js` (~760 lines) CRUD, Firestore sync, hub rendering; `spaces.css` (~540 lines) glassmorphic modal UI; Spaces modal with create/recover/manage views; "Add to Space" picker in share modal; `#space=<slug>` URL routing; Firestore `/spaces/{spaceId}` collection rules with field validation, write-token ownership, 50-item limit |
541543
| **2026-03-27** | | 📊 **Chart Bug Fixes** — fixed 6 bugs in `{{Chart:}}` DocGen: ECharts memory leak (old instances never disposed on re-render), `@code` brace-depth tracker desyncing on braces inside strings/comments, `stripTypeScript` regex mangling valid JS object values, fragile `- 2` insert offset in Add Series, confusing area-style default logic, and block index desync from re-parsing `fullMatch` substrings; extracted `parseConfigFromBody()` shared helper; added `M._activeCharts` disposal tracking |
542544
| **2026-03-26** | | 🔊 **Kokoro TTS Fixes** — patched Kokoro-JS `generate_from_ids` in `tts-worker.js` to manually slice Float32 arrays and explicitly construct `style` and `speed` Tensors, preventing runtime shape errors for non-English voices; added voice file fallback mechanism to automatically fetch from `onnx-community` if the primary `textagent` HuggingFace org is missing the binary |
543545
| **2026-03-26** | | 🎓 **Quiz DocGen** — new `{{@Quiz:}}` declarative tag for interactive quizzes in markdown; 9 question types (MCQ, True/False, Fill-in-blank, Match, Order, Short, Essay, Likert, Multi-select); dual modes: Practice (Duolingo-style instant feedback) and Test (free navigation, no answers revealed); user info screen with email format validation; gamified HUD (XP, hearts, progress bar, stars); response viewer with NEEDS REVIEW badges, ✅ Correct / ❌ Wrong grade toggle for manual grading, live score recalculation; mobile touch support for match and order drag-drop; 8 quiz templates across 7 domains (Maths, Science, History, English, CS, Geography, Biology); `quiz-docgen.js` (~1100 lines), `quiz-docgen.css` (~690 lines), `form-engine.js` response viewer enhancements |
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ECharts Chart System & Spaces Feature
2+
3+
- New `{{Chart:}}` DocGen tag with 7 declarative chart types (bar, line, pie, scatter, radar, gauge, heatmap) and raw ECharts JS code mode
4+
- Added `chart-docgen.js` (~720 lines) — parser, builder, transformer, and DOM binding for interactive chart cards
5+
- Added `chart-docgen.css` (~130 lines) — card layout, badges, actions, Add Series dropdown, dark mode
6+
- Added `echarts.css` (~40 lines) — base container styling for ECharts instances
7+
- Added ECharts lazy-loader in `vendor-globals.js` (`window.getECharts()` — CDN script injection)
8+
- Added 📊 Chart toolbar button, composer chip, and mobile toolbar integration in `index.html`
9+
- New Charts template category (`bi-bar-chart-line` icon) in template modal and template system
10+
- 11 chart gallery templates: Line, Bar, Pie, Scatter, Sunburst, Treemap, Advanced (Radar/Gauge/Heatmap/Funnel), Sankey, Parallel, Graph — totaling ~4,200 lines of ECharts examples
11+
- Template loading pipeline updated in `src/main.js` and `js/templates.js` to register all chart galleries
12+
- New Spaces feature — personal document hub with email-based ownership and access key recovery
13+
- Added `space-manager.js` (~760 lines) — CRUD, Firestore sync, share integration, hub rendering
14+
- Added `spaces.css` (~540 lines) — modal UI, cards, glassmorphism, dark mode
15+
- Firestore rules updated with `/spaces/{spaceId}` collection (create/update/read with field validation, write-token ownership)
16+
- Spaces modal HTML added to `modal-templates.js` with create/recover/manage views
17+
- Spaces buttons in header toolbar, mobile menu, and QAB in `index.html`
18+
- "Add to Space" picker integrated into share result modal
19+
- Storage key `SPACES` added to `storage-keys.js`
20+
- Space hub routing via `#space=<slug>` in `cloud-share.js`
21+
22+
---
23+
24+
## Summary
25+
Two major features: (1) a complete ECharts `{{Chart:}}` DocGen tag system with declarative chart types, raw JS code mode, 11 gallery templates (~4,200 lines of examples), lazy-loaded ECharts CDN, and full toolbar/composer integration; (2) a Spaces feature providing personal document hubs with Firestore-backed ownership, email access key recovery, share integration, and hub rendering.
26+
27+
---
28+
29+
## 1. ECharts Chart DocGen System
30+
**Files:** `js/chart-docgen.js`, `css/chart-docgen.css`, `css/echarts.css`, `src/vendor-globals.js`, `index.html`, `js/templates.js`, `src/main.js`
31+
**What:** Full `{{Chart:}}` tag pipeline: parser extracts `@type`, `@xAxis`, `@series`, `@code` fields; builder produces ECharts option JSON; transformer converts tags into interactive preview cards with type badges, title, Add Series dropdown, and remove button. ECharts loaded lazily from CDN via `window.getECharts()`. Toolbar 📊 Chart button, composer chip, and mobile toolbar button wired in `index.html`.
32+
**Impact:** Users can create interactive ECharts visualizations using simple declarative syntax or raw JS code directly in markdown documents.
33+
34+
## 2. Chart Gallery Templates
35+
**Files:** `js/templates/charts.js`, `js/templates/charts-line-gallery.js`, `js/templates/charts-bar-gallery.js`, `js/templates/charts-pie-gallery.js`, `js/templates/charts-scatter-gallery.js`, `js/templates/charts-sunburst-gallery.js`, `js/templates/charts-treemap-gallery.js`, `js/templates/charts-advanced-gallery.js`, `js/templates/charts-sankey-gallery.js`, `js/templates/charts-parallel-gallery.js`, `js/templates/charts-graph-gallery.js`
36+
**What:** 11 template files providing copy-paste-ready chart examples spanning all major ECharts visualization types. Each gallery contains 5-25+ variations (basic, styled, stacked, animated, etc.). New `charts` template category registered in `templates.js` with `bi-bar-chart-line` icon.
37+
**Impact:** Comprehensive chart template library enables zero-code chart creation for all common chart types.
38+
39+
## 3. Spaces Feature
40+
**Files:** `js/space-manager.js`, `css/spaces.css`, `js/modal-templates.js`, `js/cloud-share.js`, `js/storage-keys.js`, `firestore.rules`, `index.html`, `src/main.js`
41+
**What:** Personal document hub system with CRUD operations backed by Firestore. Email-based ownership with access key recovery. Spaces modal with create/recover/manage views. "Add to Space" picker in share modal. Space hub rendering via `#space=<slug>` URL routing. Firestore rules enforce field validation, write-token ownership, 50-item limit, and delete protection.
42+
**Impact:** Users can organize and share curated collections of documents as browsable "Space" pages.
43+
44+
---
45+
46+
## Files Changed (20 total)
47+
48+
| File | Lines Changed | Type |
49+
|------|:---:|------|
50+
| `js/chart-docgen.js` | +720 | New — chart parser/builder/transformer |
51+
| `css/chart-docgen.css` | +129 | New — chart card styling |
52+
| `css/echarts.css` | +38 | New — ECharts container base styling |
53+
| `js/templates/charts.js` | +701 | New — Chart overview templates |
54+
| `js/templates/charts-line-gallery.js` | +498 | New — Line chart gallery |
55+
| `js/templates/charts-bar-gallery.js` | +524 | New — Bar chart gallery |
56+
| `js/templates/charts-pie-gallery.js` | +510 | New — Pie chart gallery |
57+
| `js/templates/charts-scatter-gallery.js` | +464 | New — Scatter chart gallery |
58+
| `js/templates/charts-sunburst-gallery.js` | +312 | New — Sunburst chart gallery |
59+
| `js/templates/charts-treemap-gallery.js` | +314 | New — Treemap chart gallery |
60+
| `js/templates/charts-advanced-gallery.js` | +355 | New — Advanced chart gallery |
61+
| `js/templates/charts-sankey-gallery.js` | +267 | New — Sankey chart gallery |
62+
| `js/templates/charts-parallel-gallery.js` | +153 | New — Parallel chart gallery |
63+
| `js/templates/charts-graph-gallery.js` | +356 | New — Graph chart gallery |
64+
| `js/space-manager.js` | +763 | New — Spaces CRUD & rendering |
65+
| `css/spaces.css` | +544 | New — Spaces modal styling |
66+
| `index.html` | +16 | Modified — toolbar/chip/modal additions |
67+
| `js/templates.js` | +15 | Modified — chart gallery registration |
68+
| `src/main.js` | +21 | Modified — module imports |
69+
| `src/vendor-globals.js` | +12 | Modified — ECharts lazy-loader |
70+
| `js/modal-templates.js` | +116 | Modified — Spaces modal + Charts category |
71+
| `js/cloud-share.js` | +23 | Modified — Space hub routing |
72+
| `js/storage-keys.js` | +3 | Modified — SPACES key |
73+
| `firestore.rules` | +29 | Modified — Spaces collection rules |

css/chart-docgen.css

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/* ============================================
2+
Chart DocGen Tag Styles
3+
============================================ */
4+
.chart-dg-card {
5+
margin: 16px 0;
6+
border-radius: 12px;
7+
overflow: hidden;
8+
border: 1px solid var(--border-color, #334155);
9+
background: var(--card-bg, #1e293b);
10+
}
11+
12+
.chart-dg-header {
13+
display: flex;
14+
align-items: center;
15+
gap: 8px;
16+
padding: 12px 16px;
17+
border-bottom: 1px solid rgba(255,255,255,0.06);
18+
flex-wrap: wrap;
19+
}
20+
21+
.chart-dg-icon {
22+
font-size: 1.2em;
23+
}
24+
25+
.chart-dg-title {
26+
font-weight: 600;
27+
color: #e2e8f0;
28+
font-size: .95em;
29+
}
30+
31+
.chart-dg-badges {
32+
display: flex;
33+
gap: 6px;
34+
margin-left: auto;
35+
}
36+
37+
.chart-dg-type-badge,
38+
.chart-dg-series-badge {
39+
font-size: .72em;
40+
padding: 2px 8px;
41+
border-radius: 20px;
42+
background: rgba(99,102,241,0.15);
43+
color: #a5b4fc;
44+
border: 1px solid rgba(99,102,241,0.3);
45+
text-transform: capitalize;
46+
}
47+
48+
.chart-dg-series-badge {
49+
background: rgba(34,197,94,0.15);
50+
color: #86efac;
51+
border-color: rgba(34,197,94,0.3);
52+
}
53+
54+
.chart-dg-actions {
55+
display: flex;
56+
gap: 6px;
57+
}
58+
59+
.chart-dg-remove {
60+
background: none;
61+
border: none;
62+
color: #64748b;
63+
font-size: 1em;
64+
cursor: pointer;
65+
padding: 4px 8px;
66+
border-radius: 6px;
67+
transition: all .2s;
68+
}
69+
.chart-dg-remove:hover {
70+
background: rgba(239,68,68,0.15);
71+
color: #f87171;
72+
}
73+
74+
/* ── Add Series button ── */
75+
.chart-dg-add-wrap {
76+
padding: 8px 16px 12px;
77+
}
78+
79+
.chart-dg-add-btn {
80+
width: 100%;
81+
padding: 8px;
82+
background: rgba(99,102,241,0.08);
83+
color: #a5b4fc;
84+
border: 1px dashed rgba(99,102,241,0.3);
85+
border-radius: 8px;
86+
cursor: pointer;
87+
font-size: .85em;
88+
transition: all .2s;
89+
}
90+
.chart-dg-add-btn:hover {
91+
background: rgba(99,102,241,0.15);
92+
border-color: #6366f1;
93+
}
94+
95+
.chart-dg-add-dropdown {
96+
display: grid;
97+
grid-template-columns: repeat(2, 1fr);
98+
gap: 6px;
99+
margin-top: 8px;
100+
}
101+
102+
.chart-dg-add-option {
103+
display: flex;
104+
align-items: center;
105+
gap: 8px;
106+
padding: 8px 12px;
107+
background: rgba(255,255,255,0.04);
108+
border: 1px solid rgba(255,255,255,0.08);
109+
border-radius: 8px;
110+
color: #cbd5e1;
111+
cursor: pointer;
112+
font-size: .82em;
113+
transition: all .2s;
114+
}
115+
.chart-dg-add-option:hover {
116+
background: rgba(99,102,241,0.12);
117+
border-color: rgba(99,102,241,0.3);
118+
color: #e2e8f0;
119+
}
120+
121+
.chart-dg-add-icon { font-size: 1.2em; }
122+
.chart-dg-add-label { font-weight: 500; }
123+
124+
/* Ensure echarts-container inside a chart-dg-card has no extra margin */
125+
.chart-dg-card > .echarts-container {
126+
margin: 0;
127+
border: none;
128+
border-radius: 0;
129+
}

css/echarts.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* ============================================
2+
ECharts Container Styles
3+
============================================ */
4+
.echarts-container {
5+
margin: 16px 0;
6+
border-radius: 12px;
7+
overflow: hidden;
8+
border: 1px solid var(--border-color, #334155);
9+
background: var(--card-bg, #1e293b);
10+
}
11+
12+
.echarts-chart {
13+
min-height: 300px;
14+
}
15+
16+
.echarts-source {
17+
padding: 0 12px 12px;
18+
}
19+
20+
.echarts-source summary {
21+
cursor: pointer;
22+
font-size: .85em;
23+
color: #94a3b8;
24+
padding: 8px 0;
25+
user-select: none;
26+
transition: color .2s;
27+
}
28+
29+
.echarts-source summary:hover {
30+
color: #e2e8f0;
31+
}
32+
33+
.echarts-source pre {
34+
margin: 8px 0 0;
35+
border-radius: 8px;
36+
max-height: 300px;
37+
overflow: auto;
38+
}

0 commit comments

Comments
 (0)