Smiles to emojis. Natively.
Emojer is a simple library to transform your smiles like :)
to 😃.
We use the String.fromCodePoint
method to transform char code to the emoji. Not images.
To use it, is very simple, let's take a look:
const rock = emojer.parse('My rock text :rock: ;P');
The result will be: My rock text 🤘 😜
- Playground: https://cezarlz.github.io/emojer/
- Chat example: https://codepen.io/CezarLuiz0/pen/xrNKwm
npm install emojer.js --save
yarn add emojer.js
Parse the string to the string "emojed".
Example:
emojer.parse('Hello guys :D');
Add a new emoji to the list to be replaced by the charCode.
Example:
emojer.addEmoji("--'", 0x1f612);
You can check the full list of emojis and their unicodes here.
Emojer uses configs to do somethings, like add css classes to the emoji and a option to render the emojis with a HTML wrapper.
The default configs are:
{
span_classes: [],
html: true
}
You can use it:
emojer.setConfigs({
span_classes: ['foo', 'bar''],
html: false
});
By default, emojer adds the emojer-icon
css class in every emoji rendered if the flag html
is true
.
:) :] =) =] (: [: (= [= :3 :D =D ;) ;] (H) :* :| :O :P ;P :'( :'[ )': ]': :# (A) :( :[ :@ (6) +( +[ <3 S2 (L) (8) (Y) (OK) :rock: :-) :$ ;-) :-* ;* =-O :-P :/ :-P *_* +_+ >_< O_O
Just clone, yarn, npm start
, make your magic, push and open a pull request. Voilá!
Check the support of native emojis here.
Made with ❤️