add react demo for images
This commit is contained in:
42
docs/src/demos/Examples/Images/React/index.jsx
Normal file
42
docs/src/demos/Examples/Images/React/index.jsx
Normal file
@@ -0,0 +1,42 @@
|
||||
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 Image from '@tiptap/extension-image'
|
||||
import Dropcursor from '@tiptap/extension-dropcursor'
|
||||
import './styles.scss'
|
||||
|
||||
export default () => {
|
||||
const editor = useEditor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
Image,
|
||||
Dropcursor,
|
||||
],
|
||||
content: `
|
||||
<p>This is a basic example of implementing images. Drag to re-order.</p>
|
||||
<img src="https://source.unsplash.com/8xznAGy4HcY/800x400" />
|
||||
<img src="https://source.unsplash.com/K9QHL52rE2k/800x400" />
|
||||
`,
|
||||
})
|
||||
|
||||
const addImage = () => {
|
||||
const url = window.prompt('URL')
|
||||
|
||||
if (url) {
|
||||
editor.chain().focus().setImage({ src: url }).run()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button onClick={addImage}>
|
||||
add image from URL
|
||||
</button>
|
||||
<EditorContent editor={editor} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
15
docs/src/demos/Examples/Images/React/styles.scss
Normal file
15
docs/src/demos/Examples/Images/React/styles.scss
Normal file
@@ -0,0 +1,15 @@
|
||||
/* Basic editor styles */
|
||||
.ProseMirror {
|
||||
> * + * {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
|
||||
&.ProseMirror-selectednode {
|
||||
outline: 3px solid #68CEF8;
|
||||
}
|
||||
}
|
||||
}
|
||||
7
docs/src/demos/Examples/Images/Vue/index.spec.js
Normal file
7
docs/src/demos/Examples/Images/Vue/index.spec.js
Normal file
@@ -0,0 +1,7 @@
|
||||
context('/demos/Examples/Vue', () => {
|
||||
before(() => {
|
||||
cy.visit('/demos/Examples/Vue')
|
||||
})
|
||||
|
||||
// TODO: Write tests
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
context('/demos/Examples/Images', () => {
|
||||
before(() => {
|
||||
cy.visit('/demos/Examples/Images')
|
||||
})
|
||||
|
||||
// TODO: Write tests
|
||||
})
|
||||
Reference in New Issue
Block a user