Giter Club home page Giter Club logo

emojionearea's Introduction

Stand With Ukraine

EmojioneArea

EmojioneArea is a small jQuery plugin that allows you to transform any html element into simple WYSIWYG editor with ability to use Emojione icons.
The end result is a secure text/plain in which the image icons will be replaced with their Unicode analogues.

Preview version 3.x

EmojioneArea version 3.0.0

See the Live Demo here

Version 2.1.x

Installation

The preferred way to install is via bower, npm or composer.

bower install emojionearea#^3.0.0
# or
npm install emojionearea@^3.0.0
# or
composer require mervick/emojionearea ^3.0.0

Usage

Add the following lines to the head:

<link rel="stylesheet" href="file/to/path/css/emojionearea.min.css">
<script type="text/javascript" src="file/to/path/js/emojionearea.min.js"></script>

Simple usage:

<textarea id="example1"></textarea>
<script type="text/javascript">
  $(document).ready(function() {
    $("#example1").emojioneArea();
  });
</script>

EmojioneArea uses awesome Emojione emojis.
So when emojionearea.js loads, it's require to emojione.js loaded too, but if it not loaded in the page then EmojioneArea loads it from CDN.
For avoiding this behavior you can add emojione.js and emojione.css into your page.

Customize emojione version

By changing value below you can change emojione version which will be loaded from CDN

window.emojioneVersion = "3.1.2";

Options

standalone

Standalone mode

type: boolean
default: false

Example:

$(".emojionearea").emojioneArea({
    standalone: true
});

Preview:

EmojiOneArea - Standalone mode

emojiPlaceholder

The placeholder (default emoji) of the button in the standalone mode.
Works only with standalone mode

type: string
default: ':smiley:'
accepts values: [any emojione shortname]

Example:

$(".emojionearea").emojioneArea({
    emojiPlaceholder: ":smile_cat:"
});

placeholder

The placeholder of the editor

type: string
default: [uses placeholder attribute from the source input]

Example:

$(".emojionearea").emojioneArea({
    placeholder: "Type something here"
});

search

Whether is enabled search emojis in the picker

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    search: false
});

searchPlaceholder

The search placeholder

type: string
default: 'SEARCH'

Example:

$(".emojionearea").emojioneArea({
    searchPlaceholder: "Search"
});

useInternalCDN

Whether to use the loading mechanism to load EmojiOne from CDN

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    useInternalCDN: true
});

buttonTitle

The title of the emoji button (hint on the hover)

type: string
default: "Use the TAB key to insert emoji faster"

Example:

$(".emojionearea").emojioneArea({
    buttonTitle: "Use the TAB key to insert emoji faster"
});

recentEmojis

Whether to show recently selected emojis in the picker

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    recentEmojis: false
});

pickerPosition

The position of the emojis picker in the relation to the editor

type: string
default: 'top'
accepts values: 'top' | 'right' | 'bottom'

Example:

$(".emojionearea").emojioneArea({
    pickerPosition: "bottom"
});

filtersPosition

The position of the filters header in the emojis picker

type: string
default: 'top'
accepts values: 'top' | 'bottom'

Example:

$(".emojionearea").emojioneArea({
    filtersPosition: "bottom"
});

EmojiOneArea - searchPosition bottom

searchPosition

The search panel position if search option enabled

type string
default: top
accepts: 'top' | 'bottom'

Example:

$(".emojionearea").emojioneArea({
    searchPosition: "bottom"
});

EmojiOneArea - searchPosition bottom

hidePickerOnBlur

Whether to hide picker when blur event triggers

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    hidePickerOnBlur: false
});

container

The container of the plugin.

By default, emojionearea container created directly under the source.
In this option you can specify custom jQuery|selector container.

type: jQuery|selector
default: null

Examples:

<input type="text" id="emojionearea1" />
<input type="text" id="emojionearea2" />
<!-- ... -->
<div id="container1"></div> <!-- #emojionearea2 plugin will use this container -->
<div id="container2"></div> <!-- #emojionearea1 plugin will use this container -->
<script>
    $("#emojionearea1").emojioneArea({
        container: "#container2" // by selector
    });
    $("#emojionearea2").emojioneArea({
        container: $("#container1") // by jQuery object
    });
