UNPKG

ngx-joypixels

Version:

An Angular library for easily using JoyPixels' Emoji library in your app

107 lines (99 loc) 2.81 kB
import * as i0 from '@angular/core'; import { Injectable, Component, Input, Pipe, NgModule } from '@angular/core'; import * as EmojiToolkit from 'emoji-toolkit'; class EmojiService { constructor() { } /** * Convert a shortname, like :thumbsup:, to a JoyPixels image. */ shortnameToImage(shortname) { return EmojiToolkit.shortnameToImage(shortname); } /** * Convert a native unicode emoji to a shortname */ unicodeToShortname(unicode) { return EmojiToolkit.toShort(unicode); } /** * Convert a native unicode emoji to a JoyPixels image */ unicodeToImage(unicode) { const shortname = this.unicodeToShortname(unicode); return this.shortnameToImage(shortname); } /** * Replace shortcodes and/or native emoji in a blob of text to JoyPixels images */ convertText(text) { return EmojiToolkit.toImage(text); } } EmojiService.ɵprov = i0.ɵɵdefineInjectable({ factory: function EmojiService_Factory() { return new EmojiService(); }, token: EmojiService, providedIn: "root" }); EmojiService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; EmojiService.ctorParameters = () => []; class EmojiComponent { constructor(emojiService) { this.emojiService = emojiService; } ngOnChanges(changes) { if (changes.shortname.currentValue) { this.setImage(changes.shortname.currentValue); } } setImage(shortname) { this.image = this.emojiService.shortnameToImage(shortname); } } EmojiComponent.decorators = [ { type: Component, args: [{ selector: 'jp-emoji', template: "<span [innerHTML]=\"image\"></span>\n", styles: [""] },] } ]; EmojiComponent.ctorParameters = () => [ { type: EmojiService } ]; EmojiComponent.propDecorators = { shortname: [{ type: Input }] }; class EmojiPipe { constructor(emojiService) { this.emojiService = emojiService; } transform(text) { if (!text) { return ''; } return this.emojiService.convertText(text); } } EmojiPipe.decorators = [ { type: Pipe, args: [{ name: 'emoji' },] } ]; EmojiPipe.ctorParameters = () => [ { type: EmojiService } ]; class NgxJoypixelsModule { } NgxJoypixelsModule.decorators = [ { type: NgModule, args: [{ declarations: [EmojiComponent, EmojiPipe], exports: [EmojiComponent, EmojiPipe] },] } ]; /* * Public API Surface of ngx-joypixels */ /** * Generated bundle index. Do not edit. */ export { EmojiComponent, EmojiPipe, EmojiService, NgxJoypixelsModule }; //# sourceMappingURL=ngx-joypixels.js.map