Skip to content

Commit

Permalink
fix: ignore if node is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Dec 28, 2020
1 parent 445f48c commit d26a2af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/commands/Heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class Heading {
const nodePos = selection.$from.before(1);
const node = doc.nodeAt(nodePos);

const attrs = node?.attrs ?? {};

if (this.isActive(state)) {
return setBlockType(schema.nodes.paragraph, node.attrs)(state, dispatch);
return setBlockType(schema.nodes.paragraph, attrs)(state, dispatch);
}

return setBlockType(type, { ...node.attrs, level: this.level })(state, dispatch);
return setBlockType(type, { ...attrs, level: this.level })(state, dispatch);
}

isActive(state: EditorState): boolean {
Expand Down

0 comments on commit d26a2af

Please sign in to comment.