forked from yabab-dev/ng2-codemirror
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
875 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aot/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.