</script>

tones

Whether to show the skin tone buttons in the emoji picker

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    tones: false
});

tonesStyle

The style of the skin tones selector

type: string
default: 'bullet'
accepts values: 'bullet' | 'radio' | 'square' | 'checkbox'

Example:

$(".emojionearea").emojioneArea({
    tonesStyle: 'checkbox'
});

shortnames

By default EmojioneArea parses only utf8 emojis (e.g. πŸ˜€πŸ˜ŠπŸ˜πŸ€‘πŸ˜œπŸ€“) from the value of the input source.
This option enables to parse also the shortnames (e.g. :smile:, :smiley:, :cat:, etc).
Also affects the work of the method setText().

Note. Affects only to how it parse emojis.
To change how it saves emojis use saveEmojisAs option (see below).

type: boolean
default: false

Example:

$(".emojionearea").emojioneArea({
    shortnames: true
});

saveEmojisAs

The processor type of the how emojionearea saves icons to the source, also affects on the method getText()

type: string
default: 'unicode'
accepts values: 'unicode' | 'shortname' | 'image'

  • unicode - saves emojis as utf8 text (e.g. πŸ˜€πŸ˜ŠπŸ˜πŸ€‘πŸ˜œπŸ€“);
  • shortname - save emojis as shortnames (e.g. :smile:, :smiley:, :cat:, etc);
  • image - save emojis as html images, example:
<img alt="πŸ˜€" class="emojioneemoji" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/1f600.png">

hideSource

Whether to hide source input after render the plugin

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    hideSource: false
});

inline

Inline mode
Whether to use plugin editor as inline input

type: boolean|null
default: null
accepts values: null | true | false

  • null - auto detect, if input is textarea then false, when it is input[type=text] then true

Example:

$(".emojionearea").emojioneArea({
    inline: true
});

Preview:

EmojioneArea - inline mode

shortcuts

Whether to attach shortcuts events

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    shortcuts: false
});

autocomplete

Whether to add the emojis short names autocomplete functional

type: boolean
default: true

Example:

$(".emojionearea").emojioneArea({
    autocomplete: false
});

autocompleteTones

Whether to show skin emojis in the autocomplete dropdown

type: boolean
default: false

Example:

$(".emojionearea").emojioneArea({
    autocompleteTones: true
});

textcomplete

The settings of the autocomplete dropdown

type: object
default:

{
    maxCount  : 15,
    placement : null
}

where

  • maxCount - max count of items in the dropdown
  • placement - the placement of the dropdown (null | "top" | "absleft" | "absright")

Example:

$(".emojionearea").emojioneArea({
    textcomplete: {
        maxCount  : 20,
        placement : 'absleft'
    }
});

attributes

The html attributes of the editor (contenteditable) of the plugin

type: object
default:

{
    dir            : "ltr",
    spellcheck     : false,
    autocomplete   : "off",
    autocorrect    : "off",
    autocapitalize : "off",
}

where

Example:

$(".emojionearea").emojioneArea({
    attributes: {
        spellcheck : true,
        autocomplete   : "on",
    }
});

filters

The filters (tabs) in the emojis picker

type: object
default: [the full default filters you can find here here]

{
    tones: { // this tab is hidden, and used for list tones emojis
        title: "Diversity",
        emoji: "[...]", // list of the emojis, see source code
    },
    recent: {
        icon: "clock3",
        title: "Recent",
    },
    smileys_people: {
        icon: "yum",
        title: "Smileys & People",
        emoji: "[...]", // list of the emojis, see source code
    },
    animals_nature: {
        icon: "hamster",
        title: "Animals & Nature",
        emoji: "[...]", // list of the emojis, see source code
    },
    food_drink: {
        icon: "pizza",
        title: "Food & Drink",
        emoji: "[...]", // list of the emojis, see source code
    },
    activity: {
        icon: "basketball",
        title: "Activity",
        emoji: "[...]", // list of the emojis, see source code
    },
    travel_places: {
        icon: "rocket",
        title: "Travel & Places",
        emoji: "[...]", // list of the emojis, see source code
    },
    objects: {
        icon: "bulb",
        title: "Objects",
        emoji: "[...]", // list of the emojis, see source code
    },
    symbols: {
        icon: "heartpulse",
        title: "Symbols",
        emoji: "[...]", // list of the emojis, see source code
    },
    flags: {
        icon: "flag_gb",
        title: "Flags",
        emoji: "[...]", // list of the emojis, see source code
    },
}

