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

Cannot remove formatting at the begining of the text #24

Open
Betree opened this issue May 16, 2019 · 2 comments
Open

Cannot remove formatting at the begining of the text #24

Betree opened this issue May 16, 2019 · 2 comments

Comments

@Betree
Copy link

Betree commented May 16, 2019

Hey there! Great project, the user experience is really good.

I have a small issue: when adding formatting (quote, title...etc) at the beginning of the text, it cannot be removed by pressing backspace key. See screencast below.

Peek 16-05-2019 21-18

@patleeman
Copy link
Owner

Thanks for the report.

I agree this is not great. I haven't had much time to work on this module and I don't use Quill in any active projects so I haven't had much need to fix this. If anybody would like to take a crack at it and submit a PR i can review and publish. I'll leave this issue open in case anybody wants to try.

@laurensiusadi
Copy link

laurensiusadi commented Jul 27, 2019

@patleeman @Betree

I find a way to make this work, but from outside this markdown modules.
Register a keyboard module on quill modules like this:

modules: {
  toolbar: {},
  markdownShortcuts: {},
  keyboard: {
    bindings: {
      custom: {
        key: 'backspace',
        format: ['blockquote', 'header'], // need to put all possibilities here
        handler: function(range, context) {
          if (context.offset === 0) {
            // When backspace on the first character of a format,
            // remove the format instead
            this.quill.format(Object.keys(context.format)[0], false, Quill.sources.USER);
          } else {
            // Otherwise propagate to Quill's default
            return true;
          }
        }
      }
    }
  }
}

If I put that inside MarkdownShortcuts constructor using this.quill.keyboard.addBinding() it doesn't work.

Source: https://quilljs.com/docs/modules/keyboard/#configuration

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

3 participants