Merge branch 'main' of https://github.com/ueberdosis/tiptap-next into feature/suggestions

# Conflicts:
#	docs/src/docPages/api/nodes/mention.md
#	docs/src/links.yaml
This commit is contained in:
Philipp Kühn
2021-01-19 22:33:22 +01:00
46 changed files with 1207 additions and 66 deletions

View File

@@ -18,7 +18,6 @@ export default {
data() {
return {
editor: null,
provider: null,
}
},
@@ -36,7 +35,6 @@ export default {
beforeDestroy() {
this.editor.destroy()
this.provider.destroy()
},
}
</script>

View File

@@ -18,6 +18,12 @@
<div v-if="description" class="form__item form__item--description">
<editor-content :editor="description" />
</div>
<div class="form__label">
JSON
</div>
<div class="form__item form__item--json">
<code>{{ json }}</code>
</div>
</div>
</template>
@@ -31,7 +37,7 @@ import TaskList from '@tiptap/extension-task-list'
import TaskItem from '@tiptap/extension-task-item'
import Collaboration from '@tiptap/extension-collaboration'
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { yDocToProsemirrorJSON } from 'y-prosemirror'
const ParagraphDocument = Document.extend({
content: 'paragraph',
@@ -55,13 +61,12 @@ export default {
title: null,
tasks: null,
description: null,
ydoc: null,
}
},
mounted() {
const ydoc = new Y.Doc()
this.provider = new WebsocketProvider('wss://websocket.tiptap.dev', 'tiptap-multiple-editors-example', ydoc)
this.ydoc = new Y.Doc()
this.title = new Editor({
extensions: [
@@ -69,10 +74,11 @@ export default {
Paragraph,
Text,
Collaboration.configure({
document: ydoc,
document: this.ydoc,
field: 'title',
}),
],
content: '<p>No matter what you do, thisll be a single paragraph.',
})
this.tasks = new Editor({
@@ -83,10 +89,17 @@ export default {
TaskList,
CustomTaskItem,
Collaboration.configure({
document: ydoc,
document: this.ydoc,
field: 'tasks',
}),
],
content: `
<ul data-type="taskList">
<li data-type="taskItem" data-checked="true">And this</li>
<li data-type="taskItem" data-checked="false">is a task list</li>
<li data-type="taskItem" data-checked="false">and only a task list.</li>
</ul>
`,
})
this.description = new Editor({
@@ -95,13 +108,28 @@ export default {
Paragraph,
Text,
Collaboration.configure({
document: ydoc,
document: this.ydoc,
field: 'description',
}),
],
content: `
<p>
This can be lengthy text.
</p>
`,
})
},
computed: {
json() {
return {
title: yDocToProsemirrorJSON(this.ydoc, 'title'),
tasks: yDocToProsemirrorJSON(this.ydoc, 'tasks'),
description: yDocToProsemirrorJSON(this.ydoc, 'description'),
}
},
},
beforeDestroy() {
this.title.destroy()
this.tasks.destroy()
@@ -150,5 +178,23 @@ export default {
&--title {
font-size: 1.6rem;
}
&--json {
background: #0D0D0D;
color: #FFF;
font-size: 0.8rem;
}
}
pre {
font-family: 'JetBrainsMono', monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
background: none;
font-size: 0.8rem;
}
}
</style>

View File

@@ -43,8 +43,13 @@ export default {
],
content: `
<ul data-type="taskList">
<li data-type="taskItem" data-checked="true">A list item</li>
<li data-type="taskItem" data-checked="false">And another one</li>
<li data-type="taskItem" data-checked="true">flour
<li data-type="taskItem" data-checked="false">baking powder</li>
<li data-type="taskItem" data-checked="false">salt</li>
<li data-type="taskItem" data-checked="false">sugar</li>
<li data-type="taskItem" data-checked="false">milk</li>
<li data-type="taskItem" data-checked="false">eggs</li>
<li data-type="taskItem" data-checked="false">butter</li>
</ul>
`,
})
@@ -70,5 +75,9 @@ ul[data-type="taskList"] {
margin-right: 0.5rem;
}
}
input[type="checkbox"] {
cursor: pointer;
}
}
</style>