浏览代码

Fixes #15223 by handling onPaste event because of bug in Slate

Hugo Häggmark 6 年之前
父节点
当前提交
9ba98b8703
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      public/app/features/explore/QueryField.tsx

+ 9 - 0
public/app/features/explore/QueryField.tsx

@@ -468,6 +468,14 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
     );
     );
   };
   };
 
 
+  handlePaste = (event: ClipboardEvent, change: Editor) => {
+    const pastedValue = event.clipboardData.getData('Text');
+    const newValue = change.value.change().insertText(pastedValue);
+    this.onChange(newValue);
+
+    return true;
+  };
+
   render() {
   render() {
     const { disabled } = this.props;
     const { disabled } = this.props;
     const wrapperClassName = classnames('slate-query-field__wrapper', {
     const wrapperClassName = classnames('slate-query-field__wrapper', {
@@ -484,6 +492,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
             onKeyDown={this.onKeyDown}
             onKeyDown={this.onKeyDown}
             onChange={this.onChange}
             onChange={this.onChange}
             onFocus={this.handleFocus}
             onFocus={this.handleFocus}
+            onPaste={this.handlePaste}
             placeholder={this.props.placeholder}
             placeholder={this.props.placeholder}
             plugins={this.plugins}
             plugins={this.plugins}
             spellCheck={false}
             spellCheck={false}