fix: Backspace emoji as first character in heading converts to paragraph

This commit is contained in:
Tom Moor
2023-09-14 22:19:27 -04:00
parent 924ab156f3
commit 411ab6b785

View File

@@ -9,7 +9,7 @@ import { Command } from "prosemirror-state";
* @returns A prosemirror command. * @returns A prosemirror command.
*/ */
export default function backspaceToParagraph(type: NodeType): Command { export default function backspaceToParagraph(type: NodeType): Command {
return (state, dispatch) => { return (state, dispatch, view) => {
const { $from, from, to, empty } = state.selection; const { $from, from, to, empty } = state.selection;
// if the selection has anything in it then use standard delete behavior // if the selection has anything in it then use standard delete behavior
@@ -23,8 +23,7 @@ export default function backspaceToParagraph(type: NodeType): Command {
} }
// check if we're at the beginning of the heading // check if we're at the beginning of the heading
const $pos = state.doc.resolve(from - 1); if (!view?.endOfTextblock("backward", state)) {
if ($pos.parent === $from.parent) {
return false; return false;
} }