Tiptap: Hard break cannot be inserted from a menubar button: commands.hard_break is not a function

Created on 29 Sep 2020  ·  3Comments  ·  Source: ueberdosis/tiptap

Describe the bug
Despite the command being defined as hard_break in packages/tiptap-extensions/src/nodes/HardBreak.js, setting a menu bar button to call commands.hard_break produces TypeError: commands.hard_break is not a function. The break can be inserted as normal by pressing Shift-Return or Command-Return.

This is particularly annoying as I guarantee some of my users will not be able to remember the shortcut, and will use paragraph breaks instead if they cannot have a toolbar button…

Steps to Reproduce / Codesandbox Example
Steps to reproduce the behaviour:

  1. Import HardBreak from tiptap-extensions and add it to the editor's extensions.
  2. In the menu bar, add a button for hard-break:
<button @click.prevent="commands.hard_break">
  BREAK
</button>
  1. Load the page
  2. Confirm hard breaks can be added using the keyboard shortcuts.
  3. Place the cursor in some text and click the BREAK button.

https://codesandbox.io/s/vue-issue-template-forked-2xtmb?file=/src/App.vue

Expected behaviour
A hard break is inserted, and there is no console error.

Screenshots
image

Environment

  • OS: macOS 10.14.6 (18G6020)
  • Browser: Vivaldi
  • Version: 3.3.2022.45
  • Mobile / Desktop: Desktop

Additional context
For some reason, the console error is not output in the Codesandbox example, but I'm not familiar enough with that site to know if that's down to something they've done. Regardless, the hard break is still not inserted when the button is clicked.

Incidentally, the .prevent on the @click seems to be necessary when using Buefy in order to stop it reloading the page — I'm leaving this here as a note just in case it helps anybody else using Buefy :)

bug

Most helpful comment

That's fixed it — thanks 😁

All 3 comments

Oh, you’re right. Would you mind to update to the latest version of tiptap-extensions (1.33.1) and try again?

That's fixed it — thanks 😁

Thanks for checking! ✌️

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisjbrown picture chrisjbrown  ·  3Comments

santicros picture santicros  ·  3Comments

Auxxxxlx picture Auxxxxlx  ·  3Comments

bernhardh picture bernhardh  ·  3Comments

leandromatos picture leandromatos  ·  4Comments