projects/wvr-elements/src/lib/wvr-wysiwyg/wvr-wysiwyg.component.ts
changeDetection | ChangeDetectionStrategy.Default |
selector | wvr-wysiwyg-component |
styleUrls | ./wvr-wysiwyg.component.scss |
templateUrl | ./wvr-wysiwyg.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
HostBindings |
Accessors |
constructor(injector: Injector)
|
||||||
Parameters :
|
baseUrl | |
Type : string
|
|
emitSaveEvent | |
Type : string
|
|
height | |
Type : string
|
|
initialValue | |
Type : string
|
|
menu | |
Type : any
|
|
outputFormat | |
Type : "text" | "html"
|
|
Default value : 'html'
|
|
plugins | |
Type : Array<string>
|
|
skin | |
Type : string
|
|
toolbar | |
Type : string
|
|
animate | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:68
|
|
A setter which parses a json string describing animation instructions and stores the derived object in |
animateConfig | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:76
|
|
A setter which parses a json string describing animation setting and stores the derived object in |
animateId | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:84
|
|
An attribute input allowing for the designation of an animation identifier for the purpose of animation targeting. |
animateTarget | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:87
|
|
An attribute input allowing for the designation of an animation target for animation events. |
hiddenInMobile | |
Type : boolean
|
|
Default value : false
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:107
|
|
An attribute input specifying if this component should be hidden in the mobile layout. |
ngBindings | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:116
|
themeVariant | |
Type : ThemeVariantName
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:55
|
|
Used to define the class type of an alert component. |
wvrData | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:45
|
wvrTheme | |
Type : string
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:50
|
|
Allows for the override of theme for the particular component. |
animationEventTrigger | |
Type : EventEmitter
|
|
Inherited from
WvrBaseComponent
|
|
Defined in
WvrBaseComponent:110
|
|
An Output biding used for triggering animations. |
class.wvr-bootstrap |
Type : boolean
|
Default value : true
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:58
|
A host binding used to ensure the presense of the |
class.wvr-hidden |
Type : boolean
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:102
|
A host bound accessor which applies the wvr-hidden class if both isMobileLayout and hiddenInMobile evaluate to true. |
style |
Type : any
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:60
|
ngOnDestroy |
ngOnDestroy()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:98
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:77
|
Returns :
void
|
onReset | ||||
onReset($event)
|
||||
Parameters :
Returns :
void
|
onSave | ||||
onSave($event)
|
||||
Parameters :
Returns :
void
|
applyThemeOverride |
applyThemeOverride(customProperty: string, value: string)
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:237
|
Returns :
void
|
bootstrapNgBindings |
bootstrapNgBindings()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:175
|
Returns :
void
|
getWvrData |
getWvrData()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:262
|
Returns :
string
|
hasWvrData |
hasWvrData()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:258
|
Returns :
boolean
|
initializeAnimationElement |
initializeAnimationElement()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:267
|
Returns :
void
|
initializeAnimationRegistration |
initializeAnimationRegistration()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:273
|
Returns :
void
|
ngAfterContentInit |
ngAfterContentInit()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:160
|
Used for post content initialization animation setup.
Returns :
void
|
onAnimationEvent | ||||||
onAnimationEvent($event: Event)
|
||||||
Inherited from
WvrBaseComponent
|
||||||
Defined in
WvrBaseComponent:290
|
||||||
Trigger's the animation specified by the incoming event.
Parameters :
Returns :
void
|
Private processData |
processData()
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:295
|
Returns :
void
|
triggerAnimations | ||||||
triggerAnimations(animationTriggerType: string)
|
||||||
Inherited from
WvrBaseComponent
|
||||||
Defined in
WvrBaseComponent:244
|
||||||
Plays the animation specified by the incoming animation trigger.
Parameters :
Returns :
void
|
config |
Type : object
|
Default value : {
base_url: 'tinymce',
skin: 'oxide',
plugins: [
"advlist", "autolink", "lists", "link", "image", "charmap", "print",
"preview", "anchor", "searchreplace", "visualblocks", "code",
"fullscreen", "insertdatetime", "media", "table", "paste",
"help", "wordcount", "print", "preview", "save"
],
toolbar: 'undo redo | print formatselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table pagebreak | charmap codesample image | removeformat | help | cancel save',
menu: (wvrEditor as any).default,
height: '300',
save_oncancelcallback: $event => {
this.onReset($event);
},
save_onsavecallback: $event => {
this.onSave($event);
},
promotion: false
}
|
content |
Type : string
|
editor |
Decorators :
@ViewChild(EditorComponent)
|
htmlId |
Default value : `wvr-wysiwyg-${this.id}`
|
Private _animationConfig |
Type : any
|
Default value : {}
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:73
|
An object representation of the settings specifying the specific behavior of the animation for this component. |
Private Readonly _animationService |
Type : AnimationService<WvrBaseComponent>
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:93
|
A reference to the AnimationService |
Private _animationSettings |
Type : any
|
Default value : {}
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:65
|
An object representation of the animation instructions for this component. |
Private _ngBindings |
Type : literal type
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:114
|
animationRootElem |
Type : ElementRef
|
Decorators :
@ViewChild('animationRoot')
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:90
|
A view child of the template element containing the #animationRoot identifier. |
Private animationStateId |
Type : number
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:81
|
An identifier used to access the animation state for this component. |
Readonly appConfig |
Type : AppConfig
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:37
|
A reference to the AppConfig |
Readonly cdRef |
Type : ChangeDetectorRef
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:34
|
A reference to the ChangeDetectorRef |
Readonly componentRegistry |
Type : ComponentRegistryService<WvrBaseComponent>
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:25
|
A reference to the ComponentRegistryService |
data |
Type : literal type
|
Default value : {}
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:42
|
Readonly eRef |
Type : ElementRef
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:31
|
A reference to the ElementRef |
Readonly id |
Type : number
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:28
|
A generated unique identifier for this comonent. |
isMobile |
Type : Observable<boolean>
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:120
|
isMobileLayout |
Type : boolean
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:112
|
Private Readonly kebabize |
Default value : () => {...}
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:321
|
Private Readonly ngBindingsService |
Type : NgBindingsService
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:99
|
A reference to the NgBindingsService |
Readonly store |
Type : Store<RootState>
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:40
|
A reference to the Store |
style |
Decorators :
@HostBinding('style')
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:60
|
Protected subscriptions |
Type : Array<Subscription>
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:122
|
themeOverrides |
Type : object
|
Default value : {}
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:47
|
Private Readonly themeService |
Type : ThemeService
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:96
|
A reference to the ThemeService |
variantTypes |
Type : []
|
Default value : []
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:62
|
wvrBootstrap |
Default value : true
|
Decorators :
@HostBinding('class.wvr-bootstrap')
|
Inherited from
WvrBaseComponent
|
Defined in
WvrBaseComponent:58
|
A host binding used to ensure the presense of the |
baseUrl | ||||||
getbaseUrl()
|
||||||
setbaseUrl(baseUrl: string)
|
||||||
Parameters :
Returns :
void
|
skin | ||||||
getskin()
|
||||||
setskin(skin: string)
|
||||||
Parameters :
Returns :
void
|
plugins | ||||||
getplugins()
|
||||||
setplugins(plugins: Array
|
||||||
Parameters :
Returns :
void
|
toolbar | ||||||
gettoolbar()
|
||||||
settoolbar(toolbar: string)
|
||||||
Parameters :
Returns :
void
|
menu | ||||||
getmenu()
|
||||||
setmenu(editorMenu: any)
|
||||||
Parameters :
Returns :
void
|
height | ||||||
getheight()
|
||||||
setheight(height: string)
|
||||||
Parameters :
Returns :
void
|
import { ChangeDetectionStrategy, Component, Injector, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { select } from '@ngrx/store';
import { EditorComponent } from '@tinymce/tinymce-angular';
import * as JSON5 from 'json5';
import { filter, map } from 'rxjs/operators';
import tinymce from 'tinymce';
import { selectWysiwygById } from '../core/store';
import * as WysiwygActions from '../core/wysiwyg/wysiwyg.actions';
import { WvrBaseComponent } from '../shared/wvr-base.component';
import * as wvrEditor from './wvr-wysiwyg.json';
@Component({
selector: 'wvr-wysiwyg-component',
templateUrl: './wvr-wysiwyg.component.html',
styleUrls: ['./wvr-wysiwyg.component.scss'],
changeDetection: ChangeDetectionStrategy.Default
})
export class WvrWysiwygComponent extends WvrBaseComponent implements OnInit, OnDestroy {
content: string;
@ViewChild(EditorComponent) editor;
@Input() initialValue: string;
@Input() outputFormat: 'text' | 'html' = 'html';
@Input() set baseUrl(baseUrl: string) { this.config.base_url = baseUrl; }
get baseUrl(): string { return this.config.base_url; }
@Input() set skin(skin: string) { this.config.skin = skin; }
get skin(): string { return this.config.skin; }
@Input() set plugins(plugins: Array<string>) { this.config.plugins = plugins; }
get plugins(): Array<string> { return this.config.plugins; }
@Input() set toolbar(toolbar: string) { this.config.toolbar = toolbar; }
get toolbar(): string { return this.config.toolbar; }
@Input() set menu(editorMenu: any) { this.config.menu = JSON5.parse(editorMenu); }
get menu(): any { return this.config.menu; }
@Input() emitSaveEvent: string;
@Input() set height(height: string) { this.config.height = height; }
get height(): string { return this.config.height; }
config = {
base_url: 'tinymce',
skin: 'oxide',
plugins: [
"advlist", "autolink", "lists", "link", "image", "charmap", "print",
"preview", "anchor", "searchreplace", "visualblocks", "code",
"fullscreen", "insertdatetime", "media", "table", "paste",
"help", "wordcount", "print", "preview", "save"
],
toolbar: 'undo redo | print formatselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table pagebreak | charmap codesample image | removeformat | help | cancel save',
menu: (wvrEditor as any).default,
height: '300',
save_oncancelcallback: $event => {
this.onReset($event);
},
save_onsavecallback: $event => {
this.onSave($event);
},
promotion: false
};
htmlId = `wvr-wysiwyg-${this.id}`;
constructor(injector: Injector) {
super(injector);
this.config.base_url = `${this.appConfig.assetsUrl}/tinymce`;
}
ngOnInit(): void {
super.ngOnInit();
this.store.dispatch(WysiwygActions.addWysiwyg({
wysiwyg: {
id: `${this.id}`,
initialContent: `${this.initialValue}`,
content: this.initialValue
}
}));
this.subscriptions.push(this.store
.pipe(
select(selectWysiwygById(`${this.id}`)),
filter(wysiwyg => !!wysiwyg),
map(wysiwyg => wysiwyg.content)
)
.subscribe((content: string) => {
this.content = content;
}));
}
ngOnDestroy(): void {
super.ngOnDestroy();
if (!!this.editor) {
tinymce.remove(this.editor);
}
}
onReset($event): void {
this.store.dispatch(WysiwygActions.resetWysiwyg({
id: `${this.id}`
}));
}
onSave($event): void {
this.store.dispatch(WysiwygActions.saveWysiwyg({
content: this.content,
id: `${this.id}`
}));
if (this.emitSaveEvent) {
this.eRef.nativeElement.dispatchEvent(new CustomEvent(this.emitSaveEvent, {
bubbles: true,
detail: {
data: this.content,
wysiwyg: this
}
}));
}
}
}
<wvr-wysiwyg-wrapper #animationRoot class="wvr-components wvr-wysiwyg">
<editor
id="{{htmlId}}"
[init]="config"
[outputFormat]="outputFormat"
[initialValue]="initialValue"
[(ngModel)]="content">
</editor>
</wvr-wysiwyg-wrapper>
./wvr-wysiwyg.component.scss
@import "../shared/styles/variables";
:host {
@extend .variables;
}