docs: update content
This commit is contained in:
@@ -1,60 +0,0 @@
|
|||||||
<template>
|
|
||||||
<node-view-wrapper class="vue-component">
|
|
||||||
<span class="label">Vue Component</span>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
<button @click="increase">
|
|
||||||
This button has been clicked {{ node.attrs.count }} times.
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</node-view-wrapper>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { NodeViewWrapper, nodeViewProps } from '@tiptap/vue-2'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
NodeViewWrapper,
|
|
||||||
},
|
|
||||||
|
|
||||||
props: nodeViewProps,
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
increase() {
|
|
||||||
this.updateAttributes({
|
|
||||||
count: this.node.attrs.count + 1,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.vue-component {
|
|
||||||
background: #FAF594;
|
|
||||||
border: 3px solid #0D0D0D;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
margin: 1rem 0;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
margin-left: 1rem;
|
|
||||||
background-color: #0D0D0D;
|
|
||||||
font-size: 0.6rem;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
font-weight: bold;
|
|
||||||
text-transform: uppercase;
|
|
||||||
color: #fff;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
padding: 0.25rem 0.75rem;
|
|
||||||
border-radius: 0 0 0.5rem 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
margin-top: 1.5rem;
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import { Node, mergeAttributes } from '@tiptap/core'
|
|
||||||
import { VueNodeViewRenderer } from '@tiptap/vue-2'
|
|
||||||
import Component from './Component.vue'
|
|
||||||
|
|
||||||
export default Node.create({
|
|
||||||
name: 'vueComponent',
|
|
||||||
|
|
||||||
group: 'block',
|
|
||||||
|
|
||||||
atom: true,
|
|
||||||
|
|
||||||
addAttributes() {
|
|
||||||
return {
|
|
||||||
count: {
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
parseHTML() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
tag: 'vue-component',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
renderHTML({ HTMLAttributes }) {
|
|
||||||
return ['vue-component', mergeAttributes(HTMLAttributes)]
|
|
||||||
},
|
|
||||||
|
|
||||||
addNodeView() {
|
|
||||||
return VueNodeViewRenderer(Component)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
context('/demos/Examples/InteractiveNodeViews', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.visit('/demos/Examples/InteractiveNodeViews')
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO: Write tests
|
|
||||||
})
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<template>
|
|
||||||
<editor-content :editor="editor" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { Editor, EditorContent } from '@tiptap/vue-2'
|
|
||||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
|
||||||
import VueComponent from './Extension.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
EditorContent,
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
editor: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.editor = new Editor({
|
|
||||||
extensions: [
|
|
||||||
...defaultExtensions(),
|
|
||||||
VueComponent,
|
|
||||||
],
|
|
||||||
content: `
|
|
||||||
<p>
|
|
||||||
This is still the text editor you’re used to, but enriched with node views.
|
|
||||||
</p>
|
|
||||||
<vue-component count="0"></vue-component>
|
|
||||||
<p>
|
|
||||||
Did you see that? That’s a Vue component. We are really living in the future.
|
|
||||||
</p>
|
|
||||||
`,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeDestroy() {
|
|
||||||
this.editor.destroy()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
/* Basic editor styles */
|
|
||||||
.ProseMirror {
|
|
||||||
> * + * {
|
|
||||||
margin-top: 0.75em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -6,7 +6,7 @@ There is no extension or example yet, but it’s definitely on our list to build
|
|||||||
If you want to give it a shot yourself, you could start altering the [`Mention`](/api/nodes/mention) node. This uses the [`Suggestion`](/utilities/suggestion) utility, which should help with an autocomplete and such things.
|
If you want to give it a shot yourself, you could start altering the [`Mention`](/api/nodes/mention) node. This uses the [`Suggestion`](/utilities/suggestion) utility, which should help with an autocomplete and such things.
|
||||||
|
|
||||||
:::pro Fund the development ♥
|
:::pro Fund the development ♥
|
||||||
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for this extension, [become a sponsor and fund open-source](/sponsor).
|
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for this extension, [become a sponsor and fund our work](/sponsor).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Bring your own emoji picker
|
## Bring your own emoji picker
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Hashtag
|
# Hashtag
|
||||||
|
|
||||||
:::pro Fund the development ♥
|
:::pro Fund the development ♥
|
||||||
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for this extension, [become a sponsor and fund open-source](/sponsor).
|
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for this extension, [become a sponsor and fund our work](/sponsor).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Write a book
|
# Long texts
|
||||||
|
|
||||||
This demo has 250 paragraphs and more than 22,000 words, check the performance yourself.
|
This demo has 250 paragraphs and more than 22,000 words, check the performance yourself.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
# Images
|
# Images
|
||||||
|
|
||||||
|
:::pro Fund the development ♥
|
||||||
|
We need your support to maintain, update, support and develop tiptap 2. If you’re hoping for more features related to images, [become a sponsor and fund our work](/sponsor).
|
||||||
|
:::
|
||||||
|
|
||||||
<demo name="Examples/Images" />
|
<demo name="Examples/Images" />
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
# Interactive node views
|
# Interactive node views
|
||||||
|
|
||||||
<demo name="Examples/InteractiveNodeViews" />
|
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.
|
||||||
|
|
||||||
|
<demos :items="{
|
||||||
|
Vue: 'Guide/NodeViews/VueComponent',
|
||||||
|
React: 'Guide/NodeViews/ReactComponent',
|
||||||
|
}" />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Accessibility
|
# Accessibility
|
||||||
|
|
||||||
:::pro Fund the development ♥
|
:::pro Fund the development ♥
|
||||||
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for progress here, [become a sponsor and fund open-source](/sponsor).
|
We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for progress here, [become a sponsor and fund our work](/sponsor).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## toc
|
## toc
|
||||||
|
|||||||
@@ -61,24 +61,50 @@ You can even mix non-editable and editable text. That’s great to build complex
|
|||||||
**BUT**, that also means the cursor can’t just move from outside of the node view to the inside. Users have to manually place their cursor to edit the content inside the node view. Just so you know.
|
**BUT**, that also means the cursor can’t just move from outside of the node view to the inside. Users have to manually place their cursor to edit the content inside the node view. Just so you know.
|
||||||
|
|
||||||
## Markup
|
## Markup
|
||||||
|
But what happens if you [access the editor content](/guide/content)? If you’re working with HTML, you’ll need to tell tiptap how your node should be serialized.
|
||||||
|
|
||||||
|
The editor **does not** export the rendered JavaScript node, and for a lot of use cases you wouldn’t want that anyway.
|
||||||
|
|
||||||
|
Let’s say you have a node view which lets users add a video player and configure the appearance (autoplay, controls …). You want the interface to do that in the editor, not in the output of the editor. The output of the editor should probably only have the video player.
|
||||||
|
|
||||||
|
I know, I know, it’s not that easy. Just keep in mind, that you‘re in full control of the rendering inside the editor and of the output.
|
||||||
|
|
||||||
|
:::warning What if you store JSON?
|
||||||
|
That doesn’t apply to JSON. For the JSON, everything is stored as an object. There is no need to configure the “translation” to and from HTML.
|
||||||
|
:::
|
||||||
|
|
||||||
### Render HTML
|
### Render HTML
|
||||||
|
Okay, you’ve set up your node with an interactive node view and now you want to control the output. Even if you’re node view is pretty complex, the rendered HTML can be simple:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
renderHTML({ HTMLAttributes }) {
|
renderHTML({ HTMLAttributes }) {
|
||||||
return ['vue-component', mergeAttributes(HTMLAttributes)]
|
return ['my-custom-node', mergeAttributes(HTMLAttributes)]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Output: <my-custom-node count="1"></my-custom-node>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Make sure it’s something distinguishable, so it’s easier to restore the content from the HTML. If you just need something generic markup like a `<div>` consider to add a `data-type="my-custom-node"`.
|
||||||
|
|
||||||
### Parse HTML
|
### Parse HTML
|
||||||
|
The same applies to restoring the content. You can configure what markup you expect, that can be something completely unrelated to the node view markup. It just needs to contain all the information you want to restore.
|
||||||
|
|
||||||
|
Attributes are automagically restored, if you registered them through [`addAttributes`](/guide/extend-extensions#attributes).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// Input: <my-custom-node count="1"></my-custom-node>
|
||||||
|
|
||||||
parseHTML() {
|
parseHTML() {
|
||||||
return [{
|
return [{
|
||||||
tag: 'vue-component',
|
tag: 'my-custom-node',
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
## Reference
|
### Render JavaScript/Vue/React
|
||||||
|
But what if you want to render your actual JavaScript/Vue/React code? Consider using tiptap to render your output. Just set the editor to `editable: false` and no one will notice you’re using an editor to render the content. :-)
|
||||||
|
|
||||||
|
<!-- ## Reference
|
||||||
|
|
||||||
### dom: ?dom.Node
|
### dom: ?dom.Node
|
||||||
> The outer DOM node that represents the document node. When not given, the default strategy is used to create a DOM node.
|
> The outer DOM node that represents the document node. When not given, the default strategy is used to create a DOM node.
|
||||||
@@ -105,4 +131,4 @@ parseHTML() {
|
|||||||
> Called when a DOM mutation or a selection change happens within the view. When the change is a selection change, the record will have a type property of "selection" (which doesn't occur for native mutation records). Return false if the editor should re-read the selection or re-parse the range around the mutation, true if it can safely be ignored.
|
> Called when a DOM mutation or a selection change happens within the view. When the change is a selection change, the record will have a type property of "selection" (which doesn't occur for native mutation records). Return false if the editor should re-read the selection or re-parse the range around the mutation, true if it can safely be ignored.
|
||||||
|
|
||||||
### destroy: ?fn()
|
### destroy: ?fn()
|
||||||
> Called when the node view is removed from the editor or the whole editor is destroyed.
|
> Called when the node view is removed from the editor or the whole editor is destroyed. -->
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
## Introduction
|
## Introduction
|
||||||
tiptap would be nothing without its lively community. Contributions have always been and will always be welcome. Here is a little bit you should know, before you send your contribution:
|
tiptap would be nothing without its lively community. Contributions have always been and will always be welcome. Here is a little bit you should know, before you send your contribution:
|
||||||
|
|
||||||
|
:::warning Private repository
|
||||||
|
Currently, the repository is private. That means PRs are disabled, too. We’ll release a public version of tiptap 2 soonish, please wait with your PRs until the repository is public.
|
||||||
|
:::
|
||||||
|
|
||||||
## Welcome examples
|
## Welcome examples
|
||||||
* Failing regression tests as bug reports
|
* Failing regression tests as bug reports
|
||||||
* Documentation improvements, e. g. fix a typo, add a section
|
* Documentation improvements, e. g. fix a typo, add a section
|
||||||
|
|||||||
@@ -60,19 +60,19 @@
|
|||||||
link: /examples/images
|
link: /examples/images
|
||||||
- title: Formatting
|
- title: Formatting
|
||||||
link: /examples/formatting
|
link: /examples/formatting
|
||||||
- title: Task lists
|
- title: Tasks
|
||||||
link: /examples/todo-app
|
link: /examples/todo-app
|
||||||
- title: Lengthy texts
|
- title: Long texts
|
||||||
link: /examples/book
|
link: /examples/book
|
||||||
- title: Draw on a canvas
|
- title: Drawing
|
||||||
link: /examples/drawing
|
link: /examples/drawing
|
||||||
- title: Suggestions
|
- title: Mentions
|
||||||
link: /examples/community
|
link: /examples/community
|
||||||
- title: Minimal setup
|
- title: Minimal setup
|
||||||
link: /examples/minimal
|
link: /examples/minimal
|
||||||
- title: Savvy editor
|
- title: A clever editor
|
||||||
link: /examples/savvy
|
link: /examples/savvy
|
||||||
- title: Interactive node views
|
- title: Interactivity
|
||||||
link: /examples/interactive
|
link: /examples/interactive
|
||||||
|
|
||||||
- title: Guide
|
- title: Guide
|
||||||
@@ -96,6 +96,7 @@
|
|||||||
link: /guide/build-extensions
|
link: /guide/build-extensions
|
||||||
- title: Interactive node views
|
- title: Interactive node views
|
||||||
link: /guide/node-views
|
link: /guide/node-views
|
||||||
|
type: new
|
||||||
items:
|
items:
|
||||||
- title: With JavaScript
|
- title: With JavaScript
|
||||||
link: /guide/node-views/js
|
link: /guide/node-views/js
|
||||||
@@ -105,9 +106,8 @@
|
|||||||
type: draft
|
type: draft
|
||||||
- title: With Vue
|
- title: With Vue
|
||||||
link: /guide/node-views/vue
|
link: /guide/node-views/vue
|
||||||
- title: Examples
|
- title: A few examples
|
||||||
link: /guide/node-views/examples
|
link: /guide/node-views/examples
|
||||||
type: draft
|
|
||||||
- title: Working with TypeScript
|
- title: Working with TypeScript
|
||||||
link: /guide/typescript
|
link: /guide/typescript
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user