Merge branch 'main' of https://github.com/ueberdosis/tiptap-next
This commit is contained in:
43
docs/src/demos/Examples/BubbleMenu/React/index.jsx
Normal file
43
docs/src/demos/Examples/BubbleMenu/React/index.jsx
Normal 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>
|
||||||
|
)
|
||||||
|
}
|
||||||
7
docs/src/demos/Examples/BubbleMenu/React/index.spec.js
Normal file
7
docs/src/demos/Examples/BubbleMenu/React/index.spec.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
context('/demos/Examples/BubbleMenu/React', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.visit('/demos/Examples/BubbleMenu/React')
|
||||||
|
})
|
||||||
|
|
||||||
|
// TODO: Write tests
|
||||||
|
})
|
||||||
5
docs/src/demos/Examples/BubbleMenu/React/styles.scss
Normal file
5
docs/src/demos/Examples/BubbleMenu/React/styles.scss
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.ProseMirror {
|
||||||
|
> * + * {
|
||||||
|
margin-top: 0.75em;
|
||||||
|
}
|
||||||
|
}
|
||||||
7
docs/src/demos/Examples/BubbleMenu/Vue/index.spec.js
Normal file
7
docs/src/demos/Examples/BubbleMenu/Vue/index.spec.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
context('/demos/Examples/BubbleMenu/Vue', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.visit('/demos/Examples/BubbleMenu/Vue')
|
||||||
|
})
|
||||||
|
|
||||||
|
// TODO: Write tests
|
||||||
|
})
|
||||||
60
docs/src/demos/Examples/BubbleMenu/Vue/index.vue
Normal file
60
docs/src/demos/Examples/BubbleMenu/Vue/index.vue
Normal 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. You’ll 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>
|
||||||
7
docs/src/demos/Examples/Tasks/index.spec.js
Normal file
7
docs/src/demos/Examples/Tasks/index.spec.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
context('/demos/Examples/Tasks', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.visit('/demos/Examples/Tasks')
|
||||||
|
})
|
||||||
|
|
||||||
|
// TODO: Write tests
|
||||||
|
})
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
context('/demos/Examples/TodoApp', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.visit('/demos/Examples/TodoApp')
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO: Write tests
|
|
||||||
})
|
|
||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
],
|
],
|
||||||
content: `
|
content: `
|
||||||
<p>
|
<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. You’ll see a formatting menu pop up. And as always, you are in full control about content and styling of this menu.
|
||||||
</p>
|
</p>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
[](https://www.npmjs.com/package/@tiptap/extension-bubble-menu)
|
[](https://www.npmjs.com/package/@tiptap/extension-bubble-menu)
|
||||||
[](https://npmcharts.com/compare/@tiptap/extension-bubble-menu?minimal=true)
|
[](https://npmcharts.com/compare/@tiptap/extension-bubble-menu?minimal=true)
|
||||||
|
|
||||||
This extension will make a contextual menu appear near a selection of text.
|
This extension will make a contextual menu appear near a selection of text. Use it to let users apply [marks](/api/marks) to their text selection.
|
||||||
|
|
||||||
|
As always, the markup and styling is totally up to you. The menu is positioned absolute and requires a wrapper with `position: relative`, that’s basically the only requirement though.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
```bash
|
```bash
|
||||||
@@ -14,14 +16,16 @@ yarn add @tiptap/extension-bubble-menu
|
|||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
| Option | Type | Default | Description |
|
| Option | Type | Default | Description |
|
||||||
| ------------ | ------------- | --------- | --------------------------------------------------------- |
|
| ------------ | ------------- | ------- | -------------------------------------------------------------------- |
|
||||||
| element | `HTMLElement` | `null` | The DOM element of your menu. |
|
| element | `HTMLElement` | `null` | The DOM element that contains your menu. |
|
||||||
| keepInBounds | `Boolean` | `true` | Specifies that the element is not rendered across bounds. |
|
| keepInBounds | `Boolean` | `true` | When enabled, it’s rendered inside the bounding box of the document. |
|
||||||
|
|
||||||
## Source code
|
## Source code
|
||||||
[packages/extension-bubble-menu/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-bubble-menu/)
|
[packages/extension-bubble-menu/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-bubble-menu/)
|
||||||
|
|
||||||
## Using Vanilla JavaScript
|
## Usage
|
||||||
|
|
||||||
|
### JavaScript
|
||||||
```js
|
```js
|
||||||
import { Editor } from '@tiptap/core'
|
import { Editor } from '@tiptap/core'
|
||||||
import BubbleMenu from '@tiptap/extension-bubble-menu'
|
import BubbleMenu from '@tiptap/extension-bubble-menu'
|
||||||
@@ -35,7 +39,7 @@ new Editor({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using a framework
|
### Frameworks
|
||||||
<demos :items="{
|
<demos :items="{
|
||||||
Vue: 'Extensions/BubbleMenu/Vue',
|
Vue: 'Extensions/BubbleMenu/Vue',
|
||||||
React: 'Extensions/BubbleMenu/React',
|
React: 'Extensions/BubbleMenu/React',
|
||||||
|
|||||||
6
docs/src/docPages/examples/bubble-menu.md
Normal file
6
docs/src/docPages/examples/bubble-menu.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Bubble menu
|
||||||
|
|
||||||
|
<demos :items="{
|
||||||
|
Vue: 'Examples/BubbleMenu/Vue',
|
||||||
|
React: 'Examples/BubbleMenu/React',
|
||||||
|
}" />
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Interactive node views
|
# Interactivity
|
||||||
|
|
||||||
Thanks to [node views](/guide/node-views) you can add interactivity to your nodes. If you can write it in JavaScript, you can add it to the editor.
|
Thanks to [node views](/guide/node-views) you can add interactivity to your nodes. If you can write it in JavaScript, you can add it to the editor.
|
||||||
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# Minimal
|
# Minimal setup
|
||||||
|
|
||||||
<demo name="Examples/Minimal" highlight="7-9,25-27" />
|
<demo name="Examples/Minimal" highlight="7-9,25-27" />
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# Savvy editor
|
# A clever editor
|
||||||
|
|
||||||
<demo name="Examples/Savvy" />
|
<demo name="Examples/Savvy" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Suggestions
|
# Mentions
|
||||||
|
|
||||||
<demos :items="{
|
<demos :items="{
|
||||||
Vue: 'Examples/Community/Vue',
|
Vue: 'Examples/Community/Vue',
|
||||||
3
docs/src/docPages/examples/tasks.md
Normal file
3
docs/src/docPages/examples/tasks.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Tasks
|
||||||
|
|
||||||
|
<demo name="Examples/Tasks" />
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Todo App
|
|
||||||
|
|
||||||
<demo name="Examples/TodoApp" />
|
|
||||||
@@ -53,6 +53,9 @@
|
|||||||
# type: pro
|
# type: pro
|
||||||
- title: Markdown shortcuts
|
- title: Markdown shortcuts
|
||||||
link: /examples/markdown-shortcuts
|
link: /examples/markdown-shortcuts
|
||||||
|
- title: Bubble menu
|
||||||
|
link: /examples/bubble-menu
|
||||||
|
type: new
|
||||||
- title: Tables
|
- title: Tables
|
||||||
link: /examples/tables
|
link: /examples/tables
|
||||||
# type: pro
|
# type: pro
|
||||||
@@ -61,19 +64,19 @@
|
|||||||
- title: Formatting
|
- title: Formatting
|
||||||
link: /examples/formatting
|
link: /examples/formatting
|
||||||
- title: Tasks
|
- title: Tasks
|
||||||
link: /examples/todo-app
|
link: /examples/tasks
|
||||||
- title: Long texts
|
- title: Long texts
|
||||||
link: /examples/book
|
link: /examples/book
|
||||||
- title: Drawing
|
- title: Drawing
|
||||||
link: /examples/drawing
|
link: /examples/drawing
|
||||||
- title: Mentions
|
- title: Mentions
|
||||||
link: /examples/community
|
link: /examples/suggestions
|
||||||
- title: Minimal setup
|
- title: Minimal setup
|
||||||
link: /examples/minimal
|
link: /examples/minimal
|
||||||
- title: A clever editor
|
- title: A clever editor
|
||||||
link: /examples/savvy
|
link: /examples/savvy
|
||||||
- title: Interactivity
|
- title: Interactivity
|
||||||
link: /examples/interactive
|
link: /examples/interactivity
|
||||||
|
|
||||||
- title: Guide
|
- title: Guide
|
||||||
items:
|
items:
|
||||||
@@ -197,6 +200,7 @@
|
|||||||
# type: draft
|
# type: draft
|
||||||
- title: BubbleMenu
|
- title: BubbleMenu
|
||||||
link: /api/extensions/bubble-menu
|
link: /api/extensions/bubble-menu
|
||||||
|
type: new
|
||||||
- title: CharacterCount
|
- title: CharacterCount
|
||||||
link: /api/extensions/character-count
|
link: /api/extensions/character-count
|
||||||
- title: Collaboration
|
- title: Collaboration
|
||||||
|
|||||||
Reference in New Issue
Block a user