33 Commits

Author SHA1 Message Date
Gyula Halmos 2ac8bbbb06 Merge pull request #106 from lukilabs/fix/editor-link-script-regex
CI / test (push) Has been cancelled
fix: rewrite Editor link path resolution without regex
2026-05-06 12:53:19 +02:00
Gyula Halmos c97bb07371 fix: rewrite Editor link path resolution without regex
The regex literal in #105 got its backslashes consumed by the
surrounding template literal, producing "//index.html$|/$/" in the
deployed output. The "//" was parsed as a line comment, breaking the
entire inline <script type="module"> block with a syntax error and
disabling all client-side interactions (Editor link, Random Theme,
theme pills, mega-menu).

Replaced with endsWith/slice equivalent. Added a comment explaining
the template-literal interpolation pitfall to prevent the same
mistake on future inline scripts.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-05-06 12:52:43 +02:00
Gyula Halmos fa3ef7116a Merge pull request #105 from lukilabs/fix/editor-link-resolution
fix: resolve Editor link against current path
2026-05-06 12:49:32 +02:00
Gyula Halmos df4263a106 fix: resolve Editor link against current path
The relative href="editor" broke when the page URL had no trailing
slash (e.g. agents.craft.do/mermaid). The browser resolved it as a
sibling of the "mermaid" file, sending users to /editor on the
parent host instead of /mermaid/editor.

Now the script strips a trailing slash or /index.html from
location.pathname and appends "/editor", which works for:
  /             → /editor
  /index.html   → /editor
  /mermaid      → /mermaid/editor
  /mermaid/     → /mermaid/editor

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-05-06 12:47:54 +02:00
Gyula Halmos 092984cbe5 Merge pull request #104 from lukilabs/ui/add-editor-button
ui: add Editor button to hero, fix button row alignment
2026-05-06 12:43:12 +02:00
Gyula Halmos 5ee3947898 ui: normalize hero-btn line-height and box-sizing
The <button> element (Random Theme) was rendering at a slightly
different height than the <a> buttons because browsers apply
different user-agent defaults for line-height and box-sizing on
<button> vs <a>. Setting both explicitly forces all four to the
same rendered size.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-05-06 12:41:25 +02:00
Gyula Halmos 52ccdf7f87 ui: add Editor button to hero, fix button row alignment
- Adds a third secondary button linking to the live editor (relative
  href so it works under both / and /mermaid/ deploys).
- Switches .hero-buttons align-items from flex-start to center to
  remove subtle vertical drift between <a> and <button> elements.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-05-06 12:35:02 +02:00
Gyula Halmos e6a430fcc8 Merge pull request #103 from lukilabs/build/deploy-editor-page
build: include editor.html in deployed site
2026-05-06 12:16:56 +02:00
Gyula Halmos 6d82cc72c5 build: include editor.html in deployed site
The deploy pipeline only ran index.ts, so the live editor added in #97
never shipped to craft-agents-mermaid.pages.dev. Renamed build:samples
to build:site, added editor.ts to the build, and moved both index.html
and editor.html into site/ before deploy.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-05-06 09:52:42 +02:00
Gyula Halmos 2fc44e4340 Merge pull request #97 from tanishqkancharla/editor-styling
feat: live mermaid editor page
2026-05-05 16:12:20 +02:00
Tanishq Kancharla 611001069d style: match editor UI to Craft Agents design system
- Theme system: set CSS vars on :root, derive all colors via color-mix()
  with solid mixes (bg-based, never transparent). 4-tier text hierarchy
  (fg/fg2/fg3/fg4), split surface/hover levels.
- Theme dropdown: no item transitions, cursor:default, 4px item radius,
  5% fg hover tint, checkmark via ::after pseudo-element for active state.
- Export dropdown: same treatment (4px radius, 5% hover, no transitions).
- Preview panel: replaced header bar with floating toolbar — 'Preview'
  label (11px uppercase muted) on left, zoom controls in shadow-minimal
  pill on right. Toolbar-btn matches Craft's PanelHeaderCenterButton
  (opacity 0.5→1 on hover).
- Source panel: floating toolbar with 'Source' label + copy/trash buttons,
  hidden when Config tab is active.
- Config panel: section titles now match Craft SettingsSection style
  (14px semibold normal-case) instead of uppercase micro-labels.
