UNPKG

@angular-package/prism

Version:
109 lines 3.5 kB
import { ElementRef, Input, Injectable, SimpleChanges, ViewChild } from '@angular/core'; import Prism from 'prismjs'; import * as _ from 'lodash-es'; import { PrismInterface } from './prism.interface'; import { CallbackType, SanitizedType } from './prism.type'; import { PrismService } from './prism.service'; export class PrismClass { constructor(prismService) { this.prismService = prismService; this.change = false; } set async(value) { this.prismService.async = value; } get async() { return this.prismService.async; } set callback(value) { this.prismService.callback = value; } get callback() { return this.prismService.callback; } set code(value) { if (value) { if (typeof (value) === 'string') { this.prismService.code = value; } else { throw new Error(`Property \`code\` should be \`string\` instead of provided \`${typeof (value)}\``); } } else { this.prismService.code = value; } } get code() { return this.prismService.code; } set hooks(value) { this.prismService.hooks = value; } get hooks() { return this.prismService.hooks; } set language(value) { if (value) { if (typeof (value) === 'string') { this.prismService.language = value; } else { throw new Error(`Property \`language\` should be \`string\` instead of provided \`${typeof (value)}\``); } } else { throw new Error('Missing property `language`.'); } } ; get language() { return this.prismService.language; } set interpolation(value) { this.prismService.interpolation = value; } get interpolation() { return this.prismService.interpolation; } onChanges(prop, changes) { if (changes) { _.each(changes, (value, key) => { if (prop instanceof Array) { _.each(prop, (propName) => { if (key === propName) { if (changes[key].currentValue !== changes[key].previousValue && changes[key].firstChange === false) { this.change = true; } } }); } else { switch (key) { case prop: if (changes[key].currentValue !== changes[key].previousValue && changes[key].firstChange === false) { this.change = true; } break; } } }); } } } PrismClass.decorators = [ { type: Injectable }, ]; PrismClass.ctorParameters = () => [ { type: PrismService, }, ]; PrismClass.propDecorators = { "async": [{ type: Input, args: ['async',] },], "callback": [{ type: Input, args: ['callback',] },], "code": [{ type: Input, args: ['code',] },], "hooks": [{ type: Input, args: ['hooks',] },], "language": [{ type: Input, args: ['language',] },], "interpolation": [{ type: Input, args: ['interpolation',] },], "codeElementRef": [{ type: ViewChild, args: ['codeElementRef',] },], }; //# sourceMappingURL=prism.class.js.map