diff --git a/docs/src/demos/Guide/NodeViews/VueComponent/Component.vue b/docs/src/demos/Guide/NodeViews/VueComponent/Component.vue
index d956dc04..391fd8d4 100644
--- a/docs/src/demos/Guide/NodeViews/VueComponent/Component.vue
+++ b/docs/src/demos/Guide/NodeViews/VueComponent/Component.vue
@@ -4,7 +4,7 @@
- This button has been clicked {{ count }} times.
+ This button has been clicked {{ node.attrs.count }} times.
@@ -18,15 +18,23 @@ export default {
NodeViewWrapper,
},
- data() {
- return {
- count: 0,
- }
+ props: {
+ updateAttributes: {
+ type: Function,
+ required: true,
+ },
+
+ node: {
+ type: Object,
+ required: true,
+ },
},
methods: {
increase() {
- this.count += 1
+ this.updateAttributes({
+ count: this.node.attrs.count + 1,
+ })
},
},
}
diff --git a/docs/src/demos/Guide/NodeViews/VueComponent/index.js b/docs/src/demos/Guide/NodeViews/VueComponent/index.js
index 4e32f2bd..6dac246e 100644
--- a/docs/src/demos/Guide/NodeViews/VueComponent/index.js
+++ b/docs/src/demos/Guide/NodeViews/VueComponent/index.js
@@ -9,6 +9,14 @@ export default Node.create({
atom: true,
+ addAttributes() {
+ return {
+ count: {
+ default: 0,
+ },
+ }
+ },
+
parseHTML() {
return [
{
diff --git a/docs/src/demos/Guide/NodeViews/VueComponent/index.vue b/docs/src/demos/Guide/NodeViews/VueComponent/index.vue
index 7b7e67c5..2fcafcd9 100644
--- a/docs/src/demos/Guide/NodeViews/VueComponent/index.vue
+++ b/docs/src/demos/Guide/NodeViews/VueComponent/index.vue
@@ -26,11 +26,11 @@ export default {
],
content: `
- This is a radically reduced version of tiptap. It has support for a document, with paragraphs and text. That’s it. It’s probably too much for real minimalists though.
+ This is still the text editor you’re used to, but enriched with node views.
-
+
- The paragraph extension is not really required, but you need at least one node. Sure, that node can be something different.
+ Did you see that? That’s a Vue component. We are really living in the future.
`,
})
@@ -49,4 +49,15 @@ export default {
margin-top: 0.75em;
}
}
+
+.output {
+ background-color: #0D0D0D;
+ color: #fff;
+ padding: 1rem;
+ font-family: monospace;
+ font-size: 1.1rem;
+ border-radius: 0.5rem;
+ margin: 1rem 0;
+ position: relative;
+}
diff --git a/docs/src/demos/Guide/NodeViews/VueComponentContent/Component.vue b/docs/src/demos/Guide/NodeViews/VueComponentContent/Component.vue
new file mode 100644
index 00000000..14d3e302
--- /dev/null
+++ b/docs/src/demos/Guide/NodeViews/VueComponentContent/Component.vue
@@ -0,0 +1,47 @@
+
+
+ Vue Component
+
+
+
+
+
+
+
+
diff --git a/docs/src/demos/Guide/NodeViews/VueComponentContent/index.js b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.js
new file mode 100644
index 00000000..8d71f443
--- /dev/null
+++ b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.js
@@ -0,0 +1,35 @@
+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',
+
+ content: 'block+',
+
+ addAttributes() {
+ return {
+ count: {
+ default: 0,
+ },
+ }
+ },
+
+ parseHTML() {
+ return [
+ {
+ tag: 'vue-component',
+ },
+ ]
+ },
+
+ renderHTML({ HTMLAttributes }) {
+ return ['vue-component', mergeAttributes(HTMLAttributes)]
+ },
+
+ addNodeView() {
+ return VueNodeViewRenderer(Component)
+ },
+})
diff --git a/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue
new file mode 100644
index 00000000..c8d2e072
--- /dev/null
+++ b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
diff --git a/docs/src/docPages/guide/node-views.md b/docs/src/docPages/guide/node-views.md
index fcf1a36c..089ed32e 100644
--- a/docs/src/docPages/guide/node-views.md
+++ b/docs/src/docPages/guide/node-views.md
@@ -82,14 +82,59 @@ https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-task-item
TODO
### Render a Vue component
+```js
+import { Node } from '@tiptap/core'
+import { VueNodeViewRenderer } from '@tiptap/vue-2'
+import Component from './Component.vue'
+
+export default Node.create({
+ addNodeView() {
+ return VueNodeViewRenderer(Component)
+ },
+})
+```
+
### Access node attributes
-
-### Update attributes
-
+```js
+props: {
+ node: {
+ type: Object,
+ required: true,
+ },
+},
+```
+```js
+this.node.attrs.count
+```
+
+### Update node attributes
+
+```js
+props: {
+ updateAttributes: {
+ type: Function,
+ required: true,
+ },
+},
+```
+
+```js
+this.updateAttributes({
+ count: this.node.attrs.count + 1,
+})
+```
+
+### Adding a content editable
+
+
+
+`content: 'block+'`
+
+`atom: true`