- Fixed init crash: moved applyColorMode() to init.js after all DOM refs
  and functions are ready.
- Fixed theme application: set vars on document.documentElement (not body)
  so :root color-mix() expressions resolve correctly.
- All themes (Default, Catppuccin, Tokyo Night, Nord, Dracula, etc.)
  apply to full page chrome, not just diagrams.
2026-04-23 14:49:14 -07:00
maatheusgois-dd 4a179b8655 feat: live mermaid editor
Adds a live in-browser Mermaid editor alongside the existing samples
showcase, served by the existing dev server.

- Live editor under editor/ (modular CSS/JS: topbar, left/right panels,
  color + font pickers, samples, export, sharing, zoom/pan) wired through
  editor.ts.
- dev.ts: kept close to the original; / still serves the samples showcase,
  /editor serves the new editor, both get live reload via SSE.
- package.json gets an editor script.
- Architecture/change guide at .agents/skills/editor.md.

Scoped strictly to editor/infra - no changes under src/.

Made-with: Cursor
2026-04-17 15:39:33 -03:00
Balint Orosz 65f4e0ab8c v1.1.3: Fix xychart NaN colors when using CSS variable inputs
getSeriesColor() assumed hex color inputs but broke with CSS variable
refs like var(--accent), producing #NaNNaNNaN for series 1+ colors.
Now falls back to the default blue accent for color math when inputs
aren't valid hex.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-26 15:22:10 +01:00
Balint Orosz 0fae17b286 v1.1.2: Ship pre-built JS for webpack/vite/Node consumers
- Add tsup build step (ESM + declarations)
- Dual exports: Bun gets raw .ts, Node/webpack/vite get built .js
- Fix build:samples/deploy to use site/ (dist/ now for npm)
- Closes #45

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-26 14:58:57 +01:00
Balint Orosz 87707bc537 v1.1.1: Remove prepublishOnly hook, add tsup/typescript devDeps
Ship raw .ts source files directly — no build step needed for npm publish.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-26 14:09:12 +01:00
Balint Orosz b7c116169c Bump version to 1.1.0
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-26 14:06:05 +01:00
Tamas Flamich afa7e79f1c feat: xychart-beta diagram poc (#40)
* Add xychart-beta diagram support

Implement full parse → layout → render pipeline for Mermaid xychart-beta
diagrams including bar charts, line charts, combinations, horizontal mode,
multi-series with legends, and Chart.js-aligned proportions and palettes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add interactive hover tooltips for xychart data points

- Add 'interactive' option to RenderOptions
- Render CSS-based tooltips on bars and line points
- Pass category labels as data attributes for tooltip display
- Add integration tests and example SVGs

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* adding xycharts to sample ts

* progress with deisgning charts

* Added ASCII bar charts

* Add XY Charts documentation to README

- Update feature count from 5 to 6 diagram types
- Add XY Charts section with bar, line, combined, and horizontal examples
- Document axis configuration options (categorical, numeric, titles, ranges)
- Add XY Chart Styling section covering dot grid, rounded bars, smooth
  cubic spline curves, floating labels, monochromatic palette, interactive
  tooltips, and live theme switching via CSS custom properties
- Add ASCII XY Charts section documenting Unicode/ASCII block characters,
  staircase line routing, multi-series ANSI colors, and legend support
- Add `interactive` option to API Reference RenderOptions table
- Note xychart-beta auto-detection in API docs

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* Improve XY Charts: multi-series colors, tooltips, theme switching, ASCII rendering

- Add shared color palette (colors.ts) with monochromatic series shades
  derived from accent color with hue drift, adapting to light/dark backgrounds
- Refactor SVG renderer: dot grid background, rounded bars, smooth cubic
  spline curves, drop-shadow lines, interactive hover tooltips
- Support live theme switching for charts via CSS custom properties
  (--xychart-color-N) and data-xychart-colors attribute
- Improve ASCII xychart: multi-series colors, per-cell hex overrides,
  staircase line routing with rounded corners, legend support
- Export getSeriesColor and CHART_ACCENT_FALLBACK from browser bundle
  for client-side theme-switching of chart series colors
- Fix ASCII theme re-render targeting (ascii-N index correction)
- Update layout with dynamic y-axis label width and legend positioning
- Update samples and test data

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* Fix sequence diagram note overlap and improve note styling

Notes now position below self-message loops instead of inside them,
stack vertically when consecutive, and push subsequent messages down.
Note boxes use bg fill with dog-ear corner, content-fitted widths,
and increased label-to-arrow spacing.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* Fix TypeScript strict null errors in xychart modules

Add non-null assertions for array indexing patterns where indices are
guaranteed valid by loop bounds. Fixes CI tsc --noEmit failures.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Craft Agent <agents-noreply@craft.do>
Co-authored-by: Balint Orosz <balint.orosz@gmail.com>
2026-02-26 14:05:35 +01:00
Balint Orosz 9d722cf380 Fix CJK state names and text-embedded edge labels (#49)
- Fix stateDiagram parser regexes to support Unicode (CJK/Japanese/Korean)
  state names using \p{L} character class (closes #43)
- Add text-embedded edge label syntax: `-- Yes -->`, `-. Maybe .->`,
  `== Sure ==>` as fallback to pipe syntax (closes #32)
  Based on PR #36 by @liuxiaopai-ai — thank you!
- Add linkStyle, CJK, and text-embedded label samples to gallery
- Add 12 new parser tests

Co-authored-by: Craft Agent <agents-noreply@craft.do>
2026-02-26 14:03:43 +01:00
Armin Töpfer 3b382117b6 Add linkStyles support (#47)
Merge linkStyle support for inline edge styling
2026-02-26 13:29:12 +01:00
Balint Orosz 7e9dd6e78b v1.0.2: Remove DOM lib — use ambient declares for browser globals
Replace the "DOM" tsconfig lib workaround with module-scoped
`declare const` for the two browser globals (document, window).
This avoids pulling in the entire DOM type namespace for a library
that has zero DOM dependencies.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-23 18:19:17 +01:00
Balint Orosz 9833039093 fix: CI type checking — add @types/bun, DOM lib, fix test imports
- Add @types/bun devDependency for bun:test, node:fs, import.meta.dir types
- Add "DOM" to tsconfig lib for document/window references
- Set tsconfig types to ["@types/bun"] (was empty, blocking all types)
- Fix ascii-multiline.test.ts: vitest → bun:test import
- Fix sequence-layout.test.ts: non-null assertions on Map.get()

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-23 18:07:46 +01:00
Balint Orosz 026688ae04 v1.0.1: Layout quality improvements and layer alignment (#41)
* fix: edit dialog SVG rendering, source panel update, and close timing

- Make saveAndRender async to properly await renderMermaid (was showing
  [object Promise] instead of SVG)
- Update source panel code after edit (was showing stale Shiki output)
- Close dialog immediately before async render starts for better UX

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* feat: improved ELK layout quality and layer alignment

- Add centering (contentAlignment H_CENTER V_CENTER) for subgraphs
- Add BALANCED node placement (fixedAlignment) at root and subgraph level
- Add edge spacing options (edgeEdge, edgeEdgeBetweenLayers, edgeNodeBetweenLayers)
- Add high-degree node treatment (threshold 8)
- Add post-compaction and model order preservation (root-only, ELK 0.11.0 bug workaround)
- Add layer alignment post-processing to fix orthogonal routing node stagger
- Add edge bundling for fan-out/fan-in shared trunk paths with subgraph-aware junctions
- Internalize mergeEdges and thoroughness as non-configurable defaults

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

* chore: bump version to 1.0.1

Co-Authored-By: Craft Agent <agents-noreply@craft.do>

---------

Co-authored-by: Craft Agent <agents-noreply@craft.do>
2026-02-23 17:03:28 +01:00
Balint Orosz 02daec0ee8 v1.0.0: ELK.js layout, themeable ASCII, multiline labels, and more
Layout engine:
- Replace dagre with ELK.js (synchronous via FakeWorker bypass)
- Shape-aware edge clipping (diamond endpoints no longer overshoot)
- New layout options: nodeSpacing, layerSpacing, componentSpacing, thoroughness
- Disconnected component layout support
- Per-subgraph direction overrides (SEPARATE hierarchy mode)

SVG renderer:
- Multi-line labels with <br> tags in nodes, edges, and subgraph headers
- Inline formatting: <b>, <i>, <u>, <s> mapped to SVG attributes
- Variable-width text measurement (character-class buckets instead of fixed ratio)
- Semantic data-* attributes on all SVG elements (nodes, edges, subgraphs)
- Improved arrow markers (stroke + fill for crispness, adjusted refX)
- Better label pill backgrounds (increased stroke width, switched to --_text-sec)

ASCII renderer:
- Themeable output: ANSI 16/256/truecolor + HTML color modes
- AsciiTheme type with per-role colors (border, line, arrow, corner, junction)
- 12+ node shapes: rectangle, rounded, diamond, circle, hexagon, stadium,
  cylinder, doublecircle, subroutine, asymmetric, trapezoid, state start/end
- Multi-line label support (nodes and edges)
- Edge bundling for fan-in/fan-out patterns (TD direction)
- Diagonal line validation (assertNoDiagonals for test assertions)
- Multi-section boxes for class and ER diagrams
- Canvas role tracking for semantic colorization

Parser:
- <br> / <br/> / <br /> normalization in all label positions
- Composite state deduplication (no more ghost nodes)
- Bare node references no longer re-register into wrong subgraph

Styling:
- Increased node horizontal padding (16 to 20px)
- Increased connector stroke width (0.75 to 1)
- Increased group header content padding (8 to 12px)
- Arrow head height rounded (4.8 to 5)

Removed:
- dagre-adapter.ts (replaced by layout-engine.ts + elk-instance.ts)
- tsup.config.ts (no longer needed)

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-02-23 12:06:04 +01:00
Balint Orosz 3fcbb97eac Merge pull request #10 from peterc/fix-semicolon-line-separator
Fix parser to support semicolons as line separators
2026-01-29 22:18:26 +01:00
Balint Orosz f392f51261 Bump version to 0.1.3
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-01-29 21:05:11 +01:00
Danielle De Leo 165d681186 Add browser bundle for CDN script tag usage (#9)
- Add IIFE build target in tsup.config.ts that bundles all dependencies
- Update browser.ts to export all public APIs (renderMermaid, renderMermaidAscii, THEMES, etc.)
- Add unpkg and jsdelivr fields to package.json for automatic CDN support
- Document script tag usage in README with examples for both CDNs

Usage: <script src="https://unpkg.com/beautiful-mermaid/dist/beautiful-mermaid.browser.global.js"></script>
Exposes window.beautifulMermaid with all public APIs.
2026-01-29 21:04:49 +01:00
Will Dollman 68f3ab8c96 security: escape inline style values to prevent SVG attribute injection (#8)
Apply escapeXml() to user-controlled inlineStyle properties (fill, stroke,
stroke-width, color) before interpolating into SVG attributes, preventing XSS via attribute breakout and element injection.
2026-01-29 21:04:39 +01:00
Peter Cooper 04a1b4ffae Apply same semicolon fix to SVG renderer 2026-01-29 19:49:31 +00:00
Peter Cooper 4a7801d470 Fix parser to support semicolons as line separators
Mermaid syntax allows semicolons as statement separators (e.g.
`graph LR; A --> B --> C`), but the parser only split on newlines,
causing the entire input to be treated as a single line. The header
regex then failed because it saw content after the direction keyword.

Split on both newlines and semicolons in parseMermaid() and
detectDiagramType().
2026-01-29 19:37:55 +00:00
Balint Orosz 83ab883b68 Fix README: remove dead links, correct attribution (Go, not Python)
- Remove broken anchor links from header navigation
- Fix attribution: mermaid-ascii is written in Go, not Python

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-01-28 17:43:08 +01:00
Balint Orosz 40f2c9752e Add build step for Node.js compatibility
- Add tsup for TypeScript compilation (ESM + CJS)
- Generate type declarations (.d.ts)
- Update exports with proper conditional exports
- Bump to v0.1.1

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-01-28 17:39:44 +01:00
Balint Orosz 7f7b34c276 Enable npm badge after successful publish
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-01-28 17:37:44 +01:00
Balint Orosz 3185b9b691 Initial release - beautiful-mermaid v0.1.0
MIT licensed mermaid diagram renderer with SVG + ASCII output.
15 built-in themes, full Shiki compatibility, zero DOM dependencies.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-01-28 17:31:57 +01:00