fix(web): emoji length computation (#1864)
This commit is contained in:
BIN
.yarn/cache/@jest-console-npm-29.2.1-3ab9fdc9c3-b5f08dc60c.zip
vendored
Normal file
BIN
.yarn/cache/@jest-console-npm-29.2.1-3ab9fdc9c3-b5f08dc60c.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-core-npm-29.2.1-ce2b44c12c-849f9287a0.zip
vendored
Normal file
BIN
.yarn/cache/@jest-core-npm-29.2.1-ce2b44c12c-849f9287a0.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-environment-npm-29.2.1-ff40b93688-632d023c9e.zip
vendored
Normal file
BIN
.yarn/cache/@jest-environment-npm-29.2.1-ff40b93688-632d023c9e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-expect-npm-29.2.1-2895175dd4-c64b939200.zip
vendored
Normal file
BIN
.yarn/cache/@jest-expect-npm-29.2.1-2895175dd4-c64b939200.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-expect-utils-npm-29.2.1-d238dc1c64-7e6e156f45.zip
vendored
Normal file
BIN
.yarn/cache/@jest-expect-utils-npm-29.2.1-d238dc1c64-7e6e156f45.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-fake-timers-npm-29.2.1-1d0070ff5e-e4f42a2677.zip
vendored
Normal file
BIN
.yarn/cache/@jest-fake-timers-npm-29.2.1-1d0070ff5e-e4f42a2677.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-globals-npm-29.2.1-92a70cfda6-4204669366.zip
vendored
Normal file
BIN
.yarn/cache/@jest-globals-npm-29.2.1-92a70cfda6-4204669366.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-reporters-npm-29.2.1-2621c49b23-8f6419d67b.zip
vendored
Normal file
BIN
.yarn/cache/@jest-reporters-npm-29.2.1-2621c49b23-8f6419d67b.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-source-map-npm-29.2.0-cb038ff173-09f76ab63d.zip
vendored
Normal file
BIN
.yarn/cache/@jest-source-map-npm-29.2.0-cb038ff173-09f76ab63d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-test-result-npm-29.2.1-79b07e69f2-8f5f069dcf.zip
vendored
Normal file
BIN
.yarn/cache/@jest-test-result-npm-29.2.1-79b07e69f2-8f5f069dcf.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-test-sequencer-npm-29.2.1-6e7aa8e35e-ff73ce30d5.zip
vendored
Normal file
BIN
.yarn/cache/@jest-test-sequencer-npm-29.2.1-6e7aa8e35e-ff73ce30d5.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-transform-npm-29.2.1-5005852d43-bb50bfce34.zip
vendored
Normal file
BIN
.yarn/cache/@jest-transform-npm-29.2.1-5005852d43-bb50bfce34.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@jest-types-npm-29.2.1-6fb73b9831-a83f207274.zip
vendored
Normal file
BIN
.yarn/cache/@jest-types-npm-29.2.1-6fb73b9831-a83f207274.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@types-jest-npm-29.2.0-08120e58d2-6779e63d8d.zip
vendored
Normal file
BIN
.yarn/cache/@types-jest-npm-29.2.0-08120e58d2-6779e63d8d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@types-jsdom-npm-20.0.0-a0c8462a9d-13e67d3134.zip
vendored
Normal file
BIN
.yarn/cache/@types-jsdom-npm-20.0.0-a0c8462a9d-13e67d3134.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/babel-jest-npm-29.2.1-3f5ca9b26b-c340c10d8c.zip
vendored
Normal file
BIN
.yarn/cache/babel-jest-npm-29.2.1-3f5ca9b26b-c340c10d8c.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/babel-plugin-jest-hoist-npm-29.2.0-bad358f3a4-368d271cea.zip
vendored
Normal file
BIN
.yarn/cache/babel-plugin-jest-hoist-npm-29.2.0-bad358f3a4-368d271cea.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/babel-preset-jest-npm-29.2.0-d765a77392-1b09a2db96.zip
vendored
Normal file
BIN
.yarn/cache/babel-preset-jest-npm-29.2.0-d765a77392-1b09a2db96.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/expect-npm-29.2.1-77e66f565d-0a1347b569.zip
vendored
Normal file
BIN
.yarn/cache/expect-npm-29.2.1-77e66f565d-0a1347b569.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-changed-files-npm-29.2.0-e1a1846230-8ad8290324.zip
vendored
Normal file
BIN
.yarn/cache/jest-changed-files-npm-29.2.0-e1a1846230-8ad8290324.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-circus-npm-29.2.1-bb48de2990-3fe8bf27a4.zip
vendored
Normal file
BIN
.yarn/cache/jest-circus-npm-29.2.1-bb48de2990-3fe8bf27a4.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-cli-npm-29.2.1-e13d8307f2-6f190450a6.zip
vendored
Normal file
BIN
.yarn/cache/jest-cli-npm-29.2.1-e13d8307f2-6f190450a6.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-config-npm-29.2.1-af59d671b3-a2052eb47d.zip
vendored
Normal file
BIN
.yarn/cache/jest-config-npm-29.2.1-af59d671b3-a2052eb47d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-diff-npm-29.2.1-3d1e8ba84a-e3553e5bf5.zip
vendored
Normal file
BIN
.yarn/cache/jest-diff-npm-29.2.1-3d1e8ba84a-e3553e5bf5.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-docblock-npm-29.2.0-61320ddd7c-b3f1227b7d.zip
vendored
Normal file
BIN
.yarn/cache/jest-docblock-npm-29.2.0-61320ddd7c-b3f1227b7d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-each-npm-29.2.1-d12e75766e-877bd64a08.zip
vendored
Normal file
BIN
.yarn/cache/jest-each-npm-29.2.1-d12e75766e-877bd64a08.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-environment-jsdom-npm-29.2.1-94b0c32b94-7e721fefad.zip
vendored
Normal file
BIN
.yarn/cache/jest-environment-jsdom-npm-29.2.1-94b0c32b94-7e721fefad.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-environment-node-npm-29.2.1-e5f7ad4142-fc001e4292.zip
vendored
Normal file
BIN
.yarn/cache/jest-environment-node-npm-29.2.1-e5f7ad4142-fc001e4292.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-haste-map-npm-29.2.1-ad5b895784-1880e5dd12.zip
vendored
Normal file
BIN
.yarn/cache/jest-haste-map-npm-29.2.1-ad5b895784-1880e5dd12.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-leak-detector-npm-29.2.1-71814af8e4-c30107ae58.zip
vendored
Normal file
BIN
.yarn/cache/jest-leak-detector-npm-29.2.1-71814af8e4-c30107ae58.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-matcher-utils-npm-29.2.1-351cb7e187-d2a2f1ca83.zip
vendored
Normal file
BIN
.yarn/cache/jest-matcher-utils-npm-29.2.1-351cb7e187-d2a2f1ca83.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-message-util-npm-29.2.1-611c868be8-1ec1341dea.zip
vendored
Normal file
BIN
.yarn/cache/jest-message-util-npm-29.2.1-611c868be8-1ec1341dea.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-mock-npm-29.2.1-6b7fcc7ca7-fb28fc277e.zip
vendored
Normal file
BIN
.yarn/cache/jest-mock-npm-29.2.1-6b7fcc7ca7-fb28fc277e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-npm-29.2.1-157610b808-b19bf0b490.zip
vendored
Normal file
BIN
.yarn/cache/jest-npm-29.2.1-157610b808-b19bf0b490.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-regex-util-npm-29.2.0-50cc574fb1-7c533e51c5.zip
vendored
Normal file
BIN
.yarn/cache/jest-regex-util-npm-29.2.0-50cc574fb1-7c533e51c5.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-resolve-dependencies-npm-29.2.1-b591286a1c-d299081952.zip
vendored
Normal file
BIN
.yarn/cache/jest-resolve-dependencies-npm-29.2.1-b591286a1c-d299081952.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-resolve-npm-29.2.1-62e10a2e31-d9ea07ccfa.zip
vendored
Normal file
BIN
.yarn/cache/jest-resolve-npm-29.2.1-62e10a2e31-d9ea07ccfa.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-runner-npm-29.2.1-bd391c092d-5aaa04b80e.zip
vendored
Normal file
BIN
.yarn/cache/jest-runner-npm-29.2.1-bd391c092d-5aaa04b80e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-runtime-npm-29.2.1-35c31724c8-bfd535ece2.zip
vendored
Normal file
BIN
.yarn/cache/jest-runtime-npm-29.2.1-35c31724c8-bfd535ece2.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-snapshot-npm-29.2.1-78130cb701-bb09952d13.zip
vendored
Normal file
BIN
.yarn/cache/jest-snapshot-npm-29.2.1-78130cb701-bb09952d13.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-util-npm-29.2.1-9985a33765-781bd14a65.zip
vendored
Normal file
BIN
.yarn/cache/jest-util-npm-29.2.1-9985a33765-781bd14a65.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-validate-npm-29.2.1-870111abdb-33bf2671f9.zip
vendored
Normal file
BIN
.yarn/cache/jest-validate-npm-29.2.1-870111abdb-33bf2671f9.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-watcher-npm-29.2.1-1cdfae29af-c14224af26.zip
vendored
Normal file
BIN
.yarn/cache/jest-watcher-npm-29.2.1-1cdfae29af-c14224af26.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/jest-worker-npm-29.2.1-f152a67b79-10365612fa.zip
vendored
Normal file
BIN
.yarn/cache/jest-worker-npm-29.2.1-f152a67b79-10365612fa.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/pretty-format-npm-29.2.1-b89d018340-d192cbd3de.zip
vendored
Normal file
BIN
.yarn/cache/pretty-format-npm-29.2.1-b89d018340-d192cbd3de.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/ts-jest-npm-29.0.3-c1e6bc8a8a-541e51776d.zip
vendored
Normal file
BIN
.yarn/cache/ts-jest-npm-29.0.3-c1e6bc8a8a-541e51776d.zip
vendored
Normal file
Binary file not shown.
@@ -30,7 +30,7 @@
|
||||
"@babel/preset-env": "*",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
||||
"@types/jest": "^29.0.2",
|
||||
"@types/jest": "^29.2.0",
|
||||
"@types/react": "^18.0.20",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
@@ -47,8 +47,8 @@
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "^28.1.2",
|
||||
"jest-environment-jsdom": "^28.1.2",
|
||||
"jest": "^29.2.1",
|
||||
"jest-environment-jsdom": "^29.2.1",
|
||||
"lint-staged": ">=12",
|
||||
"mini-css-extract-plugin": "^2.6.1",
|
||||
"node-sass": "*",
|
||||
@@ -61,8 +61,8 @@
|
||||
"sass-loader": "*",
|
||||
"svg-jest": "^1.0.1",
|
||||
"tailwindcss": "^3.1.8",
|
||||
"ts-jest": "^28.0.5",
|
||||
"ts-loader": "^9.3.1",
|
||||
"ts-jest": "^29.0.3",
|
||||
"ts-loader": "^9.4.1",
|
||||
"typescript": "*",
|
||||
"webpack": "*",
|
||||
"webpack-dev-server": "*",
|
||||
|
||||
@@ -255,8 +255,8 @@ const ContentListView: FunctionComponent<Props> = ({
|
||||
return
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
void filesController.uploadNewFile(file)
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
void filesController.uploadNewFile(files[i])
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { getEmojiLength } from './EmojiLength'
|
||||
|
||||
describe('emoji length', () => {
|
||||
it('returns the correct length', () => {
|
||||
expect(getEmojiLength('✍️')).toEqual(1)
|
||||
expect(getEmojiLength('👩👩👧👦')).toEqual(1)
|
||||
expect(getEmojiLength('👩❤️💋👩')).toEqual(1)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
export function getEmojiLength(emoji: string): number {
|
||||
try {
|
||||
return [...new Intl.Segmenter().segment(emoji)].length
|
||||
} catch (error) {
|
||||
return [...emoji].length
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { EmojiString, Platform, VectorIconNameOrEmoji } from '@standardnotes/snj
|
||||
import { FunctionComponent, useMemo, useRef, useState } from 'react'
|
||||
import Dropdown from '../Dropdown/Dropdown'
|
||||
import { DropdownItem } from '../Dropdown/DropdownItem'
|
||||
import { getEmojiLength } from './EmojiLength'
|
||||
import { isIconEmoji } from './Icon'
|
||||
import { IconNameToSvgMapping } from './IconNameToSvgMapping'
|
||||
import { IconPickerType } from './IconPickerType'
|
||||
@@ -72,7 +73,7 @@ const IconPicker = ({ selectedValue, onIconChange, platform, className }: Props)
|
||||
const handleEmojiChange = (value: EmojiString) => {
|
||||
setEmojiInputValue(value)
|
||||
|
||||
const emojiLength = [...value].length
|
||||
const emojiLength = getEmojiLength(value)
|
||||
if (emojiLength === 1) {
|
||||
onIconChange(value)
|
||||
emojiInputRef.current?.blur()
|
||||
|
||||
@@ -898,8 +898,7 @@ class NoteView extends PureComponent<NoteViewProps, State> {
|
||||
|
||||
const observer = new MutationObserver((records) => {
|
||||
for (const record of records) {
|
||||
const removedNodes = record.removedNodes.values()
|
||||
for (const node of removedNodes) {
|
||||
record.removedNodes.forEach((node) => {
|
||||
if (node === editor) {
|
||||
this.removeTabObserver?.()
|
||||
this.removeTabObserver = undefined
|
||||
@@ -907,7 +906,7 @@ class NoteView extends PureComponent<NoteViewProps, State> {
|
||||
editor.removeEventListener('scroll', this.resetScrollPosition)
|
||||
this.scrollPosition = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "../../node_modules/@standardnotes/config/src/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ES2022"],
|
||||
"target": "ES2019",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
|
||||
Reference in New Issue
Block a user