Skip to content

Add simple flowcharts and numbered step links (#188) - #285

Open
Twest2 wants to merge 17 commits into
mainfrom
feat/188-flowchart-editor
Open

Twest2 wants to merge 17 commits into
mainfrom
feat/188-flowchart-editor

Conversation

@Twest2

@Twest2 Twest2 commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Issue

Relates to #188.

Summary

Recorded guides sometimes branch ("Already have an account?"). A step can now have a simple flowchart, either shown instead of its screenshot or as a block after its text, and descriptions can link to another step by number.

This revision replaces the first attempt on this branch with a smaller version built on main. The Markdown description mode, extra shapes/connector styles and the two-row toolbar are gone; the image toolbar is exactly main's again.

Changes

  • Image/Flowchart menu at the far right of the canvas toolbar. On Flowchart, the image tools are replaced by flowchart tools: Select, Step box, Decision, Start or end, Connect, Arrange, Delete selected. The canvas gets a dotted grid; shapes snap to it.
  • Editing: click to place a shape and type its text; drag from shape to shape to connect (arrows out of a decision ask for a Yes/No label); drag to move; double-click to rename; Delete removes; Ctrl+Z undoes. The details pane edits the selected shape (text, shape, colors, picture, linked step); there are no Delete shape / Remove flowchart buttons.
  • More shapes palette: 30 shapes (rectangle, square, circle, ellipse, cylinder, cloud, document, cube, chevron, note, callout, person, data storage, container, block arrows…). Fill / Border / Text color use the annotation color menus. Fill → Image… puts a picture in a shape, clipped to it and never stretched (Fit inside or Fill shape). Selected shapes resize from a corner handle. The Shape menu and palette are grouped (Basic / Flowchart / More). Drag empty canvas (or middle-drag) to pan. Arrows can be arrow, double, line, dashed or dotted. Ctrl + mouse wheel zooms (Ctrl+=/−/0 too).
  • Placement menu: Instead of image or As a block. The screenshot is never deleted. + Flowchart under Blocks does the same as a block, with a preview card.
  • Linked steps: a shape can link to a guide step and shows "→ Step 3", renumbered when steps move.
  • Description format: a Rich text / Markdown menu beside Description; switch freely (rich text converts to Markdown and back). Markdown is CommonMark + GitHub tables, strikethrough, autolinks, task lists, kept line breaks and inline HTML (sanitized: no scripts/styles; images become links). Preview turns blue while on. The source is kept while it still produces the stored HTML; AI/agent/Find & replace/private-detail rewrites rebuild it from the HTML. Markdown exports use the source as written. Adds pinned markdown-it@14.3.3.
  • Description → Step (beside Clear) inserts a "Step 3" link storing the target's permanent ID (href="step:<id>"). The editor and every export show the target's current number. Ctrl+click opens the step.
  • Exports: one SVG renderer (core/flowchart.js) draws both the editor and the exports; Sharp turns it into a PNG. It replaces the step image, or is added as a block, in HTML, Markdown, Wiki.js, PDF, Word, Confluence and clipboard. JSON keeps the graph.
  • AI: AI → Create a flowchart drafts one from the guide through the configured Ollama/OpenAI-compatible provider (undoable). MCP set_flowchart lets agents create, replace or remove a step's flowchart (snapshot first).

Area

  • Guide editor
  • Exports
  • AI and AI agents (MCP)
  • Translations
  • Documentation
  • Tests

Testing

  • Tested manually (describe below)

Short checks, as requested for the development stage:

  • npm test: 1,490 passed, 0 failed, 24 skipped (new tests/unit/flowcharts.test.js: model, layout, SVG escaping, AI parsing, export placement with real Sharp rendering, step-link renumbering, MCP tool).
  • Ran the real app on Linux (WSLg) over CDP with real mouse input: drew Start → step → decision → two branches, labeled Yes/No, dragged a shape, inserted a Step link from the description toolbar. Image toolbar stays one row; flowchart toolbar fits one row at 1280px.
  • node scripts/check-translations.js: 1851/1851 in all five languages.
  • Not run: bash tests/run_test.sh / the E2E suite, the live-model AI path, Windows.

Screenshots or recordings

Editor (flowchart mode):

Flowchart editor

Exported flowchart:

Exported flowchart

Rollout notes

Steps gain two fields, flowchart (null by default) and flowchartPlacement. Older steps load unchanged.

Checklist

  • Linked to an issue above
  • Scope is limited to that issue
  • New behavior has tests that check real output
  • Docs updated for anything users will notice
  • New interface text is in t(), and npm run translations lists nothing missing
  • Anything that still needs manual verification is listed above
  • No new network calls, dependencies, or third-party branding (adds markdown-it for full Markdown descriptions)

Replaces the earlier flowchart implementation (Markdown description mode,
14 shapes, two-row toolbar) with a smaller one built on main. The tree now
differs from main only by this feature.

- A step can have one flowchart. The canvas toolbar's Image/Flowchart menu
  (far right) swaps the image tools for flowchart tools: select, step box,
  decision, start/end, connect, arrange, delete. The flowchart canvas has a
  dotted grid; shapes snap to it.
- "Instead of image" or "As a block" chooses where exports put it.
- Exports draw the same SVG (via Sharp) as a step image or a block in HTML,
  Markdown, Wiki.js, PDF, Word, Confluence and clipboard; JSON keeps the graph.
- AI -> Create a flowchart drafts one from the guide; MCP set_flowchart lets
  agents create, replace or remove one.
- Description toolbar: Step (beside Clear) inserts a "Step 3" link that keeps
  the target's permanent ID and is renumbered in the editor and in exports.
- The image toolbar is back to main's single row.
@Twest2 Twest2 changed the title Add flowchart editing, AI drafts, and Markdown step links Add simple flowcharts and numbered step links (#188) Nov 8, 2026
Twest2 added 13 commits November 8, 2026 14:36
- More shapes palette with 30 shapes (rectangle, circle, cylinder, cloud,
  document, cube, person, block arrows and more); drawn by core/flowchart.js
  for the editor, the palette icons and exports alike.
- Fill, border and text colors through the annotation color menus.
- Choose image... puts a picture in a shape, clipped to it and never
  stretched (Fit inside or Fill shape); stored as a scaled-down data URL.
- Resize a selected shape from its corner handle.
- Arrow styles: arrow, double, line, dashed and dotted.
- Ctrl + mouse wheel (and Ctrl+= / Ctrl+- / Ctrl+0) zooms the flowchart.
- Remove the Delete shape and Remove flowchart buttons from the details pane.
… panning

- Description: a Rich text / Markdown menu. Markdown is CommonMark with
  GitHub tables, strikethrough, autolinks and task lists, kept line breaks
  and inline HTML (sanitized; images become links). Preview turns blue while
  on. Switching converts in both directions. The Markdown source is kept
  while it still produces the stored HTML; when AI, an agent, Find and
  replace or the private-detail check rewrites the HTML, the source is
  rebuilt from it. Markdown exports use the source as written.
- Pin markdown-it 14.3.3; core/sanitize.js also loads in the renderer, and
  allows h5, h6, del, ins, mark, kbd, dl/dt/dd and details/summary.
- Flowchart Fill menu: Image... (with an image icon) puts a picture in the
  shape; Fit inside / Fill shape and Remove image show while it has one.
- Shape menu and More shapes palette grouped: Basic, Flowchart, More.
- Drag empty canvas (or middle-drag) to pan the flowchart.
…iew links

- Rich text turns a typed [text](https://...) into a real link once the
  caret leaves it, and a bare web address once a space follows it. The Link
  button selects its placeholder so the address can be typed straight away.
- Links in the rich-text box show blue; Ctrl+click opens them (plain click
  keeps editing). Links in the Markdown preview open on click.
- The rich-text box, Markdown box and preview can be dragged taller; the
  preview opens at the Markdown box's size.
- Rich text and Markdown link example.com, www.example.com and
  [text](example.com) to https://, using markdown-it's linkify (with common
  newer endings such as .dev and .app). File names like file.txt stay text.
- A Markdown description stores a fingerprint of the HTML it produced, so a
  later change to the Markdown renderer never rebuilds the author's source;
  a real rewrite of the HTML (AI, Find and replace, private details) still does.
…lbar shapes

- Mermaid button (top right of the canvas) opens the chart as Mermaid text
  in a panel beside it, split by a vertical line. Typing Mermaid redraws the
  chart (one undo step per visit); drawing rewrites the text. Existing shapes
  keep position, size, colors, picture, step link and shapes Mermaid lacks;
  new ones go under the node leading to them. Unreadable lines are named.
  core/flowchart-mermaid.js reads brackets, @{ shape } nodes, arrows, labels,
  chains and &, and skips comments, styles and subgraphs.
- More shapes gains Lines and arrows: Connect then draws that style.
- Ellipse, Document and Cylinder join the toolbar.
- Placement menu reads Main visual / Block.
- Mermaid is a text button in the flowchart toolbar that opens and closes
  the panel (shown pressed while open), instead of a button on the canvas.
- The panel has a title and subtitle, a Syntax link to Mermaid's flowchart
  guide, an icon close button, a code-style editor and a status bar (green
  in sync, red with the line it can't read).
- A divider between the canvas and the Mermaid panel drags (or arrow keys)
  to resize it; the width is remembered (editor.mermaidWidth).
- The Mermaid text is colored with Settings -> Exports -> Code theme,
  background included (Plain leaves it uncolored). A small tokenizer in
  core/flowchart-mermaid.js names keywords, directions, nodes, arrows,
  shapes, labels, strings and comments; core/code-themes.js also loads in
  the renderer. Changing the theme recolors an open panel.
- Leaving the Mermaid box keeps the text as typed (comments included).

This branch has not been deployed

No deployments
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