Files
tiptap/packages/core/src/commands/insertContent.ts
2021-06-04 21:56:29 +02:00

17 lines
474 B
TypeScript

import { RawCommands, Content } from '../types'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
insertContent: {
/**
* Insert a node or string of HTML at the current position.
*/
insertContent: (value: Content) => ReturnType,
}
}
}
export const insertContent: RawCommands['insertContent'] = value => ({ tr, commands }) => {
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value)
}