1.0.14 • Published 11 months ago

apc-ngx-codemirror-custom v1.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

ngx-codemirror npm CircleCI coverage

DEMO: https://ngx-codemirror.vercel.app

Dependencies

Latest version available for each version of Angular

@ctrl/ngx-codemirrorAngular
1.3.106.x 7.x
2.2.18.x
3.1.39.x
4.1.110.x 11.x
current>= 12.x

An Angular component wrapper for CodeMirror that extends ngModel. Based on JedWatson/react-codemirror

Used in:

tsquery playground: https://tsquery-playground.firebaseapp.com/

Install

codemirror is a peer dependency and must also be installed

npm install @ctrl/ngx-codemirror codemirror

Use

Import CodemirrorModule and FormsModule and bring in the codemirror files for parsing the language you wish to use.

In your NgModule:

import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';

  // add to imports:
  imports: [
    BrowserModule,
    FormsModule,
    CodemirrorModule,
    ...
  ]

In your main.ts or at the root of your application, see documentation:

import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/markdown/markdown';

Import the base css file and your theme

@import '~codemirror/lib/codemirror';
@import '~codemirror/theme/material';

Use The Component

<ngx-codemirror
  [(ngModel)]="content"
  [options]="{
    lineNumbers: true,
    theme: 'material',
    mode: 'markdown'
  }"
></ngx-codemirror>

Inputs

All Inputs of ngModel and

  • options - options passed to the CodeMirror instance see http://codemirror.net/doc/manual.html#config
  • name - name applied to the created textarea
  • autoFocus - setting applied to the created textarea
  • preserveScrollPosition - preserve previous scroll position after updating value

Outputs

All outputs of ngModel and

  • focusChange - called when the editor is focused or loses focus
  • scroll - called when the editor is scrolled (not wrapped inside angular change detection must manually trigger change detection or run inside ngzone)
  • cursorActivity - called when the text cursor is moved
  • drop - called when file(s) are dropped

License

MIT


GitHub @scttcper  ·  Twitter @scttcper

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago