Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Shift+Tab to remove tabs #6

Open
avk opened this issue Aug 8, 2016 · 2 comments
Open

Support Shift+Tab to remove tabs #6

avk opened this issue Aug 8, 2016 · 2 comments

Comments

@avk
Copy link
Contributor

avk commented Aug 8, 2016

Typing Shift+Tab should remove one set of spaces inserted by typing Tab. It currently continues to insert spaces rather than remove them.

In the mean time, it could least do what backspace currently does (i.e. remove all the spaces inserted by typing Tab).

@avk
Copy link
Contributor Author

avk commented Aug 8, 2016

To support deleting tabs, I had to adapt my onTab handler to:

  handleTab(evt) {
    let newState;
    let { editorState } = this.state;

    if (evt.shiftKey) {
      // since backspace removes tabs in CodeUtils 
      // https://github.com/SamyPesse/draft-js-code/blob/9783c0f6bbedda6b7089712f9c657a72fdae636d/lib/handleKeyCommand.js#L11
      newState = CodeUtils.handleKeyCommand(editorState, 'backspace');
    } else {
      // let CodeUtils insert tabs
      newState = CodeUtils.handleTab(evt, editorState);
    }

    this.setState({
      editorState: newState,
    });
  }

This logic feels like it should live in CodeUtils.handleTab. Thoughts?

@mxstbr
Copy link
Collaborator

mxstbr commented Sep 22, 2017

Yep, this looks perfect! Mind submitting a PR? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants