joypixels / emojify.js

A Javascript module to convert Emoji keywords to images
http://hassankhan.github.io/emojify.js/
MIT License
1.8k stars 238 forks source link

Config options rewrite #87

Closed hassankhan closed 9 years ago

hassankhan commented 10 years ago

I think we could add more flexible options for targeting elements to emojify. @BenMQ volunteered to do this. Possible ideas for new options:

Option Description
whitelist An array of any #ids or .classes to always emojify
blacklist An array of any #ids or .classes to never emojify

Existing options:

Option Description
emojify_tag_type Rename to tag_type.
only_crawl_id Remove, use emojify.run(selector) instead
img_dir No change
ignore_emoticons No change
ignored_tags Rename to ignore_elements. An array of elements to never emojify
hassankhan commented 10 years ago

Rationale for getting rid of only_crawl_id: Because right now, if you don't pass emojify.run() any parameter, then it checks only_crawl_id, and if that's not specified it does the whole document body.

I propose changing it so you can do emojify.run('#content') and internally use document.querySelector() to do the magic. If you don't pass a parameter, it processes the rest of the body as usual.

hassankhan commented 9 years ago

Hi, little update, I think it might also be a good idea to remove ignored_tags and make both the blacklist and whitelist options be an array of valid selectors.

hassankhan commented 9 years ago

Update 2: The whitelist and blacklist options are now objects, rather than arrays:

blacklist: {
  "elements": ["body", "code", "script"],
  "classes": ["no-emojify"],
  "ids": ["special"]
}
hassankhan commented 9 years ago

Quick update, I've added the blacklist option and renamed emojify_tag_type. I'll leave any other improvements till later so v1.0 can be released.