JSPM

@compilr-dev/editor-core

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 26
  • Score
    100M100P100Q75680F
  • License FSL-1.1-MIT

Core library for terminal markdown editors - slash commands, 418 themes, AI writing assistance

Package Exports

  • @compilr-dev/editor-core
  • @compilr-dev/editor-core/themes

Readme

@compilr-dev/editor-core

      \|/
    ╭══════════╮     ___  ___  _ __ ___  _ __ (_) |_ __
    ║'  ▐▌  ▐▌ │    / __|/ _ \| '_ ` _ \| '_ \| | | '__|
    ║          │   | (__| (_) | | | | | | |_) | | | |
    ╰─═──────═─╯    \___|\___/|_| |_| |_| .__/|_|_|_|
      \________\                        | | .dev
                                        |_| editor-core

Core library for terminal markdown editors — slash commands, mermaid templates, snippets, themes.

npm version License: FSL-1.1-MIT

[!WARNING] This package is in early development. APIs may change between minor versions.

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-core

Quick 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 } | null

Creating 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

FSL-1.1-MIT - See LICENSE for details. Converts to MIT after 2 years per version.