mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
replace toggleBlockType with toggleNode(
This commit is contained in:
parent
540b0656f3
commit
8f6ae0e69e
@ -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. |
|
||||
|
@ -275,7 +275,7 @@ const CustomParagraph = Paragraph.extend({
|
||||
addCommands() {
|
||||
return {
|
||||
paragraph: () => ({ commands }) => {
|
||||
return commands.toggleBlockType('paragraph', 'paragraph')
|
||||
return commands.toggleNode('paragraph', 'paragraph')
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -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)
|
@ -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,
|
||||
|
@ -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)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -70,7 +70,7 @@ const Heading = Node.create({
|
||||
return false
|
||||
}
|
||||
|
||||
return commands.toggleBlockType('heading', 'paragraph', attributes)
|
||||
return commands.toggleNode('heading', 'paragraph', attributes)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -33,7 +33,7 @@ const Paragraph = Node.create({
|
||||
* Toggle a paragraph
|
||||
*/
|
||||
setParagraph: (): Command => ({ commands }) => {
|
||||
return commands.toggleBlockType('paragraph', 'paragraph')
|
||||
return commands.toggleNode('paragraph', 'paragraph')
|
||||
},
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user