manifold/web/components/editor/utils.ts
2022-08-10 15:33:10 -07:00

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()
}