diff --git a/docs/src/demos/Experiments/Annotation/index.spec.js b/docs/src/demos/Experiments/Annotation/index.spec.js index 593a5e738..f1b0a3aed 100644 --- a/docs/src/demos/Experiments/Annotation/index.spec.js +++ b/docs/src/demos/Experiments/Annotation/index.spec.js @@ -1,6 +1,6 @@ -context('/demos/Extensions/Annotations', () => { +context('/demos/Experiments/Annotation', () => { before(() => { - cy.visit('/demos/Extensions/Annotations') + cy.visit('/demos/Experiments/Annotation') }) // TODO: Write tests diff --git a/docs/src/demos/Experiments/Annotation/index.vue b/docs/src/demos/Experiments/Annotation/index.vue index 9ab118117..7ba445ae3 100644 --- a/docs/src/demos/Experiments/Annotation/index.vue +++ b/docs/src/demos/Experiments/Annotation/index.vue @@ -1,17 +1,33 @@ @@ -21,6 +37,10 @@ import { Editor, EditorContent } from '@tiptap/vue-starter-kit' import Document from '@tiptap/extension-document' import Paragraph from '@tiptap/extension-paragraph' import Text from '@tiptap/extension-text' +import Collaboration from '@tiptap/extension-collaboration' +import Bold from '@tiptap/extension-bold' +import Heading from '@tiptap/extension-heading' +import * as Y from 'yjs' import Annotation from './extension' export default { @@ -31,19 +51,29 @@ export default { data() { return { editor: null, + anotherEditor: null, comments: [], + ydoc: null, } }, mounted() { + this.ydoc = new Y.Doc() + this.editor = new Editor({ extensions: [ Document, Paragraph, Text, + Bold, + Heading, Annotation.configure({ + document: this.ydoc, onUpdate: items => { this.comments = items }, }), + Collaboration.configure({ + document: this.ydoc, + }), ], content: `

@@ -54,21 +84,49 @@ export default {

`, }) + + this.anotherEditor = new Editor({ + extensions: [ + Document, + Paragraph, + Text, + Bold, + Heading, + Annotation.configure({ + document: this.ydoc, + }), + Collaboration.configure({ + document: this.ydoc, + }), + ], + }) }, methods: { - addAnnotation() { - const content = prompt('Annotation', '') + addComment() { + const content = prompt('Comment', '') this.editor.commands.addAnnotation(content) }, - deleteAnnotation(id) { + addAnotherComment() { + const content = prompt('Comment', '') + + this.anotherEditor.commands.addAnnotation(content) + }, + deleteComment(id) { this.editor.commands.deleteAnnotation(id) }, }, + computed: { + json() { + return this.ydoc.toJSON() + }, + }, + beforeDestroy() { this.editor.destroy() + this.anotherEditor.destroy() }, } diff --git a/docs/src/demos/Experiments/Comments/index.spec.js b/docs/src/demos/Experiments/Comments/index.spec.js deleted file mode 100644 index 109134a01..000000000 --- a/docs/src/demos/Experiments/Comments/index.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -context('/demos/Examples/Annotations', () => { - before(() => { - cy.visit('/demos/Examples/Annotations') - }) - - // TODO: Write tests -}) diff --git a/docs/src/demos/Experiments/Comments/index.vue b/docs/src/demos/Experiments/Comments/index.vue deleted file mode 100644 index 9945c558a..000000000 --- a/docs/src/demos/Experiments/Comments/index.vue +++ /dev/null @@ -1,146 +0,0 @@ - - - - - diff --git a/docs/src/docPages/experiments.md b/docs/src/docPages/experiments.md index b19be9421..ecc42f16e 100644 --- a/docs/src/docPages/experiments.md +++ b/docs/src/docPages/experiments.md @@ -3,7 +3,6 @@ Congratulations! You’ve found our playground with a list of experiments. Be aw ## New * [Linter](/experiments/linter) -* [Annotation](/experiments/annotation) * [Comments](/experiments/comments) * [Color](/experiments/color) * [Commands](/experiments/commands) diff --git a/docs/src/docPages/experiments/annotation.md b/docs/src/docPages/experiments/annotation.md deleted file mode 100644 index 4d4ebbe50..000000000 --- a/docs/src/docPages/experiments/annotation.md +++ /dev/null @@ -1,5 +0,0 @@ -# Annotation - -⚠️ Experiment - - diff --git a/docs/src/docPages/experiments/comments.md b/docs/src/docPages/experiments/comments.md index 42fda4361..0a051e83f 100644 --- a/docs/src/docPages/experiments/comments.md +++ b/docs/src/docPages/experiments/comments.md @@ -2,4 +2,4 @@ ⚠️ Experiment - +