add mooore content
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
BUG: Headings can’t be transformed to a bullet or ordered list.
|
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
<button @click="editor.chain().focus().bold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().bold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
@@ -89,25 +88,24 @@ export default {
|
|||||||
Hi there,
|
Hi there,
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles you’d probably expect from a text editor. But wait until you see the bullet lists:
|
this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles you’d probably expect from a text editor. But wait until you see the lists:
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
With one …
|
That’s a bullet list with one …
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
… or two list items.
|
… or two list items.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
And yes, even more.
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Isn’t that great? But wait, there’s more. Let’s try a code block:
|
Isn’t that great? And all of that is editable. But wait, there’s more. Let’s try a code block:
|
||||||
</p>
|
</p>
|
||||||
<pre><code class="language-css">body { display: none; }</code></pre>
|
<pre><code class="language-css">body {
|
||||||
|
display: none;
|
||||||
|
}</code></pre>
|
||||||
<p>
|
<p>
|
||||||
I know, I know, it’s impressive. Give it a try and click a little bit around. But don’t forget to check the other examples too.
|
I know, I know, this is impressive. It’s only the tip of the iceberg though. Give it a try and click a little bit around. Don’t forget to check the other examples too.
|
||||||
</p>
|
</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
Wow, that’s amazing. Good work, boy! 👏
|
Wow, that’s amazing. Good work, boy! 👏
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button" @click="clearContent">
|
|
||||||
Clear Content
|
|
||||||
</button>
|
|
||||||
<button class="button" @click="setContent">
|
<button class="button" @click="setContent">
|
||||||
Set Content
|
Set Content
|
||||||
</button>
|
</button>
|
||||||
|
<button class="button" @click="clearContent">
|
||||||
|
Clear Content
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<editor-content :editor="editor" />
|
<editor-content :editor="editor" />
|
||||||
@@ -61,11 +61,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
clearContent() {
|
|
||||||
this.editor.clearContent(true)
|
|
||||||
this.editor.focus()
|
|
||||||
},
|
|
||||||
|
|
||||||
setContent() {
|
setContent() {
|
||||||
// You can pass a JSON document …
|
// You can pass a JSON document …
|
||||||
this.editor.setContent({
|
this.editor.setContent({
|
||||||
@@ -87,6 +82,11 @@ export default {
|
|||||||
// It’s likely that you’d like to focus the Editor after most commands.
|
// It’s likely that you’d like to focus the Editor after most commands.
|
||||||
this.editor.focus()
|
this.editor.focus()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearContent() {
|
||||||
|
this.editor.clearContent(true)
|
||||||
|
this.editor.focus()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import Document from '@tiptap/extension-document'
|
|||||||
import Paragraph from '@tiptap/extension-paragraph'
|
import Paragraph from '@tiptap/extension-paragraph'
|
||||||
import Text from '@tiptap/extension-text'
|
import Text from '@tiptap/extension-text'
|
||||||
import Code from '@tiptap/extension-code'
|
import Code from '@tiptap/extension-code'
|
||||||
|
import BulletList from '@tiptap/extension-bullet-list'
|
||||||
|
import ListItem from '@tiptap/extension-list-item'
|
||||||
import Focus from '@tiptap/extension-focus'
|
import Focus from '@tiptap/extension-focus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -30,6 +32,8 @@ export default {
|
|||||||
Paragraph(),
|
Paragraph(),
|
||||||
Text(),
|
Text(),
|
||||||
Code(),
|
Code(),
|
||||||
|
BulletList(),
|
||||||
|
ListItem(),
|
||||||
Focus({
|
Focus({
|
||||||
className: 'has-focus',
|
className: 'has-focus',
|
||||||
nested: true,
|
nested: true,
|
||||||
@@ -38,12 +42,11 @@ export default {
|
|||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
content: `
|
content: `
|
||||||
<p>
|
<p>
|
||||||
The focus extension adds custom classes to focused nodes. By default, it’ll add a <code>has-focus</code> class, even to nested nodes:
|
The focus extension adds a class to the focused node only. That enables you to add a custom styling to just that node. By default, it’ll add <code>.has-focus</code>, even to nested nodes.
|
||||||
</p>
|
</p>
|
||||||
<pre><code>{ className: 'has-focus', nested: true }</code></pre>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>With <code>nested: true</code> nested elements like this list item will be focused.</li>
|
<li>Nested elements (like this list item) will be focused with the default setting of <code>nested: true</code>.</li>
|
||||||
<li>Otherwise the whole list will get the focus class, even if only a single list item is selected.</li>
|
<li>Otherwise the whole list will get the focus class, even when just a single list item is selected.</li>
|
||||||
</ul>
|
</ul>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,10 +39,13 @@ export default {
|
|||||||
],
|
],
|
||||||
content: `
|
content: `
|
||||||
<p>
|
<p>
|
||||||
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web" target="_self">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isn’t that cool? Let’s try <a href="https://statamic.com/" target="_self">another one!</a> Yep, seems to work.
|
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isn’t that cool? Let’s try <a href="https://statamic.com/">another one!</a> Yep, seems to work.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
By default every link will get a \`rel="noopener noreferrer nofollow"\` attribute. It’s configurable though.
|
By default every link will get a [rel="noopener noreferrer nofollow"] attribute <a href="https://web.dev/external-anchors-use-rel-noopener/">for security reasons</a>. It’s configurable though.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Ah, and links open in a new tab by default, but that’s also - yes, you’ve guessed it - configurable.
|
||||||
</p>
|
</p>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
content: `
|
|
||||||
<p>
|
|
||||||
This is a radically reduced version of tiptap. It has only support for a document, paragraphs and text. That’s it. It’s probably too much for real minimalists though.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The paragraph extension is not literally required, but you need at least one node. That node can be something different, for example to render a task list and only that task list.
|
|
||||||
</p>
|
|
||||||
`,
|
|
||||||
extensions: [
|
extensions: [
|
||||||
Document(),
|
Document(),
|
||||||
Paragraph(),
|
Paragraph(),
|
||||||
Text(),
|
Text(),
|
||||||
],
|
],
|
||||||
|
content: `
|
||||||
|
<p>
|
||||||
|
This is a radically reduced version of tiptap. It has only support for a document, paragraphs and text. That’s it. It’s probably too much for real minimalists though.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The paragraph extension is not really required, but you need at least one node. Sure, that node can be something different. You’ll mostly likely want to add a paragraph though.
|
||||||
|
</p>
|
||||||
|
`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export default {
|
|||||||
editable: this.editable,
|
editable: this.editable,
|
||||||
content: `
|
content: `
|
||||||
<p>
|
<p>
|
||||||
This text is <strong>read-only</strong>. You are not able to edit something. <a href="https://ueber.io/">Links to fancy websites</a> are still working.
|
This text is <strong>read-only</strong>. No matter what you try, you are not able to edit something. Okay, if you toggle the checkbox above you’ll be able to edit the text.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you want to check the state, you can call <code>editor.isEditable()</code>.
|
||||||
</p>
|
</p>
|
||||||
`,
|
`,
|
||||||
extensions: defaultExtensions(),
|
extensions: defaultExtensions(),
|
||||||
@@ -60,5 +63,6 @@ export default {
|
|||||||
|
|
||||||
[contenteditable=false] {
|
[contenteditable=false] {
|
||||||
color: #999;
|
color: #999;
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
# Basic
|
# Basic
|
||||||
|
BUG: Headings can’t be transformed to a bullet or ordered list.
|
||||||
|
|
||||||
<live-demo name="Examples/Basic" />
|
<live-demo name="Examples/Basic" />
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
# Collaborative editing
|
# Collaborative editing
|
||||||
:::warning Public
|
This example shows how you can use tiptap to let different users collaboratively work on the same text in real-time.
|
||||||
The content of this editor is shared with other users.
|
|
||||||
|
It connects client with WebRTC and merges changes to the document (no matter where they come from) with the awesome library [Y.js](https://github.com/yjs/yjs) by Kevin Jahns. Be aware that in a real-world scenario you would probably add a server, which is also able to merge changes with Y.js.
|
||||||
|
|
||||||
|
If you want to learn more about collaborative text editing, [check out our guide on that topic](/guide/collaborative-editing). Anyway, it’s showtime now:
|
||||||
|
|
||||||
|
:::warning The content of this editor is shared with other users from the Internet.
|
||||||
|
Don’t share your password, credit card numbers or other things you wouldn’t make public.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
<!-- <demo name="Examples/Collaboration" :show-source="false"/> -->
|
<!-- <demo name="Examples/Collaboration" :show-source="false"/> -->
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# Focus
|
# Focus
|
||||||
|
|
||||||
<demo name="Examples/Focus" highlight="13,33-36,38" />
|
<demo name="Examples/Focus" highlight="15,37-40,42" />
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# Minimalist
|
# Minimalist
|
||||||
|
|
||||||
<demo name="Examples/Minimalist" highlight="7-9,26-28" />
|
<demo name="Examples/Minimalist" highlight="7-9,25-27" />
|
||||||
|
|||||||
24
docs/src/docPages/guide/collaborative-editing.md
Normal file
24
docs/src/docPages/guide/collaborative-editing.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Collaborative editing
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Collaborative editing allows multiple users to work on the same text document in real-time. It’s a complex topic that you should be aware before adding it blindly to you app. No worries though, here is everything you need to know.
|
||||||
|
|
||||||
|
## Configure collaboration
|
||||||
|
|
||||||
|
### WebRTC provider
|
||||||
|
|
||||||
|
### Websocket provider
|
||||||
|
|
||||||
|
### Add cursors
|
||||||
|
|
||||||
|
### Offline support
|
||||||
|
|
||||||
|
## Store the content
|
||||||
|
|
||||||
|
### Client-only implementation
|
||||||
|
|
||||||
|
### Server implementation
|
||||||
|
|
||||||
@@ -103,13 +103,14 @@ blockquote {
|
|||||||
pre {
|
pre {
|
||||||
background: rgba($colorBlack, 0.9);
|
background: rgba($colorBlack, 0.9);
|
||||||
color: rgba($colorWhite, 0.9);
|
color: rgba($colorWhite, 0.9);
|
||||||
padding: 1rem;
|
padding: 0.75rem 1rem;
|
||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
|
||||||
code {
|
code {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
background: none;
|
background: none;
|
||||||
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,9 @@
|
|||||||
- title: Use Vue Components
|
- title: Use Vue Components
|
||||||
link: /guide/use-vue-components
|
link: /guide/use-vue-components
|
||||||
draft: true
|
draft: true
|
||||||
# - title: Collaborative editing
|
- title: Collaborative editing
|
||||||
# link: /guide/use-vue-components
|
link: /guide/collaborative-editing
|
||||||
# draft: true
|
draft: true
|
||||||
|
|
||||||
- title: API
|
- title: API
|
||||||
items:
|
items:
|
||||||
|
|||||||
Reference in New Issue
Block a user