跪拜 Guibai
← Back to the summary

One JSON object: QuireKit's embed object carries mind maps, flowcharts, and whiteboards into any editor

While building QuireKit, I turned the five most common diagram types in documents—mind maps, flowcharts, whiteboards, text diagrams, and multi-dimensional tables—into a standalone open-source component set under the MIT license.

QuireKit's own three document types—paginated documents, block documents, and Markdown—all use this same set. The components can also be used independently: Tiptap, ProseMirror, CodeMirror, your own editor, or even a textarea can all integrate them.

Mind map editor Double-click the diagram in a document to open this editor.

It differs from the diagram and flowchart plugins you've seen in four ways:

What stands out in each of the five editors

Mind Map (Quire Mind)

Mind map template library Mind map template library.

Docs: https://docs.quirekit.com/plugins/reference/mind-map/

Flowchart

Hand-drawn style flowchart Hand-drawn style: natural strokes, pencil hatching fills.

Flowchart template library Flowchart template library.

Docs: https://docs.quirekit.com/plugins/reference/flowchart/

Whiteboard

Docs: https://docs.quirekit.com/plugins/reference/whiteboard/

Text Diagram

Online demo: https://text-diagram.quirekit.com

Multi-dimensional Table

Kanban view of multi-dimensional table Kanban view of the multi-dimensional table.

Docs: https://docs.quirekit.com/plugins/reference/data-view/

Why I built it

Text alone is no longer enough for documents: you need illustrations, they need to look good, and they need to be readable and writable by AI. Mind maps, flowcharts, whiteboards, and multi-dimensional tables have become standard parts of a document.

Using AI to help write articles is common, but most output is a full screen of text. To have AI produce visually rich articles, diagrams cannot be screenshots: to AI, a screenshot is just a pile of pixels—it can neither draw nor modify it. The diagram's data must remain structured inside the document for AI to draw and edit it.

Building QuireKit added another layer of difficulty: three document types—paginated, block, and Markdown—had to share the same mind map.

Common approaches on the market fall into three categories, each with its own use cases, but none met this need:

So my approach is: use ready-made libraries for the canvas, and build the 'put it into a document' layer myself, making it generic. Any document integrates once and it works.

How it's designed

The core idea is one sentence: the editor only handles editing; where the data lives is decided by the document.

The editor doesn't know which document it's in. It takes a piece of data, lets the user edit, and hands the result back. Each document type only needs a very thin adapter layer to extract the data and write back the result. Two conventions connect the layers.

Convention 1: a universal embed object

A diagram, no matter which document it lives in, is the same JSON object:

{
  "type": "quirekit-mind-map-embed",
  "version": 1,
  "id": "mind-1",
  "title": "项目推进",
  "document": { "...": "diagram data itself" },
  "preview": { "dataUrl": "data:image/png;base64,...", "width": 732, "height": 380 }
}

It consists of three parts: the diagram data, a stable ID, and a preview image.

The data lives in document; that's what AI reads and modifies. The preview image is for places that don't recognize this object: viewing Markdown on GitHub, or exporting to Word/PDF without running the editor—it just displays the image. If the preview is lost, it can be regenerated from the data.

Convention 2: an edit request

The adapter layer only needs to provide three things to open the editor:

interface MindMapEditRequest {
  document: MindMapEmbed                                                         // current data
  commit(document: MindMapEmbed): 'saved' | 'conflict' | 'readonly' | 'missing'  // write back
  release(): void                                                                // done, return focus
}

commit has four possible return values. While you're editing the diagram, the document may have been modified by someone else, become read-only, or the diagram may have been deleted; the editor uses the return value to prompt you, not silently overwrite others' content. Closing without saving is fine—changes stay in a local draft and can be recovered next time.

The kernel is swappable

The canvas kernels use mature open-source libraries: flowcharts use AntV X6, mind maps use simple-mind-map, whiteboards use Excalidraw, and text diagrams directly use the official Mermaid, PlantUML, and Graphviz libraries. Thanks to those projects.

Kernels are connected through independent adapter packages. If upstream maintenance stops, or a better option appears, swap the kernel without affecting the data in documents. The multi-dimensional table is self-written. All editors share the same component library, so the UI style is consistent.