Example:

$(".emojionearea").emojioneArea({
    filters: {
        recent : false, // disable recent
        smileys_people: {
            icon: 'cat' // change smileys_people filter icon to "cat"
        },
        animals_nature: {
            title: 'Animals' // change animals_nature filter title to "Animals"
        },
        food_drink: {
            emoji: "smiley smile cat" // change emojis of the filter food_drink
        },
        objects: false, // disable objects filter
        symbols: false, // disable symbols filter
        flags : false // disable flags filter
    }
});

Methods

List of methods

.on(events, handler)

Attach handler for event(s)

  • param events
    Type: String
    One or more space-separated event types

  • param handler
    Type: Function(jQuery Element, Event eventObject [, any extraParameter ] [, ...])
    A function to execute when the event is triggered

  • returns EmojioneArea instance

.off(events[, handler])

Remove previously attached handler (if handler is specified) or all handlers of specified event(s)

  • param events
    Type: String One or more space-separated event types

  • param handler [optional]
    Type: Function(jQuery Element, Event eventObject [, any extraParameter ] [, ... ])
    A handler function previously attached for the event(s) by .on method

  • returns EmojioneArea instance

.trigger(events[, ... ])

Trigger event(s)

  • param events
    Type: String
    One or more space-separated event types

  • params [, ...] [optional]
    Type: any Extra parameters

  • returns Boolean the result of all called handlers

.setText(str)

Set emojionearea text

  • param str Type: String
    Set text

  • returns EmojioneArea instance

.getText()

Get text of emojionearea, there is no any html, just vanilla text

  • returns String

.showPicker()

Show picker area

  • returns EmojioneArea instance

.hidePicker()

Hide picker area

  • returns EmojioneArea instance

.enable()

Enable emojionearea input area

  • returns EmojioneArea instance

.disable()

Disable emojionearea input area

  • returns EmojioneArea instance

.setFocus()

Focus on emojionearea input area

  • returns EmojioneArea instance

Methods Usage

How to use methods, example:

  var el = $("selector").emojioneArea();
  el[0].emojioneArea.on("emojibtn.click", function(btn, event) {
    console.log(btn.html());
  });
  
  // OR
  $("selector2").emojioneArea();
  $("selector2")[0].emojioneArea.getText();
  
  // OR
  $("selector3").emojioneArea();
  $("selector3").data("emojioneArea").showPicker();

Events

List of built-in events:

ready or onLoad

triggers when emojionearea is initialized
Handler type: Function (no params)

click

triggers when user clicks on emojionearea input or picker
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

mousedown

triggers on mousedown of emojionearea input or picker
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

mouseup

triggers on mouseup of emojionearea input or picker
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

keyup

triggers on keyup of emojionearea input or picker
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

keypress

triggers on keypress of emojionearea input or picker
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

focus

triggers on focus of emojionearea input
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

blur

triggers on blur of emojionearea input
Handler type: Function (editor: jQuery, event: Event)

  • param {jQuery} editor - EmojioneArea input
  • param {Event} event - jQuery Event object

paste

triggers when user has pasted content to input area
Handler type: Function (editor: jQuery, text: String, html: String)

  • param {jQuery} editor - EmojioneArea input
  • param {String} text - pasted vanilla text
  • param {String} html - pasted html content

resize

triggers when input area has resized
Handler type: Function (no params)

change

triggers when input area has changed
Handler type: Function (no params)

emojibtn.click

triggers when user clicks on emoji button at the picker area
Handler type: Function (emojibtn: jQuery)

  • param {jQuery} emojibtn - emoji button that user has clicked

button.click

triggers when user clicks on show/hide button
Handler type: Function (button: jQuery)

  • param {jQuery} button - show/hide button

