Skip to content
On this page

Configuration

Comprehensive guide to all Marzipan options.

Typography Options

ts
new Marzipan('#editor', {
  fontSize: '16px',
  lineHeight: 1.7,
  fontFamily: 'Monaco, Consolas, monospace',
  padding: '20px',
});

Mobile Options

ts
new Marzipan('#editor', {
  mobile: {
    fontSize: '16px',    // Prevents iOS zoom
    padding: '12px',
    lineHeight: 1.5
  }
});

Behavior Options

ts
new Marzipan('#editor', {
  autofocus: true,        // Auto-focus on init
  autoResize: true,       // Auto-expand height
  minHeight: '200px',     // Min height (autoResize)
  maxHeight: '800px',     // Max height (autoResize)
  placeholder: 'Type...',
  value: '# Initial content',
  smartLists: true,       // Continue lists on Enter
});

Feature Options

ts
new Marzipan('#editor', {
  toolbar: true,           // Enable toolbar
  showStats: true,         // Show statistics
  showActiveLineRaw: true, // Highlight current line
});

Callbacks

ts
new Marzipan('#editor', {
  onChange: (value, instance) => {
    console.log('Content changed:', value);
  },
  
  onKeydown: (event, instance) => {
    if (event.ctrlKey && event.key === 's') {
      event.preventDefault();
      saveContent(instance.getValue());
    }
  },
});

Toolbar Configuration

ts
new Marzipan('#editor', {
  toolbar: {
    buttons: [
      'bold', 'italic', 'code',
      '|',  // separator
      'h1', 'h2', 'h3',
      '|',
      'link', 'quote',
      '|',
      'bulletList', 'orderedList', 'taskList'
    ]
  }
});

Textarea Props

ts
new Marzipan('#editor', {
  textareaProps: {
    'data-testid': 'markdown-editor',
    'aria-label': 'Markdown content',
    maxlength: 10000,
    spellcheck: true,
  }
});

Stats Formatter

ts
new Marzipan('#editor', {
  showStats: true,
  statsFormatter: ({ words, chars, lines, line, column }) => {
    const readingTime = Math.ceil(words / 200);
    return `📝 ${words} words (${readingTime} min) • Line ${line}:${column}`;
  }
});

Plugins

ts
import { tablePlugin } from '@pinkpixel/marzipan/plugins/tablePlugin';
import { mermaidPlugin } from '@pinkpixel/marzipan/plugins/mermaidPlugin';

new Marzipan('#editor', {
  plugins: [
    tablePlugin({ defaultColumns: 3 }),
    mermaidPlugin({ theme: 'dark' })
  ]
});

Complete Example

ts
const [editor] = new Marzipan('#editor', {
  // Typography
  fontSize: '15px',
  lineHeight: 1.6,
  padding: '16px',
  
  // Behavior
  autofocus: true,
  autoResize: true,
  minHeight: '300px',
  placeholder: 'Start writing...',
  smartLists: true,
  
  // Features
  toolbar: true,
  showStats: true,
  theme: 'cave',
  
  // Callbacks
  onChange: (value) => {
    localStorage.setItem('draft', value);
  },
  
  // Plugins
  plugins: [tablePlugin()]
});

See the API Reference for complete option details.

Released under the Apache 2.0 License