Tiptap: Change enter to break line instead of new paragraph

Created on 13 Aug 2019  路  3Comments  路  Source: ueberdosis/tiptap

I have searched for a way to change the default behavior for Enter to be the same as Shift + Enter.
To get
instead of new


Is it possible to change to this behavior somehow?

question

Most helpful comment

@agentq15 You're welcome :)

import { Editor, EditorContent, EditorMenuBar, Extension } from 'tiptap'
import { HardBreak } from 'tiptap-extensions'

...

editor = new Editor({
 extensions: [
   new HardBreak(),
   new class extends Extension {
     keys() {
       return {
         Enter(state, dispatch, view) {
           const { schema, doc, tr } = view.state

           const hard_break = schema.nodes.hard_break
           const transaction = tr.replaceSelectionWith(hard_break.create()).scrollIntoView()
           view.dispatch(transaction)
           return true
         }
       }
     }
   }(),
 ],
 content: '',

...

All 3 comments

@agentq15 You're welcome :)

import { Editor, EditorContent, EditorMenuBar, Extension } from 'tiptap'
import { HardBreak } from 'tiptap-extensions'

...

editor = new Editor({
 extensions: [
   new HardBreak(),
   new class extends Extension {
     keys() {
       return {
         Enter(state, dispatch, view) {
           const { schema, doc, tr } = view.state

           const hard_break = schema.nodes.hard_break
           const transaction = tr.replaceSelectionWith(hard_break.create()).scrollIntoView()
           view.dispatch(transaction)
           return true
         }
       }
     }
   }(),
 ],
 content: '',

...

@MarvinMiles Thank you so much! Works like a charm!

@MarvinMiles Thank you! Works great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

santicros picture santicros  路  3Comments

chrisjbrown picture chrisjbrown  路  3Comments

winterdedavid picture winterdedavid  路  3Comments

jetacpp picture jetacpp  路  3Comments

jameswragg picture jameswragg  路  3Comments