tiptap/demos/src/Tutorials/1-3-yjs/React/Note.tsx
Arnau Gómez Farell 89bd9c7d29
Fix/enforce-type-imports-so-that-bundler-ignores-types (#6132)
* fix: enforce type imports so that the bundler ignores types

* chore: add changeset

* fix: export types with export type keyword
2025-03-03 15:15:30 +01:00

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