CodeEditor

App

Engine-agnostic code editor primitive. M1 ships a lightweight CodeMirror-style fallback engine (textarea + line-number gutter + active-line + theme + readonly + placeholder) so the public API is stable today. Future milestones: Monaco (VSCode) lazy engine, find/replace, multi-cursor, diagnostics (markers), custom autocomplete + hover, minimap, code folding, vim/emacs keymap. Pixel-identical React sibling at modules/ui/CodeEditor/index.tsx. Used by RulesetEditor M3 + RichTextEditor code-block insert (planned).

JavaScript readonly

Preview

Read-only JavaScript snippet with line numbers.

Code
<%- include('modules/ui/CodeEditor', {
  id: 'example',
  label: 'example.js',
  language: 'js',
  theme: 'light',
  value: source,
  readonly: true,
  showLineNumbers: true
}) %>

Markdown editable

Preview

Editable markdown. The hidden form input is synced to the value.

Code
<%- include('modules/ui/CodeEditor', {
  id: 'readme',
  name: 'readme',
  label: 'README.md',
  language: 'markdown',
  theme: 'dark',
  value: src,
  placeholder: 'Start typing markdown…'
}) %>
Source modules/ui/CodeEditor/CodeEditor.ejs
<% if (_name) { %> <% } %> <% if (_hint || _error) { %>

<%= _error || _hint %>

<% } %>