@barocss/math-editor-codemirror6
v0.2.3
Published
LaTeX source editing codemirror6 integration for Barocss math editor.
Readme
@barocss/math-editor-codemirror6
Edit LaTeX at the caret in a small math-editor popup. This adapter owns its source and version independently.
npm install @barocss/math-editor @barocss/math-editor-text @barocss/math-editor-codemirror6 @codemirror/state @codemirror/view @codemirror/commandsimport '@barocss/math-editor/style.css';
import '@barocss/math-editor-text/style.css';
import { mathEditor } from '@barocss/math-editor-codemirror6';
// Include this extension in your EditorState configuration.
const extension = mathEditor({
locale: 'en',
syntax: 'markdown',
onError: message => { statusElement.textContent = message; },
});Place the caret inside $x+1$ and press Alt+Enter (Option+Enter on macOS), or click Edit formula. Select bare LaTeX to edit an expression without delimiters. Apply replaces its source and adds one undo step. Cancel preserves the original. An unchanged Apply does not normalize source. Any source change while the popup is open invalidates the draft; reopen it instead of overwriting a newer document.
Install the host's undo/history support. Read-only hosts do not apply edits. Monaco applications must configure their normal editor worker; this adapter does not replace the host's worker setup. VS Code uses a separate extension, not this Monaco adapter.
Options include locale, messages, syntax, resolveRange, toolbar, and onError. The @barocss/math-editor-text README documents the complete editing contract. A custom resolveRange can use the host syntax tree instead of the conservative built-in scanner.
Workspace imports resolve src. Published exports resolve dist. Build artifacts contain JavaScript and type declarations; host runtimes remain external. Initial version: 0.1.0. Publication is a separate release step.
MIT, copyright barocss.com. See LICENSE.
Optional direct LaTeX input
Pass sourceEditing: {} in the adapter options for command completion in the source
editor. Add renderPreview(latex, element, displayMode) inside that object for a
preview above the caret. KaTeX is not bundled; install it separately if used by your
renderer. Use Up/Down and Enter to select, Tab/Shift+Tab to navigate inserted
arguments, Ctrl+Space to open the catalog, and Alt+Enter for visual editing.
The source caret stays in the host. Completion changes only the command range and uses the host's Undo history. See the full setup and behavior guide.
