fix: Backspace at the beginning of code block should convert to paragraph
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { NodeType } from "prosemirror-model";
|
import { NodeType } from "prosemirror-model";
|
||||||
|
import backspaceToParagraph from "../commands/backspaceToParagraph";
|
||||||
import { selectAll } from "../commands/selectAll";
|
import { selectAll } from "../commands/selectAll";
|
||||||
import CodeFence from "./CodeFence";
|
import CodeFence from "./CodeFence";
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ export default class CodeBlock extends CodeFence {
|
|||||||
|
|
||||||
keys({ type }: { type: NodeType }) {
|
keys({ type }: { type: NodeType }) {
|
||||||
return {
|
return {
|
||||||
|
Backspace: backspaceToParagraph(type),
|
||||||
"Mod-a": selectAll(type),
|
"Mod-a": selectAll(type),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import type { Dictionary } from "~/hooks/useDictionary";
|
|||||||
import { UserPreferences } from "../../types";
|
import { UserPreferences } from "../../types";
|
||||||
import Storage from "../../utils/Storage";
|
import Storage from "../../utils/Storage";
|
||||||
import { isMac } from "../../utils/browser";
|
import { isMac } from "../../utils/browser";
|
||||||
|
import backspaceToParagraph from "../commands/backspaceToParagraph";
|
||||||
import {
|
import {
|
||||||
newlineInCode,
|
newlineInCode,
|
||||||
insertSpaceTab,
|
insertSpaceTab,
|
||||||
@@ -255,6 +256,7 @@ export default class CodeFence extends Node {
|
|||||||
|
|
||||||
return newlineInCode(state, dispatch);
|
return newlineInCode(state, dispatch);
|
||||||
},
|
},
|
||||||
|
Backspace: backspaceToParagraph(type),
|
||||||
"Shift-Enter": newlineInCode,
|
"Shift-Enter": newlineInCode,
|
||||||
"Mod-a": selectAll(type),
|
"Mod-a": selectAll(type),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user