tone.click

triggers when user clicks on tone filter button
Handler type: Function (button: jQuery)

  • param {jQuery} button - tone button that user has clicked

picker.show

triggers on show picker
Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.hide

triggers when picker has been hidden
Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.mousedown

triggers on mousedown of emojionearea picker area Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.mouseup

triggers on mouseup of emojionearea picker area Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.click

triggers on click of emojionearea picker area Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.keydown

triggers on keydown of emojionearea picker area Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

picker.keypress

triggers on keypress of emojionearea picker area Handler type: Function (picker: jQuery)

  • param {jQuery} picker - picker area

search.focus

triggers on focus of picker search area
Handler type: Function (no params)

search.keypress

triggers when user press key on picker search area
Handler type: Function (no params)

Events Usage

There are 2 ways to set events, directly in options via options events.
Note: For events with . (dot) you can set event name with _(dash) instead of . (dot) here.

Example, set events in the options:

$("selector").emojioneArea({
  events: {
    paste: function (editor, event) {
      console.log('event:paste');
    },
    change: function (editor, event) {
      console.log('event:change');
    },
    emojibtn_click: function (button, event) {
      console.log('event:emojibtn.click, emoji=' + button.children().data("name"));
    }
  }
});

Also you can manage events via .on(), .off() and .trigger() methods

Example:

  var el = $("selector").emojioneArea();

  // attach event handler
  el[0].emojioneArea.on("emojibtn.click", function(button, event) {
    console.log('event:emojibtn.click, emoji=' + button.children().data("name"));
  });
  // unset all handlers attached to event
  el[0].emojioneArea.off("emojibtn.click");

  // like in jQuery you can specify few events separated by space
  el[0].emojioneArea.off("focus blur");

  // set & unset custom handler
  var eventHandler1 = function(button, event) {
    console.log('event1');
  };
  var eventHandler2 = function(button, event) {
    console.log('event2');
  };
  // attach event handlers
  el[0].emojioneArea.on("click", eventHandler1);
  el[0].emojioneArea.on("click", eventHandler2);
  // unset eventHandler1
  el[0].emojioneArea.off("click", eventHandler1);

Building

Building EmojiOneArea requires grunt, compass, and sass to be available

For making changes and build project (scss/js):

npm update
npm run build

PRs welcome!!!

FAQ / Troubleshooting

EmojiOne icons are appearing larger than expected

Most likely caused by including some scripts in the wrong order (or perhaps not at all!) Include jQuery, then EmojiOne, then EmojiOneArea scripts

Can I use EmojiOneArea to just display Emoji icons in a div?

EmojiOneArea is intended to be a text editor which supports EmojiOne. If you just want to display Emoji icons, the EmojiOne library already provides everything you need.

Can I add extra buttons into EmojiOneArea, alongside the existing emoji picker icon?

This is not fully supported, but you could respond to the jQuery onLoad event which EmojiOneArea fires once its initialised, and insert your buttons into the DOM at this point see #152

Firefox is not positioning the input caret correctly in EmojiOneArea

This appears to be a long standing FireFox bug, apparently related to contenteditable, the placeholder attribute, and the pseudo :before or :after classes https://bugzilla.mozilla.org/show_bug.cgi?id=1020973

There are various workarounds such as changing placeholder, or adding some padding See #86

Can I modify the position of EmojiOneArea picker?

You can use the pickerPosition option which provides basic control of where the picker appears, in relation to the source input. For more control, you could apply translate CSS to the picker

Known Issues

Internet Explorer focus issues

IE 11 causes EmojiOneArea to hide (and trigger blur event) when the emoji picker scrollbar is clicked There is no current fix for this, although there are a few crude workarounds See #127

EmojiOneArea positioning

There are known issues with positioning the EmojiOneArea picker. It does not currently ensure the picker is entirely visible on small screen devices, or positioned properly when it is invoked from the bottom of a page (it could be clipped) See #131

Browser loads the textcomplete.js from CDN, everytime an EmojiOneArea is instantiated

