Component simplifies integration tiptap editor with vuetify

Component simplifies integration tiptap editor with vuetify

Component simplifies integration tiptap editor with vuetify. ... WYSIWYG editor for Vuetify. The editor is based on tiptap and uses vuetify's components.

WYSIWYG editor for Vuetify. The editor is based on tiptap and uses vuetify's If you have Vuetify 1.x (not 2.x), then you can find docs and demo here.

DEMO on codesanbox

Features

  • used vuetify components
  • support for different types of icons (fa, md, mdi, mdiSvg)
  • internationalization (en, es, fr, pl, ru, uk, ptbr, tr, he, nl), with automatic detection of the current language through the Vuetify. You can make a PR for your language if it is not there, here is an example.
  • markdown support
  • easy to start using
  • props and events are available
  • TypeScript support
  • the project is ready to actively develop if there is support (stars)!
  • the ability to create and use your own extensions
  • choose where the extension buttons should be displayed: in the toolbar or in the bubble menu
  • Vuetify 2.x and 1.x support

Installation

yarn add tiptap-vuetify
# Or 
npm install --save tiptap-vuetify

Get started

NPM (ES modules)

  1. Installing the package and Vuetify 2 from scratch:
import Vue from 'vue'
import Vuetify from 'vuetify'
// import plugin
import { TiptapVuetifyPlugin } from 'tiptap-vuetify'
// don't forget to import CSS styles
import 'tiptap-vuetify/dist/main.css'
// Vuetify's CSS styles 
import 'vuetify/dist/vuetify.min.css'

// Vuetify Object (as described in the Vuetify 2 documentation)
const vuetify = new Vuetify()

// use Vuetify's plugin
Vue.use(Vuetify)
// use this package's plugin
Vue.use(TiptapVuetifyPlugin, {
  // the next line is important! You need to provide the Vuetify Object to this place.
  vuetify, // same as "vuetify: vuetify"
  // optional, default to 'md' (default vuetify icons before v2.0.0)
  iconsGroup: 'md'
})

More about vuetify icons you can read here.

  1. Use in your component. Here is a complete example:
text-html-vue
<template>
  <div>
    <!-- Use the component in the right place of the template -->
    <tiptap-vuetify
      v-model="content"
      :extensions="extensions"
    />
  </div>
</template>

<script>
// import the component and the necessary extensions
import { TiptapVuetify, Heading, Bold, Italic, Strike, Underline, Code, Paragraph, BulletList, OrderedList, ListItem, Link, Blockquote, HardBreak, HorizontalRule, History } from 'tiptap-vuetify'

export default {
  // specify TiptapVuetify component in "components"
  components: { TiptapVuetify },
  data: () => ({
    // declare extensions you want to use
    extensions: [
      History,
      Blockquote,
      Link,
      Underline,
      Strike,
      Italic,
      ListItem,
      BulletList,
      OrderedList,
      [Heading, {
        options: {
          levels: [1, 2, 3]
        }
      }],
      Bold,
      Code,
      HorizontalRule,
      Paragraph,
      HardBreak
    ],
    // starting editor's content
    content: `
      <h1>Yay Headlines!</h1>
      <p>All these <strong>cool tags</strong> are working now.</p>
    `
  })
}
</script>

Nuxt

If you have Nuxt.js, here is a simple demo how to integrate it (@nuxtjs/vuetify module is used). The code for this example is taken from this github repository, you can find more infо there.

CDN

There is another use case with the script tag (CDN version of package):

text-html-basic
<script src="https://unpkg.com/tiptap-vuetify"></script>

Or

text-html-basic
<script src="https://cdn.jsdelivr.net/npm/tiptap-vuetify"></script>

The plugin should be installed automatically after connecting the script. The only thing is that the Vuetify object must be set in window.vuetify so that the plugin gets access to it. Write if you have questions.

Props

placeholder

Placeholder is displayed when there is no content in the editor.

How to use:

text-html-vue
  <tiptap-vuetify
    placeholder="Write something …"
  />

extensions

You can use the necessary extensions. The corresponding buttons are added automatically (in the order in which you specify the extension).

How to import and use them can be seen in the example above.

