Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly copy & paste data with context menu, and handle number notion that is based on locale #296

Merged
merged 22 commits into from
Dec 29, 2023

Conversation

Michota
Copy link
Contributor

@Michota Michota commented Dec 28, 2023

Context menu copy-pasting

Parse number with respecting locale number notion

Respect the locale settings for user-supplied numerical data, whether pasted or entered manually.

  • New function parseLocaleNumber
    • Locale can be provided manually (as string). If this does not happen, the function will get it from the browser itself.
    • returns number.
function parseLocaleNumber(stringNumber: string, locale = getNavigatorLanguage()): number
parseLocaleNumber("123456,78") // returns 123456.78
parseLocaleNumber("1 234 56,78", "pl-PL") // returns 123456.78
parseLocaleNumber("1,234,56.78", "en-US") // returns 123456.78

- TypeScript config: noEmitOnError: true, for dev purposes
- Prettier: maxWidth: 120
- may not work for arabic number notations
- create function that will get decimal and thousand separators
- replace these separators in strings passed as an stringNumber argument
- create helper-function that will get decimal and thousand separators
- replace these separators in strings passed as an stringNumber argument
- replace all characters (like "USD", or "$", etc.) before and after numbers
fix after-merge conflict
fix: re-write parseLocaleNumber

- create helper-function that will get decimal and thousand separators
- replace these separators in strings passed as an stringNumber argument
- replace all characters (like "USD", or "$", etc.) before and after numbers
feat: getRowsFromClipboard function

- fixes issue #282
Added missing types, error handles, moved parts of the logic to separate functions, renamed functions and variables to better indicate their purpose
package.json Outdated Show resolved Hide resolved
src/lib/Functions/getNavigatorLanguage.ts Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@Michota Michota requested a review from DLowHP December 29, 2023 10:52
@DLowHP DLowHP added this to the Release v4.1.3 milestone Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pasting from Context Menu trims numeric values
2 participants