Files
tiptap/packages/core/src/commands/insertContent.ts
castroCrea aabdfd6f7d fix: add CreateNodeFromContentOptions to insertContent (#1678)
*  Add CreateNodeFromContentOptions  to insertContent

* 📝 Add it to the doc
2021-08-09 15:40:17 +02:00

18 lines
614 B
TypeScript

import { CreateNodeFromContentOptions } from '../helpers/createNodeFromContent'
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, options?: CreateNodeFromContentOptions) => ReturnType,
}
}
}
export const insertContent: RawCommands['insertContent'] = (value, options) => ({ tr, commands }) => {
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options)
}