From 30815381ef242c213707388576550d0c5b05bef8 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sat, 30 Apr 2022 13:22:40 +0800 Subject: [PATCH] tiptap: prevent keyboard event in mind --- packages/client/src/tiptap/extensions/mind.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/client/src/tiptap/extensions/mind.ts b/packages/client/src/tiptap/extensions/mind.ts index 7466e537..6a4b9498 100644 --- a/packages/client/src/tiptap/extensions/mind.ts +++ b/packages/client/src/tiptap/extensions/mind.ts @@ -1,5 +1,6 @@ import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core'; import { ReactNodeViewRenderer } from '@tiptap/react'; +import { Plugin, PluginKey } from 'prosemirror-state'; import { MindWrapper } from 'tiptap/wrappers/mind'; import { getDatasetAttribute } from 'tiptap/prose-utils'; @@ -125,4 +126,21 @@ export const Mind = Node.create({ }), ]; }, + + addProseMirrorPlugins() { + const { editor } = this; + + return [ + new Plugin({ + key: new PluginKey('mind'), + props: { + handleKeyDown(view, event) { + if (editor.isActive('mind')) { + return true; + } + }, + }, + }), + ]; + }, });