From 1ac470439b54212e7e5a856a6ae3f9f81efefc20 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 31 Jan 2024 04:14:14 +0100 Subject: [PATCH] Fixed paragraph shortcut --- .../ParagraphBlockContent/ParagraphBlockContent.ts | 13 +++++++++++++ packages/core/src/pm-nodes/BlockContainer.ts | 4 ---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/core/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts b/packages/core/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts index fcb532a8af..07425c77de 100644 --- a/packages/core/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +++ b/packages/core/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts @@ -4,6 +4,7 @@ import { } from "../../schema"; import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers"; import { defaultProps } from "../defaultProps"; +import { handleEnter } from "../ListItemBlockContent/ListItemKeyboardShortcuts"; export const paragraphPropSchema = { ...defaultProps, @@ -13,6 +14,18 @@ export const ParagraphBlockContent = createStronglyTypedTiptapNode({ name: "paragraph", content: "inline*", group: "blockContent", + + addKeyboardShortcuts() { + return { + Enter: () => handleEnter(this.editor), + "Mod-Alt-0": () => + this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, { + type: "paragraph", + props: {}, + }), + }; + }, + parseHTML() { return [ { tag: "div[data-content-type=" + this.name + "]" }, diff --git a/packages/core/src/pm-nodes/BlockContainer.ts b/packages/core/src/pm-nodes/BlockContainer.ts index d7aab2b0e6..77e3e3dab8 100644 --- a/packages/core/src/pm-nodes/BlockContainer.ts +++ b/packages/core/src/pm-nodes/BlockContainer.ts @@ -693,10 +693,6 @@ export const BlockContainer = Node.create<{ this.editor.commands.liftListItem("blockContainer"); return true; }, - "Mod-Alt-0": () => - this.editor.commands.BNCreateBlock( - this.editor.state.selection.anchor + 2 - ), }; }, });