From e5bac5043c570ffcfde0c6fa964f3c7614a65294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 25 Jun 2021 12:00:39 +0200 Subject: [PATCH] add react demo for formatting --- .../demos/Examples/Formatting/React/index.jsx | 98 +++++++++++++++++++ .../Examples/Formatting/React/styles.scss | 62 ++++++++++++ .../Examples/Formatting/Vue/index.spec.js | 7 ++ .../Examples/Formatting/{ => Vue}/index.vue | 0 .../demos/Examples/Formatting/index.spec.js | 7 -- docs/src/docPages/examples/formatting.md | 5 +- 6 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 docs/src/demos/Examples/Formatting/React/index.jsx create mode 100644 docs/src/demos/Examples/Formatting/React/styles.scss create mode 100644 docs/src/demos/Examples/Formatting/Vue/index.spec.js rename docs/src/demos/Examples/Formatting/{ => Vue}/index.vue (100%) delete mode 100644 docs/src/demos/Examples/Formatting/index.spec.js diff --git a/docs/src/demos/Examples/Formatting/React/index.jsx b/docs/src/demos/Examples/Formatting/React/index.jsx new file mode 100644 index 00000000..120bf7e0 --- /dev/null +++ b/docs/src/demos/Examples/Formatting/React/index.jsx @@ -0,0 +1,98 @@ +import React from 'react' +import { useEditor, EditorContent } from '@tiptap/react' +import StarterKit from '@tiptap/starter-kit' +import TextAlign from '@tiptap/extension-text-align' +import Highlight from '@tiptap/extension-highlight' +import './styles.scss' + +const MenuBar = ({ editor }) => { + if (!editor) { + return null + } + + return ( + <> + + + + + + + + + + + + + + ) +} + +export default () => { + const editor = useEditor({ + extensions: [ + StarterKit, + TextAlign.configure({ + types: ['heading', 'paragraph'], + }), + Highlight, + ], + content: ` +

+ Devs Just Want to Have Fun by Cyndi Lauper +

+

+ I come home in the morning light
+ My mother says, “When you gonna live your life right?”
+ Oh mother dear we’re not the fortunate ones
+ And devs, they wanna have fun
+ Oh devs just want to have fun

+

+ The phone rings in the middle of the night
+ My father yells, "What you gonna do with your life?"
+ Oh daddy dear, you know you’re still number one
+ But girlsdevs, they wanna have fun
+ Oh devs just want to have +

+

+ That’s all they really want
+ Some fun
+ When the working day is done
+ Oh devs, they wanna have fun
+ Oh devs just wanna have fun
+ (devs, they wanna, wanna have fun, devs wanna have) +

+ `, + }) + + return ( +
+ + +
+ ) +} diff --git a/docs/src/demos/Examples/Formatting/React/styles.scss b/docs/src/demos/Examples/Formatting/React/styles.scss new file mode 100644 index 00000000..9d4975f5 --- /dev/null +++ b/docs/src/demos/Examples/Formatting/React/styles.scss @@ -0,0 +1,62 @@ +/* Basic editor styles */ +.ProseMirror { + margin-top: 1rem; + + > * + * { + margin-top: 0.75em; + } + + ul, + ol { + padding: 0 1rem; + } + + h1, + h2, + h3, + h4, + h5, + h6 { + line-height: 1.1; + } + + code { + background-color: rgba(#616161, 0.1); + color: #616161; + } + + pre { + background: #0D0D0D; + color: #FFF; + font-family: 'JetBrainsMono', monospace; + padding: 0.75rem 1rem; + border-radius: 0.5rem; + + code { + color: inherit; + padding: 0; + background: none; + font-size: 0.8rem; + } + } + + mark { + background-color: #FAF594; + } + + img { + max-width: 100%; + height: auto; + } + + blockquote { + padding-left: 1rem; + border-left: 2px solid rgba(#0D0D0D, 0.1); + } + + hr { + border: none; + border-top: 2px solid rgba(#0D0D0D, 0.1); + margin: 2rem 0; + } +} diff --git a/docs/src/demos/Examples/Formatting/Vue/index.spec.js b/docs/src/demos/Examples/Formatting/Vue/index.spec.js new file mode 100644 index 00000000..ef29c3f1 --- /dev/null +++ b/docs/src/demos/Examples/Formatting/Vue/index.spec.js @@ -0,0 +1,7 @@ +context('/demos/Examples/Vue', () => { + before(() => { + cy.visit('/demos/Examples/Vue') + }) + + // TODO: Write tests +}) diff --git a/docs/src/demos/Examples/Formatting/index.vue b/docs/src/demos/Examples/Formatting/Vue/index.vue similarity index 100% rename from docs/src/demos/Examples/Formatting/index.vue rename to docs/src/demos/Examples/Formatting/Vue/index.vue diff --git a/docs/src/demos/Examples/Formatting/index.spec.js b/docs/src/demos/Examples/Formatting/index.spec.js deleted file mode 100644 index 0e89659b..00000000 --- a/docs/src/demos/Examples/Formatting/index.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -context('/demos/Examples/Formatting', () => { - before(() => { - cy.visit('/demos/Examples/Formatting') - }) - - // TODO: Write tests -}) diff --git a/docs/src/docPages/examples/formatting.md b/docs/src/docPages/examples/formatting.md index e6e0f8ce..48f58d99 100644 --- a/docs/src/docPages/examples/formatting.md +++ b/docs/src/docPages/examples/formatting.md @@ -1,3 +1,6 @@ # Formatting - +