npm install ngx-quill- for projects using Angular < v5.0.0 install npm install ngx-quill@1.6.0
- install @angular/core, @angular/common, @angular/forms, @angular/platform-browser, quill and rxjs - peer dependencies of ngx-quill include theme stylings: bubble.css, snow.css of quilljs in your index.html, or add them in your css/scss files with @import statements, or add them external stylings in your build process.
import { QuillModule } from 'ngx-quill'
@NgModule({
imports: [
...,
QuillModule.forRoot()
],
...
})
class YourModule { ... }- use
<quill-editor></quill-editor>in your templates to add a default quill editor - do not forget to include quill + theme css in your buildprocess, module or index.html!
<!-- quill style -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">- for builds with angular-cli >=6 only add quilljs to your scripts or scripts section of angular.json, if you need it as a global :)!
html sample
<quill-editor formControlName="description"
placeholder="Enter Description text...."
format="html"
[styles]=editorStyle
[modules]="editorConfig"
(onContentChanged)="onEditorContentChange($event)"
id="field_description">
</quill-editor>onEditorContentChange(e: any) {
this.limitEditTextSize(e);
}
limitEditTextSize(e: any) {
const textLimit = 10000;
if (e.editor.getLength() > textLimit) {
e.editor.deleteText(textLimit, e.editor.getLength());
}
}editorConfig = {
toolbar: [
['bold', 'italic', 'underline'], // toggled buttons
[{ list: 'ordered' }, { list: 'bullet' }],
['link']
]
};
editorStyle = {
height: '250px'
}; <span [innerHTML]="course.description"></span>On styles.scss
strong {
font-weight: bold !important;
}To use Quill extensions on jhipster, such as quill-image-resize, it is important to defile window.Quill as a global variable.
Edit file webpack.common.js
module.exports = (options) => (
{
// ...
pluguins: [
// ...
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js'
}),
// ...
]
}
);npm install quill-image-resize-module- Register ImageResize module on component
- Turn ImageResize option on in Quill Edit
// Component class
import * as QuillNamespace from 'quill';
let Quill: any = QuillNamespace;
import ImageResize from 'quill-image-resize-module';
Quill.register('modules/imageResize', ImageResize);
editorConfig = {
toolbar: [
['bold', 'italic', 'underline'], // toggled buttons
[{ list: 'ordered' }, { list: 'bullet' }],
['link'],
['image', 'video']
],
imageResize: {},
};<quill-editor formControlName="description"
placeholder="Enter Description text...."
format="html"
[styles]=editorStyle
[modules]="editorConfig"
(onContentChanged)="onEditorContentChange($event)"
id="field_description">
</quill-editor>