Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ctrl/ngx-codemirror

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctrl/ngx-codemirror

CodeMirror wrapper for Angular

  • 3.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-1.54%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-codemirror


npm travis codecov

DEMO: https://ngx-codemirror.netlify.com/

Dependencies

Latest version available for each version of Angular

@ctrl/ngx-codemirrorAngular
1.3.106.x 7.x
2.2.18.x
current>= 9.x

An Angular component wrapper for CodeMirror that extends ngModel

Based on:

JedWatson/react-codemirror - This project is mostly a port of react-codemirror chymz/ng2-codemirror - Good to reference

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 bring in the codemirror files for parsing the langague 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

Keywords

FAQs

Package last updated on 01 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc