@compilr-dev/editor-core
v0.0.1
Published
Core library for terminal markdown editors - slash commands, 418 themes, AI writing assistance
Downloads
115
Maintainers
Readme
@compilr-dev/editor-core
Core library for terminal markdown editors - slash commands, snippets, themes, AI writing assistance.
Features
- 40+ Slash Commands - Notion-style commands for markdown editing
- 23 Mermaid Templates - Instant diagram insertion
- 418 Themes - Full Ghostty theme collection (coming soon)
- AI Writing - Smart writing assistance (coming soon)
Installation
npm install @compilr-dev/editor-coreQuick Start
import {
registerCommands,
builtinCommands,
executeCommand,
parseCommandInput,
} from '@compilr-dev/editor-core';
// Register all built-in commands
registerCommands(builtinCommands);
// Parse user input
const input = '/mermaid flowchart';
const parsed = parseCommandInput(input);
if (parsed) {
// Execute the command
const context = {
cursor: { line: 0, column: 0, offset: 0 },
content: '',
};
const result = await executeCommand(parsed.name, parsed.args, context);
console.log(result); // Mermaid flowchart template
}Slash Commands
Content Commands
| Command | Aliases | Description |
|---------|---------|-------------|
| /h1 | /heading1 | Level 1 heading |
| /h2 | /heading2 | Level 2 heading |
| /h3 | /heading3 | Level 3 heading |
| /bold | /b | Bold text |
| /italic | /i, /em | Italic text |
| /strikethrough | /strike, /s | Strikethrough |
| /link | /a, /href | Markdown link |
| /img | /image | Image reference |
| /code | /codeblock, /fence | Code block |
| /inlinecode | /ic, /backtick | Inline code |
| /table | - | Markdown table |
| /list | /ul, /bullet | Bulleted list |
| /numbered | /ol, /numlist | Numbered list |
| /checklist | /todo, /tasks | Task checklist |
| /quote | /blockquote, /bq | Blockquote |
| /hr | /divider, /separator | Horizontal rule |
| /callout | /note, /admonition | Callout box |
| /toc | /tableofcontents | Table of contents |
| /frontmatter | /yaml, /meta | YAML frontmatter |
Mermaid Commands
| Command | Description |
|---------|-------------|
| /mermaid flowchart | Flowchart diagram |
| /mermaid sequence | Sequence diagram |
| /mermaid class | Class diagram |
| /mermaid state | State diagram |
| /mermaid er | ER diagram |
| /mermaid gantt | Gantt chart |
| /mermaid pie | Pie chart |
| /mermaid radar | Radar chart |
| /mermaid mindmap | Mind map |
| /mermaid timeline | Timeline |
| /mermaid gitgraph | Git graph |
| /mermaid quadrant | Quadrant chart |
| /mermaid sankey | Sankey diagram |
| /mermaid xychart | XY chart |
| /mermaid c4 | C4 architecture |
| /mermaid architecture | Architecture diagram |
| /mermaid kanban | Kanban board |
| /mermaid blockdiagram | Block diagram |
| /mermaid packet | Packet diagram |
| /mermaid zenuml | ZenUML sequence |
| /mermaid treemap | Treemap |
| /mermaid journey | User journey |
| /mermaid requirement | Requirements |
API
Command Registry
// Register commands
registerCommand(command: SlashCommand): void
registerCommands(commands: SlashCommand[]): void
// Query commands
getCommand(nameOrAlias: string): SlashCommand | undefined
hasCommand(nameOrAlias: string): boolean
getCommandNames(): string[]
getAllCommands(): SlashCommand[]
getCommandsByCategory(category): SlashCommand[]
searchCommands(term: string): SlashCommand[]
// Execute commands
executeCommand(name: string, args: ParsedArgs, context: CommandContext): Promise<string>
parseCommandInput(input: string): { name: string; args: ParsedArgs } | nullCreating Custom Commands
import { registerCommand, SlashCommand } from '@compilr-dev/editor-core';
const myCommand: SlashCommand = {
name: 'greeting',
description: 'Insert a greeting',
category: 'content',
aliases: ['hello', 'hi'],
args: [{ name: 'name', description: 'Person to greet', required: false }],
execute(args, context) {
const name = args.positional[0] || 'World';
return `# Hello, ${name}!\n\n`;
},
};
registerCommand(myCommand);License
MIT
