Files
tiptap/packages/core/src/commands/wrapIn.ts
Dominik 8c6751f0c6 add precommit hook for linting and automatic eslint fixes + update eslint packages (#2862)
* chore: add precommit hook for eslint fixes, fix linting issues
* chore: add eslint import sort plugin
2022-06-08 14:10:25 +02:00

23 lines
670 B
TypeScript

import { wrapIn as originalWrapIn } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { getNodeType } from '../helpers/getNodeType'
import { RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
wrapIn: {
/**
* Wraps nodes in another node.
*/
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
}
}
}
export const wrapIn: RawCommands['wrapIn'] = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
const type = getNodeType(typeOrName, state.schema)
return originalWrapIn(type, attributes)(state, dispatch)
}