Skip to content

robotcoral/ngx-codemirror6

Repository files navigation

ngx-codemirror6 npm npm

Angular Component for CodeMirror 6

Installation

To use this component in your project install it via npm

npm i @robotcoral/ngx-codemirror6 @codemirror/basic-setup --save

Using the component

Include CodeMirrorModule in your main module:

import { CodeMirrorModule } from "@robotcarol/ngx-codemirror6";

@NgModule({
  // ...
  imports: [CodeMirrorModule],
  // ...
})
export class AppModule {}

and add the ngx-codemirror selector to your feature component:

import { Component } from "@angular/core";

@Component({
  selector: "sample",
  template: ` <ngx-codemirror [config]="{...}"> </ngx-codemirror> `,
})
export class Sample {
  // ...
}

Configuration

You can pass an object of the type EditorStateConfig to the ngx-codemirror component via the [config] input.