Overview
Angular Smilies module exposes a filter and a directive for smilies parsing (replaced by an image) as well as a directive to display a "smiley picker".
Example
Edit the input and use the left picker and see the changes on the computed output.
Replacement is done in two ways:
:something:
is replaced by the smiley something- Some preconfigured emojis are also replaced, see the full list bellow (case insensitive)
Installation
Dependencies
ngSanitize
In order to use the filters (which outputs HTML) you will need the ngBindHtml
directive which is
part of ngSanitize module.
AngularUI Bootstrap or Angular Strap
The smiley picker uses Bootstrap Popover as Angular module. You can use either AngularUI Bootstrap or Angular Strap.
Includes
The module is available on Bower. Add angular-smilies
to your bower.json
file or
install it manually with bower install angular-smilies --save
.
Include the Javascript files...
... and include the stylesheet as well as Bootstrap's one. The embed version contains the smilies sprite coded in base64 where the normal version relies on an external file. The embed version weighs a little more because of the coding but saves one HTTP request.
Usage
Bootstrap
Add the necessary modules to your app definition.
As filter
The module exposes to smilies
filter useable with the ngBindHtml
directive.
As directive
The module also exposes the smilies
directive with data binding.
Smiley picker
The module includes a smiley selector based on Bootstrap Popover. It allows to display available smilies and append the corresponding code to a model.
Example with Bootstrap forms:
Notice the focusOnChange
directive which allow to focus the input when the content changes.
You can add smiliesKeepOpen
attribute to the selector to not automatically close the Popover when
the user click on a smiley. The Popover is still closeable by clicking again on the selector and anywhere
on the page (AngularUI Bootstrap only).