You can avoid this by explicitly including the textcomplete script into your document. If it already exists, EmojiOneArea will use the preloaded script instead of attempting to load it from CDN for each instance You can also avoid this by disabling autocomplete entirely by setting the autocomplete option to false

Requirements

License

EmojiOneArea is released under the MIT license.

emojionearea's People

Contributors

allanbrault avatar carpii avatar elomarns avatar got2be avatar invader444 avatar klasjersevi avatar ksullivan avatar lacerdev avatar merlinmason avatar mervick avatar ohenepee avatar pederjohnsen avatar vasiliy-bondarenko 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

emojionearea's Issues

Editable on edit button click

Hi,
I'm using the latest version of Emojionearea and think its fantastic. How can i use this to display a comment without it being editable (or showing the emoji bar) but on the click of an edit button, enable emojione area for the comment?
Thanks!

getText(): one character short

It appears that there is one character short of the text in content editable component when getText() is invoked.

I simply attached the events config below into the fiddle at https://jsfiddle.net/glui2001/ukLaz8cm/

events: {
         keypress: function (editor, event) {
           console.log(editor.html());
           console.log(this.getText());
         }
}

Autocomplete emoji

Hi,
First of all, congratulations for this awesome plugin, keep up good work.
I would like to integrate this example: http://git.emojione.com/demos/2.1.2/autocomplete.html
but doesn't work..
I would like to allow users to use also autocomplete.
I hope that you can show an example.
Autocomplete is great, but most important is to autoconvert shortcodes ( for example ❀️ ) to correct images. At the moment if you add icon via mobile, this seem not converted.
Thanks!

Mobile devices: Prevent keyboard

Would it be possible for you to prevent the keyboard (on mobile devices) from opening up while clicking among the emojis? Perhaps an option? Would really appreciate it!

Function submit / return

Hello Andrey,

nice work can you help me?
I need submit a feature to the content with the return key.
This can make an impression here is a demo:
http: // demo.like-friends.de

I would like to include in the comments, they will be sent with return.

Thanks for help
Regards, Frank

Almost perfect! Handle to instance object

Hi,

Great job on the component. I really like what you did allowing some much flexibility and configurability.

That being said I wondered if there was a way to get a handle on an instance of the emojionearea object?

For example, can it return a handle to something that I can call methods on? I can call these methods in the event handlers, but I want to access these methods outside of that

