Skip to content

Ability to disable Enter #2948

Jul 2, 2022 · 3 comments · 9 replies
Discussion options

You must be logged in to vote

If you just want to disable Enter, you can write a custom plugin and override the default behaviour of the Enter key:

import { Extension } from "@tiptap/core";

const DisableEnter = Extension.create({
  addKeyboardShortcuts() {
    return {
      Enter: () => true,
    };
  },
});

const editor = useEditor({ 
  extensions: [
    //...
    DisableEnter
  ]
})

I think line-wrap will still happen. With a little bit of CSS magic you can disable that:

.ProseMirror {
    white-space: nowrap !important;
}

This disables line-wrap for all of the editors in your app. You should set an id to the editor and use that here.

<EditorContent editor={editor} id="my-editor" />
#my-editor {
    white-space:

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
3 replies
@katerlouis
Comment options

@amirhhashemi
Comment options

@katerlouis
Comment options

Answer selected by epszaw
Comment options

You must be logged in to vote
4 replies
@epszaw
Comment options

@epszaw
Comment options

@amirhhashemi
Comment options

@castroCrea
Comment options

Comment options

You must be logged in to vote
2 replies
@amirhhashemi
Comment options

@epszaw
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants