Add TextStyle demo for React

This commit is contained in:
svenadlung
2021-11-16 17:47:47 +01:00
parent 6b31c9c378
commit 9bfeb70848
3 changed files with 44 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("Marks/TextStyle", source);
</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
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 TextStyle from '@tiptap/extension-text-style'
export default () => {
const editor = useEditor({
extensions: [Document, Paragraph, Text, TextStyle],
content: `
<p><span>This has a &lt;span&gt; tag without a style attribute, so its thrown away.</span></p>
<p><span style="">But this one is wrapped in a &lt;span&gt; tag with an inline style attribute, so its kept - even if its empty for now.</span></p>
`,
})
if (!editor) {
return null
}
return <EditorContent editor={editor} />
}

View File

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