var handle = $('.selector).emojioneArea();
handle.setText();

Support for ASCII emojies

The default emojione supports for ASCII emojies like :) :( etc.

Can the emojionearea provide the same support?

SVG icons using sprites

How to switch to SVG from PNG icons ?
I tried :
emojione.imageType = 'svg'; emojione.sprites = true; emojione.imagePathSVGSprites = './../assets/sprites/emojione.sprites.svg';

but it not work

Emojis are not presented correctly when published

Hi!

First and foremost I want to thank you for this great emoji picker plugin. You're doing a great job!

I'm having trouble with emojis being presented the wrong way when published. In the editor they look fine but when I publish the message there is another emoji (the old lady) behind each and every emoji.

image

On focus on textarea close filters and tabs

hi,
I use autoHideFilters and I would like that on focus textarea the filters and tabs is closed.
I suppose to use event on focus, but not sure how to hide them.

            events: {

                focus: function (editor, event) {
                  // Hide filters and tabs
                }
            }

Get Html Content and reset Emoji textarea

Hello.

I want to get HTML content wen i submit my form for example :

var emojiElt = $("#com_texte").emojioneArea({autocomplete: false});

$('#commentForm').on('submit', function (e) {
    e.preventDefault();
    $.ajax({
        type        : "POST",
        url         : $(this).attr("action"),
        data        : $(this).serialize(),
        beforeSend  : function () {
            $("#com_texte").val(emojiElt.getHtml()); // <-- HERE
        },
        dataType    : 'json'
    }).done(function (jsonResponse) {

        // Success code

    }).always(function () {
        // Reset myForm
        document.getElementById("commentForm").reset();

        // Reset Emoji field
        emojiElt.reset(); // <-- HERE


    }).fail(function () {
        alert("Une erreur s'est produite. Le commentaire n'est malheureusement pas pris en compte.");
    });

});

In the beforeSend i want to get HTML from the editor.

I found this way to get the HTML but it don't seems to be the best solution :

var emojiElt = $("#com_texte").emojioneArea({
    autocomplete: false,
    events: {
        keyup: function (editor, event) {
            $("#com_texte").val(editor.html());
        }
    }
});

And after success i want to reset the field.

Thank's for yout help :)

shortnames not working... v.3

Hi,
Thanks for this wanderful time saver!

I have a problem with the shortname option in "emojionearea": "^3.0.0",

This is my code:

$(this.$els.responder).emojioneArea({ <-- the textarea replaced, has value with unicode and not shortnames...
            pickerPosition: "top",
            filtersPosition: "bottom",
            tones: false,
            autocomplete: true,
            shortnames: true,
            events: {
                keyup: function (editor, event) { 
                    console.log (this.getText()) <--- this is printing with unicode.
                  //hide the picker/selector if you click on the textarea
                  // $(".emojionearea-picker").addClass("hidden");
                  // $(".emojionearea-button").removeClass("active");
                  if (event.keyCode === 13) {
                    if (self.messageToSend.length) {
                        // self.messageToSend = emojione.toShort(text);
                        var sts = self.sendMessage();
                    }
                    if (sts) this.setText('');
                  }
                },
                paste: function (editor, event) {
                    console.log('event:paste');
                    var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
                    window.document.execCommand('insertText', false, text);
                }
           }
        });

Thank you!

Show emoji inside html paragraph

The plugin is working great when attached to textbox.
However when I try to show the previous saved content in a paragraph, not all icons are showing.

Do you know what's the issue?

image

Refresh method

Is there a way to get the plugin to refresh and get the new value of the textarea ?

[BUG] Keypress, keydown events bug

Hi,

I'm having a problem getting real-time data from the "editor" parameter. For example, here's an outline of my code...

$("#commentsTextArea").emojioneArea({
  tones: false,
  autocomplete: false,
  hidePickerOnBlur: true
  ,   events: {
          mousedown: function (editor, event) { 
            //hide the picker/selector if you click on the textarea
            $(".emojionearea-picker").addClass("hidden");
            $(".emojionearea-button").removeClass("active");
          }, 
          keydown: function (editor, event) {
              console.log("reviewing text: " + editor.text());                                  
              //do some stuff with editor.text()
          }
      }

});

Every time I press a key on my emojionearea it correctly fires a keydown event. But the parameter "editor" is always one cycle out of synch - for example, the console.log statement above works like this...

  1. I type "h" in emojionearea and it prints "reviewing text: "
  2. I type "e" in emojionearea and it prints "reviewing text: h"
  3. I type "l" in emojionearea and it prints "reviewing text: he"
  4. I type "l" in emojionearea and it prints "reviewing text: hel"
  5. I type "o" in emojionearea and it prints "reviewing text: hell"
  6. I type backspace in emojionearea and it prints "reviewing text: hello"

So it's only the previous data that I'm able to use. Any ideas on a suitable way around this? Thanks!

Daniel

event cannot bind to the textarea in angular2

I use emojionearea in an angular2 project, and my textarea has an (keyup) event. But when I bind the emojionearea to the textarea, the event could not be called. I do not know how to solve this problem.

My textarea element likes this:
<textarea id="emoji-dialog" class="form-control" rows="5" [(ngModel)]="textContent" (keyup)="myKeyup(p)" (keydown)="myKeyup(p)" (change)="myKeyup(p)" #p></textarea>

And, the myKeyup() function likes this:
myKeyup(p){ this.numerator = this.textContent.length; if(this.textContent.length>this.denominator){ this.textContent = this.textContent.substring(0,300); this.numerator = this.textContent.length; }else{ this.flag = 0; } }

Looking forward to your response, thanks !

typing after emoji in Chrome

I can not type any letters after single emoji in the area if emoji is a last symbol in the text.

confirmed here: https://jsfiddle.net/1v03Lqnu/12/
i try to type in the firest textarea with "Default πŸ˜„" - i CAN type in the middle of the string, but can not type AFTER emoji.
screen with details: http://joxi.ru/Q2KnMRes9nnQJm
if i add one more emoji - i can type again :) http://joxi.ru/zAN0lnehlQQn3m
even if i add emoji somewhere else - still can type: http://joxi.ru/BA0dDL6SBGGYLA

