docs: fix typescript types for Picker's customEmoji (#30)

* docs: fix typescript types for Picker's customEmoji

* fix: fix typedoc regex
This commit is contained in:
Nolan Lawson 2020-08-09 18:27:50 -07:00 committed by GitHub
parent ccb4a8ae5e
commit c7293e111c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 18 deletions

View File

@ -232,10 +232,11 @@ The `new Picker(options)` constructor supports several options:
Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`customEmoji` | CustomEmoji[] | - | Array of custom emoji |
`dataSource` | string | "https://cdn.jsdelivr.net/npm/emojibase-data@5/en/data.json" | URL to fetch the emojibase data from |
`i18n` | I18n | - | i18n object (see below for details) |
`locale` | string | "en" | Locale string |
`skinToneEmoji` | string | "🖐️" | The emoji to use for the skin tone picker |
`skinToneEmoji` | string | "🖐️" | The emoji to use for the skin tone picker |
@ -340,23 +341,23 @@ same underlying IndexedDB connection and database.
Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`customEmoji` | CustomEmoji] | [] | Array of custom emoji |
`customEmoji` | CustomEmoji[] | [] | Array of custom emoji |
`dataSource` | string | "https://cdn.jsdelivr.net/npm/emojibase-data@5/en/data.json" | URL to fetch the emojibase data from |
`locale` | string | "en" | Locale string |
**Returns:** *[Database*
**Returns:** *Database*
#### Accessors
##### customEmoji
**get customEmoji**(): *CustomEmoji]*
**get customEmoji**(): *CustomEmoji[]*
Return the custom emoji associated with this Database, or the empty array if none.
**Returns:** *[CustomEmoji]*
**Returns:** *CustomEmoji[]*
**set customEmoji**(`customEmoji`: [CustomEmoji]): *void*
**set customEmoji**(`customEmoji`: CustomEmoji[]): *void*
Set the custom emoji for this database. Throws an error if custom emoji are not in the correct format.
@ -364,7 +365,7 @@ Set the custom emoji for this database. Throws an error if custom emoji are not
Name | Type | Description |
------ | ------ | ------ |
`customEmoji` | [CustomEmoji] | |
`customEmoji` | CustomEmoji[] | |
**Returns:** *void*
@ -398,7 +399,7 @@ ___
##### getEmojiByGroup
**getEmojiByGroup**(`group`: number): *Promise[NativeEmoji]*
**getEmojiByGroup**(`group`: number): *PromiseNativeEmoji[]*
Returns all emoji belonging to a group, ordered by `order`. Only returns native emoji;
custom emoji don't belong to a group.
@ -411,13 +412,13 @@ Name | Type | Description |
------ | ------ | ------ |
`group` | number | the group number |
**Returns:** *Promise[NativeEmoji]*
**Returns:** *PromiseNativeEmoji[]*
___
##### getEmojiBySearchQuery
**getEmojiBySearchQuery**(`query`: string): *Promise[Emoji]*
**getEmojiBySearchQuery**(`query`: string): *PromiseEmoji[]*
Returns all emoji matching the given search query, ordered by `order`.
@ -429,13 +430,13 @@ Name | Type | Description |
------ | ------ | ------ |
`query` | string | search query string |
**Returns:** *Promise[Emoji]*
**Returns:** *PromiseEmoji[]*
___
##### getEmojiByShortcode
**getEmojiByShortcode**(`shortcode`: string): *Promise[Emoji | null*
**getEmojiByShortcode**(`shortcode`: string): *PromiseEmoji | null*
Return a single emoji matching the shortcode, or null if not found.
@ -487,7 +488,7 @@ ___
##### getTopFavoriteEmoji
**getTopFavoriteEmoji**(`limit`: number): *PromiseEmoji]*
**getTopFavoriteEmoji**(`limit`: number): *PromiseEmoji[]*
Get the top favorite emoji in descending order. If there are no favorite emoji yet, returns an empty array.
@ -497,7 +498,7 @@ Name | Type | Description |
------ | ------ | ------ |
`limit` | number | maximum number of results to return |
**Returns:** *Promise[Emoji]*
**Returns:** *PromiseEmoji[]*
___
@ -535,7 +536,7 @@ ___
##### setPreferredSkinTone
**setPreferredSkinTone**(`skinTone`: [SkinTone): *Promisevoid*
**setPreferredSkinTone**(`skinTone`: SkinTone): *Promisevoid*
Set the user's preferred skin tone. Non-numbers throw an error.

View File

@ -11,7 +11,7 @@ const PICKER_END_MARKER = '<!-- picker API end -->'
// Given the typedoc output and generated into docs-tmp, inject these into the README
function removeLinks (str) {
return str.replaceAll(/\[(.*?)\]\(.*?\)/sg, (_, p1) => p1)
return str.replaceAll(/\[([^\]]+?)]\([^)]+?\)/sg, (_, p1) => p1)
}
function incrementHeadings (str) {

View File

@ -1,10 +1,11 @@
import {I18n, PickerConstructorOptions, EmojiPickerEventMap, EmojiClickEvent, SkinToneChangeEvent} from "./shared";
import {I18n, PickerConstructorOptions, EmojiPickerEventMap, CustomEmoji} from "./shared";
export default class Picker extends HTMLElement {
dataSource: string
locale: string
i18n: I18n
skinToneEmoji: string
customEmoji?: CustomEmoji[]
/**
*
@ -12,12 +13,14 @@ export default class Picker extends HTMLElement {
* @param locale - Locale string
* @param i18n - i18n object (see below for details)
* @param skinToneEmoji - The emoji to use for the skin tone picker
* @param customEmoji - Array of custom emoji
*/
constructor({
dataSource = 'https://cdn.jsdelivr.net/npm/emojibase-data@5/en/data.json',
locale = 'en',
i18n,
skinToneEmoji = '🖐️'
skinToneEmoji = '🖐️',
customEmoji
}: PickerConstructorOptions = {}) {
super()
}

View File

@ -37,6 +37,7 @@ export interface PickerConstructorOptions {
locale?: string
i18n?: I18n
skinToneEmoji?: string
customEmoji?: CustomEmoji[]
}
export interface I18n {