AI-assisted writing of visually rich articles

The biggest benefit of structured data is that AI can 'draw' directly.

Each graphic component describes its own commands for AI to call: insert flowchart, insert mind map, insert text diagram, and update them. In the MD Editor, when AI assists writing an article, it first figures out where a diagram is needed and which type: steps and branches get a flowchart, hierarchy and outlines get a mind map, sequence interactions get a sequence diagram, proportions and trends get a pie or line chart, comparisons get a table.

What AI inserts are real flowcharts and mind maps, just like ones you draw by hand—double-click to continue editing. If it makes a mistake, for example a Mermaid syntax error, that step is rejected and the error is returned; AI fixes the source and resubmits. Each insertion or modification is one undo step; when modifying an existing diagram, the version is checked so it won't overwrite what someone just changed.

(The graphic components and command descriptions are MIT; the AI assistant in MD Editor is a commercial component, free for development and evaluation.)

How to integrate in different scenarios

Rich text editors (ProseMirror, Tiptap, and similar)

Store the embed object as a property of a block node; double-click the block opens the editor. QuireKit's block editor integrates this way:

Flowchart and mind map in block editor Flowcharts and mind maps in the block editor can be dragged and copied.

Markdown

Write the embed object's JSON into a code fence. In the editor it displays as a diagram; in source it's just code:

Mind map in Markdown

Source view: mind map is a code fence Switch to source view and the map is a quirekit-mind-map code fence.

Put it in Git, and every change is visible; opening with GitHub or VS Code won't break anything. QuireKit's Markdown editor (based on CodeMirror) integrates this way.

Word-style paginated documents

Diagrams sit on the page as image objects, paginate and print with the text, and store the diagram data behind them:

Mind map in paginated document

When exporting to Word, both the preview image and original data are written into the file. After importing back, mind maps and flowcharts are still editable. This part involves the Word format and belongs to QuireKit's commercial components; development and evaluation are free.

No editor, or you want to manage storage yourself

Call directly: read data, open the editor, write back on save.

npm install @quirekit/mind-map@alpha @quirekit/mind-editor@alpha
import { createMindMapEmbed, parseMindMapEmbed, serializeMindMapEmbed } from '@quirekit/mind-map'
import { openMindMapDialog } from '@quirekit/mind-editor'
import '@quirekit/mind-editor/styles.css'

const saved = loadFromYourDoc()                      // your own read logic, returns string or null
const document = saved ? parseMindMapEmbed(saved) : createMindMapEmbed('mind-1')

openMindMapDialog({
  ownerDocument: window.document,
  request: {
    document,
    commit(next) {
      saveToYourDoc(serializeMindMapEmbed(next))     // your own write logic
      return 'saved'
    },
    release() {},
  },
})

If you want to embed in a page instead of a dialog, use the Vue component QuireMindEditor (import from @quirekit/mind-editor/vue). Flowcharts and whiteboards work the same way, just with the corresponding packages.

Preview image too large

The preview image defaults to base64 embedded in the document; no server needed. The cost is size: a diagram can be tens to hundreds of KB, and the Markdown source will show a long encoded string.

If you have an image host, provide an upload function:

openMindMapDialog({
  // ...
  uploadPreview: async (png) => uploadToYourCdn(png),   // returns image URL
})

The preview image uploads like a normal image, and the document only saves the URL.

Open source scope

About QuireKit

These graphic components are just a small part of QuireKit. QuireKit is an open-source document editor ecosystem for building online documents, knowledge bases, and Markdown writing tools in your own product. Underneath are two Tiptap-style editor frameworks—one based on ProseMirror, one on CodeMirror—and on top are three ready-made editors:

All three editors and these graphic components use the same UI component library.

Currently alpha; interfaces will be adjusted. Feedback and trials welcome:

If you find it useful, a star is appreciated. Also curious: which diagram would you most want in your editor?

Comments

Top 2 of 4 from juejin.cn, machine-translated. The original thread is authoritative.

达拉

Performance seems a bit off—when I opened the official site, a few clicks caused it to lag for quite a while.

king王一帅

Another reason is that edge nodes can have cold-start issues.

zhao1zhihui

This is so impressive.

king王一帅

Thanks for the recognition.