UNPKG

@instechnologies/ng-rooster

Version:

ng-rooster is wrapper to roosterjs, an open source library created by Microsoft: https://github.com/Microsoft/roosterjs.

2 lines 16.2 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs/operators"),require("roosterjs"),require("rxjs"),require("util"),require("@angular/forms")):"function"==typeof define&&define.amd?define("@instechnologies/ng-rooster",["exports","@angular/core","rxjs/operators","roosterjs","rxjs","util","@angular/forms"],e):e((t.instechnologies=t.instechnologies||{},t.instechnologies["ng-rooster"]={}),t.ng.core,t.rxjs.operators,t.RoosterJs,t.rxjs,t.util,t.ng.forms)}(this,function(t,e,n,h,i,r,o){"use strict";var u=(s.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],s.ctorParameters=function(){return[]},s.ngInjectableDef=e.defineInjectable({factory:function(){return new s},token:s,providedIn:"root"}),s);function s(){}var c=(l.prototype.ngOnInit=function(){},l.decorators=[{type:e.Component,args:[{selector:"lib-ng-rooster",template:"\n <p>\n ng-rooster works!\n </p>\n "}]}],l.ctorParameters=function(){return[]},l);function l(){}var p=(Object.defineProperty(a.prototype,"editor",{get:function(){return this._editor},enumerable:!0,configurable:!0}),a.prototype.ngOnInit=function(){var t=this.el.nativeElement;this._editor=new h.Editor(t,{plugins:this.plugins,defaultFormat:this.defaultFormat,initialContent:this.initialContent,disableRestoreSelectionOnFocus:this.disableRestoreSelectionOnFocus,omitContentEditableAttributeChanges:this.omitContentEditableAttributeChanges})},a.decorators=[{type:e.Directive,args:[{selector:"[rooster-editor]"}]}],a.ctorParameters=function(){return[{type:e.ElementRef}]},a.propDecorators={plugins:[{type:e.Input}],defaultFormat:[{type:e.Input}],initialContent:[{type:e.Input}],disableRestoreSelectionOnFocus:[{type:e.Input}],omitContentEditableAttributeChanges:[{type:e.Input}]},a);function a(t){this.el=t}var g=function(t,e){return(g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function d(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),u=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)u.push(i.value)}catch(s){r={error:s}}finally{try{i&&!i.done&&(n=o["return"])&&n.call(o)}finally{if(r)throw r.error}}return u}var b,m=(function j(t,e){function n(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(f,b=i.Observable),f.prototype.getContentObservable=function(){return this._contentChangeSubject},f.prototype.initialize=function(t){this.editor=t},f.prototype.getName=function(){return"FormatStateObservable"},f.prototype.dispose=function(){this._subject.complete(),this._contentChangeSubject.complete()},f.prototype.onPluginEvent=function(t){switch(t.eventType){case 4:case 0:this.getFormatState();break;case 6:this.getFormatState();case 11:this.getContent()}},f.prototype.getContent=function(){var t=this.editor.getContent(!0);this._contentChangeSubject.next(t)},f.prototype.getFormatState=function(){var t=h.getFormatState(this.editor);this._subject.next(t)},f);function f(){var t=b.call(this,function(e){t._subject.subscribe(function(t){return e.next(t)},function(t){return e.error(t)},function(){return e.complete()})})||this;return t._subject=new i.Subject,t._contentChangeSubject=new i.Subject,t}function $(t){return!t&&!r.isBoolean(t)}var y=(Object.defineProperty(v.prototype,"aligment",{set:function(t){this.aligment$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"backgroundColor",{set:function(t){this.backgroundColor$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"direction",{set:function(t){this.direction$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"fontName",{set:function(t){this.fontName$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"fontSize",{set:function(t){this.fontSize$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"indentation",{set:function(t){this.indentation$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"textColor",{set:function(t){this.textColor$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleBlockQuote$",{set:function(t){this.toggleBlockQuote$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleBold$",{set:function(t){this.toggleBold$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleBullet$",{set:function(t){this.toggleBullet$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleCodeBlock$",{set:function(t){this.toggleCodeBlock$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleHeader$",{set:function(t){this.toggleHeader$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleItalic$",{set:function(t){this.toggleItalic$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleNumbering$",{set:function(t){this.toggleNumbering$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleStrikethrough$",{set:function(t){this.toggleStrikethrough$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleSubscript$",{set:function(t){this.toggleSubscript$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleSuperscript$",{set:function(t){this.toggleSuperscript$$.next(t)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"toggleUnderline$",{set:function(t){this.toggleUnderline$$.next(t)},enumerable:!0,configurable:!0}),v.prototype.ngOnInit=function(){var e=this;this.formatStatePlugin$.getContentObservable().subscribe(function(t){return e.onChange(t)});var t=this.formatStatePlugin$.pipe(n.pairwise(),n.map(function(t){var e=d(t,2),n=e[0],i=e[1],r={};console.log(i);for(var o=Object.keys(i),u=0;u<o.length;u++){var s=o[u],c=n[s],l=i[s];l!==c&&(r[s]=l)}return r}));t.pipe(n.map(function(t){return t.fontName}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.fontNameChange.emit(t)}),t.pipe(n.map(function(t){return t.fontSize}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.fontSizeChange.emit(t)}),t.pipe(n.map(function(t){return t.isBold}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isBoldChange.emit(t)}),t.pipe(n.map(function(t){return t.isItalic}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isItalicChange.emit(t)}),t.pipe(n.map(function(t){return t.isUnderline}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isUnderlineChange.emit(t)}),t.pipe(n.map(function(t){return t.backgroundColor}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.backgroundColorChange.emit(t)}),t.pipe(n.map(function(t){return t.textColor}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.textColorChange.emit(t)}),t.pipe(n.map(function(t){return t.isBullet}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isBulletChange.emit(t)}),t.pipe(n.map(function(t){return t.isNumbering}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isNumberingChange.emit(t)}),t.pipe(n.map(function(t){return t.isStrikeThrough}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isStrikeThroughChange.emit(t)}),t.pipe(n.map(function(t){return t.isBlockQuote}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isBlockQuoteChange.emit(t)}),t.pipe(n.map(function(t){return t.isSubscript}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isSubscriptChange.emit(t)}),t.pipe(n.map(function(t){return t.isSuperscript}),n.filter(function(t){return!$(t)})).subscribe(function(t){return e.isSuperscriptChange.emit(t)})},v.prototype.ngAfterViewInit=function(){this.editor=this.editorDirective.editor,this.editor$.next(this.editor),this.editor$.complete()},v.prototype.ngOnDestroy=function(){this.aligment$.complete(),this.backgroundColor$.complete(),this.direction$.complete(),this.fontName$.complete(),this.fontSize$.complete(),this.indentation$.complete(),this.textColor$.complete(),this.toggleBlockQuote$$.complete(),this.toggleBold$$.complete(),this.toggleBullet$$.complete(),this.toggleCodeBlock$$.complete(),this.toggleHeader$$.complete(),this.toggleItalic$$.complete(),this.toggleNumbering$$.complete(),this.toggleStrikethrough$$.complete(),this.toggleSubscript$$.complete(),this.toggleSuperscript$$.complete(),this.toggleUnderline$$.complete(),this.editor.dispose()},v.prototype.writeValue=function(t){t&&this.editor.setContent(t)},v.prototype.registerOnChange=function(t){this.onChange=t},v.prototype.registerOnTouched=function(t){this.onTouched=t},v.prototype.setDisabledState=function(t){console.log(t)},v.decorators=[{type:e.Component,args:[{selector:"rooster-editor-box",template:'\r\n<div class="editor" rooster-editor [plugins]="[formatStatePlugin$]" ><ng-content></ng-content></div>\r\n',providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:e.forwardRef(function(){return v}),multi:!0}],styles:[".editor{width:100%;height:100%}:host{display:block}"]}]}],v.ctorParameters=function(){return[]},v.propDecorators={editorDirective:[{type:e.ViewChild,args:[p]}],aligment:[{type:e.Input}],backgroundColor:[{type:e.Input}],backgroundColorChange:[{type:e.Output}],direction:[{type:e.Input}],fontName:[{type:e.Input}],fontNameChange:[{type:e.Output}],fontSize:[{type:e.Input}],fontSizeChange:[{type:e.Output}],indentation:[{type:e.Input}],textColor:[{type:e.Input}],textColorChange:[{type:e.Output}],toggleBlockQuote$:[{type:e.Input}],isBlockQuoteChange:[{type:e.Output}],toggleBold$:[{type:e.Input}],isBoldChange:[{type:e.Output}],toggleBullet$:[{type:e.Input}],isBulletChange:[{type:e.Output}],toggleCodeBlock$:[{type:e.Input}],toggleHeader$:[{type:e.Input}],headerLevelChange:[{type:e.Output}],toggleItalic$:[{type:e.Input}],isItalicChange:[{type:e.Output}],toggleNumbering$:[{type:e.Input}],isNumberingChange:[{type:e.Output}],toggleStrikethrough$:[{type:e.Input}],isStrikeThroughChange:[{type:e.Output}],toggleSubscript$:[{type:e.Input}],isSubscriptChange:[{type:e.Output}],toggleSuperscript$:[{type:e.Input}],isSuperscriptChange:[{type:e.Output}],toggleUnderline$:[{type:e.Input}],isUnderlineChange:[{type:e.Output}]},v);function v(){this.onChange=function(){},this.onTouched=function(){},this.editor$=new i.Subject,this.formatStatePlugin$=new m,this.aligment$=new i.Subject,this.backgroundColor$=new i.Subject,this.backgroundColorChange=new e.EventEmitter,this.direction$=new i.Subject,this.fontName$=new i.Subject,this.fontNameChange=new e.EventEmitter,this.fontSize$=new i.Subject,this.fontSizeChange=new e.EventEmitter,this.indentation$=new i.Subject,this.textColor$=new i.Subject,this.textColorChange=new e.EventEmitter,this.toggleBlockQuote$$=new i.Subject,this.isBlockQuoteChange=new e.EventEmitter,this.toggleBold$$=new i.Subject,this.isBoldChange=new e.EventEmitter,this.toggleBullet$$=new i.Subject,this.isBulletChange=new e.EventEmitter,this.toggleCodeBlock$$=new i.Subject,this.toggleHeader$$=new i.Subject,this.headerLevelChange=new e.EventEmitter,this.toggleItalic$$=new i.Subject,this.isItalicChange=new e.EventEmitter,this.toggleNumbering$$=new i.Subject,this.isNumberingChange=new e.EventEmitter,this.toggleStrikethrough$$=new i.Subject,this.isStrikeThroughChange=new e.EventEmitter,this.toggleSubscript$$=new i.Subject,this.isSubscriptChange=new e.EventEmitter,this.toggleSuperscript$$=new i.Subject,this.isSuperscriptChange=new e.EventEmitter,this.toggleUnderline$$=new i.Subject,this.isUnderlineChange=new e.EventEmitter,i.combineLatest(this.aligment$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setAlignment(i,n)}),i.combineLatest(this.backgroundColor$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setBackgroundColor(i,n)}),i.combineLatest(this.direction$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setDirection(i,n)}),i.combineLatest(this.fontName$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setFontName(i,n)}),i.combineLatest(this.fontSize$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setFontSize(i,n)}),i.combineLatest(this.indentation$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setIndentation(i,n)}),i.combineLatest(this.textColor$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];h.setTextColor(i,n)});var r=null;i.combineLatest(this.toggleBlockQuote$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];r&&r.unsubscribe(),r=n.subscribe(function(t){h.toggleBlockQuote(i,t)})});var o=null;i.combineLatest(this.toggleBold$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];o&&o.unsubscribe(),o=n.subscribe(function(t){h.toggleBold(i)})});var u=null;i.combineLatest(this.toggleBullet$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];u&&u.unsubscribe(),u=n.subscribe(function(t){h.toggleBullet(i)})});var s=null;i.combineLatest(this.toggleCodeBlock$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];s&&s.unsubscribe(),s=n.subscribe(function(t){h.toggleCodeBlock(i,t)})});var c=null;i.combineLatest(this.toggleHeader$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];c&&c.unsubscribe(),c=n.subscribe(function(t){h.toggleHeader(i,t)})});var l=null;i.combineLatest(this.toggleItalic$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];l&&l.unsubscribe(),l=n.subscribe(function(t){h.toggleItalic(i)})});var p=null;i.combineLatest(this.toggleNumbering$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];p&&p.unsubscribe(),p=n.subscribe(function(t){h.toggleNumbering(i)})});var a=null;i.combineLatest(this.toggleStrikethrough$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];a&&a.unsubscribe(),a=n.subscribe(function(t){h.toggleStrikethrough(i)})});var g=null;i.combineLatest(this.toggleSubscript$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];g&&g.unsubscribe(),g=n.subscribe(function(t){h.toggleSubscript(i)})});var b=null;i.combineLatest(this.toggleSuperscript$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];b&&b.unsubscribe(),b=n.subscribe(function(t){h.toggleSuperscript(i)})});var f=null;i.combineLatest(this.toggleUnderline$$,this.editor$).pipe(n.filter(function(t){var e=d(t,2),n=e[0];return!$(e[1])&&!$(n)})).subscribe(function(t){var e=d(t,2),n=e[0],i=e[1];f&&f.unsubscribe(),f=n.subscribe(function(t){h.toggleUnderline(i)})})}var C=(S.decorators=[{type:e.NgModule,args:[{declarations:[c,p,y],imports:[],exports:[c,p,y]}]}],S);function S(){}t.NgRoosterService=u,t.NgRoosterComponent=c,t.NgRoosterModule=C,t.RoosterEditorComponent=y,t.EditorDirective=p,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=instechnologies-ng-rooster.umd.min.js.map