ngx-quill
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -10,43 +10,66 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["ngx-quill"] = factory(root["@angular/core"], root["@angular/forms"], root["@angular/platform-browser"], root["quill"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 1); | ||
/******/ }) | ||
@@ -56,323 +79,326 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(1)); | ||
module.exports = require("@angular/core"); | ||
/***/ }, | ||
/***/ }), | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(2); | ||
var quill_editor_component_1 = __webpack_require__(3); | ||
var QuillModule = (function () { | ||
function QuillModule() { | ||
} | ||
return QuillModule; | ||
}()); | ||
QuillModule = __decorate([ | ||
core_1.NgModule({ | ||
declarations: [ | ||
quill_editor_component_1.QuillEditorComponent | ||
], | ||
imports: [], | ||
exports: [quill_editor_component_1.QuillEditorComponent], | ||
providers: [] | ||
}) | ||
], QuillModule); | ||
exports.QuillModule = QuillModule; | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(2)); | ||
/***/ }, | ||
/***/ }), | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = require("@angular/core"); | ||
"use strict"; | ||
/***/ }, | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(0); | ||
var quill_editor_component_1 = __webpack_require__(3); | ||
var QuillModule = (function () { | ||
function QuillModule() { | ||
} | ||
return QuillModule; | ||
}()); | ||
QuillModule = __decorate([ | ||
core_1.NgModule({ | ||
declarations: [ | ||
quill_editor_component_1.QuillEditorComponent | ||
], | ||
imports: [], | ||
exports: [quill_editor_component_1.QuillEditorComponent], | ||
providers: [] | ||
}) | ||
], QuillModule); | ||
exports.QuillModule = QuillModule; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(2); | ||
var forms_1 = __webpack_require__(4); | ||
var core_2 = __webpack_require__(2); | ||
var platform_browser_1 = __webpack_require__(5); | ||
var Quill = __webpack_require__(6); | ||
var QuillEditorComponent = QuillEditorComponent_1 = (function () { | ||
function QuillEditorComponent(elementRef, doc, renderer) { | ||
this.elementRef = elementRef; | ||
this.doc = doc; | ||
this.renderer = renderer; | ||
this.emptyArray = []; | ||
this.defaultModules = { | ||
toolbar: [ | ||
['bold', 'italic', 'underline', 'strike'], | ||
['blockquote', 'code-block'], | ||
[{ 'header': 1 }, { 'header': 2 }], | ||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], | ||
[{ 'script': 'sub' }, { 'script': 'super' }], | ||
[{ 'indent': '-1' }, { 'indent': '+1' }], | ||
[{ 'direction': 'rtl' }], | ||
[{ 'size': ['small', false, 'large', 'huge'] }], | ||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], | ||
[{ 'color': this.emptyArray.slice() }, { 'background': this.emptyArray.slice() }], | ||
[{ 'font': this.emptyArray.slice() }], | ||
[{ 'align': this.emptyArray.slice() }], | ||
['clean'], | ||
['link', 'image', 'video'] // link and image, video | ||
] | ||
}; | ||
this.style = {}; | ||
this.strict = true; | ||
this.onEditorCreated = new core_1.EventEmitter(); | ||
this.onContentChanged = new core_1.EventEmitter(); | ||
this.onSelectionChanged = new core_1.EventEmitter(); | ||
this.onModelChange = function () { }; | ||
this.onModelTouched = function () { }; | ||
} | ||
QuillEditorComponent.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
var toolbarElem = this.elementRef.nativeElement.querySelector('[quill-editor-toolbar]'); | ||
var modules = this.modules || this.defaultModules; | ||
var placeholder = 'Insert text here ...'; | ||
if (this.placeholder !== null && this.placeholder !== undefined) { | ||
placeholder = this.placeholder.trim(); | ||
} | ||
if (toolbarElem) { | ||
modules['toolbar'] = toolbarElem; | ||
} | ||
this.elementRef.nativeElement.insertAdjacentHTML('beforeend', '<div quill-editor-element></div>'); | ||
this.editorElem = this.elementRef.nativeElement.querySelector('[quill-editor-element]'); | ||
if (this.style) { | ||
Object.keys(this.style).forEach(function (key) { | ||
_this.renderer.setStyle(_this.editorElem, key, _this.style[key]); | ||
}); | ||
} | ||
this.quillEditor = new Quill(this.editorElem, { | ||
modules: modules, | ||
placeholder: placeholder, | ||
readOnly: this.readOnly || false, | ||
theme: this.theme || 'snow', | ||
formats: this.formats, | ||
bounds: this.bounds || this.doc.body, | ||
strict: this.strict, | ||
scrollingContainer: this.scrollingContainer | ||
}); | ||
if (this.content) { | ||
var contents = this.quillEditor.clipboard.convert(this.content); | ||
this.quillEditor.setContents(contents); | ||
this.quillEditor.history.clear(); | ||
} | ||
this.onEditorCreated.emit(this.quillEditor); | ||
// mark model as touched if editor lost focus | ||
this.quillEditor.on('selection-change', function (range, oldRange, source) { | ||
_this.onSelectionChanged.emit({ | ||
editor: _this.quillEditor, | ||
range: range, | ||
oldRange: oldRange, | ||
source: source | ||
}); | ||
if (!range) { | ||
_this.onModelTouched(); | ||
} | ||
}); | ||
// update model if text changes | ||
this.quillEditor.on('text-change', function (delta, oldDelta, source) { | ||
var html = _this.editorElem.children[0].innerHTML; | ||
var text = _this.quillEditor.getText(); | ||
if (html === '<p><br></p>') { | ||
html = null; | ||
} | ||
_this.onModelChange(html); | ||
_this.onContentChanged.emit({ | ||
editor: _this.quillEditor, | ||
html: html, | ||
text: text, | ||
delta: delta, | ||
oldDelta: oldDelta, | ||
source: source | ||
}); | ||
}); | ||
}; | ||
QuillEditorComponent.prototype.ngOnChanges = function (changes) { | ||
if (changes['readOnly'] && this.quillEditor) { | ||
this.quillEditor.enable(!changes['readOnly'].currentValue); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.writeValue = function (currentValue) { | ||
this.content = currentValue; | ||
if (this.quillEditor) { | ||
if (currentValue) { | ||
this.quillEditor.setContents(this.quillEditor.clipboard.convert(this.content)); | ||
return; | ||
} | ||
this.quillEditor.setText(''); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.registerOnChange = function (fn) { | ||
this.onModelChange = fn; | ||
}; | ||
QuillEditorComponent.prototype.registerOnTouched = function (fn) { | ||
this.onModelTouched = fn; | ||
}; | ||
QuillEditorComponent.prototype.validate = function () { | ||
if (!this.quillEditor) { | ||
return null; | ||
} | ||
var err = {}, valid = true; | ||
var textLength = this.quillEditor.getText().trim().length; | ||
if (this.minLength && textLength && textLength < this.minLength) { | ||
err.minLengthError = { | ||
given: textLength, | ||
minLength: this.minLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.maxLength && textLength > this.maxLength) { | ||
err.maxLengthError = { | ||
given: textLength, | ||
maxLength: this.maxLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.required && !textLength) { | ||
err.requiredError = { | ||
empty: true | ||
}; | ||
valid = false; | ||
} | ||
return valid ? null : err; | ||
}; | ||
return QuillEditorComponent; | ||
}()); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "theme", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "modules", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "readOnly", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "placeholder", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "maxLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "minLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "required", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Array) | ||
], QuillEditorComponent.prototype, "formats", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "style", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "strict", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "scrollingContainer", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "bounds", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onEditorCreated", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onContentChanged", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onSelectionChanged", void 0); | ||
QuillEditorComponent = QuillEditorComponent_1 = __decorate([ | ||
core_1.Component({ | ||
selector: 'quill-editor', | ||
template: "\n <ng-content select=\"[quill-editor-toolbar]\"></ng-content>\n", | ||
providers: [{ | ||
provide: forms_1.NG_VALUE_ACCESSOR, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}, { | ||
provide: forms_1.NG_VALIDATORS, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}], | ||
encapsulation: core_1.ViewEncapsulation.None | ||
}), | ||
__param(1, core_2.Inject(platform_browser_1.DOCUMENT)), | ||
__metadata("design:paramtypes", [core_1.ElementRef, Object, core_1.Renderer2]) | ||
], QuillEditorComponent); | ||
exports.QuillEditorComponent = QuillEditorComponent; | ||
var QuillEditorComponent_1; | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(0); | ||
var forms_1 = __webpack_require__(4); | ||
var core_2 = __webpack_require__(0); | ||
var platform_browser_1 = __webpack_require__(5); | ||
var QuillNamespace = __webpack_require__(6); | ||
var Quill = QuillNamespace; | ||
var QuillEditorComponent = QuillEditorComponent_1 = (function () { | ||
function QuillEditorComponent(elementRef, doc, renderer) { | ||
this.elementRef = elementRef; | ||
this.doc = doc; | ||
this.renderer = renderer; | ||
this.emptyArray = []; | ||
this.defaultModules = { | ||
toolbar: [ | ||
['bold', 'italic', 'underline', 'strike'], | ||
['blockquote', 'code-block'], | ||
[{ 'header': 1 }, { 'header': 2 }], | ||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], | ||
[{ 'script': 'sub' }, { 'script': 'super' }], | ||
[{ 'indent': '-1' }, { 'indent': '+1' }], | ||
[{ 'direction': 'rtl' }], | ||
[{ 'size': ['small', false, 'large', 'huge'] }], | ||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], | ||
[{ 'color': this.emptyArray.slice() }, { 'background': this.emptyArray.slice() }], | ||
[{ 'font': this.emptyArray.slice() }], | ||
[{ 'align': this.emptyArray.slice() }], | ||
['clean'], | ||
['link', 'image', 'video'] // link and image, video | ||
] | ||
}; | ||
this.style = {}; | ||
this.strict = true; | ||
this.onEditorCreated = new core_1.EventEmitter(); | ||
this.onContentChanged = new core_1.EventEmitter(); | ||
this.onSelectionChanged = new core_1.EventEmitter(); | ||
this.onModelChange = function () { }; | ||
this.onModelTouched = function () { }; | ||
} | ||
QuillEditorComponent.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
var toolbarElem = this.elementRef.nativeElement.querySelector('[quill-editor-toolbar]'); | ||
var modules = this.modules || this.defaultModules; | ||
var placeholder = 'Insert text here ...'; | ||
if (this.placeholder !== null && this.placeholder !== undefined) { | ||
placeholder = this.placeholder.trim(); | ||
} | ||
if (toolbarElem) { | ||
modules['toolbar'] = toolbarElem; | ||
} | ||
this.elementRef.nativeElement.insertAdjacentHTML('beforeend', '<div quill-editor-element></div>'); | ||
this.editorElem = this.elementRef.nativeElement.querySelector('[quill-editor-element]'); | ||
if (this.style) { | ||
Object.keys(this.style).forEach(function (key) { | ||
_this.renderer.setStyle(_this.editorElem, key, _this.style[key]); | ||
}); | ||
} | ||
this.quillEditor = new Quill(this.editorElem, { | ||
modules: modules, | ||
placeholder: placeholder, | ||
readOnly: this.readOnly || false, | ||
theme: this.theme || 'snow', | ||
formats: this.formats, | ||
bounds: this.bounds || this.doc.body, | ||
strict: this.strict, | ||
scrollingContainer: this.scrollingContainer | ||
}); | ||
if (this.content) { | ||
var contents = this.quillEditor.clipboard.convert(this.content); | ||
this.quillEditor.setContents(contents); | ||
this.quillEditor.history.clear(); | ||
} | ||
this.onEditorCreated.emit(this.quillEditor); | ||
// mark model as touched if editor lost focus | ||
this.quillEditor.on('selection-change', function (range, oldRange, source) { | ||
_this.onSelectionChanged.emit({ | ||
editor: _this.quillEditor, | ||
range: range, | ||
oldRange: oldRange, | ||
source: source | ||
}); | ||
if (!range) { | ||
_this.onModelTouched(); | ||
} | ||
}); | ||
// update model if text changes | ||
this.quillEditor.on('text-change', function (delta, oldDelta, source) { | ||
var html = _this.editorElem.children[0].innerHTML; | ||
var text = _this.quillEditor.getText(); | ||
if (html === '<p><br></p>') { | ||
html = null; | ||
} | ||
_this.onModelChange(html); | ||
_this.onContentChanged.emit({ | ||
editor: _this.quillEditor, | ||
html: html, | ||
text: text, | ||
delta: delta, | ||
oldDelta: oldDelta, | ||
source: source | ||
}); | ||
}); | ||
}; | ||
QuillEditorComponent.prototype.ngOnChanges = function (changes) { | ||
if (changes['readOnly'] && this.quillEditor) { | ||
this.quillEditor.enable(!changes['readOnly'].currentValue); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.writeValue = function (currentValue) { | ||
this.content = currentValue; | ||
if (this.quillEditor) { | ||
if (currentValue) { | ||
this.quillEditor.setContents(this.quillEditor.clipboard.convert(this.content)); | ||
return; | ||
} | ||
this.quillEditor.setText(''); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.registerOnChange = function (fn) { | ||
this.onModelChange = fn; | ||
}; | ||
QuillEditorComponent.prototype.registerOnTouched = function (fn) { | ||
this.onModelTouched = fn; | ||
}; | ||
QuillEditorComponent.prototype.validate = function () { | ||
if (!this.quillEditor) { | ||
return null; | ||
} | ||
var err = {}, valid = true; | ||
var textLength = this.quillEditor.getText().trim().length; | ||
if (this.minLength && textLength && textLength < this.minLength) { | ||
err.minLengthError = { | ||
given: textLength, | ||
minLength: this.minLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.maxLength && textLength > this.maxLength) { | ||
err.maxLengthError = { | ||
given: textLength, | ||
maxLength: this.maxLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.required && !textLength) { | ||
err.requiredError = { | ||
empty: true | ||
}; | ||
valid = false; | ||
} | ||
return valid ? null : err; | ||
}; | ||
return QuillEditorComponent; | ||
}()); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "theme", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "modules", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "readOnly", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "placeholder", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "maxLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "minLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "required", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Array) | ||
], QuillEditorComponent.prototype, "formats", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "style", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "strict", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "scrollingContainer", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "bounds", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onEditorCreated", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onContentChanged", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onSelectionChanged", void 0); | ||
QuillEditorComponent = QuillEditorComponent_1 = __decorate([ | ||
core_1.Component({ | ||
selector: 'quill-editor', | ||
template: "\n <ng-content select=\"[quill-editor-toolbar]\"></ng-content>\n", | ||
providers: [{ | ||
provide: forms_1.NG_VALUE_ACCESSOR, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}, { | ||
provide: forms_1.NG_VALIDATORS, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}], | ||
encapsulation: core_1.ViewEncapsulation.None | ||
}), | ||
__param(1, core_2.Inject(platform_browser_1.DOCUMENT)), | ||
__metadata("design:paramtypes", [core_1.ElementRef, Object, core_1.Renderer2]) | ||
], QuillEditorComponent); | ||
exports.QuillEditorComponent = QuillEditorComponent; | ||
var QuillEditorComponent_1; | ||
/***/ }, | ||
/***/ }), | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("@angular/forms"); | ||
module.exports = require("@angular/forms"); | ||
/***/ }, | ||
/***/ }), | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("@angular/platform-browser"); | ||
module.exports = require("@angular/platform-browser"); | ||
/***/ }, | ||
/***/ }), | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("quill"); | ||
module.exports = require("quill"); | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -10,43 +10,66 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["ngx-quill"] = factory(root["@angular/core"], root["@angular/forms"], root["@angular/platform-browser"], root["quill"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 1); | ||
/******/ }) | ||
@@ -56,323 +79,326 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(1)); | ||
module.exports = require("@angular/core"); | ||
/***/ }, | ||
/***/ }), | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(2); | ||
var quill_editor_component_1 = __webpack_require__(3); | ||
var QuillModule = (function () { | ||
function QuillModule() { | ||
} | ||
return QuillModule; | ||
}()); | ||
QuillModule = __decorate([ | ||
core_1.NgModule({ | ||
declarations: [ | ||
quill_editor_component_1.QuillEditorComponent | ||
], | ||
imports: [], | ||
exports: [quill_editor_component_1.QuillEditorComponent], | ||
providers: [] | ||
}) | ||
], QuillModule); | ||
exports.QuillModule = QuillModule; | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(2)); | ||
/***/ }, | ||
/***/ }), | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = require("@angular/core"); | ||
"use strict"; | ||
/***/ }, | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(0); | ||
var quill_editor_component_1 = __webpack_require__(3); | ||
var QuillModule = (function () { | ||
function QuillModule() { | ||
} | ||
return QuillModule; | ||
}()); | ||
QuillModule = __decorate([ | ||
core_1.NgModule({ | ||
declarations: [ | ||
quill_editor_component_1.QuillEditorComponent | ||
], | ||
imports: [], | ||
exports: [quill_editor_component_1.QuillEditorComponent], | ||
providers: [] | ||
}) | ||
], QuillModule); | ||
exports.QuillModule = QuillModule; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(2); | ||
var forms_1 = __webpack_require__(4); | ||
var core_2 = __webpack_require__(2); | ||
var platform_browser_1 = __webpack_require__(5); | ||
var Quill = __webpack_require__(6); | ||
var QuillEditorComponent = QuillEditorComponent_1 = (function () { | ||
function QuillEditorComponent(elementRef, doc, renderer) { | ||
this.elementRef = elementRef; | ||
this.doc = doc; | ||
this.renderer = renderer; | ||
this.emptyArray = []; | ||
this.defaultModules = { | ||
toolbar: [ | ||
['bold', 'italic', 'underline', 'strike'], | ||
['blockquote', 'code-block'], | ||
[{ 'header': 1 }, { 'header': 2 }], | ||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], | ||
[{ 'script': 'sub' }, { 'script': 'super' }], | ||
[{ 'indent': '-1' }, { 'indent': '+1' }], | ||
[{ 'direction': 'rtl' }], | ||
[{ 'size': ['small', false, 'large', 'huge'] }], | ||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], | ||
[{ 'color': this.emptyArray.slice() }, { 'background': this.emptyArray.slice() }], | ||
[{ 'font': this.emptyArray.slice() }], | ||
[{ 'align': this.emptyArray.slice() }], | ||
['clean'], | ||
['link', 'image', 'video'] // link and image, video | ||
] | ||
}; | ||
this.style = {}; | ||
this.strict = true; | ||
this.onEditorCreated = new core_1.EventEmitter(); | ||
this.onContentChanged = new core_1.EventEmitter(); | ||
this.onSelectionChanged = new core_1.EventEmitter(); | ||
this.onModelChange = function () { }; | ||
this.onModelTouched = function () { }; | ||
} | ||
QuillEditorComponent.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
var toolbarElem = this.elementRef.nativeElement.querySelector('[quill-editor-toolbar]'); | ||
var modules = this.modules || this.defaultModules; | ||
var placeholder = 'Insert text here ...'; | ||
if (this.placeholder !== null && this.placeholder !== undefined) { | ||
placeholder = this.placeholder.trim(); | ||
} | ||
if (toolbarElem) { | ||
modules['toolbar'] = toolbarElem; | ||
} | ||
this.elementRef.nativeElement.insertAdjacentHTML('beforeend', '<div quill-editor-element></div>'); | ||
this.editorElem = this.elementRef.nativeElement.querySelector('[quill-editor-element]'); | ||
if (this.style) { | ||
Object.keys(this.style).forEach(function (key) { | ||
_this.renderer.setStyle(_this.editorElem, key, _this.style[key]); | ||
}); | ||
} | ||
this.quillEditor = new Quill(this.editorElem, { | ||
modules: modules, | ||
placeholder: placeholder, | ||
readOnly: this.readOnly || false, | ||
theme: this.theme || 'snow', | ||
formats: this.formats, | ||
bounds: this.bounds || this.doc.body, | ||
strict: this.strict, | ||
scrollingContainer: this.scrollingContainer | ||
}); | ||
if (this.content) { | ||
var contents = this.quillEditor.clipboard.convert(this.content); | ||
this.quillEditor.setContents(contents); | ||
this.quillEditor.history.clear(); | ||
} | ||
this.onEditorCreated.emit(this.quillEditor); | ||
// mark model as touched if editor lost focus | ||
this.quillEditor.on('selection-change', function (range, oldRange, source) { | ||
_this.onSelectionChanged.emit({ | ||
editor: _this.quillEditor, | ||
range: range, | ||
oldRange: oldRange, | ||
source: source | ||
}); | ||
if (!range) { | ||
_this.onModelTouched(); | ||
} | ||
}); | ||
// update model if text changes | ||
this.quillEditor.on('text-change', function (delta, oldDelta, source) { | ||
var html = _this.editorElem.children[0].innerHTML; | ||
var text = _this.quillEditor.getText(); | ||
if (html === '<p><br></p>') { | ||
html = null; | ||
} | ||
_this.onModelChange(html); | ||
_this.onContentChanged.emit({ | ||
editor: _this.quillEditor, | ||
html: html, | ||
text: text, | ||
delta: delta, | ||
oldDelta: oldDelta, | ||
source: source | ||
}); | ||
}); | ||
}; | ||
QuillEditorComponent.prototype.ngOnChanges = function (changes) { | ||
if (changes['readOnly'] && this.quillEditor) { | ||
this.quillEditor.enable(!changes['readOnly'].currentValue); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.writeValue = function (currentValue) { | ||
this.content = currentValue; | ||
if (this.quillEditor) { | ||
if (currentValue) { | ||
this.quillEditor.setContents(this.quillEditor.clipboard.convert(this.content)); | ||
return; | ||
} | ||
this.quillEditor.setText(''); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.registerOnChange = function (fn) { | ||
this.onModelChange = fn; | ||
}; | ||
QuillEditorComponent.prototype.registerOnTouched = function (fn) { | ||
this.onModelTouched = fn; | ||
}; | ||
QuillEditorComponent.prototype.validate = function () { | ||
if (!this.quillEditor) { | ||
return null; | ||
} | ||
var err = {}, valid = true; | ||
var textLength = this.quillEditor.getText().trim().length; | ||
if (this.minLength && textLength && textLength < this.minLength) { | ||
err.minLengthError = { | ||
given: textLength, | ||
minLength: this.minLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.maxLength && textLength > this.maxLength) { | ||
err.maxLengthError = { | ||
given: textLength, | ||
maxLength: this.maxLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.required && !textLength) { | ||
err.requiredError = { | ||
empty: true | ||
}; | ||
valid = false; | ||
} | ||
return valid ? null : err; | ||
}; | ||
return QuillEditorComponent; | ||
}()); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "theme", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "modules", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "readOnly", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "placeholder", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "maxLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "minLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "required", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Array) | ||
], QuillEditorComponent.prototype, "formats", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "style", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "strict", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "scrollingContainer", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "bounds", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onEditorCreated", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onContentChanged", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onSelectionChanged", void 0); | ||
QuillEditorComponent = QuillEditorComponent_1 = __decorate([ | ||
core_1.Component({ | ||
selector: 'quill-editor', | ||
template: "\n <ng-content select=\"[quill-editor-toolbar]\"></ng-content>\n", | ||
providers: [{ | ||
provide: forms_1.NG_VALUE_ACCESSOR, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}, { | ||
provide: forms_1.NG_VALIDATORS, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}], | ||
encapsulation: core_1.ViewEncapsulation.None | ||
}), | ||
__param(1, core_2.Inject(platform_browser_1.DOCUMENT)), | ||
__metadata("design:paramtypes", [core_1.ElementRef, Object, core_1.Renderer2]) | ||
], QuillEditorComponent); | ||
exports.QuillEditorComponent = QuillEditorComponent; | ||
var QuillEditorComponent_1; | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = __webpack_require__(0); | ||
var forms_1 = __webpack_require__(4); | ||
var core_2 = __webpack_require__(0); | ||
var platform_browser_1 = __webpack_require__(5); | ||
var QuillNamespace = __webpack_require__(6); | ||
var Quill = QuillNamespace; | ||
var QuillEditorComponent = QuillEditorComponent_1 = (function () { | ||
function QuillEditorComponent(elementRef, doc, renderer) { | ||
this.elementRef = elementRef; | ||
this.doc = doc; | ||
this.renderer = renderer; | ||
this.emptyArray = []; | ||
this.defaultModules = { | ||
toolbar: [ | ||
['bold', 'italic', 'underline', 'strike'], | ||
['blockquote', 'code-block'], | ||
[{ 'header': 1 }, { 'header': 2 }], | ||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], | ||
[{ 'script': 'sub' }, { 'script': 'super' }], | ||
[{ 'indent': '-1' }, { 'indent': '+1' }], | ||
[{ 'direction': 'rtl' }], | ||
[{ 'size': ['small', false, 'large', 'huge'] }], | ||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], | ||
[{ 'color': this.emptyArray.slice() }, { 'background': this.emptyArray.slice() }], | ||
[{ 'font': this.emptyArray.slice() }], | ||
[{ 'align': this.emptyArray.slice() }], | ||
['clean'], | ||
['link', 'image', 'video'] // link and image, video | ||
] | ||
}; | ||
this.style = {}; | ||
this.strict = true; | ||
this.onEditorCreated = new core_1.EventEmitter(); | ||
this.onContentChanged = new core_1.EventEmitter(); | ||
this.onSelectionChanged = new core_1.EventEmitter(); | ||
this.onModelChange = function () { }; | ||
this.onModelTouched = function () { }; | ||
} | ||
QuillEditorComponent.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
var toolbarElem = this.elementRef.nativeElement.querySelector('[quill-editor-toolbar]'); | ||
var modules = this.modules || this.defaultModules; | ||
var placeholder = 'Insert text here ...'; | ||
if (this.placeholder !== null && this.placeholder !== undefined) { | ||
placeholder = this.placeholder.trim(); | ||
} | ||
if (toolbarElem) { | ||
modules['toolbar'] = toolbarElem; | ||
} | ||
this.elementRef.nativeElement.insertAdjacentHTML('beforeend', '<div quill-editor-element></div>'); | ||
this.editorElem = this.elementRef.nativeElement.querySelector('[quill-editor-element]'); | ||
if (this.style) { | ||
Object.keys(this.style).forEach(function (key) { | ||
_this.renderer.setStyle(_this.editorElem, key, _this.style[key]); | ||
}); | ||
} | ||
this.quillEditor = new Quill(this.editorElem, { | ||
modules: modules, | ||
placeholder: placeholder, | ||
readOnly: this.readOnly || false, | ||
theme: this.theme || 'snow', | ||
formats: this.formats, | ||
bounds: this.bounds || this.doc.body, | ||
strict: this.strict, | ||
scrollingContainer: this.scrollingContainer | ||
}); | ||
if (this.content) { | ||
var contents = this.quillEditor.clipboard.convert(this.content); | ||
this.quillEditor.setContents(contents); | ||
this.quillEditor.history.clear(); | ||
} | ||
this.onEditorCreated.emit(this.quillEditor); | ||
// mark model as touched if editor lost focus | ||
this.quillEditor.on('selection-change', function (range, oldRange, source) { | ||
_this.onSelectionChanged.emit({ | ||
editor: _this.quillEditor, | ||
range: range, | ||
oldRange: oldRange, | ||
source: source | ||
}); | ||
if (!range) { | ||
_this.onModelTouched(); | ||
} | ||
}); | ||
// update model if text changes | ||
this.quillEditor.on('text-change', function (delta, oldDelta, source) { | ||
var html = _this.editorElem.children[0].innerHTML; | ||
var text = _this.quillEditor.getText(); | ||
if (html === '<p><br></p>') { | ||
html = null; | ||
} | ||
_this.onModelChange(html); | ||
_this.onContentChanged.emit({ | ||
editor: _this.quillEditor, | ||
html: html, | ||
text: text, | ||
delta: delta, | ||
oldDelta: oldDelta, | ||
source: source | ||
}); | ||
}); | ||
}; | ||
QuillEditorComponent.prototype.ngOnChanges = function (changes) { | ||
if (changes['readOnly'] && this.quillEditor) { | ||
this.quillEditor.enable(!changes['readOnly'].currentValue); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.writeValue = function (currentValue) { | ||
this.content = currentValue; | ||
if (this.quillEditor) { | ||
if (currentValue) { | ||
this.quillEditor.setContents(this.quillEditor.clipboard.convert(this.content)); | ||
return; | ||
} | ||
this.quillEditor.setText(''); | ||
} | ||
}; | ||
QuillEditorComponent.prototype.registerOnChange = function (fn) { | ||
this.onModelChange = fn; | ||
}; | ||
QuillEditorComponent.prototype.registerOnTouched = function (fn) { | ||
this.onModelTouched = fn; | ||
}; | ||
QuillEditorComponent.prototype.validate = function () { | ||
if (!this.quillEditor) { | ||
return null; | ||
} | ||
var err = {}, valid = true; | ||
var textLength = this.quillEditor.getText().trim().length; | ||
if (this.minLength && textLength && textLength < this.minLength) { | ||
err.minLengthError = { | ||
given: textLength, | ||
minLength: this.minLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.maxLength && textLength > this.maxLength) { | ||
err.maxLengthError = { | ||
given: textLength, | ||
maxLength: this.maxLength | ||
}; | ||
valid = false; | ||
} | ||
if (this.required && !textLength) { | ||
err.requiredError = { | ||
empty: true | ||
}; | ||
valid = false; | ||
} | ||
return valid ? null : err; | ||
}; | ||
return QuillEditorComponent; | ||
}()); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "theme", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "modules", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "readOnly", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], QuillEditorComponent.prototype, "placeholder", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "maxLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Number) | ||
], QuillEditorComponent.prototype, "minLength", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "required", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Array) | ||
], QuillEditorComponent.prototype, "formats", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "style", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Boolean) | ||
], QuillEditorComponent.prototype, "strict", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "scrollingContainer", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object) | ||
], QuillEditorComponent.prototype, "bounds", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onEditorCreated", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onContentChanged", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], QuillEditorComponent.prototype, "onSelectionChanged", void 0); | ||
QuillEditorComponent = QuillEditorComponent_1 = __decorate([ | ||
core_1.Component({ | ||
selector: 'quill-editor', | ||
template: "\n <ng-content select=\"[quill-editor-toolbar]\"></ng-content>\n", | ||
providers: [{ | ||
provide: forms_1.NG_VALUE_ACCESSOR, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}, { | ||
provide: forms_1.NG_VALIDATORS, | ||
useExisting: core_1.forwardRef(function () { return QuillEditorComponent_1; }), | ||
multi: true | ||
}], | ||
encapsulation: core_1.ViewEncapsulation.None | ||
}), | ||
__param(1, core_2.Inject(platform_browser_1.DOCUMENT)), | ||
__metadata("design:paramtypes", [core_1.ElementRef, Object, core_1.Renderer2]) | ||
], QuillEditorComponent); | ||
exports.QuillEditorComponent = QuillEditorComponent; | ||
var QuillEditorComponent_1; | ||
/***/ }, | ||
/***/ }), | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("@angular/forms"); | ||
module.exports = require("@angular/forms"); | ||
/***/ }, | ||
/***/ }), | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("@angular/platform-browser"); | ||
module.exports = require("@angular/platform-browser"); | ||
/***/ }, | ||
/***/ }), | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = require("quill"); | ||
module.exports = require("quill"); | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -1,21 +0,21 @@ | ||
Error.stackTraceLimit = Infinity; | ||
Error.stackTraceLimit = Infinity | ||
require('core-js/es6'); | ||
require('core-js/es7/reflect'); | ||
require('core-js/es6') | ||
require('core-js/es7/reflect') | ||
require('zone.js/dist/zone'); | ||
require('zone.js/dist/long-stack-trace-zone'); | ||
require('zone.js/dist/proxy'); | ||
require('zone.js/dist/sync-test'); | ||
require('zone.js/dist/jasmine-patch'); | ||
require('zone.js/dist/async-test'); | ||
require('zone.js/dist/fake-async-test'); | ||
require('zone.js/dist/zone') | ||
require('zone.js/dist/long-stack-trace-zone') | ||
require('zone.js/dist/proxy') | ||
require('zone.js/dist/sync-test') | ||
require('zone.js/dist/jasmine-patch') | ||
require('zone.js/dist/async-test') | ||
require('zone.js/dist/fake-async-test') | ||
var appContext = require.context('./src', true, /\.spec\.ts/); | ||
const appContext = require.context('./src', true, /\.spec\.ts/) | ||
appContext.keys().forEach(appContext); | ||
appContext.keys().forEach(appContext) | ||
var testing = require('@angular/core/testing'); | ||
var browser = require('@angular/platform-browser-dynamic/testing'); | ||
const testing = require('@angular/core/testing') | ||
const browser = require('@angular/platform-browser-dynamic/testing') | ||
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting()); | ||
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting()) |
@@ -1,10 +0,14 @@ | ||
var webpackConfig = require('./webpack.config.test'); | ||
const webpackConfig = require('./webpack.config.test') | ||
const karmaWebpack = require('karma-webpack') | ||
const path = require('path') | ||
var ENV = process.env.npm_lifecycle_event; | ||
var isTestWatch = ENV === 'test-watch'; | ||
const ENV = process.env.npm_lifecycle_event | ||
const isTestWatch = ENV === 'test-watch' | ||
module.exports = function (config) { | ||
var _config = { | ||
const _config = { | ||
basePath: '', | ||
plugins: ['karma-coverage-istanbul-reporter', 'karma-phantomjs-launcher', 'karma-mocha-reporter', karmaWebpack, 'karma-sourcemap-loader', 'karma-jasmine'], | ||
frameworks: ['jasmine'], | ||
@@ -17,3 +21,3 @@ | ||
preprocessors: { | ||
'./karma-shim.js': ['webpack', 'sourcemap'] | ||
'./karma-shim.js': ['webpack'] | ||
}, | ||
@@ -38,26 +42,14 @@ | ||
singleRun: true | ||
}; | ||
} | ||
if (!isTestWatch) { | ||
_config.reporters.push('coverage'); | ||
if (!isTestWatch) { | ||
_config.reporters.push('coverage-istanbul') | ||
_config.coverageReporter = { | ||
dir: 'coverage/', | ||
reporters: [{ | ||
type: 'html', | ||
dir: 'coverage', | ||
subdir: 'html', | ||
}, { | ||
type: 'json', | ||
dir: 'coverage', | ||
subdir: 'json', | ||
file: 'coverage-final.json' | ||
}, | ||
{ | ||
type: 'text-summary' | ||
}] | ||
}; | ||
_config.coverageIstanbulReporter = { | ||
fixWebpackSourcePaths: true, | ||
reports: ['text-summary'] | ||
} | ||
} | ||
config.set(_config) | ||
} | ||
config.set(_config); | ||
}; |
{ | ||
"name": "ngx-quill", | ||
"license": "MIT", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"author": { | ||
@@ -21,5 +21,4 @@ "name": "Bengt Weiße" | ||
"pretest": "npm run lint", | ||
"test": "karma start", | ||
"posttest": "remap-istanbul -i coverage/json/coverage-final.json -o coverage/html -t html", | ||
"test-watch": "karma start --no-single-run --auto-watch" | ||
"test": "./node_modules/.bin/karma start", | ||
"test-watch": "./node_modules/.bin/karma start --no-single-run --auto-watch" | ||
}, | ||
@@ -42,2 +41,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@types/quill": "^1.3.3", | ||
"quill": "^1.3.2" | ||
@@ -62,28 +62,24 @@ }, | ||
"codelyzer": "^3.0.0-beta.4", | ||
"commitizen": "^2.9.5", | ||
"core-js": "^2.4.1", | ||
"cz-conventional-changelog": "^2.0.0", | ||
"istanbul-instrumenter-loader": "^0.2.0", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^1.2.0", | ||
"istanbul-instrumenter-loader": "^3.0.0", | ||
"jasmine-core": "^2.8.0", | ||
"karma": "^1.7.1", | ||
"karma-coverage": "^1.1.1", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-mocha-reporter": "^2.2.1", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-remap-coverage": "^0.1.4", | ||
"karma-remap-istanbul": "^0.4.0", | ||
"karma-coverage-istanbul-reporter": "^1.3.0", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-mocha-reporter": "^2.2.4", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^1.8.0", | ||
"loader-utils": "^0.2.16", | ||
"reflect-metadata": "^0.1.9", | ||
"remap-istanbul": "^0.8.4", | ||
"karma-webpack": "^2.0.4", | ||
"loader-utils": "^1.1.0", | ||
"reflect-metadata": "^0.1.10", | ||
"rxjs": "^5.0.1 || ^5.2.0", | ||
"source-map-loader": "^0.1.5", | ||
"source-map-loader": "^0.2.1", | ||
"ts-helpers": "^1.1.2", | ||
"tslint": "^4.3.1", | ||
"tslint-loader": "^3.3.0", | ||
"tslint": "^4.0.0", | ||
"tslint-loader": "^3.5.3", | ||
"typescript": "~2.0.10 || ^2.2.0", | ||
"webpack": "^1.13.0", | ||
"webpack-dev-server": "^1.14.1", | ||
"webpack-node-externals": "^1.5.4", | ||
"webpack": "^3.6.0", | ||
"webpack-dev-server": "^2.8.2", | ||
"webpack-node-externals": "^1.6.0", | ||
"zone.js": "^0.7.8 || ^0.8.5" | ||
@@ -95,8 +91,3 @@ }, | ||
} | ||
], | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
] | ||
} |
@@ -15,4 +15,4 @@ # ngx-quill [![Build Status](https://travis-ci.org/KillerCodeMonkey/ngx-quill.svg?branch=develop)](https://travis-ci.org/KillerCodeMonkey/ngx-quill) | ||
## Installation | ||
- install QuillJS 1.1.9 `npm install ngx-quill` | ||
- include bubble.css, snow.css in your index.html | ||
- `npm install ngx-quill` | ||
- include theme stylings: bubble.css, snow.css of quilljs in your index.html | ||
@@ -19,0 +19,0 @@ ### For standard webpack and tsc builds |
@@ -17,3 +17,4 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
import { DOCUMENT } from '@angular/platform-browser'; | ||
var Quill = require('quill'); | ||
import * as QuillNamespace from "quill"; | ||
var Quill = QuillNamespace; | ||
var QuillEditorComponent = QuillEditorComponent_1 = (function () { | ||
@@ -20,0 +21,0 @@ function QuillEditorComponent(elementRef, doc, renderer) { |
@@ -24,3 +24,4 @@ import { | ||
const Quill = require('quill'); | ||
import * as QuillNamespace from "quill"; | ||
let Quill: any = QuillNamespace; | ||
@@ -27,0 +28,0 @@ @Component({ |
@@ -28,2 +28,2 @@ { | ||
} | ||
} | ||
} |
@@ -1,9 +0,11 @@ | ||
const webpack = require('webpack'); | ||
const nodeExternals = require('webpack-node-externals') | ||
const path = require('path') | ||
module.exports = { | ||
entry: './index', | ||
entry: { | ||
'ngx-quill': path.resolve(__dirname, 'index.ts') | ||
}, | ||
output: { | ||
path: './bundles', | ||
path: path.resolve(__dirname, 'bundles'), | ||
libraryTarget: 'umd', | ||
@@ -21,6 +23,11 @@ library: 'ngx-quill', | ||
module: { | ||
loaders: [ | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
loaders: ['awesome-typescript-loader?declaration=false'] | ||
use: [{ | ||
loader: 'awesome-typescript-loader', | ||
options: { | ||
declaration: false | ||
} | ||
}] | ||
} | ||
@@ -31,5 +38,3 @@ ] | ||
plugins: [ | ||
new webpack.NoErrorsPlugin(), | ||
new webpack.optimize.DedupePlugin() | ||
] | ||
}; | ||
} |
@@ -1,8 +0,12 @@ | ||
var ENV = process.env.npm_lifecycle_event; | ||
var isTestWatch = ENV === 'test-watch'; | ||
var isTest = ENV === 'test' || isTestWatch; | ||
const ENV = process.env.npm_lifecycle_event | ||
const isTestWatch = ENV === 'test-watch' | ||
const isTest = ENV === 'test' || isTestWatch | ||
const path = require('path') | ||
var _config = { | ||
let _config = { | ||
resolve: { | ||
extensions: ['', '.ts', '.js'] | ||
extensions: ['.ts', '.js'] | ||
}, | ||
entry: { | ||
'ngx-quill': path.resolve(__dirname, 'index.ts') | ||
} | ||
@@ -12,33 +16,43 @@ } | ||
if (isTest) { | ||
_config.devtool = 'inline-source-map'; | ||
_config.devtool = 'inline-source-map' | ||
} | ||
var atlOptions = ''; | ||
let atlOptions = '' | ||
if (isTest && !isTestWatch) { | ||
// awesome-typescript-loader needs to output inlineSourceMap for code coverage to work with source maps. | ||
atlOptions = 'inlineSourceMap=true&sourceMap=false'; | ||
atlOptions = { | ||
inlineSourceMap: true, | ||
sourceMap: false | ||
} | ||
} | ||
_config.module = { | ||
loaders: [ | ||
{ | ||
test: /\.ts$/, | ||
loaders: ['awesome-typescript-loader?' + atlOptions] | ||
} | ||
], | ||
ts: './webpack.config.test.json' | ||
rules: [] | ||
} | ||
_config.module.rules.push({ | ||
test: /\.ts$/, | ||
use: [{ | ||
loader: 'awesome-typescript-loader', | ||
options: atlOptions | ||
}] | ||
}) | ||
if (isTest && !isTestWatch) { | ||
// instrument only testing sources with Istanbul, covers ts files | ||
_config.module.postLoaders = [{ | ||
test: /\.ts$/, | ||
loader: 'istanbul-instrumenter-loader?embedSource=true&noAutoWrap=true', | ||
exclude: [ | ||
'node_modules', | ||
/\.(e2e|spec)\.ts$/ | ||
] | ||
}]; | ||
// instrument only testing sources with Istanbul, covers ts files | ||
_config.module.rules.push({ | ||
test: /\.ts$/, | ||
enforce: 'post', | ||
use: [{ | ||
loader: 'istanbul-instrumenter-loader', | ||
options: { | ||
embedSource: true, | ||
noAutoWrap: true | ||
} | ||
}], | ||
exclude: [ | ||
'node_modules', | ||
/\.(e2e|spec)\.ts$/ | ||
] | ||
}) | ||
} | ||
module.exports = _config; | ||
module.exports = _config |
Sorry, the diff of this file is not supported yet
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
503541
34
55
2234
5
2
+ Added@types/quill@^1.3.3
+ Added@types/quill@1.3.10(transitive)