CodeMirror form component for angular.
@angular/common
@angular/core
@angular/forms
codemirror
rxjs
$ npm install --save @webacad/ng-codemirror
or with yarn
$ yarn add @webacad/ng-codemirror
app.module.ts:
import {CodemirrorModule} from '@webacad/ng-codemirror';
@NgModule({
imports: [
CodemirrorModule,
],
})
export class AppModule {}
<wa-codemirror mode="javascript"></wa-codemirror>
Available options:
mode
: codemirrormode
optiontheme
: codemirrortheme
optionlineNumbers
: codemirrorlineNumbers
optionviewportMargin
: codemirrorviewportMargin
option
This package implements all the necessary code for angular forms. That means that you can use it just like any other ordinary form control.
The component itself provides only a few options for codemirror. If you need to have more control over the codemirror
or if you want to configure it globally, use the WA_CODEMIRROR_DEFAULTS
injection token:
import * as CodeMirror from 'codemirror';
export const AppCodeMirrorConfiguration: CodeMirror.EditorConfiguration = {
lineNumbers: true,
theme: 'material',
};
and register it in your app module:
import {CodemirrorModule, WA_CODEMIRROR_DEFAULTS} from '@webacad/ng-codemirror';
import {AppCodeMirrorConfiguration} from './codemirror-configuration';
@NgModule({
imports: [
CodemirrorModule,
],
providers: [
{
provide: WA_CODEMIRROR_DEFAULTS,
useValue: CodeMirrorConfiguration,
},
],
})
export class AppModule {}