Tiptap: unable to hook plugin to 'enter' key

Created on 20 Feb 2019  路  2Comments  路  Source: ueberdosis/tiptap

I am unable to use enter key in keymap

    this.editor.registerPlugin(keymap({
      'Enter': printSomething
    }))

this doesn't work in tiptap, but something similar works in prosemirror
Help

Most helpful comment

You could also register a custom plugin.

import { Editor, EditorContent, EditorMenuBar, Extension } from 'tiptap'

new Editor({
  extensions: [
    new class extends Extension {
      keys() {
        return {
          Enter(state, dispatch, view) {
            // return true prevents default behaviour
            return true
          },
        }
      }
    }(),
  ],
  content: '',
});

All 2 comments

it was added use basekeymap in tiptap/Editor.js
overrode it for my usecase

You could also register a custom plugin.

import { Editor, EditorContent, EditorMenuBar, Extension } from 'tiptap'

new Editor({
  extensions: [
    new class extends Extension {
      keys() {
        return {
          Enter(state, dispatch, view) {
            // return true prevents default behaviour
            return true
          },
        }
      }
    }(),
  ],
  content: '',
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

klaasgeldof picture klaasgeldof  路  3Comments

jetacpp picture jetacpp  路  3Comments

chrisjbrown picture chrisjbrown  路  3Comments

connecteev picture connecteev  路  3Comments

nekooee picture nekooee  路  3Comments