Code Monkey home page Code Monkey logo

emoji-picker's Introduction

Emoji Picker

😍 😜 πŸ˜‚ πŸ˜› Instantly add Emoji support to input fields on your website! πŸ’₯ ✨ πŸ‘ 🀘

Example Screenshot

Demo: https://js-emoji-picker.arifdev.com/

Installation & Usage:

  1. In your <head> section, add the following stylesheet links. Adjust the lib/css path to match yours.
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="lib/css/emoji.css" rel="stylesheet">
  1. Before the end of your <body> section, add the following JavaScript links. This library depends on jQuery, so jQuery must also be included, before these scripts are run. Once again, adjust the lib/js path to match yours.
  <!-- ** Don't forget to Add jQuery here ** -->
  <script src="lib/js/config.min.js"></script>
  <script src="lib/js/util.min.js"></script>
  <script src="lib/js/jquery.emojiarea.min.js"></script>
  <script src="lib/js/emoji-picker.min.js"></script>
  1. On any input field, add the data attribute data-emojiable="true".

  2. Put your input field in a container with class="emoji-picker-container" to make sure picker would be displayed upper right corner of the input field.

  3. Create a new EmojiPicker instance and bind it to your input field.

    <script>
      $(function() {
        // Initializes and creates emoji set from sprite sheet
        window.emojiPicker = new EmojiPicker({
          emojiable_selector: '[data-emojiable=true]',
          assetsPath: '/lib/img/',
          popupButtonClasses: 'fa fa-smile-o' // far fa-smile if you're using FontAwesome 5
        });
        // Finds all elements with `emojiable_selector` and converts them to rich emoji input fields
        // You may want to delay this step if you have dynamically created input fields that appear later in the loading process
        // It can be called as many times as necessary; previously converted input fields will not be converted again
        window.emojiPicker.discover();
      });
    </script>
  1. That's all you need for the default options. Play around with the demo to see what the default options give you.

Configuring Options

I want the Emoji selector to input Unicode characters instead of images

Add data-emoji-input="unicode" to your input field. Only the unicode value is checked for; entering anything else has no effect.

I want to limit my input field to a certain number of characters (maxlength)

The maxlength property is supported. Character input and emoji input each count as one character, so it'll stop you from entering more than the max length.

I want classes from my original input field to be copied over to the rich emoji input area

They are!

Trivia

