Skip to content

Commit

Permalink
create angular 6 example
Browse files Browse the repository at this point in the history
  • Loading branch information
fxmontigny committed Jun 14, 2018
1 parent cff4ab9 commit bb1535b
Show file tree
Hide file tree
Showing 52 changed files with 11,891 additions and 111 deletions.
118 changes: 118 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# ng2-ace-editor

[![npm version](https://badge.fury.io/js/ng2-ace-editor.svg)](https://www.npmjs.com/package/ng2-ace-editor)
Ace editor integration with typescript for angular 5.
**To use Angular 4 install version 0.3.1 (npm i -S [email protected]).**

# Install
`npm i -S ng2-ace-editor`

##### Load the module for your app:

```javascript
import { AceEditorModule } from 'ng2-ace-editor';

@NgModule({
...
imports: [
...
AceEditorModule
]
})
```

# Use directive

> Minimal
```js
//import { AceEditorModule } from 'ng2-ace-editor';

import { Component } from '@angular/core';

@Component({
template: `
<div ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
></div>
`
})
export class MyComponent {
text:string = "";
}
```

> Complete
```js
import { Component } from '@angular/core';

//to use theme "eclipse"
//with angular-cli add "../node_modules/ace-builds/src-min/ace.js"
//and "../node_modules/ace-builds/src-min/theme-eclipse.js" to "scripts" var into the file angular-cli.json

@Component({
template: `
<div ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
[mode]="'sql'" //string or object (thx ckiffel)
[theme]="'eclipse'"
[options]="options"
[readOnly]="false"
[autoUpdateContent]="true" //change content when [text] change
[durationBeforeCallback]="1000" //wait 1s before callback 'textChanged' sends new value
(textChanged)="onChange($event)"
style="min-height: 200px; width:100%; overflow: auto;"></div>
`
})
export class MyComponent {
text:string = "";
options:any = {maxLines: 1000, printMargin: false};

onChange(code) {
console.log("new code", code);
}
}
```

# Use Component

```js
import {Component, ViewChild} from '@angular/core';

//to use theme eclipse
//with angular-cli add "../node_modules/ace-builds/src-min/ace.js"
//and "../node_modules/ace-builds/src-min/theme-eclipse.js" to "scripts" var into the file angular-cli.json

@Component({
template: `
<ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
#editor style="height:150px;"></ace-editor>
`
})
export class AceCmp {
@ViewChild('editor') editor;
text: string = "";

ngAfterViewInit() {
this.editor.setTheme("eclipse");

this.editor.getEditor().setOptions({
enableBasicAutocompletion: true
});

this.editor.getEditor().commands.addCommand({
name: "showOtherCompletions",
bindKey: "Ctrl-.",
exec: function (editor) {

}
})
}
}
```


# Power by
[Use Code](http://www.use-code.com)
70 changes: 35 additions & 35 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"name": "ng2-ace-editor",
"version": "0.3.7",
"description": "Ace editor integration with typescript for Angular.",
"main": "bundles/ng2-ace-editor.umd.min.js",
"module": "index.js",
"typings": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/fxmontigny/ng2-ace-editor.git"
},
"keywords": [
"angular5",
"angular cli",
"ace",
"brace",
"typescript",
"directive",
"component",
"editor",
"ng2-ace",
"angular2-ace"
],
"author": "François-Xavier Montigny <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/fxmontigny/ng2-ace-editor/issues"
},
"dependencies": {
"ace-builds": "^1.2.9",
"brace": "^0.10.0"
},
"peerDependencies": {
"@angular/core": "^6.0.0"
}
}
"name": "ng2-ace-editor",
"version": "0.3.8",
"description": "Ace editor integration with typescript for Angular.",
"main": "bundles/ng2-ace-editor.umd.min.js",
"module": "index.js",
"typings": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/fxmontigny/ng2-ace-editor.git"
},
"keywords": [
"angular5",
"angular cli",
"ace",
"brace",
"typescript",
"directive",
"component",
"editor",
"ng2-ace",
"angular2-ace"
],
"author": "François-Xavier Montigny <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/fxmontigny/ng2-ace-editor/issues"
},
"dependencies": {
"ace-builds": "^1.2.9",
"brace": "^0.10.0"
},
"peerDependencies": {
"@angular/core": "^6.0.0"
}
}
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/basic-5.X.X/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions examples/basic-5.X.X/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/dist-server
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db
27 changes: 27 additions & 0 deletions examples/basic-5.X.X/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Basic

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.3.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions examples/basic-5.X.X/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
File renamed without changes.
49 changes: 49 additions & 0 deletions examples/basic-5.X.X/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "basic",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"ng2-ace-editor": "^0.3.5",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
File renamed without changes.
6 changes: 6 additions & 0 deletions examples/basic-5.X.X/src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.aceEditorDirective {
margin-top: 50px;
min-height: 200px;
width: 100%;
overflow: auto;
}
16 changes: 16 additions & 0 deletions examples/basic-5.X.X/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>
Basic
</h1>
<ace-editor #firstEditor [text]="content" (textChanged)="onRuleChange($event)" [autoUpdateContent]="true" style="min-height: 200px; width:100%; overflow: auto;"
mode="html"></ace-editor>
<div ace-editor [text]="content" class="aceEditorDirective" mode="sql"></div>
<h2>Highlight</h2>
<ace-editor #highlight [text]="content" mode="sql" style="min-height: 200px; width:100%; overflow: auto;"></ace-editor>
<h2>Auto update</h2>
<ace-editor [(text)]="contentAutoUpdate" mode="sql" style="min-height: 200px; width:100%; overflow: auto;"></ace-editor>
<div ace-editor [(text)]="contentAutoUpdate" mode="sql" style="min-height: 200px; width:100%; overflow: auto;"></div>
<h1>Auto height</h1>
<ace-editor #editorInfinity [text]="content" [options]="{maxLines: 'Infinity'}" style="min-height: 50px; width:100%;"></ace-editor>
<h1>NgModel</h1>
<ace-editor [(text)]="myCode" style="min-height: 200px; width:100%; overflow: auto;"></ace-editor>
<ace-editor [(text)]="myCode" style="min-height: 200px; width:100%; overflow: auto;"></ace-editor>
27 changes: 27 additions & 0 deletions examples/basic-5.X.X/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
Loading

0 comments on commit bb1535b

Please sign in to comment.