import { NodeType } from 'prosemirror-model' import { RawCommands } from '../types' declare module '@tiptap-es5/core' { interface Commands { replace: { /** * Replaces text with a node. */ replace: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, } } } export const replace: RawCommands['replace'] = (typeOrName, attributes = {}) => ({ state, commands }) => { console.warn('[tiptap warn]: replace() is deprecated. please use insertContent() instead.') const { from, to } = state.selection const range = { from, to } return commands.replaceRange(range, typeOrName, attributes) }