add Commands interface
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { wrapIn as originalWrapIn } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../types'
|
||||
import { AnyObject, Command, Commands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
/**
|
||||
* Wraps nodes in another node.
|
||||
*/
|
||||
export const wrapIn = (typeOrName: string | NodeType, attributes = {}): Command => ({ state, dispatch }) => {
|
||||
export const wrapIn: Commands['wrapIn'] = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
|
||||
const type = getNodeType(typeOrName, state.schema)
|
||||
const isActive = isNodeActive(state, type, attributes)
|
||||
|
||||
@@ -17,3 +17,9 @@ export const wrapIn = (typeOrName: string | NodeType, attributes = {}): Command
|
||||
|
||||
return originalWrapIn(type, attributes)(state, dispatch)
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
wrapIn: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user