rename setBlockType to setNode

This commit is contained in:
Philipp Kühn
2020-11-20 23:56:41 +01:00
parent c433428fba
commit 540b0656f3
7 changed files with 20 additions and 20 deletions

View 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)
}