Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
4.4 KiB

  1. # node-emoji
  2. [![NPM version (1.0.3)](https://img.shields.io/npm/v/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![NPM Downloads](https://img.shields.io/npm/dm/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![Build Status](https://img.shields.io/travis/omnidan/node-emoji/master.svg?style=flat-square)](https://travis-ci.org/omnidan/node-emoji) [![Dependencies](https://img.shields.io/david/omnidan/node-emoji.svg?style=flat-square)](https://david-dm.org/omnidan/node-emoji) [![Code Climate](https://img.shields.io/codeclimate/github/omnidan/node-emoji.svg?style=flat-square)](https://codeclimate.com/github/omnidan/node-emoji) [![https://paypal.me/DanielBugl/9](https://img.shields.io/badge/donate-paypal-yellow.svg?style=flat-square)](https://paypal.me/DanielBugl/9)
  3. _simple emoji support for node.js projects_
  4. ![node-emoji example](https://i.imgur.com/yIo5Uux.png)
  5. ## Installation
  6. To install `node-emoji`, you need [node.js](http://nodejs.org/) and [npm](https://github.com/npm/npm#super-easy-install). :rocket:
  7. Once you have that set-up, just run `npm install --save node-emoji` in your project directory. :ship:
  8. You're now ready to use emoji in your node projects! Awesome! :metal:
  9. ## Usage
  10. ```javascript
  11. var emoji = require('node-emoji')
  12. emoji.get('coffee') // returns the emoji code for coffee (displays emoji on terminals that support it)
  13. emoji.which(emoji.get('coffee')) // returns the string "coffee"
  14. emoji.get(':fast_forward:') // `.get` also supports github flavored markdown emoji (http://www.emoji-cheat-sheet.com/)
  15. emoji.emojify('I :heart: :coffee:!') // replaces all :emoji: with the actual emoji, in this case: returns "I ❤️ ☕️!"
  16. emoji.random() // returns a random emoji + key, e.g. `{ emoji: '❤️', key: 'heart' }`
  17. emoji.search('cof') // returns an array of objects with matching emoji's. `[{ emoji: '☕️', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`
  18. emoji.unemojify('I ❤️ 🍕') // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"
  19. emoji.find('🍕') // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;
  20. emoji.find('pizza') // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;
  21. emoji.hasEmoji('🍕') // Validate if this library knows an emoji like `🍕`
  22. emoji.hasEmoji('pizza') // Validate if this library knowns a emoji with the name `pizza`
  23. emoji.strip('⚠️ 〰️ 〰️ low disk space') // Strips the string from emoji's, in this case returns: "low disk space".
  24. emoji.replace('⚠️ 〰️ 〰️ low disk space', (emoji) => `${emoji.key}:`) // Replace emoji's by callback method: "warning: low disk space"
  25. ```
  26. ## Options
  27. ### onMissing
  28. `emoji.emojify(str, onMissing)`
  29. As second argument, `emojify` takes an handler to parse unknown emojis. Provide a function to add your own handler:
  30. ```js
  31. var onMissing = function (name) {
  32. return name;
  33. });
  34. var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', onMissing);
  35. // emojified: I unknown_emoji ⭐️ another_one
  36. ```
  37. ### format
  38. `emoji.emojify(str, onMissing, format)`
  39. As third argument, `emojify` takes an handler to wrap parsed emojis. Provide a function to place emojis in custom elements, and to apply your custom styling:
  40. ```js
  41. var format = function (code, name) {
  42. return '<img alt="' + code + '" src="' + name + '.png" />';
  43. });
  44. var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', null, format);
  45. // emojified: I <img alt="❤️" src="heart.png" /> <img alt="☕️" src="coffee.png" />
  46. ```
  47. ## Adding new emoji
  48. Emoji come from js-emoji (Thanks a lot :thumbsup:). You can get a JSON file with all emoji here: https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json
  49. To update the list or add custom emoji, clone this repository and put them into `lib/emojifile.js`.
  50. Then run `npm run-script emojiparse` in the project directory or `node emojiparse` in the lib directory.
  51. This should generate the new emoji.json file and output `Done.`.
  52. That's all, you now have more emoji you can use! :clap:
  53. ## Support / Donations
  54. If you want to support node-emoji development, please consider donating (it helps me keeping my projects active and alive!):
  55. * Paypal: [![daniel.bugl@gmail.com](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YBMS9EKTNPZHJ)
  56. * Bitcoin: [1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA](bitcoin:1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA)