rename setBlockType to setNode
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { setBlockType as originalSetBlockType } from 'prosemirror-commands'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
/**
|
||||
* Replace a given range with a node.
|
||||
*/
|
||||
export const setBlockType = (typeOrName: string | NodeType, attrs = {}): Command => ({ state, dispatch }) => {
|
||||
const type = getNodeType(typeOrName, state.schema)
|
||||
|
||||
return originalSetBlockType(type, attrs)(state, dispatch)
|
||||
}
|
||||
13
packages/core/src/commands/setNode.ts
Normal file
13
packages/core/src/commands/setNode.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { setBlockType } from 'prosemirror-commands'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
/**
|
||||
* Replace a given range with a node.
|
||||
*/
|
||||
export const setNode = (typeOrName: string | NodeType, attrs = {}): Command => ({ state, dispatch }) => {
|
||||
const type = getNodeType(typeOrName, state.schema)
|
||||
|
||||
return setBlockType(type, attrs)(state, dispatch)
|
||||
}
|
||||
@@ -12,8 +12,8 @@ export const toggleBlockType = (typeOrName: string | NodeType, toggleTypeOrName:
|
||||
const isActive = nodeIsActive(state, type, attrs)
|
||||
|
||||
if (isActive) {
|
||||
return commands.setBlockType(toggleType)
|
||||
return commands.setNode(toggleType)
|
||||
}
|
||||
|
||||
return commands.setBlockType(type, attrs)
|
||||
return commands.setNode(type, attrs)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ import * as resetNodeAttributes from '../commands/resetNodeAttributes'
|
||||
import * as scrollIntoView from '../commands/scrollIntoView'
|
||||
import * as selectAll from '../commands/selectAll'
|
||||
import * as selectParentNode from '../commands/selectParentNode'
|
||||
import * as setBlockType from '../commands/setBlockType'
|
||||
import * as setContent from '../commands/setContent'
|
||||
import * as setMark from '../commands/setMark'
|
||||
import * as setNode from '../commands/setNode'
|
||||
import * as sinkListItem from '../commands/sinkListItem'
|
||||
import * as splitBlock from '../commands/splitBlock'
|
||||
import * as splitListItem from '../commands/splitListItem'
|
||||
@@ -50,9 +50,9 @@ export const Commands = Extension.create({
|
||||
...scrollIntoView,
|
||||
...selectAll,
|
||||
...selectParentNode,
|
||||
...setBlockType,
|
||||
...setContent,
|
||||
...setMark,
|
||||
...setNode,
|
||||
...sinkListItem,
|
||||
...splitBlock,
|
||||
...splitListItem,
|
||||
|
||||
Reference in New Issue
Block a user