emoji 表情

js-emoji - Display emoji in the browser, everywhere

Build StatusCoverage Status

Most macOS and iOS versions allow display and input of emoji. It's nice to show them onother devices too, and the browser is a good place to do it. This library converts emoji(either from character codes or colon-sequences like :smile:) into something that willwork on the host computer - either native character codes, a CSS styled span or a textrepresentation.

Installation

Either clone the git repo, or npm install emoji-js

Usage

 
 
<link href="emoji.css" rel="stylesheet" type="text/css" />
<script src="emoji.js" type="text/javascript"></script>
<script type="text/javascript">
 
var emoji = new EmojiConvertor();
 
// replaces \u{1F604} with platform appropriate content
var output1 = emoji.replace_unified(input);
 
// replaces :smile: with platform appropriate content
var output2 = emoji.replace_colons(input);
 
// force text output mode
emoji.text_mode = true;
 
// show the short-name as a `title` attribute for css/img emoji
emoji.include_title = true;
 
// change the path to your emoji images (requires trailing slash)
// you can grab the images from the emoji-data link here:
// https://github.com/iamcal/js-emoji/tree/master/build
emoji.img_sets.apple.path = 'http://my-cdn.com/emoji-apple-64/';
emoji.img_sets.apple.sheet = 'http://my-cdn.com/emoji-apple-sheet-64.png';
 
// Configure this library to use the sheets defined in `img_sets` (see above)
emoji.use_sheet = true;
 
// find out the auto-detected mode
alert(emoji.replace_mode);
 
// add some aliases of your own - you can override builtins too
emoji.addAliases({
  'doge' : '1f415',
  'cat'  : '1f346'
});
 
// remove your custom aliases - this will reset builtins
emoji.removeAliases([
  'doge',
  'cat',
]);
 
// convert colons to unicode
emoji.init_env(); // else auto-detection will trigger when we first convert
emoji.replace_mode = 'unified';
emoji.allow_native = true;
var output3 = emoji.replace_colons(input);
 
</script> 

You can view a live demo here.

原文链接:https://www.npmjs.com/package/emoji-js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值