Use Sprite instead of individual png files

Hi!

I want to know, how can i use an sprite instead of individual png files.

I already tried to use
"useSprite : true"
and
"emojione.sprites : true"

but seems not working.

Yes... i already included the emojione.sprites.css file in my project .. not working;

clear textarea

Hello, I want to clear emojionearea textarea. How can i do it? Thankyou!

Cannot make it work

Hi!

I'm having some problems with my node.js app.
I'm using Socket.io and Express along with other plugins. Every time I load the page where the input I want to transform is I get this error:
Uncaught TypeError: Cannot read property 'indexOf' of undefined emojione.js:367
And looking into the trace there are a lot of calls to emojionearea.js

Any ideas?

Thank you! :)

Compatibility with others WYSIWYG editors.

Is there an easy way to add compatibility with the editors? I have already editors like jHtmlArea and TinyMCE , i just need the Icons Picker and the autocomplete functions. Do you know how can i achieve this?

Size issue with TEXTAREA

Is the emoji editor a fixed size [height]?
I added ROWS to TEXTAREA, and the emoji editor doesnt resize accordingly [in height].

BUG Options sprite vs useSprite

The homepage docs and the demo HTML use useSprite: false in the options, but this does not work you need to use sprite: false as shown in the actual lib code.

Lazy load emojis

How to make the most fast download for images?
I hoped to use SVG-sprites with gzip-compression, but seems like it's not possible any more...

Pasting not working

I don't have a particular Use Case for this, but sometimes when my application starts something goes wrong with the editor. Typing and adding of emojis works, but pasting is not working at all. Even a rightclick on the contenteditable is not showing me the copy/cut menu options. Is it a contenteditable problem or a emojionearea problem? Any ideas?

Emoji is getting added before the contenteditable instead of inside it

Again, a "sometimes" issue i have faced with the tool. Sometimes when a Emoji is added via the selection menu, it is getting added before the contenteditable inside of the container which is created by the tool. I don't know if there is something going wrong inside of the tool and appends the emoji to the wrong container.

image misplaced

getRecent() assumes localStorage

This causes an error on browsers that don't support local storage...

define([], function() {
   return function () {
        return localStorage.getItem("recent_emojis") || "";
    }
});

I think the following should work but haven't had time to test

define([], function() {
   return function () {
        return (window.localStorage) ? localStorage.getItem("recent_emojis") : "";
    }
});

Can make a PR later if you want?

Set emojione version in parameteres

How about doing emojioneVersion configurable on init?

Currently it's hardcoded in emojionearea/js/emojionearea.js@56:

var emojioneVersion = '1.5.2';

I downgraded from 2.0.1 to 1.5.2 in order to have a consistent look between all the icons, but it would be cool to use any emojione version, even if, at the moment, the newer icons on the sprite are still not supported.

Loading display-only emojis

I have no problem using emojionearea to create emoji inputs on textareas like this...

$("#commentsTextArea").emojioneArea({
tones: false,
autocomplete: false,
hidePickerOnBlur: true
});

But then when I take this input and save the comment to the database and display the result in a normal text element on the page, of course it's up to the browser to try and find a suitable emoji (sometimes they find one but it always looks different).

So I need a way to apply emojionearea to my display-only elements without adding the option to choose new emojis. Hopefully that makes sense but so far I've found no parameters that would enable me to "display as emojionearea" without adding the picker/selector.

Thanks in advance for any hints!

output emoji codes

I am looking for it to output emoji codes πŸ˜„ (:shortcut:) I thought that might have been the short names option but when I set that to true, it still outputs unicode.

Update textarea on keyup

How i can get textarea updated every time i pressed to key, after event keyup.
I using it with angularjs and need to update model every time.

i tried to fix this in source and it works, but how i can do it correctly:

