diff --git a/docs/src/docPages/guide/node-views.md b/docs/src/docPages/guide/node-views.md index abaa55e8..b80f1fb2 100644 --- a/docs/src/docPages/guide/node-views.md +++ b/docs/src/docPages/guide/node-views.md @@ -39,9 +39,9 @@ That’s how you could render mentions, which shouldn’t 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. That’s 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. That’s 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
@@ -60,14 +60,16 @@ You can even mix non-editable and editable text. That’s great to build complex **BUT**, that also means the cursor can’t 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 [{ diff --git a/docs/src/docPages/installation/nuxt.md b/docs/src/docPages/installation/nuxt.md index 55910f52..7ccaa0e1 100644 --- a/docs/src/docPages/installation/nuxt.md +++ b/docs/src/docPages/installation/nuxt.md @@ -89,7 +89,7 @@ Now, let’s replace the content of `pages/index.vue` with the following example Note that tiptap needs to run in the client, not on the server. It’s required to wrap the editor in a `` tag. [Read more about cient-only components.](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. ## 5. Use v-model (optional) You’re probably used to bind your data with `v-model` in forms, that’s also possible with tiptap. Here is a working example component, that you can integrate in your project: diff --git a/docs/src/docPages/installation/react.md b/docs/src/docPages/installation/react.md index 554666d8..1bdb2f3e 100644 --- a/docs/src/docPages/installation/react.md +++ b/docs/src/docPages/installation/react.md @@ -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, that’s fine too. Just skip this step and proceed with the next step. + +For the sake of this guide, let’s 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. Let’s finally install tiptap! For the following example you’ll 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 you’re working with an existing project. + +## 3. Create a new component +To actually start using tiptap, you’ll need to add a new component to your app. Let’s 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: '

Hello World! 🌎️

', + }) + + return ( + + ) +} + +export default Tiptap +``` + +## 4. Add it to your app +Now, let’s 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 ( +
+ +
+ ) +} + +export default App +``` + +You should now see tiptap in your browser. You’ve 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: diff --git a/docs/src/docPages/installation/vue2.md b/docs/src/docPages/installation/vue2.md index cdc94d23..47c4aa57 100644 --- a/docs/src/docPages/installation/vue2.md +++ b/docs/src/docPages/installation/vue2.md @@ -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 you’re 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 you’re working with an existing project. ## 3. Create a new component To actually start using tiptap, you’ll need to add a new component to your app. Let’s call it `Tiptap` and put the following example code in `components/Tiptap.vue`. @@ -97,7 +97,7 @@ export default { ``` -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. ## 5. Use v-model (optional) You’re probably used to bind your data with `v-model` in forms, that’s also possible with tiptap. Here is a working example component, that you can integrate in your project: diff --git a/docs/src/docPages/installation/vue3.md b/docs/src/docPages/installation/vue3.md index 58cecca0..bbba831a 100644 --- a/docs/src/docPages/installation/vue3.md +++ b/docs/src/docPages/installation/vue3.md @@ -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, that’s fine too. Just skip this step and proceed with the next step. -For the sake of this guide, let’s 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, let’s 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 you’re 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 you’re working with an existing project. ## 3. Create a new component To actually start using tiptap, you’ll need to add a new component to your app. Let’s call it `Tiptap` and put the following example code in `components/Tiptap.vue`. @@ -125,7 +125,7 @@ export default { ``` -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. ## 5. Use v-model (optional) You’re probably used to bind your data with `v-model` in forms, that’s also possible with tiptap. Here is how that would work with tiptap: @@ -185,3 +185,4 @@ export default { }, } +``` diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 53f4bb6a..ff2117f0 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -8,7 +8,7 @@ skip: true - title: React link: /installation/react - type: draft + type: new skip: true - title: Vue 3 link: /installation/vue3