14 lines
293 B
TypeScript
14 lines
293 B
TypeScript
import { Editor, Content } from '@tiptap/react'
|
|
|
|
export function insertContent(editor: Editor | null, ...contents: Content[]) {
|
|
if (!editor) {
|
|
return
|
|
}
|
|
|
|
let e = editor.chain()
|
|
for (const content of contents) {
|
|
e = e.createParagraphNear().insertContent(content)
|
|
}
|
|
e.run()
|
|
}
|