MarkonEditor
MarkonEditor is a full-featured, accessible WYSIWYG authoring canvas featuring 28 toolbar actions, floating bubble menus, slash commands (/), gutter drag handles, and KaTeX mathematics.
typescript
// Framework-Agnostic Core
import { MarkonEditor, type MarkonEditorOptions } from '@nofinite/markon';
// React Adapter
import { MarkonEditor as ReactMarkonEditor } from '@nofinite/markon/react';Interactive Preview
1. Framework-Agnostic Core Usage
Direct DOM Mounting (new MarkonEditor)
Mount the authoring canvas directly into any HTML element:
typescript
import { MarkonEditor } from '@nofinite/markon';
import '@nofinite/nuicss/styles.css';
const container = document.querySelector('#editor-root')!;
const editor = new MarkonEditor({
element: container,
initialValue: '# Product Roadmap 2026\n\nDetailed milestones...',
placeholder: "Type '/' for commands...",
showSlashCommands: true,
showBubbleMenu: true,
showWordCount: true,
showSaveStatus: true,
autoSave: {
key: 'draft-roadmap-2026',
debounceMs: 1000
},
onChange: (html, json, text) => {
console.log('Words:', editor.getCounts().words);
},
onUploadFile: async (file) => {
// Custom S3 / R2 upload logic
return 'https://cdn.example.com/uploads/photo.jpg';
}
});
// Programmatic methods:
// const markdown = editor.getMarkdown();
// const html = editor.getHTML();
// const jsonAst = editor.getJSON();
// editor.setMarkdown('# Updated Document');
// editor.focus();
// editor.destroy();2. React Adapter Usage
In React applications, manage document state declaratively:
tsx
import React, { useState } from 'react';
import { MarkonEditor } from '@nofinite/markon/react';
import '@nofinite/nuicss/styles.css';
export default function DocumentCanvas() {
const [content, setContent] = useState('<h2>Sprint Tasks</h2><p>Edit directly...</p>');
return (
<div className="w-full max-w-3xl p-6 rounded-2xl border border-default bg-surface shadow-xs">
<MarkonEditor
content={content}
onChange={setContent}
slashCommands={true}
dragHandle={true}
wordCount={true}
placeholder="Type '/' for commands..."
onUploadFile={async (file: File) => {
const res = await fetch('/api/upload', { method: 'POST', body: file });
const data = await res.json();
return data.url;
}}
/>
</div>
);
}Features & Configuration
1. Slash Commands (/)
Press / on any blank line to open a keyboard-navigable command palette:
- Headings (H1, H2, H3)
- Bulleted & Numbered Lists
- Task Checklists
- Code Blocks with language syntax highlighting
- KaTeX Math Formulas
- Blockquotes & Callout Boxes
- Data Tables with dynamic row/column insertion
2. Contextual Bubble Menu
Selecting text automatically reveals a floating bubble menu providing quick access to Bold, Italic, Strikethrough, Code, Color chips, Link insertion, and Typography alignment.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
| / | Open floating slash command palette |
| Mod + B | Toggle Bold text |
| Mod + I | Toggle Italic text |
| Mod + K | Insert or edit link |
| Mod + Alt + 1 | Format as Heading 1 |
| Mod + Alt + 2 | Format as Heading 2 |
| Mod + Alt + C | Insert Code Block |
| Mod + Z | Undo |
| Mod + Shift + Z | Redo |