{"version":3,"file":"primeng-editor.mjs","sources":["../../src/app/components/editor/editor.ts","../../src/app/components/editor/primeng-editor.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n AfterContentInit,\n AfterViewChecked,\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ContentChild,\n ContentChildren,\n ElementRef,\n EventEmitter,\n Input,\n NgModule,\n Output,\n QueryList,\n TemplateRef,\n ViewEncapsulation,\n forwardRef\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { Header, LicenseManager, PrimeTemplate, SharedModule } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport 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 styleUrls: ['./editor.css'],\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'p-element'\n }\n})\nexport class Editor implements AfterViewInit, AfterViewChecked, AfterContentInit, ControlValueAccessor {\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 delayedCommand: Function | null = null;\n\n _readonly: boolean;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n quill: any;\n\n headerTemplate: TemplateRef;\n\n private get isAttachedQuillEditorToDOM(): boolean {\n return this.quillElements?.editorElement?.isConnected;\n }\n\n private quillElements: { editorElement: HTMLElement; toolbarElement: HTMLElement } | null = null;\n\n constructor(public el: ElementRef) {}\n\n ngAfterViewInit(): void {\n this.initQuillElements();\n\n if (this.isAttachedQuillEditorToDOM) {\n this.initQuillEditor();\n }\n\n LicenseManager.check();\n }\n\n ngAfterViewChecked(): void {\n // The problem is inside the `quill` library, we need to wait for a new release.\n // Function `isLine` - used `getComputedStyle`, it was rewritten in the next release.\n // (We need to wait for a release higher than 1.3.7).\n // These checks and code can be removed.\n if (!this.quill && this.isAttachedQuillEditorToDOM) {\n this.initQuillEditor();\n }\n\n // Can also be deleted after updating `quill`.\n if (this.delayedCommand && this.isAttachedQuillEditorToDOM) {\n this.delayedCommand();\n this.delayedCommand = null;\n }\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch (item.getType()) {\n case 'header':\n this.headerTemplate = 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 const command = (): void => {\n this.quill.setContents(this.quill.clipboard.convert(this.value));\n };\n\n if (this.isAttachedQuillEditorToDOM) {\n command();\n } else {\n this.delayedCommand = command;\n }\n } else {\n const command = (): void => {\n this.quill.setText('');\n };\n\n if (this.isAttachedQuillEditorToDOM) {\n command();\n } else {\n this.delayedCommand = command;\n }\n }\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) this.quill.disable();\n else this.quill.enable();\n }\n }\n\n private initQuillEditor(): void {\n this.initQuillElements();\n\n const { toolbarElement, editorElement } = this.quillElements;\n let defaultModule = { toolbar: toolbarElement };\n let modules = this.modules ? { ...defaultModule, ...this.modules } : defaultModule;\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.setContents(this.quill.clipboard.convert(this.value));\n }\n\n this.quill.on('text-change', (delta, oldContents, source) => {\n if (source === 'user') {\n let html = DomHandler.findSingle(editorElement, '.ql-editor').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 private initQuillElements(): void {\n if (!this.quillElements) {\n this.quillElements = {\n editorElement: DomHandler.findSingle(this.el.nativeElement, 'div.p-editor-content'),\n toolbarElement: DomHandler.findSingle(this.el.nativeElement, 'div.p-editor-toolbar')\n };\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":[],"mappings":";;;;;;;;;AAwBa,MAAA,qBAAqB,GAAQ;AACtC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,MAAM,CAAC;AACrC,IAAA,KAAK,EAAE,IAAI;EACb;MA8DW,MAAM,CAAA;AA+Cf,IAAA,WAAA,CAAmB,EAAc,EAAA;AAAd,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAY;AA9CvB,QAAA,IAAA,CAAA,YAAY,GAAsB,IAAI,YAAY,EAAE,CAAC;AAErD,QAAA,IAAA,CA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