docs: add the react installation instructions

This commit is contained in:
Hans Pagel
2021-03-18 23:33:47 +01:00
parent 080ccf0131
commit ae2505fe21
6 changed files with 88 additions and 12 deletions

View File

@@ -39,9 +39,9 @@ Thats how you could render mentions, which shouldnt be editable. Users can
Statamic uses those for their Bard editor, which renders complex modules inside tiptap, which can have their own text inputs.
### Mixed content
You can even mix non-editable and editable text. Thats great to build complex things, and even use marks like bold and italic inside the editable content.
You can even mix non-editable and editable text. Thats great to build complex things, and still use marks like bold and italic inside the editable content.
**BUT**, if there are other elements with non-editable text in your node view, the cursor can jump there. You can improve that with manually adding `contenteditable` attributes to the specific parts of your node view.
**BUT**, if there are other elements with non-editable text in your node view, the cursor can jump there. You can improve that with manually adding `contenteditable="false"` to the specific parts of your node view.
```html
<div class="Prosemirror" contenteditable="true">
@@ -60,14 +60,16 @@ You can even mix non-editable and editable text. Thats great to build complex
**BUT**, that also means the cursor cant just move from outside of the node view to the inside. Users have to manually place their cursor to edit the content inside the node view. Just so you know.
## Render as HTML
## Markup
### Render HTML
```js
renderHTML({ HTMLAttributes }) {
return ['vue-component', mergeAttributes(HTMLAttributes)]
},
```
## Restore from HTML
### Parse HTML
```js
parseHTML() {
return [{

View File

@@ -89,7 +89,7 @@ Now, lets replace the content of `pages/index.vue` with the following example
Note that tiptap needs to run in the client, not on the server. Its required to wrap the editor in a `<client-only>` tag. [Read more about cient-only components.](https://nuxtjs.org/api/components-client-only)
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back. Lets start to configure your editor in the next step.
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back.
## 5. Use v-model (optional)
Youre probably used to bind your data with `v-model` in forms, thats also possible with tiptap. Here is a working example component, that you can integrate in your project:

View File

@@ -5,6 +5,79 @@
## Introduction
The following guide describes how to integrate tiptap with your [React](https://reactjs.org/) project.
TODO
## Requirements
* [Node](https://nodejs.org/en/download/) installed on your machine
* Experience with [React](https://reactjs.org/docs/getting-started.html)
## 1. Create a project (optional)
If you already have an existing React project, thats fine too. Just skip this step and proceed with the next step.
For the sake of this guide, lets start with a fresh React project called `tiptap-example`. [*Create React App*](https://reactjs.org/docs/getting-started.html) sets up everything we need.
```bash
# create a project
npx create-react-app tiptap-example
# change directory
cd tiptap-example
```
## 2. Install the dependencies
Okay, enough of the boring boilerplate work. Lets finally install tiptap! For the following example youll need the `@tiptap/react` package, with a few components, and `@tiptap/starter-kit` which has the most common extensions to get started quickly.
```bash
# install with npm
npm install @tiptap/react @tiptap/starter-kit
# install with Yarn
yarn add @tiptap/react @tiptap/starter-kit
```
If you followed step 1 and 2, you can now start your project with `npm run start` or `yarn start`, and open [http://localhost:3000](http://localhost:3000) in your favorite browser. This might be different, if youre working with an existing project.
## 3. Create a new component
To actually start using tiptap, youll need to add a new component to your app. Lets call it `Tiptap` and put the following example code in `src/Tiptap.jsx`.
This is the fastest way to get tiptap up and running with Vue. It will give you a very basic version of tiptap, without any buttons. No worries, you will be able to add more functionality soon.
```js
import { useEditor, EditorContent } from '@tiptap/react'
import { defaultExtensions } from '@tiptap/starter-kit'
const Tiptap = () => {
const editor = useEditor({
extensions: defaultExtensions(),
content: '<p>Hello World! 🌎️</p>',
})
return (
<EditorContent editor={editor} />
)
}
export default Tiptap
```
## 4. Add it to your app
Now, lets replace the content of `src/App.js` with the following example code to use our new `Tiptap` component in our app.
```js
import Tiptap from './Tiptap.jsx'
const App = () => {
return (
<div className="App">
<Tiptap />
</div>
)
}
export default App
```
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back.
## 5. The complete setup (optional)
Ready to add more? Below is a demo that shows how you could set up what we call the default editor. Feel free to take this and start customizing it then:
<demo name="Examples/Default/React" />

View File

@@ -34,7 +34,7 @@ npm install @tiptap/vue-2 @tiptap/starter-kit
yarn add @tiptap/vue-2 @tiptap/starter-kit
```
If you followed step 1 and 2, you can now start your project with `npm run dev` or `yarn dev`, and open [http://localhost:8080/](http://localhost:3000/) in your favorite browser. This might be different, if youre working with an existing project.
If you followed step 1 and 2, you can now start your project with `npm run dev` or `yarn dev`, and open [http://localhost:8080](http://localhost:8080) in your favorite browser. This might be different, if youre working with an existing project.
## 3. Create a new component
To actually start using tiptap, youll need to add a new component to your app. Lets call it `Tiptap` and put the following example code in `components/Tiptap.vue`.
@@ -97,7 +97,7 @@ export default {
</script>
```
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back. Lets start to configure your editor in the next step.
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back.
## 5. Use v-model (optional)
Youre probably used to bind your data with `v-model` in forms, thats also possible with tiptap. Here is a working example component, that you can integrate in your project:

View File

@@ -13,7 +13,7 @@ The following guide describes how to integrate tiptap with your [Vue](https://vu
## 1. Create a project (optional)
If you already have an existing Vue project, thats fine too. Just skip this step and proceed with the next step.
For the sake of this guide, lets start with a fresh Vue project called `tiptap-example`. The Vue CLI sets up everything we need, just select the default Vue 2 template.
For the sake of this guide, lets start with a fresh Vue project called `tiptap-example`. The Vue CLI sets up everything we need, just select the Vue 3 template.
```bash
# create a project
@@ -34,7 +34,7 @@ npm install @tiptap/vue-3 @tiptap/starter-kit
yarn add @tiptap/vue-3 @tiptap/starter-kit
```
If you followed step 1 and 2, you can now start your project with `npm run dev` or `yarn dev`, and open [http://localhost:8080/](http://localhost:3000/) in your favorite browser. This might be different, if youre working with an existing project.
If you followed step 1 and 2, you can now start your project with `npm run dev` or `yarn dev`, and open [http://localhost:8080](http://localhost:8080) in your favorite browser. This might be different, if youre working with an existing project.
## 3. Create a new component
To actually start using tiptap, youll need to add a new component to your app. Lets call it `Tiptap` and put the following example code in `components/Tiptap.vue`.
@@ -125,7 +125,7 @@ export default {
</script>
```
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back. Lets start to configure your editor in the next step.
You should now see tiptap in your browser. Youve successfully set up tiptap! Time to give yourself a pat on the back.
## 5. Use v-model (optional)
Youre probably used to bind your data with `v-model` in forms, thats also possible with tiptap. Here is how that would work with tiptap:
@@ -185,3 +185,4 @@ export default {
},
}
</script>
```

View File

@@ -8,7 +8,7 @@
skip: true
- title: React
link: /installation/react
type: draft
type: new
skip: true
- title: Vue 3
link: /installation/vue3