fix: add CreateNodeFromContentOptions to insertContent (#1678)

*  Add CreateNodeFromContentOptions  to insertContent

* 📝 Add it to the doc
This commit is contained in:
castroCrea
2021-08-09 14:40:17 +01:00
committed by GitHub
parent a0444b5ec3
commit aabdfd6f7d
4 changed files with 48 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import { CreateNodeFromContentOptions } from '../helpers/createNodeFromContent'
import { RawCommands, Content } from '../types'
declare module '@tiptap/core' {
@@ -6,11 +7,11 @@ declare module '@tiptap/core' {
/**
* Insert a node or string of HTML at the current position.
*/
insertContent: (value: Content) => ReturnType,
insertContent: (value: Content, options?: CreateNodeFromContentOptions) => ReturnType,
}
}
}
export const insertContent: RawCommands['insertContent'] = value => ({ tr, commands }) => {
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value)
export const insertContent: RawCommands['insertContent'] = (value, options) => ({ tr, commands }) => {
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options)
}