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 680ec3b897
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 5s
CI/CD / test-go-pg (push) Successful in 2m34s
CI/CD / test-sqlite (push) Successful in 2m46s
CI/CD / build-and-deploy (push) Successful in 1m55s
Feat rebrand armature (#43)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-03-31 23:25:37 +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 + ')');