-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Create a common function to insert an emoji into a text #17346
Merged
cead22
merged 19 commits into
Expensify:main
from
bernhardoj:fix/15951-remove-space-on-add-emoji-from-picker
Apr 21, 2023
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f3abb8a
create a common function to insert an emoji into a text
bernhardoj 9754214
add return type
bernhardoj 12160a4
fix lint
bernhardoj be7f2a5
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj aeb0286
move the function to another util file
bernhardoj 28b6f81
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj 3ef5fa6
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj 114d424
Revert "move the function to another util file"
bernhardoj 61c8bdf
move the function to another util file
bernhardoj c24368b
fix lint
bernhardoj 1403e4b
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj dc19e14
move to another util file
bernhardoj f9c3222
fix lint
bernhardoj 980318e
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj 317f581
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj 530ed07
reorganize common and platform specific file
bernhardoj e549f83
simplify code
bernhardoj a50526b
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj 307c828
Merge branch 'main' into fix/15951-remove-space-on-add-emoji-from-picker
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Get the current number of lines in the composer | ||
* | ||
* @param {Number} maxLines | ||
* @param {Number} lineHeight | ||
* @param {Number} paddingTopAndBottom | ||
* @param {Number} scrollHeight | ||
* | ||
* @returns {Number} | ||
*/ | ||
function getNumberOfLines(maxLines, lineHeight, paddingTopAndBottom, scrollHeight) { | ||
let newNumberOfLines = Math.ceil((scrollHeight - paddingTopAndBottom) / lineHeight); | ||
newNumberOfLines = maxLines <= 0 ? newNumberOfLines : Math.min(newNumberOfLines, maxLines); | ||
return newNumberOfLines; | ||
} | ||
|
||
export default getNumberOfLines; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Get the current number of lines in the composer | ||
* | ||
* @param {Number} lineHeight | ||
* @param {Number} paddingTopAndBottom | ||
* @param {Number} scrollHeight | ||
* | ||
* @returns {Number} | ||
*/ | ||
function getNumberOfLines(lineHeight, paddingTopAndBottom, scrollHeight) { | ||
return Math.ceil((scrollHeight - paddingTopAndBottom) / lineHeight); | ||
} | ||
|
||
export default getNumberOfLines; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import getNumberOfLines from './getNumberOfLines'; | ||
import updateNumberOfLines from './updateNumberOfLines'; | ||
|
||
/** | ||
* Get the current number of lines in the composer | ||
* | ||
* @param {Number} maxLines | ||
* @param {Number} lineHeight | ||
* @param {Number} paddingTopAndBottom | ||
* @param {Number} scrollHeight | ||
* | ||
* @returns {Number} | ||
* Replace substring between selection with a text. | ||
* @param {String} text | ||
* @param {Object} selection | ||
* @param {String} textToInsert | ||
* @returns {String} | ||
*/ | ||
function getNumberOfLines(maxLines, lineHeight, paddingTopAndBottom, scrollHeight) { | ||
let newNumberOfLines = Math.ceil((scrollHeight - paddingTopAndBottom) / lineHeight); | ||
newNumberOfLines = maxLines <= 0 ? newNumberOfLines : Math.min(newNumberOfLines, maxLines); | ||
return newNumberOfLines; | ||
function insertText(text, selection, textToInsert) { | ||
return text.slice(0, selection.start) + textToInsert + text.slice(selection.end, text.length); | ||
} | ||
|
||
export default getNumberOfLines; | ||
export { | ||
getNumberOfLines, | ||
updateNumberOfLines, | ||
insertText, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, coming from #18515. This PR raise regression Emoji gets added in between the text when selecting text and adding new emoji by search and entering.
The
this.state.selection
we pass should be the state before it gets updated, it's due to the state update may be asynchronous.