You get:

  • Input fields converted to contenteditable rich text areas with emoji support
  • A happy face icon on the top right of each rich text area, which brings up the menu on click
  • An emoji selection menu, with recently selected emojis at the top (thanks to angular-emoji-popup's author)
  • Text area values can be easily converted between Unicode and HTML (Unicode+Image Tags)

What happens under the hood:

  • When you call new EmojiPicker().discover(), all elements with the data attribute data-emojiable="true" are found, a contenteditable div is created after each one, and the original input field is hidden.
  • When you type text into this contenteditable div, events are triggered upon each keypress/text change as well as each emoji selection, and the contents of this contenteditable div are copied to the original (now hidden) input field
  • Text entered into this contenteditable div is plain text; selected emojis are actually <img> tags
  • To get the value of the contenteditable div, call element.val() on the underlying hidden input field. The <img> emojis will be converted into Unicode emojis (plain text)

Credits:

This was originally built to power emoji selection for OneSignal, an omni-channel customer engagement platform.

This is a slightly modified version of angular-emoji-popup, which was written based on jquery-emojiarea (converts input fields to rich emoji input areas) and uses nanoScrollerJs (for the popup's custom-skinned scrollbar). This version removes AngularJS as a dependency.

Improvements from the original forks:

  • The top-right smiley face that allows you to bring up the emoji picker menu
  • The smiley face shifts left appropriately when text entered exceeds the height and causes a scrollbar to appear
  • The maxlength property of input fields is respected (emoji selections count as a single character)
  • CSS classes from the original input field are copied over to the new contenteditable div

emoji-picker's People

Contributors

atakane avatar gdeglin avatar jmadler avatar marifuli avatar mastergroosha avatar naevtamarkus avatar timbest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emoji-picker's Issues

Why render emoji as images at all?

Maybe I'm a noob but I don't understand why you chose to render the emojis in the picker via an image rather than rendering as unicode. Browsers support rendering emojis as unicode. Unless you want to force a specific emoji image set (eg. google, twitter, or apple) requiring the user to download a spritesheet seems to me like a waste of bandwidth. Am I misunderstanding something with how emojis work?

Add package.json

Can we please add package.json to this project and version tags so cdnjs can host it.

#2
#3

How to save emoji in mysql and retrieve them perfect ?

I am saving unicode of emoji in db. It worked but when I retrieve, it did not work as expected. I can decode from unicode to emoji, it showed normal black and white emojis. I need the emoji image from spritesheet. Any help ?

Conflict with ckeditor

Hi! I've tried to use your plugin on my website. But on the same form that I wanna to use emoji, it has also a field with ckeditor set and the field that I want to use now get the settings with ckeditor enabled from the other field. How to avoid this conflict?

Thanks

RogΓ©rio

Restricing single line input fields to one line

How do you keep the single input fields to stay on one line? It seems that you can break return and have multiline even though it's a single line input field. Makes sense for textareas, but should not happen for single line input fields.

There is overlap when enable emoji-picker in textarea.

I try to use this emoji-picker on my web application, it works well exception this issue:
Text and pictures have overlap when enable emoji-picker in textarea, it works well under Safari but met problem on Chrome(on Mac).

Safari
snip20160513_5

Chrome
snip20160513_4

Is there any way to retrieve "alt" value on submit form

Hi

I am using emoji-picker in my app. when we click on any emoji.
it render following html in text area.

<img src="/assets/emoji//blank.gif" class="img" style="display:inline-block;width:25px;height:25px;background:url('/assets/emoji//emoji_spritesheet_0.png') -75px 0px no-repeat;background-size:675px 175px;" alt=":blush:">

when i submit the form i want to receive values as ": blush :" rather than "symbol "

is thr any way to do that?

Thanks

How to reset the input?

I'm using sockets to send messages. On form submit I clear the text area. How do I update the emoji div?

I also change the placeholder text depending on certain selections in the form I'd like to force update that for the content.

Emoji menu not visible for mobile screen

For small screen, only 1st column is visible.
In demo page horizontal scroll appear in body to show other rows. But for responsive site, horizontal scroll is disabled so we can't visible other columns.

Can you please look at this issue?

Regards,
Arpan

emoji-mobile-issue

emoji-menu transform change when scroll (tetherjs modified?)

  1. Before scroll
    .emoji-menu
    transform: translateX(993px) translateY(194px) translateZ(0px);
  2. After scroll
    transform: translateX(880px) translateY(194px) translateZ(0px);

Expect

this.tether = new Tether({
element: '[data-id="' + this.id + '"][data-type="menu"]',
target: '[data-id="' + this.id + '"][data-type="picker"]',
attachment: 'bottom center',
targetAttachment: 'top center',
offset: '230px 110px', --------> could change offset and make sense
constraints: [
{
to: 'html',
pin: true
}
]
});

Convert input values

hello!haw can i display like emoji icons value (f.e. smile) from inputs?
i try to $('#inputId').emojiarea({wysiwyg: true}); but i have an arror
Cannot read property 'unicodeToImage' of undefined

Emoji Picker Icon Not Showing

Looks like it's taking over my input box correctly, however, the actual emoji picker icon isn't showing. I have font-awesome correctly inserted into my tag.

Here is what the tag looks like
<i class="emoji-picker-icon emoji-picker undefined" data-id="b7aa839f-a6fa-4354-8a33-cfcadf8cba1a" data-type="picker"></i>

Get Unicode Values

This is kind of along the line of #5, I want to grab the unicode value of whatever emoji I'm using. I'm submitting form via ajax and updating the view with that content and need to get the actual emoji instead of just the black/white sketch img. Thanks!

jQuery on('keyup') didn't working

After using data-emoji-input="unicode" data-emojiable="true" all keyup binding data stop to working. Just working with change event.

Input design changed

The whole design of the input is changed, e.g. its now on top insteat on bottom. You know why?
So i'm opening a new window and in that input it doesnt work, i think he doesnt get the classes. But in the ones on the other window is work

Pressing the enter key in text input that has data-emojiable="true" does not trigger ng-click event bound to button

Anyone else having this problem? See code below. I'd expect that when you type text into the input and press the enter key it should trigger the ng-click event. It does so when when I remove the data-emojiable="true" from the input field...

<form name="chatMessage"> <div class="input-group"> <span class="input-group-btn"> <button class="btn btn-default" type="button" ngf-select="vm.upload($file)">+</button> </span> <input type="text" class="form-control" ng-model="vm.chatMessage" data-emojiable="true"> <span class="input-group-btn"> <button id="send-message-button" type="submit" class="btn btn-default" ng-click="vm.sendChatMessage()">Send </button> </span> </div> </form>

The skintone of the emoji is not respected

Hi,
I was implementing this plugin in my project and I noticed that when I select ': point - right' or ':muscle' emoji (or any emoji containing hand i.e; punch ,finger etc) the skintone changes in my div..any fix for this.

PS: this is happening when you put data-emoji-input="unicode" not in case of img (which is obvious)

Emojis popup position

Is there a way to open the popup of emojis in another position, look at my image I am not able to see the emojis when the popup is opened near the bottom of the page.

emojiarea

TextArea height not getting set

If we apply this to TextArea element the height of resultant DIV is not adjusted as per the TextArea rows. To achieve this I added the following line of code..

jquery.emojipicker.js

--look for this block --

if ($textarea.attr('maxlength')) {
      this.$editor.attr('maxlength', $textarea.attr('maxlength'));
    }

    var unicodeToImageText = this.emojiPopup.unicodeToImage($textarea.val());
        this.$editor.html(unicodeToImageText);
        this.$editor.attr({
            'data-id': id,
            'data-type': 'input',
            'placeholder': $textarea.attr('placeholder'),
            'contenteditable': 'true',
        });


--REPLACE with this block---


if ($textarea.attr('maxlength')) {
      this.$editor.attr('maxlength', $textarea.attr('maxlength'));
    }

        this.$editor.height($textarea.outerHeight()); //auto adjust height

    var unicodeToImageText = this.emojiPopup.unicodeToImage($textarea.val());
        this.$editor.html(unicodeToImageText);
        this.$editor.attr({
            'data-id': id,
            'data-type': 'input',
            'placeholder': $textarea.attr('placeholder'),
            'contenteditable': 'true',
        });

Does not show in Iphone Safair

First thank you for this nice work. I know it is a lot of effort.
So I did all steps you showed and its not appearing on iphones. It works on PC and Android though. Here are some minor bugs. On small screens the emoji drawer could be out of the screen. On android it sometimes flies to the left.

Text copied from MS Word gets mangled- some words get joined.

On copying text from a MS Word document to an emoji-picker field, some spaces get removed leading to concatenated words. This happens on the demo page as well. For example:
"This term X was coined in 1920 by the 9 year old nephew of American mathematician Edward Kasner."
became: "This term X was coinedin 1920 by the 9 year old nephew of American mathematician Edward Kasner."
It looks like the library is taking text and adding \n newline characters at certain places and then later doing a string join on newline while eliminating the spaces in between words.
newlinedatacausingissue
I was able to handle this by doing a one-line change.

Emoji

Help Me.. i am using this one signal/emojipicker in my php (laravel) project.
but when i copy that msg containing emoji that time it give shortname but i want unicode emoji character rather than short name...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.