UNPKG

ngx-joypixels

Version:

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

146 lines (134 loc) 5.2 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('emoji-toolkit')) : typeof define === 'function' && define.amd ? define('ngx-joypixels', ['exports', '@angular/core', 'emoji-toolkit'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-joypixels'] = {}, global.ng.core, global.EmojiToolkit)); }(this, (function (exports, i0, EmojiToolkit) { 'use strict'; function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n['default'] = e; return Object.freeze(n); } var i0__namespace = /*#__PURE__*/_interopNamespace(i0); var EmojiToolkit__namespace = /*#__PURE__*/_interopNamespace(EmojiToolkit); var EmojiService = /** @class */ (function () { function EmojiService() { } /** * Convert a shortname, like :thumbsup:, to a JoyPixels image. */ EmojiService.prototype.shortnameToImage = function (shortname) { return EmojiToolkit__namespace.shortnameToImage(shortname); }; /** * Convert a native unicode emoji to a shortname */ EmojiService.prototype.unicodeToShortname = function (unicode) { return EmojiToolkit__namespace.toShort(unicode); }; /** * Convert a native unicode emoji to a JoyPixels image */ EmojiService.prototype.unicodeToImage = function (unicode) { var shortname = this.unicodeToShortname(unicode); return this.shortnameToImage(shortname); }; /** * Replace shortcodes and/or native emoji in a blob of text to JoyPixels images */ EmojiService.prototype.convertText = function (text) { return EmojiToolkit__namespace.toImage(text); }; return EmojiService; }()); EmojiService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EmojiService_Factory() { return new EmojiService(); }, token: EmojiService, providedIn: "root" }); EmojiService.decorators = [ { type: i0.Injectable, args: [{ providedIn: 'root' },] } ]; EmojiService.ctorParameters = function () { return []; }; var EmojiComponent = /** @class */ (function () { function EmojiComponent(emojiService) { this.emojiService = emojiService; } EmojiComponent.prototype.ngOnChanges = function (changes) { if (changes.shortname.currentValue) { this.setImage(changes.shortname.currentValue); } }; EmojiComponent.prototype.setImage = function (shortname) { this.image = this.emojiService.shortnameToImage(shortname); }; return EmojiComponent; }()); EmojiComponent.decorators = [ { type: i0.Component, args: [{ selector: 'jp-emoji', template: "<span [innerHTML]=\"image\"></span>\n", styles: [""] },] } ]; EmojiComponent.ctorParameters = function () { return [ { type: EmojiService } ]; }; EmojiComponent.propDecorators = { shortname: [{ type: i0.Input }] }; var EmojiPipe = /** @class */ (function () { function EmojiPipe(emojiService) { this.emojiService = emojiService; } EmojiPipe.prototype.transform = function (text) { if (!text) { return ''; } return this.emojiService.convertText(text); }; return EmojiPipe; }()); EmojiPipe.decorators = [ { type: i0.Pipe, args: [{ name: 'emoji' },] } ]; EmojiPipe.ctorParameters = function () { return [ { type: EmojiService } ]; }; var NgxJoypixelsModule = /** @class */ (function () { function NgxJoypixelsModule() { } return NgxJoypixelsModule; }()); NgxJoypixelsModule.decorators = [ { type: i0.NgModule, args: [{ declarations: [EmojiComponent, EmojiPipe], exports: [EmojiComponent, EmojiPipe] },] } ]; /* * Public API Surface of ngx-joypixels */ /** * Generated bundle index. Do not edit. */ exports.EmojiComponent = EmojiComponent; exports.EmojiPipe = EmojiPipe; exports.EmojiService = EmojiService; exports.NgxJoypixelsModule = NgxJoypixelsModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ngx-joypixels.umd.js.map