diff options
| author | Ryan Mehri <[email protected]> | 2020-05-26 22:52:03 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-26 22:52:03 -0600 |
| commit | 337acf66e9147da3278495e91d7f3284de44429c (patch) | |
| tree | 4312f67f801a7628dd6c021e5ca3e4e01300a39e /frontend/src/components/NewPaste.js | |
| parent | Merge pull request #35 from jackyzha0/fixing-html (diff) | |
| parent | add tab support (diff) | |
| download | ctrl-v-337acf66e9147da3278495e91d7f3284de44429c.tar.xz ctrl-v-337acf66e9147da3278495e91d7f3284de44429c.zip | |
Merge pull request #40 from jackyzha0/add-tab-support
add tab support
Diffstat (limited to 'frontend/src/components/NewPaste.js')
| -rw-r--r-- | frontend/src/components/NewPaste.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/frontend/src/components/NewPaste.js b/frontend/src/components/NewPaste.js index f17c8b4..55e9c93 100644 --- a/frontend/src/components/NewPaste.js +++ b/frontend/src/components/NewPaste.js @@ -52,6 +52,7 @@ class NewPaste extends React.Component { this.handleSubmit = this.handleSubmit.bind(this); this.togglePreview = this.togglePreview.bind(this); this.renderPreview = this.renderPreview.bind(this); + this.insertTab = this.insertTab.bind(this); this.ErrorLabel = React.createRef(); } @@ -101,9 +102,17 @@ class NewPaste extends React.Component { } } + insertTab(start, end) { + const oldContent = this.state.content + this.setState({ + content: oldContent.substring(0, start) + ' ' + oldContent.substring(end) + }) + } + renderPreview() { const pasteInput = <PasteInput onChange={this.handleChange} + insertTabCallback={this.insertTab} content={this.state.content} maxLength="100000" id="pasteInput" /> |