Skip to content

Commit

Permalink
fix(): improve readme tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Ks89 committed Jul 24, 2018
1 parent 6ea313d commit 503693a
Show file tree
Hide file tree
Showing 16 changed files with 875 additions and 17 deletions.
7 changes: 7 additions & 0 deletions @ks89/ngx-codemirror/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/*
*.iml
.idea
aot/*
lib/*
npm-debug.log
.DS_Store
1 change: 1 addition & 0 deletions @ks89/ngx-codemirror/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aot/*
22 changes: 22 additions & 0 deletions @ks89/ngx-codemirror/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2018 Stefano Cappa (Ks89)
Copyright (c) 2016 Simon Babay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
141 changes: 141 additions & 0 deletions @ks89/ngx-codemirror/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# @ks89/ngx-codemirror

**Fork of the official [ng2-codemirror](https://github.com/chymz/ng2-codemirror) library with angular-universal / Server side rendering support.**

<br><br>

**Tested only with Angular 6.x.x and angular-cli 6.x.x**


## Installation

`npm i --save @ks89/ngx-codemirror@latest codemirror`

## Configuration

1. Install `npm i --save-dev @types/node`
2. Modify your tsconfig.app.json adding this:

```
"compilerOptions": {
"types": [
"node"
]
}
```
3. Add this in your main tsconfig.json (if already not available):
```
"compilerOptions": {
"typeRoots": [
"node_modules/@types"
]
}
```
4. Import language in main.ts
```
import 'codemirror/mode/htmlmixed/htmlmixed';
import 'codemirror/mode/javascript/javascript';
```
5. Add `"node_modules/codemirror/lib/codemirror.js"` in all scripts arrays of yout angular.json file
```
...
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
...
"scripts": [
"node_modules/codemirror/lib/codemirror.js"
],
...
}
}
},
...
"test": {
...
"scripts": [
"node_modules/codemirror/lib/codemirror.js"
],
...
}
```
<br><br>
## Contributions
To build this project run `tsc` in the root folder.
<br><br>
Use the [CodeMirror (5.x)](http://codemirror.net/) code editor in your Angular application.
**Demo** : https://embed.plnkr.co/8e9gxss9u10VeFrv29Zt/
### <a name="install"></a>Installation
- Include Codemirror javascript files in your application (with files for modes)
- Install ng2-codemirror
- JSPM : `jspm install npm:ng2-codemirror`
- NPM : `npm install ng2-codemirror`
### <a name="dependencies"></a>Dependencies
CodeMirror library is required for this component :
- Install via NPM : `npm install codemirror`
- Install via JSPM : `jspm install npm:codemirror`
CodeMirror need to be accessible by `import 'codemirror'`
Then you need to include base CSS of codemirror located in `codemirror/lib/codemirror.css`
### <a name="sample"></a>Sample
Include `CodemirrorModule` in your main module :
```javascript
import { CodemirrorModule } from 'ng2-codemirror';
@NgModule({
// ...
imports: [
CodemirrorModule
],
// ...
})
export class AppModule { }
```

```javascript
import { Component } from 'angular2/core';

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

### <a name="config"></a>Configuration

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

### <a name="licence"></a>Licence
See `LICENSE` file
220 changes: 220 additions & 0 deletions @ks89/ngx-codemirror/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 503693a

Please sign in to comment.