-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various problems with documentation (or me ^^) #1821
Comments
Thanks, we’re in the process of upgrading everything to Vue 3. Can you make a screen recording for 3? |
Thanks for your quick answer! Actually I'll be glad to keep finding documentation for @tiptap/vue-2 because if I'm not mistaken Nuxt is still using Vue 2 :) About the same example: For my third point: I wanted to do a sandbox for you but couldn't make it work :( (stuck on welcome screen). I did an app from scratch and it was a good idea because I don't have the reload bug! I'll have to investigate in my app what's causing it. Instead and just because I did my first screen recording for you :D here is one showing v-model is not working (new app and copy-paste of your example). PS. : following this older tutorial and probably older version of tiptap: https://dev.to/casualcoder/tiptap-with-vuetify-1lmi, I don't have the reload problem. Enregistrement.de.l.ecran.2021-09-01.a.10.27.57.mov |
Okay, I’ll need to go through the Nuxt.js integration guide again. If someone want’s to chime in and help here, that would be amazing! I’ll probably need a while until I can tackle this. |
Hello, I am trying to understand: Does tiptap work with Nuxt2? @cdefy did you get it working? |
I got it to work. This is my component (Typescript) (WIP): HTML<template>
<div>
<div v-if="editor" class="mb-2">
<span v-if="label && showLabel" class="v-label">{{ label }}</span>
<v-row no-gutters>
<v-col cols="12">
<v-btn-toggle dense class="mr-1">
<v-btn :disabled="disabled" small>
<v-icon small>$align-left</v-icon>
</v-btn>
<v-btn :disabled="disabled" small>
<v-icon small>$align-center</v-icon>
</v-btn>
<v-btn :disabled="disabled" small>
<v-icon small>$align-right</v-icon>
</v-btn>
<v-btn :disabled="disabled" small>
<v-icon small>$align-justify</v-icon>
</v-btn>
</v-btn-toggle>
<v-btn-toggle dense>
<v-btn
:disabled="disabled"
small
:class="{
'v-btn v-item--active v-btn--active': editor.isActive('bold'),
}"
@click="editor.chain().focus().toggleBold().run()"
>
<v-icon small>$bold</v-icon>
</v-btn>
<v-btn
:disabled="disabled"
small
:class="{
'v-btn v-item--active v-btn--active': editor.isActive('italic'),
}"
@click="editor.chain().focus().toggleItalic().run()"
>
<v-icon small>$italic</v-icon>
</v-btn>
<v-btn
:disabled="disabled"
small
:class="{
'v-btn v-item--active v-btn--active':
editor.isActive('underline'),
}"
>
<v-icon small>$underline</v-icon>
</v-btn>
</v-btn-toggle>
</v-col>
</v-row>
</div>
<editor-content :editor="editor" />
<v-alert
v-for="(item, index) of errorMessages"
:key="index"
type="error"
border="left"
>{{ item }}
</v-alert>
</div>
</template> Scriptimport { Component, Prop, Vue } from "nuxt-property-decorator";
import { Editor, EditorContent } from "@tiptap/vue-2";
import StarterKit from "@tiptap/starter-kit";
import { debounce } from "lodash";
@Component({
components: { EditorContent },
})
export default class AppEditor extends Vue {
@Prop({ required: true, default: "" }) readonly value!: string;
@Prop({ required: false, default: false }) readonly disabled!: boolean;
@Prop({ required: true }) readonly label: string;
@Prop({ required: false, default: true }) readonly showLabel!: boolean;
@Prop({ required: false }) readonly rules: string;
@Prop({ required: false }) readonly errorMessages: string[];
editor: Editor = null;
debounceInput: () => void = null;
created() {
this.debounceInput = debounce(() => {
this.$emit("input", this.editor.getHTML());
}, 300);
}
mounted() {
this.editor = new Editor({
content: this.value,
// injectCSS: true,
editable: !this.disabled,
onUpdate: () => {
// this.$emit('input', this.editor.getHTML())
this.debounceInput();
},
extensions: [StarterKit],
});
}
beforeDestroy() {
this.editor.destroy();
}
} SCSS/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
ul,
ol {
padding: 0 1rem;
}
h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1.1;
}
code {
background-color: rgba(#616161, 0.1);
color: #616161;
}
pre {
background: #0d0d0d;
color: #fff;
font-family: "JetBrainsMono", monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
padding: 0;
background: none;
font-size: 0.8rem;
}
}
img {
max-width: 100%;
height: auto;
}
blockquote {
padding-left: 1rem;
border-left: 2px solid rgba(#0d0d0d, 0.1);
}
hr {
border: none;
border-top: 2px solid rgba(#0d0d0d, 0.1);
margin: 2rem 0;
}
} Using:
|
Thanks, @kompetenzlandkarte ! I will study it. It seems, however, quite a bit of a difference compared to what the docs stated. Is the author's focus now with Nuxt3/Vue3? |
@dosstx I managed to have something working following this tutorial : https://dev.to/casualcoder/tiptap-with-vuetify-1lmi but I'm using an older version of tiptap": "^1.32.2" and "tiptap-extensions": "^1.35.2". For your last question, yes they said they were in the process of upgrading everything to Vue 3. Thanks for sharing @kompetenzlandkarte , I might retry the integration with your example! |
Ok dumb question: Do I need to use Typescript to use your example? |
No Typescript is optional. I use the Class API (https://typescript.nuxtjs.org/examples/class-api/basic) which is not used in the normal JS code. Migrating the code should be pretty easy however. |
Hi guys, The solution for this problem is pretty straightforward. Of course, I spent a couple of hours figuring out what is the problem. The problem lies in Nuxt itself which uses Vue2, but the Tiptap example for Nuxt was written for Vue3. So, till stable Nuxt3, we have to put a few lines of code into the // ~/components/Editor.vue
// The template part is the same
<script>
// Yes, we have to use Vue2
import { Editor, EditorContent } from '@tiptap/vue-2';
import StarterKit from '@tiptap/starter-kit';
export default {
components: {
EditorContent,
},
// This part was missing, more info why it is important here:
// https://v3.vuejs.org/guide/migration/v-model.html#_2-x-syntax
model: {
prop: 'modelValue',
event: 'update:modelValue',
},
// the rest is the same I hope it helps. |
@philippkuehn Can you check the v-model examples?
It might be wrong. We’re using Vue.js 3 in the docs, but the interactive example is only on the Vue 2 and Nuxt.js page. |
yep. fixed it! |
Thanks for the correction. I did another install following the tutorial and manage to have a working version this time. About my third point in the original post, I finally found a fix: #729 ! |
Hi,
I reckon there's an error in the Nuxt documentation: https://www.tiptap.dev/installation/nuxt
At step 2, we install @tiptap/vue-2 and at step 5, the example for v-model is importing @tiptap/vue-3 in Editor.vue
I couldn't make the v-model to work like in the example. I had to actually use a basic prop and watch for the event.
Thanks to anyone for any help or advice. Please ask for more info if needed.
Cheers!
The text was updated successfully, but these errors were encountered: