Skip to content

Commit

Permalink
fix: toggle heading only when same level
Browse files Browse the repository at this point in the history
Fixes #105
  • Loading branch information
dancormier committed May 11, 2022
1 parent e709127 commit 9491176
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rich-text/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ function toggleWrapIn(nodeType: NodeType) {
/** Command to set a block type to a paragraph (plain text) */
const setToTextCommand = setBlockType(schema.nodes.paragraph);

function toggleBlockType(
export function toggleBlockType(
nodeType: NodeType,
attrs?: { [key: string]: unknown }
) {
const nodeCheck = nodeTypeActive(nodeType);
const nodeCheck = nodeTypeActive(nodeType, attrs);
const setBlockTypeCommand = setBlockType(nodeType, attrs);

return (state: EditorState, dispatch: (tr: Transaction) => void) => {
Expand Down
2 changes: 2 additions & 0 deletions test/rich-text/commands/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ describe("commands", () => {
describe("toggleBlockType", () => {
it.todo("should insert a paragraph at the end of the doc");
it.todo("should not insert a paragraph at the end of the doc");
it.todo("should change heading level from 1 to 2");
it.todo("should change toggle heading off");
});

describe("insertHorizontalRuleCommand", () => {
Expand Down

0 comments on commit 9491176

Please sign in to comment.