A CodeMirror 6 editor factory with a scholarly aesthetic, supporting JavaScript, HTML, CSS, Markdown, and LaTeX.
Include the bundle and create editors:
<script src="dist/editorMaker.bundle.min.js"></script>
<script>
// Using the unified API
const editor = EditorMaker.createEditor("#container", "javascript", {
theme: "scholarly", // or "solarizedLight", "dracula", etc.
lineWrapping: true, // default: true
tabSize: 4, // default: 4
doc: "// initial code", // optional initial content
placeholder: "Type..." // optional placeholder
});
// Or use convenience functions
const jsEditor = EditorMaker.createJSEditor("#js");
const htmlEditor = EditorMaker.createHTMLEditor("#html");
const cssEditor = EditorMaker.createCSSEditor("#css");
const mdEditor = EditorMaker.createMarkdownEditor("#md");
const latexEditor = EditorMaker.createLaTeXEditor("#latex");
</script>
// Get content
const code = editor.getContent();
// Set content
editor.setContent("new code here");
// Insert at cursor
editor.insert("inserted text");
// Get selection
const selected = editor.getSelection();
// Replace selection
editor.replaceSelection("replacement");
// Focus the editor
editor.focusEditor();
# Install dependencies
npm install
# Build all bundles
npm run build
# or
make build
# Watch mode for development
npm run dev
# Serve with browser-sync
make serve
# Build and serve
make dev