if (options.shortcuts) {
            self.on("@keydown", function(_, e) {
                    //Here i trigger it every time
                    trigger(self, 'change', [editor]);
                    source.trigger("change");
                   ....
            }
}

Can not submit form with event keypress

I cant submit a form when pressing enter in textarea. It only works when I click to somewhere, then click to the textarea and press enter.
My form

<form id="add-msg-form">
        <div class="panel-footer">
            <div class="input-group" style="display: -webkit-box" id="txtbox">
                <textarea id="txtMessage" placeholder="Vui lΓ²ng nhαΊ­p nα»™i dung tin nhαΊ―n" ></textarea>
                <span class="input-group-btn">
                    <button class="btn btn-info" id="btnSend" type="submit">Send</button>
                </span>
           </div>
    </div>
</form>
$(document).ready(function() {
    $("#txtMessage").emojioneArea({
        events: {
            keypress: function (editor, event) {
                if(event.which == 13){
                    console.log('event:keypress'); //work
                        $('#add-msg-form').submit(); //not work
                                        $('#txtMessage').val(''); //not work
                                }
            },
        }
    });
});

[BUG] New lines <br>, <p>, <div> to \n

I have a use case where I'd like to preset the editable content text with a value that contains embedded HTML.

For example, I'd like to call myHandle.setText('<br> -signature');, but have the HTML interpreted as such instead of displayed verbatim.

Submit button issue

Hi,
When I click the submit button, if emojionearea is open then first of all occur event to close emoji, and submit form is not executed. I need to click one second time on submit button.
There is a way to prevent this?
Thanks

If getText() is called for an "paste" event it only returns a space

This returns " ":

       emojioneArea[0].emojioneArea.on('keyup paste emojibtn.click change',
                function () {
                    console.log(emojioneArea[0].emojioneArea.getText());
                });

This returns " text":

  emojioneArea[0].emojioneArea.on('keyup paste emojibtn.click change',
                function () {
                    setTimeout(function() {
                        scope.$apply(function () {
                            console.log(emojioneArea[0].emojioneArea.getText());
                        });
                    }, 300);
                });
  1. Why is there an delay?
  2. Why is there a space?

Parse initial and injected text

Hey, thanks for a great plugin, I have a small feature request!

When initialising the plugin, it would be useful if the existing text was parsed and converted to emoji images.

<textarea>My existing text :smile:</textarea>

In a similar manner, it would also be useful if the setText method parsed input for emojis too.

.setText("My updated text :smile:")

Generated text area doesn't copy data attributes

Generated text area doesn't copy data attributes from original input which in some cases are necessary.

For example: I'm using the data attribute to know to which user the message should arrive. Since the text area doesn't contains it the ajax call throws an error.

disable

Will there be an option to disable ?
if (!emojione || getSupportMode(detectVersion()) < 2) { $.getScript(cdn_base + emojioneVersion + "/lib/js/emojione.min.js", function () { emojione = window.emojione; emojioneVersion = detectVersion(); emojioneSupportMode = getSupportMode(emojioneVersion); cdn_base += emojioneVersion + "/assets"; var sprite = cdn_base +"/sprites/emojione.sprites.css"; if (document.createStyleSheet) { document.createStyleSheet(sprite); } else { $('<link/>', {rel: 'stylesheet', href: sprite}).appendTo('head'); } while (readyCallbacks.length) { readyCallbacks.shift().call(); } }); } else { emojioneVersion = detectVersion(); emojioneSupportMode = getSupportMode(emojioneVersion); cdn_base += emojioneVersion + "/assets"; }
and add path to their own?

EmojioneArea textarea doesn't save to database in HTML

Hello,

It's an awesome work. But I have an issue that need to be fixed fast.
Whatever I try to submit and save the text in textarea using emojionearea to database, it doesn't save properly in HTML and it cause the emoji become '?????????' question marks in database. Also other HTML tags like bold tag and other else also doesn't work.

For note, I use laravel PHP for my development. Do you have any solution? Thanks in advance.

how can i insert html content to the textarea?

is there an api to do this? for example:

now the content of textarea is : πŸ‘ hello
then i want to insert this: to the textarea
after that the content is: πŸ‘ hello [image] to the textarea

the [image] is a real image.

thanks for your good job.

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.