Comments (4)
逻辑倒是不复杂,就是上传组件怎么监听粘贴事件没想出来好的实践。 如果监听 onPaste 的话,需要 Upload 获取焦点(一般是点击 upload上传节点,但这个时候会唤起文件选择器)
在业务里自行实现下应该也很快: https://codepen.io/yinkaihui/pen/gOyzbQw?editors=0011
from arco-design.
确实是个好点子,希望增加一个
from arco-design.
好的,我之前使用tdesign,他们是自带这个功能的
from arco-design.
@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)
- Table 的 `renderPagination` 更多功能
- [Bug] 文档图示计算和逻辑错误
- 字体会放置到body上面,影响到我的项目
- 许愿table能加个按shift多选的能力
- 【Form】验证通过后返回所有字段数据
- 使用了已废弃的 findDOMNode 方法。React 提示这个API将在未来的重大版本中被移除,并推荐直接在需要引用的元素上添加一个 ref 来替代。 HOT 1
- Transfer 组件开启 simple 和 draggable 属性后视觉效果有问题,少了 6px 间距
- InputNumber 精度问题
- Form item control's inner state `validateStatus` always be `validating` while no rules received. HOT 1
- Trigger 组件设置了clickOutsideToClose.capture true, 控制台会一直报错
- 表格虚拟化以后,如果每列都设置宽度,表头和表格主体对不齐
- Form should not validate hidden form item
- table组件columns筛掉了某些列后显示异常
- Upload 组件通过 customRequest 自定义 onError 后,error icon 被 hover 时渲染出错
- [bug] Typography 组件在开启 `showTooltip : true` 时,添加了 span 导致 css 省略失效
- 递归的横向Menu菜单在屏幕宽度小于某个临界值后js报错页面展示异常
- 如何兼容tailwindcss base模式呢? HOT 1
- 【datepicker】时间选择器是否能够增加addbefore api
- useFormContext hook is missing generic type
- Rendering performance issue of SelectView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arco-design.