npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lt-codemirror

v10.0.0

Published

Use the [CodeMirror (5.x)](http://codemirror.net/) code editor in your Angular application.

Downloads

51

Readme

Angular - Codemirror component

Use the CodeMirror (5.x) code editor in your Angular application.

| versione | Typescript Support | Angular Support | | :-------------: |:-----------------------:| :--------------:| | ^1.x.x | ~2.3.3 | ^4.2.4 | | ^2.x.x | ^2.4.2 | ^5.0.0 | | ^3.x.x | ~2.9.2 | ^6.0.0 | | ^4.x.x | ~3.2.2 | ^7.0.0 | | ^5.x.x | ~3.5.3 | ^8.0.0 | | ^6.x.x | ~3.8.3 | ^9.0.0 | | ^7.x.x | ~4.0.2 | ^10.0.0 | | ^8.x.x | ~4.1.5 | ^11.0.0 | | ^9.x.x | ~4.3.5 | ^12.0.0 | | ^10.x.x | ~4.6.4 | ^13.0.0 |

NB:

  • Breaking Changes:
    • from versione 10.x.x angular 12 is not supported.
    • from version 9.x.x angular 11 is not supported.
    • from version 8.x.x angular 10 is not supported.
    • from version 7.x.x angular 9 is not supported.
    • from version 6.x.x angular 8 is not supported.
    • from version 5.x.x angular 7 is not supported.
    • from version 4.x.x angular 6 is not supported.
    • from version 3.x.x angular 2,4 and 5 not are more supported.

Installation

  • Include Codemirror javascript files in your application (with files for modes)
  • Install lt-codemirror
    • NPM : npm install lt-codemirror

Dependencies

CodeMirror library is required for this component, if NPM doesn't install it for you, type this :

  
  npm install codemirror

CodeMirror need to be accessible by import 'codemirror'

Then you need to include base CSS and base JS of codemirror in angular.json

  {
    "build": {
      "options": {
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          "src/styles.css",
          "./node_modules/codemirror/lib/codemirror.css",
          "./node_modules/codemirror/theme/dracula.css"
        ],
        "scripts": [
          "./node_modules/codemirror/lib/codemirror.js",
          "./node_modules/codemirror/mode/htmlmixed/htmlmixed.js"
        ]
      },
    }
  }

Sample

Include CodemirrorModule in your main module :

import { CodemirrorModule } from 'lt-codemirror';

@NgModule({
  // ...
  imports:      [
    CodemirrorModule
  ],
  // ...
})
export class AppModule { }
import { Component } from '@angular/core';

@Component({
  selector: 'sample',
  template: `
    <codemirror [(ngModel)]="code"
      [config]="{...}"
      [size]="{w:'100%',h:477}"
      (focus)="onFocus()"
      (blur)="onBlur()">
    </codemirror>
  `
})
export class Sample{
  constructor(){
    this.code = `// Some code...`;
  }
}

if you want to change the themes or add mode, you must add this simple line

Example

  {
    "apps": [{
      "styles": [
        "../node_modules/codemirror/lib/codemirror.css",
        "../node_modules/codemirror/theme/dracula.css",
      ],
      "scripts": [
        "../node_modules/codemirror/lib/codemirror.js",
        "../node_modules/codemirror/mode/htmlmixed/htmlmixed.js"
      ]
    }]
  }
import { Component } from '@angular/core';
import 'codemirror/mode/htmlmixed/htmlmixed';

@Component({
  selector: 'sample',
  template: `
    <codemirror [(ngModel)]="code"
      [config]="config"
      [size]="{w:'100%',h:477}"
      (focus)="onFocus()"
      (blur)="onBlur()">
    </codemirror>
  `
})
export class Sample{
  constructor(){
    this.code = `// Some code...`;
    this.config = {
      lineNumbers: true,
      mode : 'htmlmixed',
      styleActiveLine: true,
      matchBrackets: true,
      theme: 'dracula'
    }
  }
}

New Implementation

  • Added the Size for TextArea

Configuration

  • config : The configuration object for CodeMirror see http://codemirror.net/doc/manual.html#config

Credits to Simon Babay forked from the original package.

Licence

See LICENSE file