This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/src/editor/index.mjs
Jeffrey Smith 0003e66e43
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 3s
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-go-pg (pull_request) Successful in 2m40s
CI/CD / test-sqlite (pull_request) Successful in 2m45s
CI/CD / build-and-deploy (pull_request) Successful in 25s
rebrand: sweep remaining switchboard refs + rename cookies/storage keys
- CSS headers (4 files): Switchboard Core → Armature
- Editor .mjs headers (8 files): Chat Switchboard → Armature
- SQL migration comments + seed data (20 files): Switchboard Core → Armature
- Webhook header: X-Switchboard-Event → X-Armature-Event
- Cookie: sb_token → arm_token (3 Go files + auth.js)
- localStorage: sb_auth → arm_auth (auth.js + 2 test runners)
- localStorage: switchboard_theme → armature_theme (theme.js + base.html)
- Debug engine filter: chatSwitchboard/switchboard/sb_ → armatureChat/armature/arm_
- JS export: switchboardTheme → armatureTheme (theme.mjs + code-editor.mjs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 23:11:38 +00:00

72 lines
2.5 KiB
JavaScript

// ==========================================
// Armature — CM6 Bundle Entrypoint
// ==========================================
// esbuild compiles this into an IIFE that sets
// window.CM with factory functions and utilities.
//
// Consumers:
// if (window.CM) {
// const editor = CM.chatInput(el, opts);
// const code = CM.codeEditor(el, opts);
// }
// ==========================================
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
import { json } from '@codemirror/lang-json';
import { markdown } from '@codemirror/lang-markdown';
import { sql } from '@codemirror/lang-sql';
import { html } from '@codemirror/lang-html';
import { css } from '@codemirror/lang-css';
import { yaml } from '@codemirror/lang-yaml';
import { go } from '@codemirror/lang-go';
import { python } from '@codemirror/lang-python';
import { rust } from '@codemirror/lang-rust';
import { vim } from '@replit/codemirror-vim';
import { emacs } from '@replit/codemirror-emacs';
import { codeEditor } from './code-editor.mjs';
import { chatInput } from './chat-input.mjs';
import { noteEditor } from './note-editor.mjs';
import { mentionExtension } from './mention.mjs';
// ── Expose on window ────────────────────────
window.CM = {
// Version (injected by the build script or matched to app version)
version: '0.17.3',
// Low-level access (for advanced use / debug console)
EditorView,
EditorState,
// Factory: full-featured code editor
// CM.codeEditor(container, { language, value, lineNumbers, darkMode, keymap, onChange })
codeEditor,
// Factory: chat message input (markdown mode, minimal chrome)
// CM.chatInput(container, { placeholder, onSubmit, onChange, maxHeight, darkMode })
chatInput,
// Factory: rich markdown note editor with wikilinks
// CM.noteEditor(container, { value, darkMode, onChange, onLink, linkCompleter })
noteEditor,
// Extension: @mention autocomplete + decoration for chat input
// CM.mentionExtension({ completer: async (query) => [{ label, handle, type }] })
mentionExtension,
// Bundled language modes (for reference / dynamic use)
languages: {
javascript, json, markdown, sql, html, css, yaml, go, python, rust,
},
// Keybinding modes (for reference / settings UI)
keybindings: { vim, emacs },
};
console.log('[CM6] CodeMirror bundle loaded (v' + window.CM.version + ')');