mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 23:15:15 +08:00
Add Collaboration extension demo for React
This commit is contained in:
parent
98fa684ed7
commit
c1068aedcf
15
demos/src/Extensions/Collaboration/React/index.html
Normal file
15
demos/src/Extensions/Collaboration/React/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module">
|
||||
import setup from "../../../../setup/react.ts";
|
||||
import source from "@source";
|
||||
setup("Extensions/Collaboration", source);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
34
demos/src/Extensions/Collaboration/React/index.jsx
Normal file
34
demos/src/Extensions/Collaboration/React/index.jsx
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react'
|
||||
import { useEditor, EditorContent } from '@tiptap/react'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import Collaboration from '@tiptap/extension-collaboration'
|
||||
import Placeholder from '@tiptap/extension-placeholder'
|
||||
import * as Y from 'yjs'
|
||||
import { WebrtcProvider } from 'y-webrtc'
|
||||
import './styles.scss'
|
||||
|
||||
const ydoc = new Y.Doc()
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
|
||||
|
||||
export default () => {
|
||||
const editor = useEditor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
Collaboration.configure({
|
||||
document: ydoc,
|
||||
}),
|
||||
Placeholder.configure({
|
||||
placeholder:
|
||||
'Write something … It’ll be shared with everyone else looking at this example.',
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
return <EditorContent editor={editor} />
|
||||
}
|
7
demos/src/Extensions/Collaboration/React/index.spec.js
Normal file
7
demos/src/Extensions/Collaboration/React/index.spec.js
Normal file
@ -0,0 +1,7 @@
|
||||
context('/src/Extensions/Collaboration/React/', () => {
|
||||
before(() => {
|
||||
cy.visit('/src/Extensions/Collaboration/React/')
|
||||
})
|
||||
|
||||
// TODO: Write tests
|
||||
})
|
15
demos/src/Extensions/Collaboration/React/styles.scss
Normal file
15
demos/src/Extensions/Collaboration/React/styles.scss
Normal file
@ -0,0 +1,15 @@
|
||||
/* Basic editor styles */
|
||||
.ProseMirror {
|
||||
> * + * {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Placeholder (at the top) */
|
||||
.ProseMirror p.is-editor-empty:first-child::before {
|
||||
color: #adb5bd;
|
||||
content: attr(data-placeholder);
|
||||
float: left;
|
||||
height: 0;
|
||||
pointer-events: none;
|
||||
}
|
Loading…
Reference in New Issue
Block a user