Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vuetify editor. Component simplifies integration tiptap editor with vuetify. WYSIWYG

NotificationsYou must be signed in to change notification settings

777genius/tiptap-vuetify

Repository files navigation

WYSIWYG editor for Vuetify. The editor is based ontiptap and usesvuetify's components. 💪

VersionDownloadsLicenseCircleCI Build StatusLanguage grade: JavaScriptcodebeat badgecodebeat badge

If you have Vuetify1.x (not2.x), then you can find docs and demohere.

Navigation

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, ja, de, ko, zhHans, fa, sv, cs, it, el), 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
  • support for custom image upload. You can use any method of upload through your Vue component.
  • Vuetify2.x and1.x support

Installation

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

Get started

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 fromthis github repository, you can find more infо there.

NPM (ES modules)

  1. Installing the package and Vuetify 2 from scratch:
importVuefrom'vue'importVuetifyfrom'vuetify'// import pluginimport{TiptapVuetifyPlugin}from'tiptap-vuetify'// don't forget to import CSS stylesimport'tiptap-vuetify/dist/main.css'// Vuetify's CSS stylesimport'vuetify/dist/vuetify.min.css'// Vuetify Object (as described in the Vuetify 2 documentation)constvuetify=newVuetify()// use Vuetify's pluginVue.use(Vuetify)// use this package's pluginVue.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 readhere.

  1. Use in your component. Here is a complete example:
<template>  <div><!-- Use the component in the right place of the template-->    <tiptap-vuetifyv-model="content":extensions="extensions"    />  </div></template><script>// import the component and the necessary extensionsimport {TiptapVuetify,Heading,Bold,Italic,Strike,Underline,Code,Paragraph,BulletList,OrderedList,ListItem,Link,Blockquote,HardBreak,HorizontalRule,History }from'tiptap-vuetify'exportdefault {// 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>

CDN

Attention: it seems that this method does not work due to the fact that this is not done in thetiptap package itself. Therefore, it most likely will not work.More details.

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

<scriptsrc="https://unpkg.com/tiptap-vuetify"></script>

Or

<scriptsrc="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 inwindow.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:

  <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 fromtiptap-extensions package):

  • Bold
  • Italic
  • Strike
  • Underline
  • Code
  • CodeBlock
  • Image
  • Paragraph
  • BulletList orOrderedList (use with theListItem extension)
  • ListItem
  • Link
  • Blockquote
  • HardBreak
  • HorizontalRule
  • History
  • TodoList (use with theTodoItem extension)
  • TodoItem

I can easily add more.

toolbar-attributes

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

For example, change the color:

:toolbar-attributes="{ color: 'yellow' }"

card-props

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

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

editor-properties

TiptapEditor properties (passed to the constructor).

You can see the full list of propertieshere.

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

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

native-extensions

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

How to use:

<tiptap-vuetify  :native-extensions="nativeExtensions"/>
// You can import from tiptap's built-in extensionsimport{TrailingNode}from'tiptap-extensions'// or your own extensionimportTitlefrom'./Title'// in script:data(){return{nativeExtensions:[newTitle(),newTrailingNode({node:'paragraph',notAfter:['paragraph'],})]}}

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

custom image upload components

A custom image upload / selection component allows you to upload images to or select images from your application's backend system.The when properly configured, the component will be displayed as a tab in the Add Image window.

To implement this, first create a component where users can upload and/or select images. The component will not get any props from the image window.When a user selects an image, the component must emit aselect-file event with an object containingsrc andalt properties.For example:

selectImage(){// When doing an asynchronous upload, you can set the src property to the value provided by the server (backend).this.$emit('select-file',{src:'/path/to/image.jpg',alt:'Uploaded image'});}

To add your component to the image extension, make the following changes:Import your component, e.g.

importFileSelectorfrom'~/Components/FileSelector'

Updatetiptap-vuetify :extensions value for Image as follows:

...[Image,{options:{imageSources:[{component:FileSelector,name:'File Selector'}]}}]...

The value ofname will be the tab name.

By default, your component will be added to tiptap-vuetify's own image sources (URL and data url Upload). If you want to exclude these image sources you can setimageSourcesOverride: true in the extension's options.

A basic example implementation can be found in the package's demo code inFileSelector.vue andIndex.vue.

output-format

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

For example, to get json instead:

<tiptap-vuetify  output-format="json"/>

disabled

Flag for disabling entire editor (disabled toolbar items andready-only content area). Default false.

For example, disabled editor by component prop:

<tiptap-vuetify  :disabled="editorDisabled"/>

Events

init

first argument (object):

{// tiptap editor instanceeditor:Editor}

How to use:

<tiptap-vuetify  @init="onInit"/>

keydown

Called when the editor receives a keydown event.

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

Note: if you need to work with theEnter, then lookhere.

What isview?

Slots

toolbar

You can manually display the toolbar. How to use:

  1. Since Vue2.6.0 (new syntax):
<tiptap-vuetifyv-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. Before2.6.0:
<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

Footer of the Editor.

toolbar-before

You can add content before the toolbar.

toolbar-after

You can add content after the toolbar.

Donate (creating code at your request out of turn)

#133

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

About

Vuetify editor. Component simplifies integration tiptap editor with vuetify. WYSIWYG

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors41


[8]ページ先頭

©2009-2025 Movatter.jp