Selaa lähdekoodia

fix: can't input special chars using the press key block (#1583)

Ahmad Kholid 1 vuosi sitten
vanhempi
commit
cdc2659299
1 muutettua tiedostoa jossa 6 lisäystä ja 4 poistoa
  1. 6 4
      src/content/blocksHandler/handlerPressKey.js

+ 6 - 4
src/content/blocksHandler/handlerPressKey.js

@@ -60,11 +60,13 @@ async function pressKeyWithJs({ element, keys, pressTime }) {
       const isTextField = textFieldTags.includes(element.tagName);
 
       if (isEditable || isTextField) {
-        const isDigit = /^[0-9]$/.test(key);
         const contentKey = isEditable ? 'textContent' : 'value';
-
-        if (isLetter || isDigit) {
-          element[contentKey] += key;
+        if (isLetter || (keyDefinitions[key] && key.length === 1)) {
+          if (isEditable && document.execCommand) {
+            document.execCommand('insertText', false, key);
+          } else {
+            element[contentKey] += key;
+          }
 
           return;
         }