diff --git a/docs/src/demos/Examples/Images/React/index.jsx b/docs/src/demos/Examples/Images/React/index.jsx new file mode 100644 index 00000000..52dc8c31 --- /dev/null +++ b/docs/src/demos/Examples/Images/React/index.jsx @@ -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: ` +

This is a basic example of implementing images. Drag to re-order.

+ + + `, + }) + + const addImage = () => { + const url = window.prompt('URL') + + if (url) { + editor.chain().focus().setImage({ src: url }).run() + } + } + + return ( +
+ + +
+ ) +} diff --git a/docs/src/demos/Examples/Images/React/styles.scss b/docs/src/demos/Examples/Images/React/styles.scss new file mode 100644 index 00000000..3678b51a --- /dev/null +++ b/docs/src/demos/Examples/Images/React/styles.scss @@ -0,0 +1,15 @@ +/* Basic editor styles */ +.ProseMirror { + > * + * { + margin-top: 0.75em; + } + + img { + max-width: 100%; + height: auto; + + &.ProseMirror-selectednode { + outline: 3px solid #68CEF8; + } + } +} diff --git a/docs/src/demos/Examples/Images/Vue/index.spec.js b/docs/src/demos/Examples/Images/Vue/index.spec.js new file mode 100644 index 00000000..ef29c3f1 --- /dev/null +++ b/docs/src/demos/Examples/Images/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/Images/index.vue b/docs/src/demos/Examples/Images/Vue/index.vue similarity index 100% rename from docs/src/demos/Examples/Images/index.vue rename to docs/src/demos/Examples/Images/Vue/index.vue diff --git a/docs/src/demos/Examples/Images/index.spec.js b/docs/src/demos/Examples/Images/index.spec.js deleted file mode 100644 index 40cfc04b..00000000 --- a/docs/src/demos/Examples/Images/index.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -context('/demos/Examples/Images', () => { - before(() => { - cy.visit('/demos/Examples/Images') - }) - - // TODO: Write tests -}) diff --git a/docs/src/docPages/examples/images.md b/docs/src/docPages/examples/images.md index 3855995a..a88117b5 100644 --- a/docs/src/docPages/examples/images.md +++ b/docs/src/docPages/examples/images.md @@ -8,4 +8,7 @@ Though thousands of developers use tiptap every day, it’s still not our full-t [Become a sponsor on GitHub →](https://github.com/sponsors/ueberdosis) ::: - +