Browse Source
Merge pull request #120 from roderickhsiao/custom-data
Support customized data
master
Joe Attardi
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
7 additions and
5 deletions
-
src/categoryButtons.ts
-
src/emojiArea.ts
-
src/index.ts
-
src/types.ts
|
|
@ -40,8 +40,8 @@ export class CategoryButtons { |
|
|
|
const container = createElement('div', CLASS_CATEGORY_BUTTONS); |
|
|
|
|
|
|
|
let categories = this.options.showRecents |
|
|
|
? ['recents', ...(this.options.categories || emojiData.categories)] |
|
|
|
: this.options.categories || emojiData.categories; |
|
|
|
? ['recents', ...(this.options.categories || this.options.emojiData?.categories || emojiData.categories)] |
|
|
|
: this.options.categories || this.options.emojiData?.categories || emojiData.categories; |
|
|
|
|
|
|
|
if (this.options.custom) { |
|
|
|
categories = [...categories, 'custom']; |
|
|
|
|
|
@ -53,7 +53,7 @@ export class EmojiArea { |
|
|
|
private options: EmojiButtonOptions |
|
|
|
) { |
|
|
|
this.emojisPerRow = options.emojisPerRow || 8; |
|
|
|
this.categories = options.categories || emojiData.categories; |
|
|
|
this.categories = options.categories || options.emojiData?.categories || emojiData.categories; |
|
|
|
|
|
|
|
if (options.showRecents) { |
|
|
|
this.categories = ['recents', ...this.categories]; |
|
|
|
|
|
@ -57,6 +57,7 @@ const DEFAULT_OPTIONS: EmojiButtonOptions = { |
|
|
|
showVariants: true, |
|
|
|
showCategoryButtons: true, |
|
|
|
recentsCount: 50, |
|
|
|
emojiData, |
|
|
|
emojiVersion: '12.1', |
|
|
|
theme: 'light', |
|
|
|
categories: [ |
|
|
@ -301,9 +302,9 @@ export class EmojiButton { |
|
|
|
this.events, |
|
|
|
this.i18n, |
|
|
|
this.options, |
|
|
|
emojiData.emoji, |
|
|
|
this.options.emojiData.emoji, |
|
|
|
(this.options.categories || []).map(category => |
|
|
|
emojiData.categories.indexOf(category) |
|
|
|
this.options.emojiData.categories.indexOf(category) |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
|
|
@ -54,6 +54,7 @@ export interface EmojiButtonOptions { |
|
|
|
showCategoryButtons?: boolean; |
|
|
|
recentsCount?: number; |
|
|
|
rootElement?: HTMLElement; |
|
|
|
emojiData?: EmojiData, |
|
|
|
emojiVersion?: EmojiVersion; |
|
|
|
i18n?: I18NStrings; |
|
|
|
zIndex?: number; |
|
|
|