Skip to content
QuireKit
Core docs
Alpha · evolving API
Build a productView Markdown ↗

Add your own content type

Build a note group by understanding nodes, commands, display and selection step by step.

Suppose your knowledge base needs a note group containing editable paragraphs. Users should select, copy and save it with the document. This is a new document structure, beyond changing a paragraph's color.

We call it docsNote. First define its content and insertion command, then add Canvas/SVG display and selection behavior.

1. Define what it stores

In feature/node.ts, Node.create() defines the structure:

feature/node.ts · Structurets

name is stored in JSON. group: 'block' lets the group appear alongside paragraphs. content: 'block+' requires at least one block child. isolating makes general editing operations respect the container boundary.

The complete file also maps HTML input and output to aside[data-docs-note], preserving children when copying HTML. This excerpt explains the structure fields; inspect the complete definition at the end of this page.

2. Provide an insertion command

The interface should call “insert note” without constructing JSON itself. feature/extension.ts provides insertDocsNote(text). Its command body is:

feature/extension.ts · Insertionts

Using insertContent() preserves Core transactions and undo. The complete file adds TypeScript declarations and installs the node through addExtensions(). After installing DocsNoteFeature, a button can call:

Call from a buttonts

Use can().insertDocsNote(...) to determine whether that button is enabled.

3. Arrange children in Canvas/SVG

DOM can display HTML elements directly. Canvas/SVG uses QuireKit layout results, so renderHTML() alone is insufficient. The note also needs a layout provider.

feature/layout.ts uses existing engine services to lay out paragraphs within the available width and place them in the group. It does not measure browser DOM or reimplement text layout. addLayoutProviders() registers this behavior.

The group now has a display in both Canvas and SVG. Detailed size, document-range and pagination parameters are in the extension API; start by reusing this ordinary container layout.

4. Explain container boundaries to selection

Dragging inside the group should select ordinary text. Dragging across its boundary also requires a definition of which children belong to the selection.

feature/selection.ts delegates internal selection to text and uses child units when crossing the group. addSelectionAdapters() registers these rules, allowing copy and replacement to use consistent content ranges.

Try it

Click “Insert note group”, type inside it, select across its boundary and undo. Switch to SVG and confirm that content remains. Download JSON to see docsNote and its paragraphs.

Preparing the example…

Inspect complete files by purpose

FileWhen to read itResponsibility
feature/node.tsChange attributes or allowed childrenStructure and HTML parsing/output
feature/extension.tsInstall the feature or change insertionCommand types, implementation and registration
feature/layout.tsChange container arrangementCanvas/SVG child sizes and positions
feature/selection.tsChange cross-container selectionInternal and boundary selection rules

Choose one file below. Read the node and extension first; inspect the other two when adjusting layout or selection.

product/feature/extension.tsts

Saving and other formats

The node is saved with document JSON; install the extension again on restore. This example implements neither DOCX conversion nor AI integration. Add the respective rules through addDocx() and addAiCapabilities() when needed. JSON persistence alone does not provide another format's support.

For a toolbar or sidebar rather than new content, continue with product plugins.

QuireKitQuireKit · Core, plugins and Classic docs