rename toggleNode to toggleBlockType

This commit is contained in:
Philipp Kühn
2020-09-24 22:27:17 +02:00
parent 2d0c5eb737
commit 570e67b085
8 changed files with 10 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ editor.chain().focus().bold().run()
| .replaceWithNode() | Replace a given range with a node. |
| .selectParentNode() | Select the parent node. |
| .toggleMark() | Toggle a mark on and off. |
| .toggleNode() | Toggle a node with another node. |
| .toggleBlockType() | Toggle a node with another node. |
| .updateMark() | Update a mark with new attributes. |
### Selection

View File

@@ -47,7 +47,7 @@ import Paragraph from '@tiptap/extension-paragraph'
const CustomParagraph = Paragraph()
.commands(() => ({
paragraph: () => ({ commands }) => {
return commands.toggleNode(name, 'paragraph')
return commands.toggleBlockType(name, 'paragraph')
},
}))
.create()

View File

@@ -14,7 +14,7 @@ export { selectParentNode } from './selectParentNode'
export { setContent } from './setContent'
export { sinkListItem } from './sinkListItem'
export { splitListItem } from './splitListItem'
export { toggleBlockType } from './toggleBlockType'
export { toggleList } from './toggleList'
export { toggleMark } from './toggleMark'
export { toggleNode } from './toggleNode'
export { updateMark } from './updateMark'

View File

@@ -4,7 +4,7 @@ import { Command } from '../Editor'
import nodeIsActive from '../utils/nodeIsActive'
import getNodeType from '../utils/getNodeType'
type ToggleNodeCommand = (
type ToggleBlockTypeCommand = (
typeOrName: string | NodeType,
toggleType: string | NodeType,
attrs?: {}
@@ -12,11 +12,11 @@ type ToggleNodeCommand = (
declare module '../Editor' {
interface Commands {
toggleNode: ToggleNodeCommand,
toggleBlockType: ToggleBlockTypeCommand,
}
}
export const toggleNode: ToggleNodeCommand = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state, dispatch }) => {
export const toggleBlockType: ToggleBlockTypeCommand = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state, dispatch }) => {
const type = getNodeType(typeOrName, state.schema)
const toggleType = getNodeType(toggleTypeOrName, state.schema)
const isActive = nodeIsActive(state, type, attrs)

View File

@@ -25,7 +25,7 @@ export default new Node()
}))
.commands(({ name }) => ({
[name]: attrs => ({ commands }) => {
return commands.toggleNode(name, 'paragraph', attrs)
return commands.toggleBlockType(name, 'paragraph', attrs)
},
}))
.keys(({ editor }) => ({

View File

@@ -25,7 +25,7 @@ export default new Node()
}))
.commands(({ name }) => ({
codeBlock: attrs => ({ commands }) => {
return commands.toggleNode(name, 'paragraph', attrs)
return commands.toggleBlockType(name, 'paragraph', attrs)
},
}))
.keys(({ editor }) => ({

View File

@@ -39,7 +39,7 @@ export default new Node<HeadingOptions>()
}))
.commands(({ name }) => ({
[name]: attrs => ({ commands }) => {
return commands.toggleNode(name, 'paragraph', attrs)
return commands.toggleBlockType(name, 'paragraph', attrs)
},
}))
// TODO: Keyboard Shortcuts

View File

@@ -20,7 +20,7 @@ export default new Node()
}))
.commands(({ name }) => ({
[name]: () => ({ commands }) => {
return commands.toggleNode(name, 'paragraph')
return commands.toggleBlockType(name, 'paragraph')
},
}))
.keys(({ editor }) => ({