This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
unknown
committed
Dec 19, 2016
1 parent
26238e5
commit 0b5f56e
Showing
4 changed files
with
85 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/* | ||
npm-debug.log | ||
examples/* |
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,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) | ||
} | ||
} |
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,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); | ||
} | ||
} | ||
} |
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