- Notifications
You must be signed in to change notification settings - Fork127
Vuetify editor. Component simplifies integration tiptap editor with vuetify. WYSIWYG
777genius/tiptap-vuetify
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
WYSIWYG editor for Vuetify. The editor is based ontiptap and usesvuetify's components. 💪
If you have Vuetify1.x
(not2.x
), then you can find docs and demohere.
- 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.
- Vuetify
2.x
and1.x
support
yarn add tiptap-vuetify# Or npm install --save tiptap-vuetify
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.
- 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.
- 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>
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.
Placeholder is displayed when there is no content in the editor.
How to use:
<tiptap-vuetify placeholder="Write something …" />
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.
You can specify your attributes for the toolbar (<v-toolbar>
vuetify component).
For example, change the color:
:toolbar-attributes="{ color: 'yellow' }"
Allows you to pass props for the editor's<v-card>
.
<tiptap-vuetify :card-props="{ flat:true, color:'#26c6da' }"/>
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.
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.
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.
The format to output from the v-model. This defaults tohtml
For example, to get json instead:
<tiptap-vuetify output-format="json"/>
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"/>
first argument (object):
{// tiptap editor instanceeditor:Editor}
How to use:
<tiptap-vuetify @init="onInit"/>
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.
You can manually display the toolbar. How to use:
- Since Vue
2.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>
- Before
2.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 of the Editor.
You can add content before the toolbar.
You can add content after the toolbar.
- 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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.