add react demo for markdown shortcuts
This commit is contained in:
37
docs/src/demos/Examples/MarkdownShortcuts/React/index.jsx
Normal file
37
docs/src/demos/Examples/MarkdownShortcuts/React/index.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react'
|
||||
import { useEditor, EditorContent } from '@tiptap/react'
|
||||
import StarterKit from '@tiptap/starter-kit'
|
||||
import Highlight from '@tiptap/extension-highlight'
|
||||
import Typography from '@tiptap/extension-typography'
|
||||
import './styles.scss'
|
||||
|
||||
export default () => {
|
||||
const editor = useEditor({
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Highlight,
|
||||
Typography,
|
||||
],
|
||||
content: `
|
||||
<p>
|
||||
Markdown shortcuts make it easy to format the text while typing.
|
||||
</p>
|
||||
<p>
|
||||
To test that, start a new line and type <code>#</code> followed by a space to get a heading. Try <code>#</code>, <code>##</code>, <code>###</code>, <code>####</code>, <code>#####</code>, <code>######</code> for different levels.
|
||||
</p>
|
||||
<p>
|
||||
Those conventions are called input rules in tiptap. Some of them are enabled by default. Try <code>></code> for blockquotes, <code>*</code>, <code>-</code> or <code>+</code> for bullet lists, or <code>\`foobar\`</code> to highlight code, <code>~~tildes~~</code> to strike text, or <code>==equal signs==</code> to highlight text.
|
||||
</p>
|
||||
<p>
|
||||
You can overwrite existing input rules or add your own to nodes, marks and extensions.
|
||||
</p>
|
||||
<p>
|
||||
For example, we added the <code>Typography</code> extension here. Try typing <code>(c)</code> to see how it’s converted to a proper © character. You can also try <code>-></code>, <code>>></code>, <code>1/2</code>, <code>!=</code>, or <code>--</code>.
|
||||
</p>
|
||||
`,
|
||||
})
|
||||
|
||||
return (
|
||||
<EditorContent editor={editor} />
|
||||
)
|
||||
}
|
||||
53
docs/src/demos/Examples/MarkdownShortcuts/React/styles.scss
Normal file
53
docs/src/demos/Examples/MarkdownShortcuts/React/styles.scss
Normal file
@@ -0,0 +1,53 @@
|
||||
.ProseMirror {
|
||||
> * + * {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
padding-left: 1rem;
|
||||
border-left: 2px solid rgba(#0D0D0D, 0.1);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
context('/demos/Examples/MarkdownShortcuts', () => {
|
||||
context('/demos/Examples/MarkdownShortcuts/Vue', () => {
|
||||
before(() => {
|
||||
cy.visit('/demos/Examples/MarkdownShortcuts')
|
||||
cy.visit('/demos/Examples/MarkdownShortcuts/Vue')
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -1,7 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<editor-content :editor="editor" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -23,6 +21,11 @@ export default {
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Highlight,
|
||||
Typography,
|
||||
],
|
||||
content: `
|
||||
<p>
|
||||
Markdown shortcuts make it easy to format the text while typing.
|
||||
@@ -40,11 +43,6 @@ export default {
|
||||
For example, we added the <code>Typography</code> extension here. Try typing <code>(c)</code> to see how it’s converted to a proper © character. You can also try <code>-></code>, <code>>></code>, <code>1/2</code>, <code>!=</code>, or <code>--</code>.
|
||||
</p>
|
||||
`,
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Highlight,
|
||||
Typography,
|
||||
],
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# Markdown shortcuts
|
||||
|
||||
<demo name="Examples/MarkdownShortcuts" />
|
||||
<demos :items="{
|
||||
Vue: 'Examples/MarkdownShortcuts/Vue',
|
||||
React: 'Examples/MarkdownShortcuts/React',
|
||||
}" />
|
||||
|
||||
Reference in New Issue
Block a user