Skip to content

feat(renderer): add echarts diagram block rendering - #4158

Open
heartacker wants to merge 6 commits into
iOfficeAI:mainfrom
heartacker:feat/echarts-render
Open

feat(renderer): add echarts diagram block rendering#4158
heartacker wants to merge 6 commits into
iOfficeAI:mainfrom
heartacker:feat/echarts-render

Conversation

@heartacker

Copy link
Copy Markdown
Contributor

Pull Request

Description

This PR adds support for rendering Apache ECharts code blocks in markdown (echarts, echart, chart), providing dynamic theme synchronization, responsive resizing, and a unified toolbar UX.

Key features:

  1. Lenient Option Parsing (echartsUtils.ts):
    • Strips JavaScript wrappers (option = { ... }, const option = ...;, export default ...).
    • Parses JSON5 with unquoted keys, single quotes, comments, and trailing commas.
    • Guards non-ECharts code blocks with isLikelyEChartsOption before attempting rendering.
  2. Interactive Rendering (EchartsBlock.tsx):
    • Automatically adapts between light and dark modes (isDark).
    • Automatically handles container resizing via ResizeObserver.
    • Supports fallback to syntax-highlighted source code on parse/render errors.
  3. Unified Toolbar UI/UX:
    • Aligns header layout with MermaidBlock and WavedromBlock (<echarts> tag, Preview / Source toggle links, error indicators, PreviewOpen panel button, and Copy button).
  4. i18n & Bundling:
    • Added translations across all 11 supported locales.
    • Configured echarts and zrender into dedicated vendor chunk in electron.vite.config.ts.

Type of Change

  • feat — New feature (non-breaking change which adds functionality)

Atomic PR Checklist (Rule 1)

  • This PR contains exactly one feature or bug fix that cannot be further decomposed
  • The PR title follows Conventional Commit format: <type>(<scope>): <subject> (English)

Local Checks (Rule 3)

  • bun run format — formatting passes
  • bun run lint — no lint errors
  • bunx tsc --noEmit — no type errors
  • bunx vitest run — tests pass
  • i18n validated (bun run i18n:types + node scripts/check-i18n.js)
  • New/changed user-facing text uses i18n keys (no hardcoded strings)

Runtime Verification

  • Verified on Linux
  • I have performed a self-review of my own code

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

@heartacker

Copy link
Copy Markdown
Contributor Author

ready

image

@heartacker
heartacker force-pushed the feat/echarts-render branch from d89e9c2 to fc8df7e Compare August 24, 2026 13:11
@heartacker

Copy link
Copy Markdown
Contributor Author

rebase done.

@heartacker
heartacker force-pushed the feat/echarts-render branch from fc8df7e to 14be935 Compare August 26, 2026 03:03
The fresh-diagram reset ran in a separate [svg] passive effect, which on
slow CI runners could flush after a user's first zoom click and silently
swallow the scale change. Move the reset inline next to setSvg so it lands
in the same commit as the rendered diagram.
@heartacker
heartacker force-pushed the feat/echarts-render branch from c6ce9d0 to acd8bd8 Compare August 29, 2026 08:13
@heartacker

Copy link
Copy Markdown
Contributor Author

@piorpua

@heartacker

Copy link
Copy Markdown
Contributor Author

@claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant