@dialpad/dialtone 9.34.3 → 9.34.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -29
- package/dist/css/dialtone.css +2 -2
- package/dist/tokens/css/variables-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-light.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-light.css +1 -1
- package/dist/tokens/css/variables-light.css +1 -1
- package/dist/tokens/css/variables-tmo-dark.css +1 -1
- package/dist/tokens/css/variables-tmo-light.css +1 -1
- package/dist/tokens/less/variables-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-light.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-light.less +1 -1
- package/dist/tokens/less/variables-light.less +1 -1
- package/dist/tokens/less/variables-tmo-dark.less +1 -1
- package/dist/tokens/less/variables-tmo-light.less +1 -1
- package/dist/vue2/common/emoji.cjs +4 -1
- package/dist/vue2/common/emoji.cjs.map +1 -1
- package/dist/vue2/common/emoji.js +4 -1
- package/dist/vue2/common/emoji.js.map +1 -1
- package/dist/vue2/dialtone-vue.cjs +1 -0
- package/dist/vue2/dialtone-vue.cjs.map +1 -1
- package/dist/vue2/dialtone-vue.js +2 -1
- package/dist/vue2/lib/rich-text-editor.cjs +22 -9
- package/dist/vue2/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor.js +22 -9
- package/dist/vue2/lib/rich-text-editor.js.map +1 -1
- package/dist/vue2/types/common/emoji/index.d.ts +11 -2
- package/dist/vue2/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/common/emoji.cjs +4 -1
- package/dist/vue3/common/emoji.cjs.map +1 -1
- package/dist/vue3/common/emoji.js +4 -1
- package/dist/vue3/common/emoji.js.map +1 -1
- package/dist/vue3/dialtone-vue.cjs +1 -0
- package/dist/vue3/dialtone-vue.cjs.map +1 -1
- package/dist/vue3/dialtone-vue.js +2 -1
- package/dist/vue3/lib/message-input.cjs +32 -3
- package/dist/vue3/lib/message-input.cjs.map +1 -1
- package/dist/vue3/lib/message-input.js +32 -3
- package/dist/vue3/lib/message-input.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor.cjs +271 -35
- package/dist/vue3/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor.js +272 -36
- package/dist/vue3/lib/rich-text-editor.js.map +1 -1
- package/dist/vue3/types/common/emoji/index.d.ts +1 -0
- package/dist/vue3/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandComponent.vue.d.ts +73 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandComponent.vue.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandSuggestion.vue.d.ts +17 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/SlashCommandSuggestion.vue.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts +2 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts +12 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts.map +1 -0
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +38 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/slash_command_suggestion.d.ts +15 -0
- package/dist/vue3/types/components/rich_text_editor/slash_command_suggestion.d.ts.map +1 -0
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +38 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -323,49 +323,165 @@ nx build dialtone-documentation
|
|
|
323
323
|
|
|
324
324
|
### Releasing
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
Currently, Dialtone packages are being release in two different ways: `scheduled` and `manually`.
|
|
327
|
+
The `scheduled` release will only release changes to `production` while `manually` you can choose to release
|
|
328
|
+
`alpha`, `beta` or `next` branches.
|
|
328
329
|
|
|
329
|
-
|
|
330
|
-
[release.yml](https://github.com/dialpad/dialtone/actions/workflows/release.yml)
|
|
330
|
+
#### Production
|
|
331
331
|
|
|
332
|
-
|
|
333
|
-
option on GitHub.
|
|
332
|
+
##### Scheduled
|
|
334
333
|
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
On every Tuesday at 10:00 am UTC, [release action](.github/workflows/release.yml) will trigger the production release process which
|
|
335
|
+
automatically release all packages that need to be released following the next steps:
|
|
337
336
|
|
|
338
|
-
|
|
337
|
+
1. Run the `nx release` on every project.
|
|
338
|
+
2. Merge the release commits created by the semantic release bot on `staging` to `production` branch.
|
|
339
|
+
3. Push the `production` branch.
|
|
340
|
+
4. An [action](https://github.com/dialpad/dialtone/actions/workflows/publish.yml) will publish the packages with its corresponding tag.
|
|
341
|
+
|
|
342
|
+
##### Manually
|
|
339
343
|
|
|
340
|
-
|
|
344
|
+
In case you need to release earlier than the next scheduled date, you can trigger the release via `Run workflow` on [GitHub](https://github.com/dialpad/dialtone/actions/workflows/release.yml).
|
|
341
345
|
|
|
342
|
-
1.
|
|
343
|
-
2.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
1. Select `staging` branch.
|
|
347
|
+
2. Select the `package` that you want to release or leave it empty to release all of them.
|
|
348
|
+
|
|
349
|
+
This will trigger the [release action](.github/workflows/release.yml), release changes on `staging` and automatically publish the selected packages following the next steps:
|
|
350
|
+
|
|
351
|
+
1. Run the `nx release` on selected packages (all if `package` is empty).
|
|
352
|
+
2. Merge the release commits created by the semantic release bot on `staging` to `production` branch.
|
|
353
|
+
3. Push the `production` branch.
|
|
354
|
+
4. An [action](https://github.com/dialpad/dialtone/actions/workflows/publish.yml) will publish the packages with its corresponding tag.
|
|
348
355
|
|
|
349
356
|
```bash
|
|
350
357
|
nx run release
|
|
351
358
|
```
|
|
352
359
|
|
|
353
|
-
#### Alpha/Beta
|
|
360
|
+
#### Alpha/Beta/Next
|
|
354
361
|
|
|
355
|
-
|
|
362
|
+
##### Manually
|
|
356
363
|
|
|
357
|
-
1.
|
|
358
|
-
2.
|
|
359
|
-
3.
|
|
360
|
-
4.
|
|
361
|
-
5. Push updated `alpha/beta` branch to origin.
|
|
362
|
-
- A GHA will publish the release on npm and GitHub with `@alpha` or `@beta` tag.
|
|
363
|
-
6. Merge changes from `alpha/beta` back to your feature branch.
|
|
364
|
+
1. Merge your changes to the branch you want to release, commit and push to origin.
|
|
365
|
+
2. Go to [GitHub](https://github.com/dialpad/dialtone/actions/workflows/release.yml) and click on `Run workflow`.
|
|
366
|
+
3. Select `alpha`, `beta` or `next` branch.
|
|
367
|
+
4. Select the `package` that you want to release or leave it empty to release all of them.
|
|
364
368
|
|
|
365
|
-
|
|
366
|
-
|
|
369
|
+
This will trigger the [release action](.github/workflows/release.yml), release changes on the selected branch and automatically publish the selected packages following the next steps:
|
|
370
|
+
|
|
371
|
+
1. Run the `nx release` on selected packages (all if `package` is empty).
|
|
372
|
+
2. An [action](https://github.com/dialpad/dialtone/actions/workflows/publish.yml) will publish the packages with its corresponding tag.
|
|
373
|
+
|
|
374
|
+
## Usage
|
|
375
|
+
|
|
376
|
+
### Install it via NPM:
|
|
377
|
+
|
|
378
|
+
#### Vue 3
|
|
379
|
+
|
|
380
|
+
```shell
|
|
381
|
+
npm install @dialpad/dialtone@next @tiptap/vue-3
|
|
367
382
|
```
|
|
368
383
|
|
|
369
|
-
|
|
370
|
-
|
|
384
|
+
#### Vue 2
|
|
385
|
+
|
|
386
|
+
```shell
|
|
387
|
+
npm install @dialpad/dialtone@next @linusborg/vue-simple-portal @tiptap/vue-2
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Import packages:
|
|
391
|
+
|
|
392
|
+
#### Dialtone CSS
|
|
393
|
+
|
|
394
|
+
- CSS
|
|
395
|
+
|
|
396
|
+
```css
|
|
397
|
+
@import "@dialpad/dialtone/css";
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
- Javascript
|
|
401
|
+
|
|
402
|
+
```js
|
|
403
|
+
import "@dialpad/dialtone/css";
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### Dialtone eslint-plugin
|
|
407
|
+
|
|
408
|
+
```js
|
|
409
|
+
import dialtone from "@dialpad/dialtone/eslint-plugin"
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### Dialtone icons
|
|
413
|
+
|
|
414
|
+
- Importing for Vue 2:
|
|
415
|
+
|
|
416
|
+
```js
|
|
417
|
+
// Named import
|
|
418
|
+
import { DtIconArrowUp } from '@dialpad/dialtone-icons/vue2';
|
|
419
|
+
|
|
420
|
+
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
421
|
+
import DtIconArrowUp from '@dialpad/dialtone-icons/vue2/arrow-up';
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
- Importing for Vue 3:
|
|
425
|
+
|
|
426
|
+
```js
|
|
427
|
+
// Named import
|
|
428
|
+
import { DtIconArrowUp } from '@dialpad/dialtone-icons/vue3';
|
|
429
|
+
|
|
430
|
+
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
431
|
+
import DtIconArrowUp from '@dialpad/dialtone-icons/vue3/arrow-up';
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
- Importing json files
|
|
435
|
+
|
|
436
|
+
```js
|
|
437
|
+
import keywords from '@dialpad/dialtone-icons/keywords.json';
|
|
438
|
+
import iconsList from '@dialpad/dialtone-icons/icons.json';
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
#### Dialtone Vue
|
|
442
|
+
|
|
443
|
+
- Vue 2
|
|
444
|
+
|
|
445
|
+
```js
|
|
446
|
+
// Named import
|
|
447
|
+
import { DtButton } from "@dialpad/dialtone/vue2"
|
|
448
|
+
|
|
449
|
+
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
450
|
+
import { DtButton } from "@dialpad/dialtone/vue2/lib/button"
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
- Vue 3
|
|
454
|
+
|
|
455
|
+
```js
|
|
456
|
+
// Named import
|
|
457
|
+
import { DtButton } from "@dialpad/dialtone/vue3"
|
|
458
|
+
|
|
459
|
+
// Default import (Prefered if using webpack as it is tree-shakeable by default)
|
|
460
|
+
import { DtButton } from "@dialpad/dialtone/vue3/lib/button"
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### Dialtone Tokens
|
|
464
|
+
|
|
465
|
+
Dialtone tokens doesn't have a default export, so you need to access
|
|
466
|
+
the files directly as following:
|
|
467
|
+
|
|
468
|
+
- CSS
|
|
469
|
+
|
|
470
|
+
```css
|
|
471
|
+
@import "@dialpad/dialtone/tokens/variables-light.css" // Light tokens
|
|
472
|
+
@import "@dialpad/dialtone/tokens/variables-dark.css" // Dark tokens
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
- LESS
|
|
476
|
+
|
|
477
|
+
```less
|
|
478
|
+
@import "@dialpad/dialtone/tokens/variables-light.less" // Light tokens
|
|
479
|
+
@import "@dialpad/dialtone/tokens/variables-dark.less" // Dark tokens
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
- JSON
|
|
483
|
+
|
|
484
|
+
```js
|
|
485
|
+
import "@dialpad/dialtone/tokens/tokens-light.json" // Light tokens
|
|
486
|
+
import "@dialpad/dialtone/tokens/tokens-dark.json" // Dark tokens
|
|
371
487
|
```
|
package/dist/css/dialtone.css
CHANGED
|
@@ -7485,7 +7485,7 @@ body {
|
|
|
7485
7485
|
}
|
|
7486
7486
|
/**
|
|
7487
7487
|
* Do not edit directly
|
|
7488
|
-
* Generated on
|
|
7488
|
+
* Generated on Wed, 15 May 2024 17:47:40 GMT
|
|
7489
7489
|
*/
|
|
7490
7490
|
|
|
7491
7491
|
.dialtone-theme-light {
|
|
@@ -8302,7 +8302,7 @@ body {
|
|
|
8302
8302
|
|
|
8303
8303
|
/**
|
|
8304
8304
|
* Do not edit directly
|
|
8305
|
-
* Generated on
|
|
8305
|
+
* Generated on Wed, 15 May 2024 17:47:40 GMT
|
|
8306
8306
|
*/
|
|
8307
8307
|
|
|
8308
8308
|
.dialtone-theme-dark {
|
|
@@ -10,6 +10,7 @@ exports.emojiFileExtensionSmall = ".png";
|
|
|
10
10
|
exports.emojiImageUrlLarge = defaultEmojiAssetUrl;
|
|
11
11
|
exports.emojiFileExtensionLarge = ".png";
|
|
12
12
|
const emojiJson = emojiJsonLocal;
|
|
13
|
+
const emojiShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)", "g");
|
|
13
14
|
function getEmojiData() {
|
|
14
15
|
return emojiJson;
|
|
15
16
|
}
|
|
@@ -121,6 +122,7 @@ function stringToUnicode(str) {
|
|
|
121
122
|
return result;
|
|
122
123
|
}
|
|
123
124
|
function codeToEmojiData(code) {
|
|
125
|
+
code = code == null ? void 0 : code.trim();
|
|
124
126
|
if (code.startsWith(":") && code.endsWith(":")) {
|
|
125
127
|
return shortcodeToEmojiData(code);
|
|
126
128
|
} else {
|
|
@@ -132,7 +134,7 @@ function codeToEmojiData(code) {
|
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
function findShortCodes(textContent) {
|
|
135
|
-
const shortcodes = textContent.match(
|
|
137
|
+
const shortcodes = (textContent.match(emojiShortCodeRegex) || []).map((code) => code.trim());
|
|
136
138
|
return filterValidShortCodes(shortcodes);
|
|
137
139
|
}
|
|
138
140
|
function filterValidShortCodes(shortcodes) {
|
|
@@ -147,6 +149,7 @@ function findEmojis(textContent) {
|
|
|
147
149
|
exports.codeToEmojiData = codeToEmojiData;
|
|
148
150
|
exports.defaultEmojiAssetUrl = defaultEmojiAssetUrl;
|
|
149
151
|
exports.emojiJson = emojiJson;
|
|
152
|
+
exports.emojiShortCodeRegex = emojiShortCodeRegex;
|
|
150
153
|
exports.emojiVersion = emojiVersion;
|
|
151
154
|
exports.filterValidShortCodes = filterValidShortCodes;
|
|
152
155
|
exports.findEmojis = findEmojis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.cjs","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = textContent.match(
|
|
1
|
+
{"version":3,"file":"emoji.cjs","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport const emojiShortCodeRegex = /(^| |(?<=:))(:\\w+:)/g;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n code = code?.trim();\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = (\n textContent.match(emojiShortCodeRegex) || []\n ).map(code => code.trim());\n return filterValidShortCodes(shortcodes);\n}\n\nexport function filterValidShortCodes (shortcodes) {\n const filtered = shortcodes ? shortcodes.filter(code => shortcodeToEmojiData(code)) : [];\n return new Set(filtered);\n}\n\n// Finds every emoji in slot text\n// removes duplicates\n// @returns {string[]}\nexport function findEmojis (textContent) {\n const matches = [...textContent.matchAll(emojiRegex())];\n const emojis = matches.length ? matches.map(match => match[0]) : [];\n return new Set(emojis);\n}\n"],"names":["customEmojiAssetUrl","emojiImageUrlSmall","emojiFileExtensionSmall","emojiImageUrlLarge","emojiFileExtensionLarge"],"mappings":";;;;AAGY,MAAC,eAAe;AAChB,MAAC,uBAAuB,+CAA+C,eAAe;AACvFA,QAAAA,sBAAsB;AAGtBC,QAAAA,qBAAqB;AACrBC,QAAAA,0BAA0B;AAG1BC,QAAAA,qBAAqB;AACrBC,QAAAA,0BAA0B;AAEzB,MAAC,YAAY;AAEb,MAAC,sBAAsB,WAAuB,wBAAA,GAAA;AAEnD,SAAS,eAAgB;AAC9B,SAAO;AACT;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,U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AK,SAAS,GAAG,GAAG;AAC9C,WAAO,qBAAqB,IAAI;AAAA,EACpC,OAAS;AACL,UAAM,gBAAgB,gBAAgB,IAAI;AAE1C,UAAM,SAAS,UAAU,aAAa;AACtC,QAAI;AAAQ,aAAO,MAAM;AACzB,WAAO;AAAA,EACR;AACH;AAMO,SAAS,eAAgB,aAAa;AAC3C,QAAM,cACJ,YAAY,MAAM,mBAAmB,KAAK,CAAE,GAC5C,IAAI,UAAQ,KAAK,KAAM,CAAA;AACzB,SAAO,sBAAsB,UAAU;AACzC;AAEO,SAAS,sBAAuB,YAAY;AACjD,QAAM,WAAW,aAAa,WAAW,OAAO,UAAQ,qBAAqB,IAAI,CAAC,IAAI;AACtF,SAAO,IAAI,IAAI,QAAQ;AACzB;AAKO,SAAS,WAAY,aAAa;AACvC,QAAM,UAAU,CAAC,GAAG,YAAY,SAAS,WAAY,CAAA,CAAC;AACtD,QAAM,SAAS,QAAQ,SAAS,QAAQ,IAAI,WAAS,MAAM,CAAC,CAAC,IAAI;AACjE,SAAO,IAAI,IAAI,MAAM;AACvB;;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,6 +8,7 @@ let emojiFileExtensionSmall = ".png";
|
|
|
8
8
|
let emojiImageUrlLarge = defaultEmojiAssetUrl;
|
|
9
9
|
let emojiFileExtensionLarge = ".png";
|
|
10
10
|
const emojiJson = emojiJsonLocal;
|
|
11
|
+
const emojiShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)", "g");
|
|
11
12
|
function getEmojiData() {
|
|
12
13
|
return emojiJson;
|
|
13
14
|
}
|
|
@@ -119,6 +120,7 @@ function stringToUnicode(str) {
|
|
|
119
120
|
return result;
|
|
120
121
|
}
|
|
121
122
|
function codeToEmojiData(code) {
|
|
123
|
+
code = code == null ? void 0 : code.trim();
|
|
122
124
|
if (code.startsWith(":") && code.endsWith(":")) {
|
|
123
125
|
return shortcodeToEmojiData(code);
|
|
124
126
|
} else {
|
|
@@ -130,7 +132,7 @@ function codeToEmojiData(code) {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
function findShortCodes(textContent) {
|
|
133
|
-
const shortcodes = textContent.match(
|
|
135
|
+
const shortcodes = (textContent.match(emojiShortCodeRegex) || []).map((code) => code.trim());
|
|
134
136
|
return filterValidShortCodes(shortcodes);
|
|
135
137
|
}
|
|
136
138
|
function filterValidShortCodes(shortcodes) {
|
|
@@ -151,6 +153,7 @@ export {
|
|
|
151
153
|
emojiImageUrlLarge,
|
|
152
154
|
emojiImageUrlSmall,
|
|
153
155
|
emojiJson,
|
|
156
|
+
emojiShortCodeRegex,
|
|
154
157
|
emojiVersion,
|
|
155
158
|
filterValidShortCodes,
|
|
156
159
|
findEmojis,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.js","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = textContent.match(
|
|
1
|
+
{"version":3,"file":"emoji.js","sources":["../../common/emoji/index.js"],"sourcesContent":["import emojiRegex from 'emoji-regex';\nimport emojiJsonLocal from 'emoji-toolkit/emoji_strategy.json';\n\nexport const emojiVersion = '8.0';\nexport const defaultEmojiAssetUrl = 'https://cdn.jsdelivr.net/joypixels/assets/' + emojiVersion + '/png/unicode/32/';\nexport let customEmojiAssetUrl = null;\n\n// Used for emoji 16px and smaller\nexport let emojiImageUrlSmall = defaultEmojiAssetUrl;\nexport let emojiFileExtensionSmall = '.png';\n\n// Used for emoji larger than 16px\nexport let emojiImageUrlLarge = defaultEmojiAssetUrl;\nexport let emojiFileExtensionLarge = '.png';\n\nexport const emojiJson = emojiJsonLocal;\n\nexport const emojiShortCodeRegex = /(^| |(?<=:))(:\\w+:)/g;\n\nexport function getEmojiData () {\n return emojiJson;\n}\n\nexport function setEmojiAssetUrlSmall (url, fileExtension = '.png') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlSmall = url;\n emojiFileExtensionSmall = fileExtension;\n}\n\nexport function setEmojiAssetUrlLarge (url, fileExtension = '.svg') {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n emojiImageUrlLarge = url;\n emojiFileExtensionLarge = fileExtension;\n}\n\nexport function setCustomEmojiUrl (url) {\n customEmojiAssetUrl = url;\n}\n\nexport function setCustomEmojiJson (json) {\n validateCustomEmojiJson(json);\n}\n\n/**\n * Validate custom emoji json\n */\nexport function validateCustomEmojiJson (json) {\n const customEmojiProps = ['extension', 'custom'];\n const customEmojiRequiredProps = [\n 'name',\n 'category',\n 'shortname',\n 'extension',\n 'custom',\n ];\n\n /**\n * Update single emoji properties.\n * If the property exists in emojiData, it'll add the values if the property is an array, otherwise will overwrite.\n * If not exists, will add the property to the emojiData object.\n */\n const _updateNativeEmojiData = (emojiData, propName, propValue) => {\n if (emojiData[propName] === undefined) {\n if (!customEmojiProps.includes(propName)) {\n return;\n }\n\n // new property to add\n emojiData[propName] = propValue;\n } else {\n if (Array.isArray(emojiData[propName])) {\n emojiData[propName] = emojiData[propName].concat(propValue);\n } else {\n emojiData[propName] = propValue;\n }\n }\n };\n\n Object.entries(json).forEach((item) => {\n const [customEmojiKey, customEmojiValue] = item;\n\n if (customEmojiKey in emojiJson) {\n // custom emoji exists in emoji json which means to update some data in the native emoji\n const emojiData = emojiJson[customEmojiKey];\n\n for (const customEmojiPropertyName in customEmojiValue) {\n const customEmojiPropertyValue = customEmojiValue[customEmojiPropertyName];\n\n _updateNativeEmojiData(emojiData, customEmojiPropertyName, customEmojiPropertyValue);\n }\n } else {\n // new custom emoji\n const _validateRequiredProps = () =>\n customEmojiRequiredProps.every((val) => {\n return customEmojiValue[val] !== undefined;\n });\n\n if (_validateRequiredProps()) {\n emojiJson[customEmojiKey] = customEmojiValue;\n } else {\n console.error(\n 'The following custom emoji doesn\\'t contain the required properties:',\n customEmojiValue,\n );\n }\n }\n });\n}\n\n// recursively searches the emoji data object containing data for all emojis\n// and returns the object with the specified shortcode.\nexport function shortcodeToEmojiData (shortcode) {\n // eslint-disable-next-line complexity\n function f (o, key) {\n if (!o || typeof o !== 'object') {\n return;\n }\n if ('shortname' in o) {\n if (o.shortname === shortcode || o.shortname_alternates.includes(shortcode)) {\n o.key = key;\n reference = o;\n return true;\n }\n }\n Object.keys(o).some(function (k) {\n return f(o[k], k);\n });\n }\n\n let reference;\n f(getEmojiData(), null);\n return reference;\n}\n\n// Takes in an emoji unicode character(s) and converts it to an emoji string in the format the emoji data object expects\n// as a key. There can be multiple unicode characters in an emoji to denote the emoji itself, skin tone, gender\n// and such. Note that this function does NOT return variation selectors (fe0f) or zero width joiners (200d), as these\n// are not included as part of the key in the emoji.json.\n//\n// Example:\n// return value for smile emoji (no skin tone): 1f600\n// return value for left facing fist (light skin tone): 1f91b-1f3fb\nexport function unicodeToString (emoji) {\n let key = '';\n for (const codePoint of emoji) {\n const codepoint = codePoint.codePointAt(0).toString(16).padStart(4, '0');\n\n // skip 200d and fe0f as these are not included in emoji_strategy.json keys\n if (['200d', 'fe0f'].includes(codepoint)) continue;\n if (key !== '') { key = key + '-'; }\n key = key + codepoint;\n }\n return key;\n}\n\n// Takes in unicode in string form ex: '1f91b-1f3fb' and converts it to an actual unicode character.\nexport function stringToUnicode (str) {\n const uChars = str.split('-');\n let result = '';\n uChars.forEach((uChar) => {\n result = result + String.fromCodePoint(parseInt(uChar, 16));\n });\n return result;\n}\n\n// Takes in a code (which could be unicode or shortcode) and returns the emoji data for it.\nexport function codeToEmojiData (code) {\n code = code?.trim();\n if (code.startsWith(':') && code.endsWith(':')) {\n return shortcodeToEmojiData(code);\n } else {\n const unicodeString = unicodeToString(code);\n\n const result = emojiJson[unicodeString];\n if (result) result.key = unicodeString;\n return result;\n }\n}\n\n// Finds every shortcode in slot text\n// filters only the existing codes in emojiJson\n// removes duplicates.\n// @returns {string[]}\nexport function findShortCodes (textContent) {\n const shortcodes = (\n textContent.match(emojiShortCodeRegex) || []\n ).map(code => code.trim());\n return filterValidShortCodes(shortcodes);\n}\n\nexport function filterValidShortCodes (shortcodes) {\n const filtered = shortcodes ? shortcodes.filter(code => shortcodeToEmojiData(code)) : [];\n return new Set(filtered);\n}\n\n// Finds every emoji in slot text\n// removes duplicates\n// @returns {string[]}\nexport function findEmojis (textContent) {\n const matches = [...textContent.matchAll(emojiRegex())];\n const emojis = matches.length ? matches.map(match => match[0]) : [];\n return new Set(emojis);\n}\n"],"names":[],"mappings":";;AAGY,MAAC,eAAe;AAChB,MAAC,uBAAuB,+CAA+C,eAAe;AACxF,IAAC,sBAAsB;AAGvB,IAAC,qBAAqB;AACtB,IAAC,0BAA0B;AAG3B,IAAC,qBAAqB;AACtB,IAAC,0BAA0B;AAEzB,MAAC,YAAY;AAEb,MAAC,sBAAsB,WAAuB,wBAAA,GAAA;AAEnD,SAAS,eAAgB;AAC9B,SAAO;AACT;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACD,uBAAqB;AACrB,4BAA0B;AAC5B;AAEO,SAAS,sBAAuB,KAAK,gBAAgB,QAAQ;AAClE,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,MAAM;AAAA,EACb;AACD,uBAAqB;AACrB,4BAA0B;AAC5B;AAEO,SAAS,kBAAmB,KAAK;AACtC,wBAAsB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,KAAK,KAAM,CAAA;AACzB,SAAO,sBAAsB,UAAU;AACzC;AAEO,SAAS,sBAAuB,YAAY;AACjD,QAAM,WAAW,aAAa,WAAW,OAAO,UAAQ,qBAAqB,IAAI,CAAC,IAAI;AACtF,SAAO,IAAI,IAAI,QAAQ;AACzB;AAKO,SAAS,WAAY,aAAa;AACvC,QAAM,UAAU,CAAC,GAAG,YAAY,SAAS,WAAY,CAAA,CAAC;AACtD,QAAM,SAAS,QAAQ,SAAS,QAAQ,IAAI,WAAS,MAAM,CAAC,CAAC,IAAI;AACjE,SAAO,IAAI,IAAI,MAAM;AACvB;"}
|
|
@@ -157,6 +157,7 @@ Object.defineProperty(exports, "emojiImageUrlSmall", {
|
|
|
157
157
|
get: () => common_emoji.emojiImageUrlSmall
|
|
158
158
|
});
|
|
159
159
|
exports.emojiJson = common_emoji.emojiJson;
|
|
160
|
+
exports.emojiShortCodeRegex = common_emoji.emojiShortCodeRegex;
|
|
160
161
|
exports.emojiVersion = common_emoji.emojiVersion;
|
|
161
162
|
exports.filterValidShortCodes = common_emoji.filterValidShortCodes;
|
|
162
163
|
exports.findEmojis = common_emoji.findEmojis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialtone-vue.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialtone-vue.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_VALIDATION_MESSAGE_TYPE, DESCRIPTION_SIZE_TYPES, VALIDATION_MES
|
|
|
2
2
|
import { validationMessageValidator } from "./common/validators.js";
|
|
3
3
|
import { filterFormattedMessages, formatMessages, getUniqueString, getValidationState } from "./common/utils.js";
|
|
4
4
|
import { durationInHHMM, getDateMedium, relativeDate, setDateLocale } from "./common/dates.js";
|
|
5
|
-
import { codeToEmojiData, customEmojiAssetUrl, defaultEmojiAssetUrl, emojiFileExtensionLarge, emojiFileExtensionSmall, emojiImageUrlLarge, emojiImageUrlSmall, emojiJson, emojiVersion, filterValidShortCodes, findEmojis, findShortCodes, getEmojiData, setCustomEmojiJson, setCustomEmojiUrl, setEmojiAssetUrlLarge, setEmojiAssetUrlSmall, shortcodeToEmojiData, stringToUnicode, unicodeToString, validateCustomEmojiJson } from "./common/emoji.js";
|
|
5
|
+
import { codeToEmojiData, customEmojiAssetUrl, defaultEmojiAssetUrl, emojiFileExtensionLarge, emojiFileExtensionSmall, emojiImageUrlLarge, emojiImageUrlSmall, emojiJson, emojiShortCodeRegex, emojiVersion, filterValidShortCodes, findEmojis, findShortCodes, getEmojiData, setCustomEmojiJson, setCustomEmojiUrl, setEmojiAssetUrlLarge, setEmojiAssetUrlSmall, shortcodeToEmojiData, stringToUnicode, unicodeToString, validateCustomEmojiJson } from "./common/emoji.js";
|
|
6
6
|
import { CheckableMixin, GroupableMixin, InputMixin } from "./chunks/input-6kbd8Pju.js";
|
|
7
7
|
import { InputGroupMixin } from "./chunks/input_group-qVZaS5Bb.js";
|
|
8
8
|
import { KeyboardNavigation } from "./chunks/keyboard_list_navigation-ScXhrxya.js";
|
|
@@ -330,6 +330,7 @@ export {
|
|
|
330
330
|
emojiImageUrlLarge,
|
|
331
331
|
emojiImageUrlSmall,
|
|
332
332
|
emojiJson,
|
|
333
|
+
emojiShortCodeRegex,
|
|
333
334
|
emojiVersion,
|
|
334
335
|
filterFormattedMessages,
|
|
335
336
|
filterValidShortCodes,
|