From f3c29ce39cf57d2517a95f79fffea81462293543 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Tue, 26 May 2020 21:35:53 -0700 Subject: add tab support --- frontend/src/components/NewPaste.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'frontend/src/components/NewPaste.js') 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 = -- cgit v1.2.3