fix: Backspace emoji as first character in heading converts to paragraph
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user