rename setBlockType to setNode
This commit is contained in:
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)
|
||||
}
|
||||
Reference in New Issue
Block a user