Skip to main content

API

import { MarkdownEditor, useMarkdownEditor } from '@zuilib/text-editor'
import '@zuilib/text-editor/styles.css'

Package entry points: . (ESM + types), ./styles.css, ./package.json. DRAWING_FORMAT.md and CHANGELOG.md ship in the package too.

Component and hook

ExportPurpose
MarkdownEditorThe component. Compound parts as statics: .Root, .Content, .Toolbar, .ToolbarButton, .ToolbarDivider, .FormatButtons, .InsertButtons, .HistoryButtons, .Outline, .useEditor
MarkdownEditorProps, ToolbarItemsProps of the component; the groups handed to a toolbar render function
EditorRootProps, EditorContentProps, EditorModeTypes of the compound parts
useMarkdownEditor(), MarkdownEditorApiHeadless hook and its return type (Toolbar)
Toolbar, ToolbarButton, ToolbarDivider, FormatButtons, InsertButtons, HistoryButtonsToolbar primitives as named exports

Markdown transformers and nodes

For assembling your own Lexical editor with the same dialect. Order matters: FRONTMATTER, DRAWING and DIAGRAM must claim their blocks before CODE_BLOCK; CHECK_LIST before UNORDERED_LIST.

ExportPurpose
TABLEGFM table transformer
CODE_BLOCKFenced code transformer; untagged blocks export as bare fences
FRONTMATTER, FrontmatterNode, $createFrontmatterNode, $isFrontmatterNode, SerializedFrontmatterNodeFrontmatter block
DRAWING, DIAGRAM, DrawingNode, $createDrawingNode, $isDrawingNode, SerializedDrawingNodeDrawing node and its two transformers (```drawing and ```diagram)

Tables

ExportPurpose
TableDensity, TableSettings, TableSettingsOptions, DEFAULT_TABLE_SETTINGSSetting types and defaults
$getSelectedTable, $getTableSettings, $setTableSettings, $isTableWidthExplicit, $getTableWidth, $setTableWidth, $getTableDensity, $setTableDensitySetting helpers, inside editor.update / read
parseTableSettingsMarker, formatTableSettingsMarkerMarker comment ⇄ TableSettings
TABLE_WIDTH_MARKERDeprecated; use formatTableSettingsMarker
TableCellPosition, $getSelectedTableCell, $getTableCellPositionWhere the selection is
$insertTableRowAt, $deleteTableRowAt, $insertTableRowNear, $deleteSelectedTableRowRow operations
$insertTableColumnAt, $deleteTableColumnAt, $insertTableColumnNear, $deleteSelectedTableColumnColumn operations
insertableRowIndices, insertableColumnIndices, canDeleteRow, canDeleteColumnPure guards for custom toolbars

Block width

ExportPurpose
BlockWidth'full' | 'text' | 'content'
BLOCK_WIDTHS, isBlockWidthValues and type guard
BlockWidthDefaultsShape of the defaultBlockWidth prop

Drawing payload

ExportPurpose
DrawingData, DrawingShape, DrawingShapeType, BoxType, ConnectorType, Binding, BindingSide, PointPayload types
parseDrawingData, serializeDrawingData, normalizeDrawingDataLenient parse, serialise, re-anchor bindings
DRAWING_DATA_JSON_SCHEMAJSON Schema of the payload
BOX_TYPES, CONNECTOR_TYPES, SHAPE_TYPES, SIDE_FIXED_POINTS, STROKE_COLORS, FILL_COLORS, EMPTY_DRAWINGConstants
BOX_DEFINITIONS, BoxDefinition, TextFieldData-driven shape geometry and text slots
anchorPoint, boxOutline, connectorPoints, routeElbowGeometry: binding resolution, connector paths, the elbow router

Skeleton and Mermaid

ExportPurpose
DrawingSkeleton, SkeletonBox, SkeletonConnector, SkeletonEnd, SkeletonText, ColorNameSkeleton types
parseDrawingSkeleton, isDrawingSkeleton, expandSkeletonParse and expand to DrawingData
DRAWING_SKELETON_JSON_SCHEMA, COLOR_PRESETSJSON Schema; palette name → stroke / fill
drawingToMermaid, MermaidOptions, MermaidDirectionMermaid flowchart export

Code highlighting

ExportPurpose
CodeGrammar, CodeRule, CodeToken, CodeTokenTypeGrammar and token types
registerCodeLanguage, hasCodeLanguage, resolveCodeLanguage, getCodeLanguagesRegistry
tokenizeCode, codeTokenizer, registerCodeBlockHighlightingLexer, Lexical tokenizer adapter, editor wiring
BUILTIN_CODE_LANGUAGES, CODE_TOKEN_TYPES, PLAIN_LANGUAGEConstants

Ink style

ExportPurpose
DrawingStyle, InkOptions, InkStrokeTypes
inkStroke, inkAmplitude, inkFillOffset, seedFrom, roundedRectPolygon, roundedPolylineGeometry helpers for custom renderers