rename toggleNode to toggleBlockType
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
@@ -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 }) => ({
|
||||
|
||||
@@ -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 }) => ({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@ export default new Node()
|
||||
}))
|
||||
.commands(({ name }) => ({
|
||||
[name]: () => ({ commands }) => {
|
||||
return commands.toggleNode(name, 'paragraph')
|
||||
return commands.toggleBlockType(name, 'paragraph')
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
|
||||
Reference in New Issue
Block a user