This commit is contained in:
Philipp Kühn
2021-04-01 15:57:34 +02:00
18 changed files with 161 additions and 25 deletions

View File

@@ -0,0 +1,43 @@
import React from 'react'
import { useEditor, EditorContent, BubbleMenu } from '@tiptap/react'
import { defaultExtensions } from '@tiptap/starter-kit'
import './styles.scss'
export default () => {
const editor = useEditor({
extensions: [
...defaultExtensions(),
],
content: `
<p>
Hey, try to select some text here. There will popup a menu for selecting some inline styles. Remember: you have full control about content and styling of this menu.
</p>
`,
})
return (
<div style={{ position: 'relative' }}>
{editor && <BubbleMenu editor={editor}>
<button
onClick={() => editor.chain().focus().toggleBold().run()}
className={editor.isActive('bold') ? 'is-active' : ''}
>
bold
</button>
<button
onClick={() => editor.chain().focus().toggleItalic().run()}
className={editor.isActive('italic') ? 'is-active' : ''}
>
italic
</button>
<button
onClick={() => editor.chain().focus().toggleCode().run()}
className={editor.isActive('code') ? 'is-active' : ''}
>
code
</button>
</BubbleMenu>}
<EditorContent editor={editor} />
</div>
)
}

View File

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

View File

@@ -0,0 +1,5 @@
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}

View File

@@ -0,0 +1,7 @@
context('/demos/Examples/BubbleMenu/Vue', () => {
before(() => {
cy.visit('/demos/Examples/BubbleMenu/Vue')
})
// TODO: Write tests
})

View File

@@ -0,0 +1,60 @@
<template>
<div style="position: relative">
<bubble-menu :editor="editor" v-if="editor">
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
bold
</button>
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
italic
</button>
<button @click="editor.chain().focus().toggleCode().run()" :class="{ 'is-active': editor.isActive('code') }">
code
</button>
</bubble-menu>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, BubbleMenu } from '@tiptap/vue-2'
import { defaultExtensions } from '@tiptap/starter-kit'
export default {
components: {
EditorContent,
BubbleMenu,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
...defaultExtensions(),
],
content: `
<p>
Hey, try to select some text here. Youll see a formatting menu pop up. And as always, you are in full control about content and styling of this menu.
</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
</style>

View File

@@ -0,0 +1,7 @@
context('/demos/Examples/Tasks', () => {
before(() => {
cy.visit('/demos/Examples/Tasks')
})
// TODO: Write tests
})

View File

@@ -1,7 +0,0 @@
context('/demos/Examples/TodoApp', () => {
before(() => {
cy.visit('/demos/Examples/TodoApp')
})
// TODO: Write tests
})

View File

@@ -38,7 +38,7 @@ export default {
],
content: `
<p>
Hey, try to select some text here. There will popup a menu for selecting some inline styles. Remember: you have full control about content and styling of this menu.
Hey, try to select some text here. Youll see a formatting menu pop up. And as always, you are in full control about content and styling of this menu.
</p>
`,
})