aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/NewPaste.js
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-26 21:35:53 -0700
committerjackyzha0 <[email protected]>2020-05-26 21:35:53 -0700
commitf3c29ce39cf57d2517a95f79fffea81462293543 (patch)
tree4312f67f801a7628dd6c021e5ca3e4e01300a39e /frontend/src/components/NewPaste.js
parentMerge pull request #35 from jackyzha0/fixing-html (diff)
downloadctrl-v-f3c29ce39cf57d2517a95f79fffea81462293543.tar.xz
ctrl-v-f3c29ce39cf57d2517a95f79fffea81462293543.zip
add tab support
Diffstat (limited to 'frontend/src/components/NewPaste.js')
-rw-r--r--frontend/src/components/NewPaste.js9
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" />