angular-froala-wysiwyg-2.7.1
Version:
Angular 2 and Angular 4 bindings for Froala WYSIWYG HTML rich text editor
1 lines • 16.5 kB
Source Map (JSON)
{"version":3,"sources":["../../src/editor/editor.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,UAAA,EAAsB,KAAA,EAAO,MAAA,EAAkB,YAAA,EAAc,UAAA,EAAY,MAAA,EAAO,MAAM,eAAA,CAAgB;AAE1H,OAAO,EAAuB,iBAAA,EAAkB,MAAM,gBAAA,CAAiB;AAMvE;IA2BE,+BAAY,EAAc,EAAW,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAzBjD,iBAAiB;QACT,UAAK,GAAQ;YACnB,2BAA2B,EAAE,KAAK;YAClC,kBAAkB,EAAE,IAAI;SACzB,CAAC;QAKM,iBAAY,GAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACzD,oBAAe,GAAW,WAAW,CAAC;QACtC,mBAAc,GAAY,KAAK,CAAC;QAQhC,qBAAgB,GAAa,EAAE,CAAC;QAEhC,uBAAkB,GAAY,KAAK,CAAC;QAEpC,cAAS,GAAW,IAAI,CAAC;QAiBjC,qCAAqC;QACrC,aAAQ,GAAG,UAAC,CAAC,IAAM,CAAC,CAAC;QACrB,cAAS,GAAG,cAAO,CAAC,CAAC;QAkCrB,yEAAyE;QACxE,sBAAiB,GAAsB,IAAI,YAAY,EAAO,CAAC;QAEhE,oEAAoE;QACnE,eAAU,GAAyB,IAAI,YAAY,EAAU,CAAC;QArD7D,IAAI,OAAO,GAAQ,EAAE,CAAC,aAAa,CAAC;QAEpC,wCAAwC;QACxC,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;QAED,gCA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ACH,CAAC;IAED,2CAAW,GAAX;QACE,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IACI,gCAAU,GAA0B;QAC3C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oBACxB,QAAQ,EAAE,gBAAgB;oBACzB,SAAS,EAAE,CAAC;4BACX,OAAO,EAAE,iBAAiB,EAAC,WAAW,EACpC,UAAU,CAAC,cAAM,OAAA,qBAAqB,EAArB,CAAqB,CAAC;4BACzC,KAAK,EAAE,IAAI;yBACZ,CAAC;iBACH,EAAG,EAAE;KACL,CAAC;IACF,kBAAkB;IACX,oCAAc,GAAmE,cAAM,OAAA;QAC9F,EAAC,IAAI,EAAE,UAAU,GAAG;QACpB,EAAC,IAAI,EAAE,MAAM,GAAG;KACf,EAH6F,CAG7F,CAAC;IACK,oCAAc,GAA2C;QAChE,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAClC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACjC,mBAAmB,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxC,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;KAChC,CAAC;IACF,4BAAC;CAhTD,AAgTC,IAAA;SAhTY,qBAAqB","file":"editor.directive.js","sourceRoot":"","sourcesContent":["import { Directive, ElementRef, Renderer, Input, Output, Optional, EventEmitter, forwardRef, NgZone} from '@angular/core';\n\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from \"@angular/forms\";\n\ndeclare var $: JQueryStatic;\n\n\n\nexport class FroalaEditorDirective implements ControlValueAccessor {\n\n // editor options\n private _opts: any = {\n immediateAngularModelUpdate: false,\n angularIgnoreAttrs: null\n };\n\n // jquery wrapped element\n private _$element: any;\n\n private SPECIAL_TAGS: string[] = ['img', 'button', 'input', 'a'];\n private INNER_HTML_ATTR: string = 'innerHTML';\n private _hasSpecialTag: boolean = false;\n\n // editor element\n private _editor: any;\n\n // initial editor content\n private _model: string;\n\n private _listeningEvents: string[] = [];\n\n private _editorInitialized: boolean = false;\n\n private _oldModel: string = null;\n\n constructor(el: ElementRef, private zone: NgZone) {\n\n let element: any = el.nativeElement;\n\n // check if the element is a special tag\n if (this.SPECIAL_TAGS.indexOf(element.tagName.toLowerCase()) != -1) {\n this._hasSpecialTag = true;\n }\n\n // jquery wrap and store element\n this._$element = (<any>$(element));\n\n this.zone = zone;\n }\n\n // Begin ControlValueAccesor methods.\n onChange = (_) => {};\n onTouched = () => {};\n\n // Form model content changed.\n writeValue(content: any): void {\n this.updateEditor(content);\n }\n\n registerOnChange(fn: (_: any) => void): void { this.onChange = fn; }\n registerOnTouched(fn: () => void): void { this.onTouched = fn; }\n // End ControlValueAccesor methods.\n\n // froalaEditor directive as input: store the editor options\n set froalaEditor(opts: any) {\n this._opts = opts || this._opts;\n }\n\n // froalaModel directive as input: store initial editor content\n set froalaModel(content: any) {\n this.updateEditor(content);\n }\n\n // Update editor with model contents.\n private updateEditor(content: any) {\n\n if (JSON.stringify(this._oldModel) == JSON.stringify(content)) {\n return;\n }\n this._model = content;\n\n if (this._editorInitialized) {\n this.setContent();\n }\n }\n\n // froalaModel directive as output: update model if editor contentChanged\n froalaModelChange: EventEmitter<any> = new EventEmitter<any>();\n\n // froalaInit directive as output: send manual editor initialization\n froalaInit: EventEmitter<Object> = new EventEmitter<Object>();\n\n // update model if editor contentChanged\n private updateModel() {\n this.zone.run(() => {\n\n let modelContent: any = null;\n\n if (this._hasSpecialTag) {\n\n let attributeNodes = this._$element[0].attributes;\n let attrs = {};\n\n for (let i = 0; i < attributeNodes.length; i++ ) {\n\n let attrName = attributeNodes[i].name;\n if (this._opts.angularIgnoreAttrs && this._opts.angularIgnoreAttrs.indexOf(attrName) != -1) {\n continue;\n }\n\n attrs[attrName] = attributeNodes[i].value;\n }\n\n if (this._$element[0].innerHTML) {\n attrs[this.INNER_HTML_ATTR] = this._$element[0].innerHTML;\n }\n\n modelContent = attrs;\n } else {\n\n let returnedHtml: any = this._$element.froalaEditor('html.get');\n if (typeof returnedHtml === 'string') {\n modelContent = returnedHtml;\n }\n }\n\n this._oldModel = modelContent;\n\n // Update froalaModel.\n this.froalaModelChange.emit(modelContent);\n\n // Update form model.\n this.onChange(modelContent);\n\n })\n }\n\n // register event on jquery element\n private registerEvent(element, eventName, callback) {\n\n if (!element || !eventName || !callback) {\n return;\n }\n\n this._listeningEvents.push(eventName);\n element.on(eventName, callback);\n }\n\n private initListeners() {\n\n let self = this;\n\n // bind contentChange and keyup event to froalaModel\n this.registerEvent(this._$element, 'froalaEditor.contentChanged',function () {\n setTimeout(function (){\n self.updateModel();\n }, 0);\n });\n if (this._opts.immediateAngularModelUpdate) {\n this.registerEvent(this._editor, 'keyup', function () {\n setTimeout(function (){\n self.updateModel();\n }, 0);\n });\n }\n }\n\n // register events from editor options\n private registerFroalaEvents() {\n\n if (!this._opts.events) {\n return;\n }\n\n for (let eventName in this._opts.events) {\n\n if (this._opts.events.hasOwnProperty(eventName)) {\n this.registerEvent(this._$element, eventName, this._opts.events[eventName]);\n }\n }\n }\n\n private createEditor() {\n\n if (this._editorInitialized) {\n return;\n }\n\n this.setContent(true);\n\n // Registering events before initializing the editor will bind the initialized event correctly.\n this.registerFroalaEvents();\n\n // init editor\n this.zone.runOutsideAngular(() => {\n console.log (this._opts)\n this._editor = this._$element.froalaEditor(this._opts).data('froala.editor').$el;\n })\n\n this.initListeners();\n\n this._editorInitialized = true;\n }\n\n private setHtml() {\n this._$element.froalaEditor('html.set', this._model || '', true);\n\n //This will reset the undo stack everytime the model changes externally. Can we fix this?\n this._$element.froalaEditor('undo.reset');\n this._$element.froalaEditor('undo.saveStep');\n }\n\n private setContent(firstTime = false) {\n\n let self = this;\n // set initial content\n if (this._model || this._model == '') {\n this._oldModel = this._model;\n if (this._hasSpecialTag) {\n\n let tags: Object = this._model;\n\n // add tags on element\n if (tags) {\n\n for (let attr in tags) {\n if (tags.hasOwnProperty(attr) && attr != this.INNER_HTML_ATTR) {\n this._$element.attr(attr, tags[attr]);\n }\n }\n\n if (tags.hasOwnProperty(this.INNER_HTML_ATTR)) {\n this._$element[0].innerHTML = tags[this.INNER_HTML_ATTR];\n }\n }\n } else {\n if (firstTime) {\n this.registerEvent(this._$element, 'froalaEditor.initialized', function () {\n self.setHtml();\n });\n } else {\n self.setHtml();\n }\n\n }\n }\n }\n\n private destroyEditor() {\n if (this._editorInitialized) {\n this._$element.off(this._listeningEvents.join(\" \"));\n this._editor.off('keyup');\n this._$element.froalaEditor('destroy');\n this._listeningEvents.length = 0;\n this._editorInitialized = false;\n }\n }\n\n private getEditor() {\n if (this._$element) {\n return this._$element.froalaEditor.bind(this._$element);\n }\n\n return null;\n }\n\n // send manual editor initialization\n private generateManualController() {\n let self = this;\n let controls = {\n initialize: this.createEditor.bind(this),\n destroy: this.destroyEditor.bind(this),\n getEditor: this.getEditor.bind(this),\n };\n this.froalaInit.emit(controls);\n }\n\n // TODO not sure if ngOnInit is executed after @inputs\n ngOnInit() {\n\n // check if output froalaInit is present. Maybe observers is private and should not be used?? TODO how to better test that an output directive is present.\n if (!this.froalaInit.observers.length) {\n this.createEditor();\n } else {\n this.generateManualController();\n }\n }\n\n ngOnDestroy() {\n this.destroyEditor();\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Directive, args: [{\n selector: '[froalaEditor]',\n providers: [{\n provide: NG_VALUE_ACCESSOR,useExisting:\n forwardRef(() => FroalaEditorDirective),\n multi: true\n }]\n}, ] },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: ElementRef, },\n{type: NgZone, },\n];\nstatic propDecorators: {[key: string]: DecoratorInvocation[]} = {\n'froalaEditor': [{ type: Input },],\n'froalaModel': [{ type: Input },],\n'froalaModelChange': [{ type: Output },],\n'froalaInit': [{ type: Output },],\n};\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}