Add Dropcursor demo for React

This commit is contained in:
Sven Adlung
2021-11-16 13:52:37 +01:00
parent d1b582cd92
commit 1cf0309f90
4 changed files with 53 additions and 0 deletions

View 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/Dropcursor", source);
</script>
</body>
</html>

View File

@@ -0,0 +1,20 @@
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 Dropcursor from '@tiptap/extension-dropcursor'
import Image from '@tiptap/extension-image'
import './styles.scss'
export default () => {
const editor = useEditor({
extensions: [Document, Paragraph, Text, Image, Dropcursor],
content: `
<p>Try to drag around the image. While you drag, the editor should show a decoration under your cursor. The so called dropcursor.</p>
<img src="https://source.unsplash.com/8xznAGy4HcY/800x400" />
`,
})
return <EditorContent editor={editor} />
}

View File

@@ -0,0 +1,7 @@
context('/src/Examples/Dropcursor/React/', () => {
before(() => {
cy.visit('/src/Examples/Dropcursor/React/')
})
// TODO: Write tests
})

View File

@@ -0,0 +1,11 @@
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
img {
height: auto;
max-width: 100%;
}
}