Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
Update to V1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Dec 19, 2016
1 parent 26238e5 commit 0b5f56e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/*
npm-debug.log
examples/*
35 changes: 35 additions & 0 deletions examples/01-example.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Component, ViewChild, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'quill-example-01',
template: `<quill-editor [(ngModel)]="editorContent"
[config]="editorConfig"
(ready)="onEditorCreated($event)">
(change)="onContentChanged($event)">
</quill-editor>
<br>
<div class="ql-editor" [innerHTML]="editorContent"></div>`
})
export class QuillEditorComponentExample01 {

public editorContent = `<p>I am Example 01</p>`;
public editorConfig = {
placeholder: "输入公告内容,支持html"
};

constructor() {}

onEditorCreated(quill) {
console.log('this is quill object', quill);
}

onContentChanged({ quill, html, text }) {
console.log(quill, html, text);
}

ngOnInit() {
setTimeout(() => {
this.editorContent = '<h1>i am changed!</h1>'
}, 1800)
}
}
48 changes: 48 additions & 0 deletions examples/02-example.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Component, ViewChild, ViewEncapsulation } from '@angular/core';
import { FormGroup, AbstractControl, FormBuilder, Validators } from '@angular/forms';

@Component({
selector: 'quill-example-02',
styles: [`.form-group { border: 1px solid #ccc; } .has-error { border-color: red; } .has-success { border-color: green; }`],
template: `<form [formGroup]="form" (ngSubmit)="onSubmit(form.value)" class="form">
<div class="form-group" [ngClass]="{'has-error': (!content.valid && content.touched), 'has-success': (content.valid && content.touched)}">
<quill-editor class="form-control" [formControl]="content" [config]="editorConfig"></quill-editor>
</div>
</form>`
})
export class QuillEditorComponentExample02 {

public form:FormGroup;
public content:AbstractControl;

public editorConfig = {
theme: 'bubble',
placeholder: "输入任何内容,支持html",
modules: {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['link', 'image'],
['clean']
]
}
};

constructor(private _fb:FormBuilder) {
this.form = _fb.group({
'content': ['<p>I am Example 02</p>', Validators.compose([Validators.required])],
});

this.content = this.form.controls['content'];
};

public submitAnnouncement(values:Object):void {
if (this.form.valid) {
console.log('Submit!', values);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-quill-editor",
"version": "1.0.0",
"version": "1.1.0",
"description": "quill editor component for Angular2",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0b5f56e

Please sign in to comment.