Add Text demo for React
This commit is contained in:
15
demos/src/Nodes/Text/React/index.html
Normal file
15
demos/src/Nodes/Text/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("Nodes/Text", source);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
20
demos/src/Nodes/Text/React/index.jsx
Normal file
20
demos/src/Nodes/Text/React/index.jsx
Normal 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'
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
const editor = useEditor({
|
||||||
|
extensions: [Document, Paragraph, Text],
|
||||||
|
content: `
|
||||||
|
<p>The Text extension is required, at least if you want to have text in your text editor and that’s very likely.</p>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!editor) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return <EditorContent editor={editor} />
|
||||||
|
}
|
||||||
15
demos/src/Nodes/Text/React/index.spec.js
Normal file
15
demos/src/Nodes/Text/React/index.spec.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
context('/src/Nodes/Text/React/', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.visit('/src/Nodes/Text/React/')
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
|
editor.commands.clearContent()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('text should be wrapped in a paragraph by default', () => {
|
||||||
|
cy.get('.ProseMirror').type('Example Text').find('p').should('contain', 'Example Text')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user