mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00

* fix: enforce type imports so that the bundler ignores types * chore: add changeset * fix: export types with export type keyword
34 lines
772 B
TypeScript
34 lines
772 B
TypeScript
import { Collaboration } from '@tiptap/extension-collaboration'
|
|
import { EditorContent, useEditor } from '@tiptap/react'
|
|
import { StarterKit } from '@tiptap/starter-kit'
|
|
import React from 'react'
|
|
import * as Y from 'yjs'
|
|
|
|
import type { TNote } from './types.js'
|
|
|
|
export default ({ note }: { note: TNote }) => {
|
|
const doc = new Y.Doc()
|
|
|
|
const editor = useEditor({
|
|
content: note.defaultContent,
|
|
editorProps: {
|
|
attributes: {
|
|
class: 'textarea',
|
|
},
|
|
},
|
|
extensions: [
|
|
StarterKit.configure({
|
|
history: false, // important because history will now be handled by Y.js
|
|
}),
|
|
Collaboration.configure({
|
|
document: doc,
|
|
}),
|
|
],
|
|
})
|
|
|
|
return (
|
|
// @ts-ignore
|
|
<EditorContent editor={editor} />
|
|
)
|
|
}
|