コンテンツにスキップ
Oleaflyv0.4.6

Editing tools

The diagram composer: draw on a canvas or write the code, in TikZ for LaTeX, fletcher for Typst, or Mermaid for Markdown, with a live preview and editable source.

このコンテンツはまだ日本語訳がありません。

Draw a diagram on a canvas and get plain source code in your document’s language: TikZ for LaTeX, a fletcher diagram for Typst, or a Mermaid flowchart for Markdown. The drawing and the code stay in step, so you can switch between them at any point.

The composer runs on your device and needs no account. (For figures written by the assistant, see Draw figures with AI.)

From the home screen, choose Diagram Composer in the dock. You can also run Open Diagram Composer from the ⌘K (Ctrl+K) command palette, or type /diagram in the search omnibar. A dialog, Choose a diagram composer, asks what the diagram is for: TikZ diagram for LaTeX documents, Typst diagram for Typst documents, or Mermaid diagram for Markdown documents.

From an open document, choose Draw a diagram on the editor toolbar instead. The composer skips the question and uses the document’s language: TikZ in a .tex file, Typst in a .typ file, and Mermaid in a Markdown file. Back to project takes you back to the document.

The header shows the diagram’s name, which you can click to rename, and a small label with its language.

Draw mode is the canvas. It works the same way in all three languages.

Pick a shape from the palette (rectangle, rounded box, circle, ellipse, diamond, parallelogram, or text), then click and drag to place and size it. Math and Code are text boxes that start with an equation or a code sample in the diagram’s language.

To connect two shapes, drag from a handle on one to the other. The connector stays attached when you move either shape. Select it to choose the arrowhead (end, both, or none), the routing (straight, orthogonal, or curved), and a label. Select a shape to change its label, fill, border, corner radius, or font.

Shapes snap into line as you move them, and undo and redo work as usual. Hold Space and drag to pan, and double-click a shape to edit its text.

Code mode shows the same diagram as source, with a Snippets menu for common pieces such as a rectangle node, a circle node, an arrow edge, and a line edge. Edit either side and the other follows: move a box and the code changes, rename a label in the code and the canvas changes.

The code is ordinary source for each language:

  • TikZ: a tikzpicture with nodes and edges.
  • Typst: a complete fletcher snippet, with the #import "@preview/fletcher:…" line and a #diagram(…) call holding node(…) and edge(…) items. The fletcher version matches the open Typst project’s Typst version: 0.5.8 for Typst 0.13 and later, 0.5.5 for 0.12, and 0.5.1 for older releases.
  • Mermaid: a flowchart with node shapes, labelled links, style lines for colors, and subgraphs for group boxes. Mermaid lays out the diagram itself, so positions you set on the canvas are not part of the code.

In Typst and Mermaid, code the canvas can’t show stays exactly as you wrote it. For Typst that includes imports, #let lines, wrappers such as #figure(…), extra diagram settings, and loops. For Mermaid it includes click lines, directives, comments, and frontmatter. A node or edge you don’t touch on the canvas keeps its text, and one you do touch keeps the options the canvas doesn’t know about.

When the canvas doesn’t show everything, a notes button appears in the header with a count, such as 2 notes. It lists what stays only in the code and what the canvas shows approximately, such as nodes without a set size, formatted labels, or a Mermaid shape the canvas doesn’t have.

TikZ behaves differently. The notes name the TikZ commands the canvas doesn’t model, and a canvas edit rewrites the TikZ from the drawing, so those commands are lost. Keep hand-written or complex TikZ in Code mode.

Compile renders the diagram on its own, away from your document, in a preview pane beside the canvas. Choose a PNG scale of 1x, 2x, or 3x, and a background color or a transparent background.

  • TikZ compiles with Tectonic in a separate build, so a half-finished diagram never touches your document.
  • Typst previews with the open Typst project’s own Typst version and package cache, or with the bundled Typst when no Typst project is open. The first Typst preview downloads fletcher from Typst Universe. In offline mode, or with no connection, the preview says the package is missing instead of showing a general error.
  • Mermaid previews with the app’s own Mermaid renderer.

Errors appear in the preview pane. For Typst and Mermaid, each error names its line in the code, and clicking it jumps there.

If a compile fails, Fix with AI sends the code and its errors to your connected AI provider and asks for corrected code in the same language.

Compile first, then open the Save menu next to Compile:

  • Insert as TikZ, Insert as Typst, or Insert as Mermaid puts the diagram at the cursor in the open .tex, .typ, or Markdown document, in that document’s language. If the composer is set to another language, the drawing is converted through the canvas first, so code the canvas can’t show doesn’t carry over.
  • Save to project writes figures/<name>.png and the source, figures/<name>.tikz, .typ, or .mmd, into a project you choose from the list. Saving into a project that uses another language converts the drawing to that project’s language. Oleafly asks before replacing files that already exist. Add a saved Typst diagram to a document with #include, and a Mermaid diagram inside a mermaid code block.
  • Save to project → New project creates a diagram project in the composer’s language.
  • Save Figure keeps the PNG and its source in Oleafly’s figure cache, outside any project.

The Download menu saves a PNG, an SVG for Typst and Mermaid diagrams, or the source as TikZ (.tikz), Typst (.typ), or Mermaid (.mmd). Downloading another language converts the drawing through the canvas.

Inserting into a Markdown document adds a fenced mermaid code block, and the Markdown preview draws it. A PDF needs an image, so the composer also saves a rendered PNG at figures/mermaid-<hash>.png, and the Markdown compile puts that image in place of the block. The diagram therefore appears in the compiled PDF too. If you edit the block by hand later, the PDF shows the code until you insert or save the diagram from the composer again.

Source files the composer saves end with a one-line comment that holds the canvas model. Import one of them and the drawing comes back exactly as you left it.

Import diagram file in the header opens a .tikz, .tex, .typ, .mmd, or .md file and replaces the current draft. A file in another language switches the composer to that language. Code the canvas can read is drawn; anything else opens as code only.

A diagram project holds one figure. Create one in any of the three languages with Save to project → New project. A Typst diagram project has a standalone main.typ whose page is sized to the drawing, so compiling it produces the diagram PDF.

Open the project’s main file and switch the editor toolbar from Code to Canvas (TikZ) or Visual (Typst and Markdown) to edit it on the same canvas.

The Diagram / Figure template (TikZ) and the Typst Figure template also start a one-figure project, written as source. Projects like these preview as the figure itself, and their export menu offers Export as PDF (vector image) and Export as PNG. Use them for figures you reuse across papers.

Image preview

AI answers couldn’t load

Try again, or search the documentation.