Преглед на файлове

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

Enrico Berti преди 8 години
родител
ревизия
cdf13f7
променени са 1 файла, в които са добавени 13 реда и са изтрити 0 реда
  1. 13 0
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 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) {