Giter Site home page Giter Site logo

sameralrawi / ngx-codemirror Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scttcper/ngx-codemirror

0.0 2.0 0.0 1.46 MB

Codemirror Wrapper for Angular

Home Page: https://typectrl.github.io/ngx-codemirror/

License: MIT License

TypeScript 73.90% HTML 11.28% JavaScript 5.90% CSS 8.92%

ngx-codemirror's Introduction

ngx-codemirror


npm travis codecov

DEMO: https://typectrl.github.io/ngx-codemirror/

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.

// Added to NgModule
import { CodemirrorModule } from '@ctrl/ngx-codemirror';

// Import your required language in main.ts or at the root of your application
// see https://codemirror.net/mode/index.html
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/markdown/markdown';

Import the base css file and your theme

@import "~codemirror/lib/codemirror.css";
@import "~codemirror/theme/material.css";

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

License

MIT


GitHub @scttcper  ·  Twitter @scttcper

ngx-codemirror's People

Contributors

angular-cli avatar renovate-bot avatar renovate[bot] avatar scttcper avatar zakhenry avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.