mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +08:00
Emoji backspace fix
This commit is contained in:
parent
ad17363173
commit
30603e76b5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-keyboard",
|
"name": "simple-keyboard",
|
||||||
"version": "2.3.22",
|
"version": "2.3.23",
|
||||||
"description": "On-screen Virtual Keyboard",
|
"description": "On-screen Virtual Keyboard",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -74,9 +74,20 @@ class Utilities {
|
|||||||
let output = input;
|
let output = input;
|
||||||
let newLineOnEnter = options.newLineOnEnter;
|
let newLineOnEnter = options.newLineOnEnter;
|
||||||
|
|
||||||
if(button === "{bksp}" && output.length > 0)
|
if(button === "{bksp}" && output.length > 0){
|
||||||
output = output.slice(0, -1);
|
/**
|
||||||
else if(button === "{space}")
|
* Emojis are made out of two characters, so we must take a custom approach to trim them.
|
||||||
|
* For more info: https://mathiasbynens.be/notes/javascript-unicode
|
||||||
|
*/
|
||||||
|
let lastTwoChars = output.slice(-2);
|
||||||
|
let emojiMatched = lastTwoChars.match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g);
|
||||||
|
|
||||||
|
if(emojiMatched){
|
||||||
|
output = output.slice(0, -2);
|
||||||
|
} else {
|
||||||
|
output = output.slice(0, -1);
|
||||||
|
}
|
||||||
|
} else if(button === "{space}")
|
||||||
output = output + ' ';
|
output = output + ' ';
|
||||||
else if(button === "{tab}")
|
else if(button === "{tab}")
|
||||||
output = output + "\t";
|
output = output + "\t";
|
||||||
|
Loading…
Reference in New Issue
Block a user