Ngx Codemirror screenshot

Ngx Codemirror

Author Avatar Theme by Scttcper
Updated: 12 Feb 2025
283 Stars

Codemirror Wrapper for Angular

Categories

Overview

ngx-codemirror is an Angular component wrapper for CodeMirror that extends ngModel. It is a tool used for code editing with features such as importing CodemirrorModule, bringing in the codemirror files for parsing the desired language, and setting up the editor with various options. The component is based on JedWatson/react-codemirror and is compatible with different versions of Angular.

Features

  • Angular Component Wrapper: Extends ngModel functionality for Angular applications.
  • Support for Different Angular Versions: Compatible with a range of Angular versions from 6.x to the latest.
  • CodeMirror Integration: Uses CodeMirror for code editing capabilities.
  • Multiple Inputs and Outputs: Supports various inputs like options, name, autoFocus, and outputs like codeMirrorLoaded, focusChange, and more.
  • License: Distributed under the MIT license.

Installation

To install ngx-codemirror, ensure that Codemirror is installed as a peer dependency. Import CodemirrorModule and FormsModule, and include the necessary Codemirror files for parsing the desired language. In your NgModule, you can import the base CSS file and your preferred theme. You can utilize various inputs and outputs provided by the component for a customized experience.

npm install @ctrl/ngx-codemirror codemirror
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import 'codemirror/lib/codemirror';
import 'codemirror/theme/material.css'; // Example theme import

Summary

ngx-codemirror is a versatile Angular component that provides code editing capabilities by leveraging the features of CodeMirror. Its compatibility with different Angular versions, easy installation process, and rich set of inputs and outputs make it a valuable tool for developers working on Angular applications.