Giter Club home page Giter Club logo

Comments (4)

yinkaihui avatar yinkaihui commented on May 25, 2024 2

逻辑倒是不复杂,就是上传组件怎么监听粘贴事件没想出来好的实践。 如果监听 onPaste 的话,需要 Upload 获取焦点(一般是点击 upload上传节点,但这个时候会唤起文件选择器)

在业务里自行实现下应该也很快: https://codepen.io/yinkaihui/pen/gOyzbQw?editors=0011

from arco-design.

kanyxmo avatar kanyxmo commented on May 25, 2024

确实是个好点子,希望增加一个

from arco-design.

a289459798 avatar a289459798 commented on May 25, 2024

好的,我之前使用tdesign,他们是自带这个功能的

from arco-design.

kwooshung avatar kwooshung commented on May 25, 2024

@a289459798 @yinkaihui 我有个拙见,就是能不能给这个组件设置一个 boolean 属性,当它为true的时候就监听 onPaste甚至全局监听

如果担心多个上传之间的监听问题,也好解决,开发者自己解决都行,只需需要用户定义state,赋不同的值进行判断就好。

假设这个属性名就叫:paste,就像让下的示例,状态paste设置不同的值,就可以监听不同的。
最好也支持onPaste事件。

import React from 'react';
import { Upload } from '@arco-design/web-react';

function App() {
  const [paste, setPaste] = React.useState(1);
  return (
    <>
    <Upload
      paste={paste===1}
      onPaste={(e) => {
        setPaste(2);
      }}
    />
    <Upload
      paste={paste===2}
      onPaste={(e) => {
        setPaste(0);
      }}
    />
    <>
  );
}

export default App;

因为粘贴上传,一般是弹窗、已经触发的网页截图、所见即所得编辑器之类的都是聚焦后,等场景。

只需要开放这个属性,让开发者根据逻辑控制其监听就好了,就可以不用理会什么时候监听。

from arco-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.