From 8f6ae0e69e10d5e24e94f7d7f7290ba149860f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sat, 21 Nov 2020 00:00:57 +0100 Subject: [PATCH] replace toggleBlockType with toggleNode( --- docs/src/docPages/api/commands.md | 4 ++-- docs/src/docPages/guide/build-custom-extensions.md | 2 +- .../core/src/commands/{toggleBlockType.ts => toggleNode.ts} | 2 +- packages/core/src/extensions/commands.ts | 4 ++-- packages/extension-code-block/src/index.ts | 2 +- packages/extension-heading/src/index.ts | 2 +- packages/extension-paragraph/src/index.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename packages/core/src/commands/{toggleBlockType.ts => toggleNode.ts} (76%) diff --git a/docs/src/docPages/api/commands.md b/docs/src/docPages/api/commands.md index 25f2dd31..60211a10 100644 --- a/docs/src/docPages/api/commands.md +++ b/docs/src/docPages/api/commands.md @@ -110,11 +110,11 @@ Have a look at all of the core commands listed below. They should give you a goo | .extendMarkRange() | Extends the text selection to the current mark. | | .resetNodeAttributes() | Resets all node attributes to the default value. | | .selectParentNode() | Select the parent node. | -| .setNode() | Replace a given range with a node. | | .setMark() | Add a mark with new attributes. | +| .setNode() | Replace a given range with a node. | | .splitBlock() | Forks a new node from an existing node. | -| .toggleBlockType() | Toggle a node with another node. | | .toggleMark() | Toggle a mark on and off. | +| .toggleNode() | Toggle a node with another node. | | .toggleWrap() | Wraps nodes in another node, or removes an existing wrap. | | .unsetMark() | Remove a mark in the current selection. | | .unsetMarks() | Remove all marks in the current selection. | diff --git a/docs/src/docPages/guide/build-custom-extensions.md b/docs/src/docPages/guide/build-custom-extensions.md index 15e7d770..400d01bf 100644 --- a/docs/src/docPages/guide/build-custom-extensions.md +++ b/docs/src/docPages/guide/build-custom-extensions.md @@ -275,7 +275,7 @@ const CustomParagraph = Paragraph.extend({ addCommands() { return { paragraph: () => ({ commands }) => { - return commands.toggleBlockType('paragraph', 'paragraph') + return commands.toggleNode('paragraph', 'paragraph') }, } }, diff --git a/packages/core/src/commands/toggleBlockType.ts b/packages/core/src/commands/toggleNode.ts similarity index 76% rename from packages/core/src/commands/toggleBlockType.ts rename to packages/core/src/commands/toggleNode.ts index 9ab8ea3b..d4bff993 100644 --- a/packages/core/src/commands/toggleBlockType.ts +++ b/packages/core/src/commands/toggleNode.ts @@ -6,7 +6,7 @@ import getNodeType from '../utils/getNodeType' /** * Toggle a node with another node. */ -export const toggleBlockType = (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attrs = {}): Command => ({ state, commands }) => { +export const toggleNode = (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attrs = {}): Command => ({ state, commands }) => { const type = getNodeType(typeOrName, state.schema) const toggleType = getNodeType(toggleTypeOrName, state.schema) const isActive = nodeIsActive(state, type, attrs) diff --git a/packages/core/src/extensions/commands.ts b/packages/core/src/extensions/commands.ts index 6029e4f1..c99c2ff3 100644 --- a/packages/core/src/extensions/commands.ts +++ b/packages/core/src/extensions/commands.ts @@ -21,9 +21,9 @@ import * as setNode from '../commands/setNode' import * as sinkListItem from '../commands/sinkListItem' import * as splitBlock from '../commands/splitBlock' import * as splitListItem from '../commands/splitListItem' -import * as toggleBlockType from '../commands/toggleBlockType' import * as toggleList from '../commands/toggleList' import * as toggleMark from '../commands/toggleMark' +import * as toggleNode from '../commands/toggleNode' import * as toggleWrap from '../commands/toggleWrap' import * as unsetMark from '../commands/unsetMark' import * as unsetMarks from '../commands/unsetMarks' @@ -56,9 +56,9 @@ export const Commands = Extension.create({ ...sinkListItem, ...splitBlock, ...splitListItem, - ...toggleBlockType, ...toggleList, ...toggleMark, + ...toggleNode, ...toggleWrap, ...unsetMark, ...unsetMarks, diff --git a/packages/extension-code-block/src/index.ts b/packages/extension-code-block/src/index.ts index 679dab1e..12856e88 100644 --- a/packages/extension-code-block/src/index.ts +++ b/packages/extension-code-block/src/index.ts @@ -84,7 +84,7 @@ const CodeBlock = Node.create({ * Toggle a code block */ toggleCodeBlock: (attributes?: { language: string }): Command => ({ commands }) => { - return commands.toggleBlockType('codeBlock', 'paragraph', attributes) + return commands.toggleNode('codeBlock', 'paragraph', attributes) }, } }, diff --git a/packages/extension-heading/src/index.ts b/packages/extension-heading/src/index.ts index 809afd23..553468d1 100644 --- a/packages/extension-heading/src/index.ts +++ b/packages/extension-heading/src/index.ts @@ -70,7 +70,7 @@ const Heading = Node.create({ return false } - return commands.toggleBlockType('heading', 'paragraph', attributes) + return commands.toggleNode('heading', 'paragraph', attributes) }, } }, diff --git a/packages/extension-paragraph/src/index.ts b/packages/extension-paragraph/src/index.ts index ffe062c1..b8804177 100644 --- a/packages/extension-paragraph/src/index.ts +++ b/packages/extension-paragraph/src/index.ts @@ -33,7 +33,7 @@ const Paragraph = Node.create({ * Toggle a paragraph */ setParagraph: (): Command => ({ commands }) => { - return commands.toggleBlockType('paragraph', 'paragraph') + return commands.toggleNode('paragraph', 'paragraph') }, } },