What is @tiptap/extension-hard-break?
@tiptap/extension-hard-break is an extension for the Tiptap editor that allows users to insert hard line breaks (similar to pressing Shift+Enter in a traditional text editor). This is useful for creating new lines within a paragraph without starting a new paragraph.
What are @tiptap/extension-hard-break's main functionalities?
Insert Hard Break
This feature allows users to insert a hard break into the text. The code sample demonstrates how to import the HardBreak extension and use the setHardBreak command to insert a hard break at the current cursor position.
import { HardBreak } from '@tiptap/extension-hard-break';
const editor = new Editor({
extensions: [
HardBreak,
],
});
// Use the command to insert a hard break
editor.commands.setHardBreak();
Custom Key Bindings
This feature allows users to configure custom key bindings for inserting hard breaks. The code sample shows how to configure the HardBreak extension to insert a hard break when the user presses 'Mod-Enter' (Cmd-Enter on Mac or Ctrl-Enter on Windows).
import { HardBreak } from '@tiptap/extension-hard-break';
const editor = new Editor({
extensions: [
HardBreak.configure({
keymap: {
'Mod-Enter': () => editor.commands.setHardBreak(),
},
}),
],
});
Other packages similar to @tiptap/extension-hard-break
prosemirror-schema-basic
The prosemirror-schema-basic package provides a basic schema for ProseMirror, including support for hard breaks. It is more general-purpose compared to @tiptap/extension-hard-break, which is specifically designed for Tiptap.
draft-js
Draft.js is a rich text editor framework for React that includes support for hard breaks. While it offers similar functionality, it is a more comprehensive solution for building rich text editors and is not specifically tailored to Tiptap.
@tiptap/extension-hard-break
Introduction
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Official Documentation
Documentation can be found on the Tiptap website.
License
Tiptap is open sourced software licensed under the MIT license.