ueberdosis/tiptap

[Bug]: Blockquote toggle shortcut not working

yan-yanishevsky opened this issue · 2 comments

Which packages did you experience the bug in?

extension-blockquote

What Tiptap version are you using?

2.0.0-beta.220

What’s the bug you are facing?

Mod-Shift-b doesn't toggle the Blockquote, it toggles Bold mark instead.
Tried on https://tiptap.dev/examples/default example

But It works if I disable Bold extension or if I extend Blockquote extension like this

const CustomBlockquote = Blockquote.extend({
  addKeyboardShortcuts() {
    return {
      'Mod-Shift-B': () => this.editor.commands.toggleBlockquote(),
    }
  },
})

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

Blockquote keyboard shortcut should work

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖

The order of execution of keyboard shortcuts depends on the priority.
Since currently pressing Ctrl+Shift+B will fall back to Ctrl+B if Ctrl+Shift+B has lower priority or can't be executed. (Ref: #4006)

The default priority of all extensions is 100. (Ref: https://tiptap.dev/guide/custom-extensions/#priority)
To make this shortcut work, you can increase the priority of the blockquote extension to 101.

const CustomBlockquote = Blockquote.extend({
  priority: 101,
  addKeyboardShortcuts() {
    return {
      'Mod-Shift-B': () => this.editor.commands.toggleBlockquote(),
    }
  },
})

Hmm, I didn't know this also affects shortcuts.
So I guess the problem is in StarterKit extension, where Blockquote goes before Bold extension (as I know the order in extensions array also affects the order of their execution). Not sure if it is intentional.
Changing priority is also a solution, thanks