ngx-quill
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -122,27 +122,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var Quill = __webpack_require__(5); | ||
// function createMinMaxValidator(minLength: number, maxLength: number, quillEditor: any) { | ||
// return function validateMinMax(c: FormControl) { | ||
// let err: { | ||
// minLengthError?: {given: number, minLength: number}; | ||
// maxLengthError?: {given: number, maxLength: number}; | ||
// } = {}, | ||
// valid = true; | ||
// const textLength = quillEditor.getText().trim().length; | ||
// if (minLength) { | ||
// err.minLengthError = { | ||
// given: textLength, | ||
// minLength: minLength | ||
// }; | ||
// valid = textLength >= minLength; | ||
// } | ||
// if (maxLength) { | ||
// err.maxLengthError = { | ||
// given: textLength, | ||
// maxLength: maxLength | ||
// }; | ||
// valid = textLength < maxLength; | ||
// } | ||
// return valid ? null : err; | ||
// }; | ||
// } | ||
var QuillEditorComponent = (function () { | ||
@@ -185,3 +160,2 @@ function QuillEditorComponent(elementRef) { | ||
}); | ||
//this.validateFn = createMinMaxValidator(this.minLength, this.maxLength, this.quillEditor); | ||
if (this.content) { | ||
@@ -261,3 +235,3 @@ this.quillEditor.pasteHTML(this.content); | ||
}; | ||
valid = textLength < this.maxLength; | ||
valid = textLength <= this.maxLength && valid; | ||
} | ||
@@ -264,0 +238,0 @@ return valid ? null : err; |
@@ -122,27 +122,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var Quill = __webpack_require__(5); | ||
// function createMinMaxValidator(minLength: number, maxLength: number, quillEditor: any) { | ||
// return function validateMinMax(c: FormControl) { | ||
// let err: { | ||
// minLengthError?: {given: number, minLength: number}; | ||
// maxLengthError?: {given: number, maxLength: number}; | ||
// } = {}, | ||
// valid = true; | ||
// const textLength = quillEditor.getText().trim().length; | ||
// if (minLength) { | ||
// err.minLengthError = { | ||
// given: textLength, | ||
// minLength: minLength | ||
// }; | ||
// valid = textLength >= minLength; | ||
// } | ||
// if (maxLength) { | ||
// err.maxLengthError = { | ||
// given: textLength, | ||
// maxLength: maxLength | ||
// }; | ||
// valid = textLength < maxLength; | ||
// } | ||
// return valid ? null : err; | ||
// }; | ||
// } | ||
var QuillEditorComponent = (function () { | ||
@@ -185,3 +160,2 @@ function QuillEditorComponent(elementRef) { | ||
}); | ||
//this.validateFn = createMinMaxValidator(this.minLength, this.maxLength, this.quillEditor); | ||
if (this.content) { | ||
@@ -261,3 +235,3 @@ this.quillEditor.pasteHTML(this.content); | ||
}; | ||
valid = textLength < this.maxLength; | ||
valid = textLength <= this.maxLength && valid; | ||
} | ||
@@ -264,0 +238,0 @@ return valid ? null : err; |
@@ -18,3 +18,3 @@ { | ||
"core-js": "2.4.1", | ||
"ngx-quill": "^0.2.2", | ||
"ngx-quill": "^0.3.0", | ||
"rxjs": "5.0.0-rc.4", | ||
@@ -21,0 +21,0 @@ "zone.js": "0.7.4" |
@@ -16,3 +16,3 @@ import { Component } from '@angular/core'; | ||
{{title}} | ||
<quill-editor [(ngModel)]="title" required="true" [readOnly]="isReadOnly" [modules]="{toolbar: false}" (onContentChanged)="logChange($event);"></quill-editor> | ||
<quill-editor [(ngModel)]="title" [maxLength]="5" [minLength]="3" required="true" [readOnly]="isReadOnly" [modules]="{toolbar: false}" (onContentChanged)="logChange($event);"></quill-editor> | ||
` | ||
@@ -19,0 +19,0 @@ }) |
{ | ||
"name": "ngx-quill", | ||
"license": "MIT", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Bengt Weiße" |
@@ -5,27 +5,2 @@ "use strict"; | ||
var Quill = require('quill'); | ||
// function createMinMaxValidator(minLength: number, maxLength: number, quillEditor: any) { | ||
// return function validateMinMax(c: FormControl) { | ||
// let err: { | ||
// minLengthError?: {given: number, minLength: number}; | ||
// maxLengthError?: {given: number, maxLength: number}; | ||
// } = {}, | ||
// valid = true; | ||
// const textLength = quillEditor.getText().trim().length; | ||
// if (minLength) { | ||
// err.minLengthError = { | ||
// given: textLength, | ||
// minLength: minLength | ||
// }; | ||
// valid = textLength >= minLength; | ||
// } | ||
// if (maxLength) { | ||
// err.maxLengthError = { | ||
// given: textLength, | ||
// maxLength: maxLength | ||
// }; | ||
// valid = textLength < maxLength; | ||
// } | ||
// return valid ? null : err; | ||
// }; | ||
// } | ||
var QuillEditorComponent = (function () { | ||
@@ -68,3 +43,2 @@ function QuillEditorComponent(elementRef) { | ||
}); | ||
//this.validateFn = createMinMaxValidator(this.minLength, this.maxLength, this.quillEditor); | ||
if (this.content) { | ||
@@ -144,3 +118,3 @@ this.quillEditor.pasteHTML(this.content); | ||
}; | ||
valid = textLength < this.maxLength; | ||
valid = textLength <= this.maxLength && valid; | ||
} | ||
@@ -147,0 +121,0 @@ return valid ? null : err; |
@@ -164,2 +164,21 @@ import { TestBed, async, fakeAsync, tick, ComponentFixture } from '@angular/core/testing'; | ||
})); | ||
it('should validate maxlength and minlength', async(() => { | ||
const editorComponent = this.fixture.debugElement.children[0].componentInstance; | ||
this.fixture.detectChanges(); | ||
editorComponent.quillEditor.setText('Blume'); | ||
this.fixture.detectChanges(); | ||
expect(this.fixture.debugElement.children[0].nativeElement.className).toMatch('ng-valid'); | ||
this.fixture.componentInstance.minLength = 3; | ||
this.fixture.componentInstance.maxLength = 5; | ||
this.fixture.detectChanges(); | ||
this.fixture.whenStable(() => { | ||
expect(this.fixture.debugElement.children[0].nativeElement.className).toMatch('ng-invalid'); | ||
}); | ||
})); | ||
}); |
@@ -24,34 +24,2 @@ import { | ||
// function createMinMaxValidator(minLength: number, maxLength: number, quillEditor: any) { | ||
// return function validateMinMax(c: FormControl) { | ||
// let err: { | ||
// minLengthError?: {given: number, minLength: number}; | ||
// maxLengthError?: {given: number, maxLength: number}; | ||
// } = {}, | ||
// valid = true; | ||
// const textLength = quillEditor.getText().trim().length; | ||
// if (minLength) { | ||
// err.minLengthError = { | ||
// given: textLength, | ||
// minLength: minLength | ||
// }; | ||
// valid = textLength >= minLength; | ||
// } | ||
// if (maxLength) { | ||
// err.maxLengthError = { | ||
// given: textLength, | ||
// maxLength: maxLength | ||
// }; | ||
// valid = textLength < maxLength; | ||
// } | ||
// return valid ? null : err; | ||
// }; | ||
// } | ||
@Component({ | ||
@@ -84,3 +52,2 @@ selector: 'quill-editor', | ||
emptyArray: any[] = []; | ||
// validateFn: Function = ():any => null; | ||
content: any; | ||
@@ -138,4 +105,2 @@ defaultModules = { | ||
//this.validateFn = createMinMaxValidator(this.minLength, this.maxLength, this.quillEditor); | ||
if (this.content) { | ||
@@ -189,4 +154,2 @@ this.quillEditor.pasteHTML(this.content); | ||
} | ||
//this.validateFn = createMinMaxValidator(min, max, this.quillEditor); | ||
} | ||
@@ -243,3 +206,3 @@ } | ||
valid = textLength < this.maxLength; | ||
valid = textLength <= this.maxLength && valid; | ||
} | ||
@@ -246,0 +209,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3597076
87116