File

projects/wvr-elements/src/lib/wvr-wysiwyg/wvr-wysiwyg.component.ts

Extends

WvrBaseComponent

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs
HostBindings
Accessors

Constructor

constructor(injector: Injector)
Parameters :
Name Type Optional
injector Injector No

Inputs

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

A setter which parses a json string describing animation instructions and stores the derived object in _animationSettings.

animateConfig
Type : string
Inherited from WvrBaseComponent

A setter which parses a json string describing animation setting and stores the derived object in _animationConfig.

animateId
Type : string
Inherited from WvrBaseComponent

An attribute input allowing for the designation of an animation identifier for the purpose of animation targeting.

animateTarget
Type : string
Inherited from WvrBaseComponent

An attribute input allowing for the designation of an animation target for animation events.

hiddenInMobile
Type : boolean
Default value : false
Inherited from WvrBaseComponent

An attribute input specifying if this component should be hidden in the mobile layout.

ngBindings
Type : string
Inherited from WvrBaseComponent
themeVariant
Type : ThemeVariantName
Inherited from WvrBaseComponent

Used to define the class type of an alert component.

wvrData
Type : string
Inherited from WvrBaseComponent
wvrTheme
Type : string
Inherited from WvrBaseComponent

Allows for the override of theme for the particular component.

Outputs

animationEventTrigger
Type : EventEmitter
Inherited from WvrBaseComponent

An Output biding used for triggering animations.

HostBindings

class.wvr-bootstrap
Type : boolean
Default value : true
Inherited from WvrBaseComponent

A host binding used to ensure the presense of the wvr-bootstrap class.

class.wvr-hidden
Type : boolean
Inherited from WvrBaseComponent

A host bound accessor which applies the wvr-hidden class if both isMobileLayout and hiddenInMobile evaluate to true.

style
Type : any
Inherited from WvrBaseComponent

Methods

ngOnDestroy
ngOnDestroy()
Inherited from WvrBaseComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from WvrBaseComponent
Returns : void
onReset
onReset($event)
Parameters :
Name Optional
$event No
Returns : void
onSave
onSave($event)
Parameters :
Name Optional
$event No
Returns : void
applyThemeOverride
applyThemeOverride(customProperty: string, value: string)
Inherited from WvrBaseComponent
Parameters :
Name Type Optional
customProperty string No
value string No
Returns : void
bootstrapNgBindings
bootstrapNgBindings()
Inherited from WvrBaseComponent
Returns : void
getWvrData
getWvrData()
Inherited from WvrBaseComponent
Returns : string
hasWvrData
hasWvrData()
Inherited from WvrBaseComponent
Returns : boolean
initializeAnimationElement
initializeAnimationElement()
Inherited from WvrBaseComponent
Returns : void
initializeAnimationRegistration
initializeAnimationRegistration()
Inherited from WvrBaseComponent
Returns : void
ngAfterContentInit
ngAfterContentInit()
Inherited from WvrBaseComponent

Used for post content initialization animation setup.

Returns : void
onAnimationEvent
onAnimationEvent($event: Event)
Inherited from WvrBaseComponent

Trigger's the animation specified by the incoming event.

Parameters :
Name Type Optional
$event Event No
Returns : void
Private processData
processData()
Inherited from WvrBaseComponent
Returns : void
triggerAnimations
triggerAnimations(animationTriggerType: string)
Inherited from WvrBaseComponent

Plays the animation specified by the incoming animation trigger.

Parameters :
Name Type Optional
animationTriggerType string No
Returns : void

Properties

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

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

A reference to the AnimationService

Private _animationSettings
Type : any
Default value : {}
Inherited from WvrBaseComponent

An object representation of the animation instructions for this component.

Private _ngBindings
Type : literal type
Inherited from WvrBaseComponent
animationRootElem
Type : ElementRef
Decorators :
@ViewChild('animationRoot')
Inherited from WvrBaseComponent

A view child of the template element containing the #animationRoot identifier.

Private animationStateId
Type : number
Inherited from WvrBaseComponent

An identifier used to access the animation state for this component.

Readonly appConfig
Type : AppConfig
Inherited from WvrBaseComponent

A reference to the AppConfig

Readonly cdRef
Type : ChangeDetectorRef
Inherited from WvrBaseComponent

A reference to the ChangeDetectorRef

Readonly componentRegistry
Type : ComponentRegistryService<WvrBaseComponent>
Inherited from WvrBaseComponent

A reference to the ComponentRegistryService

data
Type : literal type
Default value : {}
Inherited from WvrBaseComponent
Readonly eRef
Type : ElementRef
Inherited from WvrBaseComponent

A reference to the ElementRef

Readonly id
Type : number
Inherited from WvrBaseComponent

A generated unique identifier for this comonent.

isMobile
Type : Observable<boolean>
Inherited from WvrBaseComponent
isMobileLayout
Type : boolean
Inherited from WvrBaseComponent
Private Readonly kebabize
Default value : () => {...}
Inherited from WvrBaseComponent
Private Readonly ngBindingsService
Type : NgBindingsService
Inherited from WvrBaseComponent

A reference to the NgBindingsService

Readonly store
Type : Store<RootState>
Inherited from WvrBaseComponent

A reference to the Store

style
Decorators :
@HostBinding('style')
Inherited from WvrBaseComponent
Protected subscriptions
Type : Array<Subscription>
Inherited from WvrBaseComponent
themeOverrides
Type : object
Default value : {}
Inherited from WvrBaseComponent
Private Readonly themeService
Type : ThemeService
Inherited from WvrBaseComponent

A reference to the ThemeService

variantTypes
Type : []
Default value : []
Inherited from WvrBaseComponent
wvrBootstrap
Default value : true
Decorators :
@HostBinding('class.wvr-bootstrap')
Inherited from WvrBaseComponent

A host binding used to ensure the presense of the wvr-bootstrap class.

Accessors

baseUrl
getbaseUrl()
setbaseUrl(baseUrl: string)
Parameters :
Name Type Optional
baseUrl string No
Returns : void
skin
getskin()
setskin(skin: string)
Parameters :
Name Type Optional
skin string No
Returns : void
plugins
getplugins()
setplugins(plugins: Array)
Parameters :
Name Type Optional
plugins Array<string> No
Returns : void
toolbar
gettoolbar()
settoolbar(toolbar: string)
Parameters :
Name Type Optional
toolbar string No
Returns : void
menu
getmenu()
setmenu(editorMenu: any)
Parameters :
Name Type Optional
editorMenu any No
Returns : void
height
getheight()
setheight(height: string)
Parameters :
Name Type Optional
height string No
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;

}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""