Available extensions (native tiptap extensions from tiptap-extensions package):

  • Bold
  • Italic
  • Strike
  • Underline
  • Code
  • CodeBlock
  • Image
  • Paragraph
  • BulletList
  • OrderedList
  • ListItem
  • Link
  • Blockquote
  • HardBreak
  • HorizontalRule
  • History

I can easily add more.

toolbar-attributes

You can specify your attributes for the toolbar (<v-toolbar> vuetify component).

For example, change the color:

text-html-vue
:toolbar-attributes="{ color: 'yellow' }"

card-props

Allows you to pass props for the editor's <v-card>.

text-html-vue
<tiptap-vuetify
  :card-props="{ flat: true, color: '#26c6da' }"
/>

editor-properties

Tiptap Editor properties (passed to the constructor).

You can see the full list of properties here.

This is the most powerful way to customize the editor for yourself. Pay particular attention to editorProps.

Only these properties are not available: content, onUpdate, they are used in this package. If you want to add extensions to the extensions property, then use the native-extensions prop of this package.

)native-extensions

You can transfer native extensions (not related to this package) to the extensions property.

How to use:

text-html-vue
<tiptap-vuetify
  :native-extensions="nativeExtensions"
/>
source-js
// You can import from tiptap's built-in extensions
import {
  TrailingNode
} from 'tiptap-extensions'
// or your own extension
import Title from './Title'

// in script:
data () {
  return {
    nativeExtensions: [
      new Title(),
      new TrailingNode({
        node: 'paragraph',
        notAfter: ['paragraph'],
      })
    ]
  }
}

Here is example of how to create your extension from scratch.

output-format

The format to output from the v-model. This defaults to html

For example, to get json instead:

text-html-vue
<tiptap-vuetify
  output-format="json"
/>

Events

init

first argument (object):

source-ts
{
  // tiptap editor instance
  editor: Editor
}

How to use:

text-html-vue
<tiptap-vuetify
  @init="onInit"
/>

keydown

Called when the editor receives a keydown event.

text-html-vue
<tiptap-vuetify
  @keydown="onKeyDown"
/>
source-js
methods: {
  onkeydown (event, view) {
    console.log('event', event.key)
  }
}

Note: if you need to work with the Enter, then look here.

What is view?

Slots

toolbar

You can manually display the toolbar. How to use:

  1. Since Vue 2.6.0 (new syntax):
text-html-vue
<tiptap-vuetify
  v-model="content"
  :extensions="extensions"
  :toolbar-attributes="{ color: 'yellow' }"
>
  <template #toolbar="{ buttons, commands, isActive }">
    <!--You can render the buttons as you wish (you can see in the source code how this is done).-->
    <pre>{{ buttons }}</pre>
  </template>
</tiptap-vuetify>
  1. Before 2.6.0:
text-html-vue
<tiptap-vuetify>
  <div 
    slot="toolbar" 
    slot-scope="{ buttons, commands, isActive }"
  >
    <!--You can render the buttons as you wish (you can see in the source code how this is done).-->
    <pre>{{ buttons }}</pre>
  </div>
</tiptap-vuetify>

Footer of the Editor.

toolbar-before

You can add content before the toolbar.

toolbar-after

You can add content after the toolbar.

TODO

  • better images support: uploading (free hosting by default) Relevant issue. Ability to choose your uploading strategy. Resize image and change other params.
  • site with full-docs and examples
  • emoticons
  • tests
  • support for more extensions

Github

tiptap-vuetify

vuejs javascript vue-js vue

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.

A Vue.js wrapper component for Grid.js

A Vue wrapper component for Grid.js. Grid.js is a Free and open-source HTML table plugin written in TypeScript. It works with most JavaScript frameworks.

Vue.js image clipping Components using Vue-Rx

vuejs-clipper .Vue.js image clipping components using Vue-Rx. Add image clipping components to your Vue application in nothing flat. Touch devices supported and fully responsive.

Vue.js JWT Authentication with Vuex and Vue Router

Build a Vue.js JWT Authentication application using Vuex, Vue Router, VeeValidate - JWT authentication with Vue, Vuex, Vue Router that supports VeeValidate

Vue.js JWT Authentication with Vuex and Vue Router

Vue Vuex JWT Auth .Vue.js JWT Authentication with Vuex and Vue Router