{"version":3,"file":"primeng-editor.umd.js","sources":["../../src/app/components/editor/editor.ts","../../src/app/components/editor/primeng-editor.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,AfterViewInit,Input,Output,EventEmitter,ContentChild,forwardRef,ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, QueryList, AfterContentInit, TemplateRef} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {SharedModule,Header, PrimeTemplate} from 'primeng/api'\nimport {DomHandler} from 'primeng/dom';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\nimport * as Quill from \"quill\";\n\nexport const EDITOR_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => Editor),\n multi: true\n};\n\n@Component({\n selector: 'p-editor',\n template: `\n
\n
\n \n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n `,\n providers: [EDITOR_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class Editor implements AfterViewInit,AfterContentInit,ControlValueAccessor {\n \n @Output() onTextChange: EventEmitter = new EventEmitter();\n \n @Output() onSelectionChange: EventEmitter = new EventEmitter();\n \n @ContentChild(Header) toolbar;\n \n @Input() style: any;\n \n @Input() styleClass: string;\n \n @Input() placeholder: string;\n \n @Input() formats: string[];\n\n @Input() modules: any;\n\n @Input() bounds: any;\n\n @Input() scrollingContainer: any;\n\n @Input() debug: string;\n \n @Output() onInit: EventEmitter = new EventEmitter();\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n \n value: string;\n \n _readonly: boolean;\n \n onModelChange: Function = () => {};\n \n onModelTouched: Function = () => {};\n \n quill: any;\n\n toolbarTemplate: TemplateRef;\n \n constructor(public el: ElementRef) {}\n\n ngAfterViewInit() {\n let editorElement = DomHandler.findSingle(this.el.nativeElement ,'div.p-editor-content'); \n let toolbarElement = DomHandler.findSingle(this.el.nativeElement ,'div.p-editor-toolbar'); \n let defaultModule = {toolbar: toolbarElement};\n let modules = this.modules ? {...defaultModule, ...this.modules} : defaultModule;\n\n this.quill = new Quill(editorElement, {\n modules: modules,\n placeholder: this.placeholder,\n readOnly: this.readonly,\n theme: 'snow',\n formats: this.formats,\n bounds: this.bounds,\n debug: this.debug,\n scrollingContainer: this.scrollingContainer\n });\n \n if (this.value) {\n this.quill.pasteHTML(this.value);\n }\n \n this.quill.on('text-change', (delta, oldContents, source) => {\n if (source === 'user') {\n let html = editorElement.children[0].innerHTML;\n let text = this.quill.getText().trim();\n if (html === '


') {\n html = null;\n }\n\n this.onTextChange.emit({\n htmlValue: html,\n textValue: text,\n delta: delta,\n source: source\n });\n \n this.onModelChange(html);\n this.onModelTouched();\n }\n });\n \n this.quill.on('selection-change', (range, oldRange, source) => {\n this.onSelectionChange.emit({\n range: range,\n oldRange: oldRange,\n source: source\n });\n });\n \n this.onInit.emit({\n editor: this.quill\n });\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'toolbar':\n this.toolbarTemplate = item.template;\n break;\n }\n });\n }\n \n writeValue(value: any) : void {\n this.value = value;\n \n if (this.quill) {\n if (value)\n this.quill.pasteHTML(value);\n else\n this.quill.setText('');\n }\n }\n \n registerOnChange(fn: Function): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: Function): void {\n this.onModelTouched = fn;\n }\n \n getQuill() {\n return this.quill;\n }\n \n @Input() get readonly(): boolean {\n return this._readonly;\n }\n\n set readonly(val:boolean) {\n this._readonly = val;\n \n if (this.quill) {\n if (this._readonly)\n this.quill.disable();\n else\n this.quill.enable();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Editor,SharedModule],\n declarations: [Editor]\n})\nexport class EditorModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NG_VALUE_ACCESSOR","forwardRef","EventEmitter","DomHandler","Quill","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","Output","ContentChild","Header","Input","ContentChildren","PrimeTemplate","NgModule","CommonModule","SharedModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;QAOa,qBAAqB,GAAQ;QACxC,OAAO,EAAEA,uBAAiB;QAC1B,WAAW,EAAEC,eAAU,CAAC,cAAM,OAAA,MAAM,GAAA,CAAC;QACrC,KAAK,EAAE,IAAI;MACX;;QAkGE,gBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAtCvB,iBAAY,GAAsB,IAAIC,iBAAY,EAAE,CAAC;YAErD,sBAAiB,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAoB1D,WAAM,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAQzD,kBAAa,GAAa,eAAQ,CAAC;YAEnC,mBAAc,GAAa,eAAQ,CAAC;SAMC;QAErC,gCAAe,GAAf;YAAA,iBAoDC;YAnDG,IAAI,aAAa,GAAGC,cAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;YACzF,IAAI,cAAc,GAAGA,cAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;YAC1F,IAAI,aAAa,GAAI,EAAC,OAAO,EAAE,cAAc,EAAC,CAAC;YAC/C,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,mCAAO,aAAa,GAAK,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC;YAEjF,IAAI,CAAC,KAAK,GAAG,IAAIC,gBAAK,CAAC,aAAa,EAAE;gBAClC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,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