Ver código fonte

HUE-5883 [editor] Remove weird spaces from a query on paste

Enrico Berti 8 anos atrás
pai
commit
cdf13f7

+ 13 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3435,6 +3435,19 @@
         }
       }
 
+      var lastEditorValue = null;
+      var checkEditorValueInterval = -1;
+      editor.on('paste', function (e) {
+        window.clearInterval(checkEditorValueInterval);
+        checkEditorValueInterval = window.setInterval(function () {
+          if (lastEditorValue !== editor.getValue()) {
+            window.clearInterval(checkEditorValueInterval);
+            lastEditorValue = editor.getValue();
+            editor.setValue(removeUnicodes(lastEditorValue), 1);
+          }
+        }, 10);
+      });
+
       editor.on("input", function () {
         if (editor.getValue().length == 0) {
           if (!placeHolderVisible && placeHolderElement) {