ngEmbed
An AngularJS filter/directive for converting text into emoticons, embedding videos (youtube/vimeo/mp4,ogg), audio, pdf, highlighting code syntax and embedding almost every service in an ordinary text string .
The demo examples are given here
PS : The jquery version of this module is embed-js.
Contents
- Features
- Dependencies
- Installation
- CDN
- Getting Started
- Filter Usage
- Directive Usage
- Default Template
- Template Variables
- Releases
- Contributing
Features
- Converts emoticon text codes into emoticons 😄 , ❤️
- Finds links in text input and turns them into html links.
- Youtube and Vimeo video embedding with video details fetched from the api.
- HTML5 player supported media embedding (mp3,mp4,ogg)
- PDF viewing with preview and then the actual pdf in a frame.
- Inline Code Syntax highlighting (uses highlight.js)
- Twitter tweet embedding supported
- CodePen, jsBin, jsFiddle, Ideone, plunker and Github gist embed supported
- Soundcloud and Spotify support
- Twitch TV, dotSub, Dailymotion, TED, LiveLeak and UStream support.
Dependencies
- AngularJs 1.2 or above
- angular-sanitize 1.2 or above
- highlight.js (Optional if code highlighting required)
- Twitter widget js (if twitter embedding required)
Installation
Install through bower
bower install --save ng-embed
Install through npm
npm install --save ng-embed
CDN
Getting Started
Load [ng-embed.min.css] stylesheet file
Then load [angular.min.js] and [angular-sanitize.min.js] dependencies before loading [ng-embed.min.js]
<!--==== Optional =====--><!--===================-->
Load 'ngEmbed' as a dependency
angular
Filter Use
You can use the filter for basic use. Its features are limited to converting text into emojis, font smileys and HTML Links.
or with custom options
Options
Defaults:
var embed = fontSmiley :true // toggle converting ascii smileys into font smileys sanitizeHtml: true // toggle converting html code into text emoji :true // toggle converting emojis short names into images link :true // toggle converting urls into anchor tags linkTarget :'_self' //_blank|_self|_parent|_top|framename|cordova
Directive Usage
The directive supports many features in additions to the features supported by the filter and is fully customizable.
Directive
Attribute | Description |
---|---|
embed-data | The scope variable that contains the text string to be processed |
embed-options | The scope variable that contains the options object (mandatory) |
embed-template-url | User defined template for the processed text |
Options
angular ;
Default Template
<!--====== Main text with emoticons and link ============--> <!--==========Video Embedding code (Youtube and vimeo)============--> {{video.title}} {{video.description}} {{video.views}} {{video.likes}} <!--=====video player for mp4 and other html5 player supported videos==--> <!--====== image preview code (gif|jpg|jpeg|tiff|png|svg|webp) =======--> {{pdf.url}} Download View PDF <!--====== pdf viewer =========--> <!--===== audio player ===========-->
Change the styling of the default template by styling the classes or provide a custom template. The default template is provided as an example.
There are certain variables that are available for the template. Its structure is given below.
Template Variables
These variable can be used while you are creating your custom template.
var video= host :String // youtube/vimeo title :String // Title of the video thumbnail :String // Url of the video thumbnail description :String // Description of the video truncating after 250 characters replacing linebreak (especially for vimeo) rawDescription :String // Description of the video as sent by the server views :Number // Number of video views likes :Number // No. of likes uploader :String // username of video uploader uploaderPage :String // url of uploader's page uploadDate :Date // Date of video upload url :String // video url embedSrc :String // video embed url width :Number height :Number // dimensions of the embedded video var image =url:String var audio =url:String var pdf =url:String var codeServices :Array // array of embed code of links of jsbin, jsfiddle, ideone and codepen var audioServices :Array //array of embed code of spotify and soundcloud var videoServices :Array // Array of embed code of dailymotion, ted, liveleak, dotsub and twitch tv var gist :Array // Array of all gist ids.
Examples
The examples are given here
Releases
Older releases are listed in RELEASES.md
Contributing
- If you are interested in contributing to this project, you are most welcome.
- Start by filing an issue concerning whatever you’d like to see changed.
- In case of larger changes, get the issue allotted
- In case of bugfixes or very minor additions, feel free to file a pull request on the master # branch.
- Please run the default grunt-task before filing any pull requests.
License
ngEmbed © 2014-2017+ Ritesh Kumar.
Released under the [MIT] License.
Authored and maintained by Ritesh Kumar with help from contributors.