docs: add content
This commit is contained in:
@@ -70,7 +70,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
nextPage() {
|
nextPage() {
|
||||||
return this.flattenedItems[this.currentIndex + 1]
|
let nextIndex = this.currentIndex + 1
|
||||||
|
|
||||||
|
while (this.flattenedItems[nextIndex]?.skip) {
|
||||||
|
nextIndex += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.flattenedItems[nextIndex]
|
||||||
},
|
},
|
||||||
|
|
||||||
previousPage() {
|
previousPage() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
content: '<p>Hello, here is tiptap! 👋</p>',
|
content: '<p>Hello World! 🌎️</p>',
|
||||||
extensions: defaultExtensions(),
|
extensions: defaultExtensions(),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# Collaboration
|
# Collaboration
|
||||||
The Collaboration extension enables you to collaborate with others on one document. The implementation is based on [Y.js by Kevin Jahns](https://github.com/yjs/yjs), which is the coolest thing to [integrate collaborative editing](/guide/collaborative-editing) in your project.
|
The Collaboration extension enables you to collaborate with others on one document. The implementation is based on [Y.js by Kevin Jahns](https://github.com/yjs/yjs), which is the coolest thing to [integrate collaborative editing](/guide/collaborative-editing) in your project.
|
||||||
|
|
||||||
|
The history works totally different in a collaborative editing setup. If you undo a change, you don’t want to undo changes of other users. To handle that behaviour this extension provides an own `undo` and `redo` command. Don’t load the default [`History`](/api/extensions/history) extension together with the Collaboration extension to avoid conflicts.
|
||||||
|
|
||||||
:::premium Pro Extension
|
:::premium Pro Extension
|
||||||
We kindly ask you to [sponsor our work](/sponsor) when using this extension in production.
|
We kindly ask you to [sponsor our work](/sponsor) when using this extension in production.
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# Create a toolbar
|
|
||||||
|
|
||||||
## toc
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
- [ ] commands
|
|
||||||
- [ ] commands toggle
|
|
||||||
- [ ] focus
|
|
||||||
- [ ] isActive
|
|
||||||
- [ ] isActive node/mark
|
|
||||||
- [ ] isActive node/mark, attributes
|
|
||||||
- [ ] isActive attributes
|
|
||||||
|
|
||||||
<!-- ## Introduction
|
|
||||||
In its simplest version tiptap comes very raw. There is no menu, no buttons, no styling. That’s intended. See tiptap as your building blocks to build exactly the editor you would like to have.
|
|
||||||
|
|
||||||
## Adding a menu
|
|
||||||
Let’s start to add your first button to the editor. Once initiated the editor has a powerful API. The so called *commands* allow you to modify selected text (and tons of other things). Here is an example with one single button:
|
|
||||||
|
|
||||||
<demo name="SimpleMenuBar" highlight="5-11" />
|
|
||||||
|
|
||||||
To mark selected text bold we can use `editor.commands.toggleBold()`. There a ton of other commands and you can even chain them to do multiple things at once.
|
|
||||||
|
|
||||||
You might wonder what features tiptap supports out of the box. In the above example we added the `@tiptap/starter-kit`. That already includes support for paragraphs, text, bold, italic, inline code and code blocks. There are a lot more, but you have to explicitly import them. You will learn how that works in the next example.
|
|
||||||
|
|
||||||
### Related Links
|
|
||||||
* [List of available commands](/api/commands)
|
|
||||||
|
|
||||||
## Configure extensions
|
|
||||||
You are free to choose which parts of tiptap you want to use. tiptap has support for different nodes (paragraphs, blockquotes, tables and many more) and different marks (bold, italic, links). If you want to explicitly configure what kind of nodes and marks are allowed and which are not allowed, you can configure those.
|
|
||||||
|
|
||||||
Note that `Document`, `Paragraph` and `Text` are required. Otherwise you won’t be able to add any plain text.
|
|
||||||
|
|
||||||
<demo name="Guide/BuildYourEditor" highlight="10-13,30-33" />
|
|
||||||
|
|
||||||
That’s also the place where you can register custom extensions, which you or someone else built for tiptap. -->
|
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
tiptap 2 is framework-agnostic and even works with plain JavaScript, if that’s your thing. We’re working on guides for all the different frameworks and workflows, but here is the general one. The following steps should help you to integrate tiptap in your JavaScript project.
|
tiptap 2 is framework-agnostic and even works with plain JavaScript, if that’s your thing. We’re working on guides for all the different frameworks and workflows, but here is the general one. The following steps should help you to integrate tiptap in your JavaScript project.
|
||||||
|
|
||||||
## Alternative Guides
|
## Alternative Guides
|
||||||
|
|
||||||
* [Vue CLI](/guide/getting-started/vue-cli)
|
* [Vue CLI](/guide/getting-started/vue-cli)
|
||||||
|
* [Nuxt.js](/guide/getting-started/nuxtjs)
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
* [Node](https://nodejs.org/en/download/) installed on your machine
|
* [Node](https://nodejs.org/en/download/) installed on your machine
|
||||||
|
|||||||
@@ -79,11 +79,17 @@ Now, let’s replace the content of `pages/index.vue` with the following example
|
|||||||
```html
|
```html
|
||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
<client-only>
|
||||||
<tiptap />
|
<tiptap />
|
||||||
|
</client-only>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that tiptap needs to run in the client, not on the server. It’s required to wrap the editor in a `<client-only>` tag.
|
||||||
|
|
||||||
|
[Read more](https://nuxtjs.org/api/components-client-only)
|
||||||
|
|
||||||
You should now see tiptap in your browser. You’ve successfully set up tiptap! Time to give yourself a pat on the back. Let’s start to configure your editor in the next step.
|
You should now see tiptap in your browser. You’ve successfully set up tiptap! Time to give yourself a pat on the back. Let’s start to configure your editor in the next step.
|
||||||
|
|
||||||
## 5. Use v-model (optional)
|
## 5. Use v-model (optional)
|
||||||
|
|||||||
72
docs/src/docPages/guide/toolbar.md
Normal file
72
docs/src/docPages/guide/toolbar.md
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Create a toolbar
|
||||||
|
|
||||||
|
## toc
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
tiptap comes very raw, but that’s a good thing. You have full control (and when we say full, we mean full) about the appearance of it. That also means you have to build the editor toolbar on your own. Don’t worry though, you can start with a few buttons and we help you with everything else.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
Let’s assume you’ve got the editor running already and you want to add your first button. You’ll need a `<button>` HTML tag, and add a click handler. Depending on your setup, that can look like the following Vue.js example:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button @click="editor.chain().toggleBold().focus().run()">
|
||||||
|
Bold
|
||||||
|
</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
Oh, that’s a long command, right? Actually, it’s a [chain of commands](/api/commands#chain-commands), so let’s go through this one by one:
|
||||||
|
|
||||||
|
```js
|
||||||
|
editor.chain().toggleBold().focus().run()
|
||||||
|
```
|
||||||
|
|
||||||
|
1. `editor` should be a tiptap instance,
|
||||||
|
2. `chain()` is used to tell the editor you want to execute multiple commands,
|
||||||
|
3. `toggleBold()` marks selected text bold, or removes the bold mark from the text selection if it’s already applied,
|
||||||
|
4. `focus()` sets the focus back to the editor and
|
||||||
|
5. `run()` will execute the chain.
|
||||||
|
|
||||||
|
In other words: This will be the typical **Bold** button for your text editor.
|
||||||
|
|
||||||
|
Which commands are available depends on what extensions you’ve registered with editor. Most of the extensions come with a `set…()`, `unset…()` and `toggle…()` command. Read the extension documentation to see what’s actually available or just surf through your code editor’s autocomplete.
|
||||||
|
|
||||||
|
## Keep the focus
|
||||||
|
You’ve seen the `focus()` command in the above example already. When you click on the button, the browser focuses that DOM element and the editor loses focus. It’s likely you want to add `focus()` to all your toolbar buttons, so the writing flow of your users isn’t interrupted.
|
||||||
|
|
||||||
|
## The active state
|
||||||
|
The editor provides an `isActive()` method to check if something is applied to the selected text already. In Vue.js you can toggle a CSS class with help of that function like that:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button :class="{ 'is-active': editor.isActive('bold') }" @click="editor.chain().toggleBold().focus().run()">
|
||||||
|
Bold
|
||||||
|
</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
This toggles the `.is-active` class accordingly. This works for nodes, and marks. You can even check for specific attributes, here is an example with the [`Highlight`](/api/marks/highlight) mark, that ignores different attributes:
|
||||||
|
|
||||||
|
```js
|
||||||
|
editor.isActive('highlight')
|
||||||
|
```
|
||||||
|
|
||||||
|
And an example that compares the given attribute(s):
|
||||||
|
|
||||||
|
```js
|
||||||
|
editor.isActive('highlight', { color: '#ffa8a8' })
|
||||||
|
```
|
||||||
|
|
||||||
|
You can even ignore nodes and marks, but check for the attributes only. Here is an example with the [`TextAlign`](/api/extensions/text-align) extension:
|
||||||
|
|
||||||
|
```js
|
||||||
|
editor.isActive({ textAlign: 'right' })
|
||||||
|
```
|
||||||
|
|
||||||
|
If your selection spans multiple nodes or marks, or only part of the selection has a mark, `isActive()` will return `false` and indicate nothing is active. That is how it is supposed to be, because it allows people to apply a new node or mark to that selection right-away.
|
||||||
|
|
||||||
|
## Icons
|
||||||
|
Most editor toolbars use icons for their buttons. In some of our demos, we use the open source icon set [Remix Icon](https://remixicon.com/), that’s free to use. But it’s totally up to you what you use. Here are a few icon sets you can consider:
|
||||||
|
|
||||||
|
* [Remix Icon](https://remixicon.com/#editor)
|
||||||
|
* [Font Awesome](https://fontawesome.com/icons?c=editors)
|
||||||
|
* [UI icons](https://www.ibm.com/design/language/iconography/ui-icons/library/)
|
||||||
|
|
||||||
|
Also, we’re working on providing a configurable interface for tiptap. If you think that’s a great idea, [become a sponsor](/sponsor) to show us your support. 💖
|
||||||
@@ -52,9 +52,15 @@ Note that tiptap needs to run in the client, not on the server. It’s required
|
|||||||
## Option 3: CodeSandbox
|
## Option 3: CodeSandbox
|
||||||
CodeSandbox is an online coding environment. It’s great to fiddle around without setting up a local project and to share your code with others.
|
CodeSandbox is an online coding environment. It’s great to fiddle around without setting up a local project and to share your code with others.
|
||||||
|
|
||||||
It’s also amazing for bug reports. Try to recreate a bug there and share it with us before when you [file an issue on GitHub](https://github.com/ueberdosis/tiptap-next/issues/new/choose). That helps us to reproduce the bug quickly, and fix them faster.
|
<iframe
|
||||||
|
src="https://codesandbox.io/embed/tiptap-issue-template-b83rr?fontsize=14&hidenavigation=1&module=%2Fsrc%2Fcomponents%2FTiptap.vue&theme=dark"
|
||||||
|
style="width:100%; height:400px; border:0; border-radius: 4px; overflow:hidden;"
|
||||||
|
title="tiptap-issue-template"
|
||||||
|
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
|
||||||
|
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
||||||
|
></iframe>
|
||||||
|
|
||||||
* [Vue.js/tiptap on CodeSandbox](https://codesandbox.io/s/tiptap-issue-template-b83rr?file=/src/components/Tiptap.vue)
|
It’s also amazing for bug reports. Try to recreate a bug there and share it with us before when you [file an issue on GitHub](https://github.com/ueberdosis/tiptap-next/issues/new/choose). That helps us to reproduce the bug quickly, and fix them faster.
|
||||||
|
|
||||||
|
|
||||||
## Option 4: CDN (Draft)
|
## Option 4: CDN (Draft)
|
||||||
@@ -83,7 +89,7 @@ Skypack enables you to use ES modules, which should be supported in all modern b
|
|||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Unpkg (UMD, deprecated)
|
### ~~Unpkg (UMD, deprecated)~~
|
||||||
We also have an UMD build on unpkg. Those UMD builds are larger, but should work even in older browsers. As tiptap doesn’t work in older browsers anyway, we tend to remove those builds. What do you think? Anyway, here‘s how you can use it:
|
We also have an UMD build on unpkg. Those UMD builds are larger, but should work even in older browsers. As tiptap doesn’t work in older browsers anyway, we tend to remove those builds. What do you think? Anyway, here‘s how you can use it:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
|||||||
@@ -38,13 +38,14 @@
|
|||||||
items:
|
items:
|
||||||
- title: Vue CLI
|
- title: Vue CLI
|
||||||
link: /guide/getting-started/vue-cli
|
link: /guide/getting-started/vue-cli
|
||||||
|
skip: true
|
||||||
- title: Nuxt.js
|
- title: Nuxt.js
|
||||||
link: /guide/getting-started/nuxtjs
|
link: /guide/getting-started/nuxtjs
|
||||||
|
skip: true
|
||||||
- title: Configure the editor
|
- title: Configure the editor
|
||||||
link: /guide/configure-the-editor
|
link: /guide/configuration
|
||||||
- title: Create a toolbar
|
- title: Create a toolbar
|
||||||
link: /guide/create-a-toolbar
|
link: /guide/toolbar
|
||||||
draft: true
|
|
||||||
- title: Custom styling
|
- title: Custom styling
|
||||||
link: /guide/styling
|
link: /guide/styling
|
||||||
- title: Store content
|
- title: Store content
|
||||||
@@ -94,6 +95,7 @@
|
|||||||
- title: Table
|
- title: Table
|
||||||
link: /api/nodes/table
|
link: /api/nodes/table
|
||||||
draft: true
|
draft: true
|
||||||
|
pro: true
|
||||||
- title: TaskList
|
- title: TaskList
|
||||||
link: /api/nodes/task-list
|
link: /api/nodes/task-list
|
||||||
- title: TaskItem
|
- title: TaskItem
|
||||||
@@ -141,6 +143,7 @@
|
|||||||
- title: Suggestion
|
- title: Suggestion
|
||||||
link: /api/extensions/suggestion
|
link: /api/extensions/suggestion
|
||||||
draft: true
|
draft: true
|
||||||
|
pro: true
|
||||||
- title: TextAlign
|
- title: TextAlign
|
||||||
link: /api/extensions/text-align
|
link: /api/extensions/text-align
|
||||||
- title: Typography
|
- title: Typography
|
||||||
|
|||||||
Reference in New Issue
Block a user