fix: Shift-Enter in code block in table should behave correctly
closes #6994
This commit is contained in:
@@ -2,6 +2,7 @@ import { NodeSpec, NodeType } from "prosemirror-model";
|
|||||||
import { Command } from "prosemirror-state";
|
import { Command } from "prosemirror-state";
|
||||||
import { isInTable } from "prosemirror-tables";
|
import { isInTable } from "prosemirror-tables";
|
||||||
import { MarkdownSerializerState } from "../lib/markdown/serializer";
|
import { MarkdownSerializerState } from "../lib/markdown/serializer";
|
||||||
|
import isInCode from "../queries/isInCode";
|
||||||
import isNodeActive from "../queries/isNodeActive";
|
import isNodeActive from "../queries/isNodeActive";
|
||||||
import breakRule from "../rules/breaks";
|
import breakRule from "../rules/breaks";
|
||||||
import Node from "./Node";
|
import Node from "./Node";
|
||||||
@@ -36,9 +37,12 @@ export default class HardBreak extends Node {
|
|||||||
keys({ type }: { type: NodeType }): Record<string, Command> {
|
keys({ type }: { type: NodeType }): Record<string, Command> {
|
||||||
return {
|
return {
|
||||||
"Shift-Enter": (state, dispatch) => {
|
"Shift-Enter": (state, dispatch) => {
|
||||||
|
const isParagraphActive = isNodeActive(state.schema.nodes.paragraph)(
|
||||||
|
state
|
||||||
|
);
|
||||||
if (
|
if (
|
||||||
!isInTable(state) &&
|
(!isInTable(state) && !isParagraphActive) ||
|
||||||
!isNodeActive(state.schema.nodes.paragraph)(state)
|
isInCode(state, { onlyBlock: true })
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user