react-component / textarea

React Textarea
MIT License
26 stars 35 forks source link

feat: add newLine #9

Closed xrkffgg closed 3 years ago

xrkffgg commented 3 years ago

close https://github.com/ant-design/ant-design/issues/29612

xrkffgg commented 3 years ago

@kerm1it 来 see see

codecov[bot] commented 3 years ago

Codecov Report

Merging #9 (f5cf9e2) into master (3f86668) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
+ Coverage   98.02%   98.05%   +0.02%     
==========================================
  Files           3        3              
  Lines         152      154       +2     
  Branches       44       46       +2     
==========================================
+ Hits          149      151       +2     
  Misses          3        3              
Impacted Files Coverage Δ
src/ResizableTextArea.tsx 98.36% <ø> (ø)
src/index.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3f86668...f5cf9e2. Read the comment docs.

xrkffgg commented 3 years ago

@afc163 @kerm1it @zombieJ PTAL

zombieJ commented 3 years ago

我有点担心 ant-design/ant-design#29612 算不算过度需求,onPressEnter 本身已经带了 shift 信息。代码也没有复杂到需要封装一个额外 api 的感觉:

<TextArea
  onPressEnter={(e) => {
    if (!e.shiftKey) {
      e.preventDefault();
    }
  }}
/>

如果用户未来需要自定义条件换行,那是不是又要变成这种:

<TextArea
  newLine={() => {
    if (this.state.a) {
      return true;
    }

    return 'ShiftEnter';
  }}
/>
xrkffgg commented 3 years ago

赞同~

hyl1374961656 commented 3 years ago

所以自定义换行现在支持了么