UNPKG

5.22 kBMarkdownView Raw
1WYSIWYG editor for Vuetify. Component simplifies integration [tiptap](https://github.com/scrumpy/tiptap) with [vuetify](https://github.com/vuetifyjs/vuetify).
2
3[DEMO on codesanbox](https://codesandbox.io/s/p2wnzxyo90?fontsize=14&module=%2Fsrc%2Fexamples%2FSimple.vue)
4[
5![](https://i.imgur.com/C46cX8m.png)
6](https://codesandbox.io/s/p2wnzxyo90?fontsize=14&module=%2Fsrc%2Fexamples%2FSimple.vue)
7
8## Features
9
10- used vuetify components
11- internationalization (2 languages: en, ru)
12- everything is ready for use
13- props and events are available
14- the project is ready to actively develop if there is support (stars)!
15
16## Installation
17
18```
19yarn add tiptap-vuetify
20# Or
21npm install --save tiptap-vuetify
22```
23
24
25## Get started
26
271) Add `Vue.use` for plugin. You can select your icons group (`iconsGroup`, `'md'` by default).
28
29```js
30import { TiptapVuetifyPlugin } from 'tiptap-vuetify'
31// don't forget to import styles
32import 'tiptap-vuetify/dist/main.css'
33
34Vue.use(TiptapVuetifyPlugin, {
35 // optional, default to 'md' (default vuetify icons before v2.0.0)
36 iconsGroup: 'md'
37})
38```
39
40More about vuetify icons you can read [here](https://vuetifyjs.com/en/components/icons).
41
422) Use in your component. Here is a complete example:
43
44```vue
45<template>
46 <div>
47 <!--Use the component in the right place of the template-->
48 <tiptap-vuetify
49 v-model="content"
50 :extensions="extensions"
51 />
52
53 <!--Here's how to make a preview (optional)-->
54 <h1>Preview</h1>
55 <hr>
56
57 <div
58 class="tiptap-vuetify-editor__content"
59 v-html="content"
60 />
61 </div>
62</template>
63
64<script>
65// import the component and the necessary extensions
66import { TiptapVuetify, Heading, Bold, Italic, Strike, Underline, Code, CodeBlock, Paragraph, BulletList, OrderedList,
67 ListItem, Link, Blockquote, HardBreak, HorizontalRule, History
68} from 'tiptap-vuetify'
69
70export default {
71 // specify in the list of components
72 components: { TiptapVuetify },
73 data: () => ({
74 // declare extensions you want to use
75 extensions: [
76 // you can specify options for extension
77 new Heading({
78 levels: [1, 2, 3]
79 }),
80 new Bold(),
81 new Italic(),
82 new Strike(),
83 new Underline(),
84 new Code(),
85 new CodeBlock(),
86 new Paragraph(),
87 new BulletList(),
88 new OrderedList(),
89 new ListItem(),
90 new Link(),
91 new Blockquote(),
92 new HardBreak(),
93 new HorizontalRule(),
94 new History()
95 ],
96 // starting content for the editor
97 content: `
98 <h1>Yay Headlines!</h1>
99 <p>All these <strong>cool tags</strong> are working now.</p>
100 `
101 })
102}
103</script>
104```
105
106There is another use case with the script tag (CDN version of package):
107
108```html
109<script src="https://unpkg.com/tiptap-vuetify"></script>
110```
111
112Or
113
114```html
115<script src="https://cdn.jsdelivr.net/npm/tiptap-vuetify"></script>
116```
117
118## Props
119
120### extensions
121
122You can use the necessary extensions. The corresponding buttons are added automatically
123(in the order in which you specify the extension).
124
125How to import and use them can be seen in the example above.
126
127Available extensions:
128
129- `Bold`
130- `Italic`
131- `Strike`
132- `Underline`
133- `Code`
134- `CodeBlock`
135- `Paragraph`
136- `BulletList`
137- `OrderedList`
138- `ListItem`
139- `Link`
140- `Blockquote`
141- `HardBreak`
142- `HorizontalRule`
143- `History`
144
145### toolbar-attributes
146
147You can specify your attributes for the toolbar (`<v-toolbar>` vuetify component).
148
149For example, change the color:
150```vue
151:toolbar-attributes="{ color: 'yellow' }"
152```
153
154### editor-properties
155
156Tiptap `Editor` properties (passed to the constructor).
157
158You can see the full list of machines [here](https://github.com/scrumpy/tiptap#editor-properties).
159
160Only these machines are not available: `content`, `onUpdate`, they are used in this package.
161If you want to add extensions to the `extensions` property, then use the `native-extensions` prop of this package.
162
163
164### native-extensions
165
166How to use:
167
168```vue
169<tiptap-vuetify
170 :native-extensions="nativeExtensions"
171/>
172```
173
174```js
175// in script:
176data () {
177 return {
178 nativeExtensions: [new TiptapExtension1(), new TiptapExtension2()]
179 }
180}
181```
182
183## Events
184
185### @init
186
187**first argument** (object):
188```ts
189{
190 // tiptap editor instance
191 editor: Editor
192}
193```
194
195How to use:
196
197```vue
198<tiptap-vuetify
199 @init="onInit"
200/>
201```
202
203## Slots
204
205### toolbar
206
207How to use:
208
2091) Since Vue `2.6.0` (new syntax):
210
211```vue
212<tiptap-vuetify
213 v-model="content"
214 :extensions="extensions"
215 :toolbar-attributes="{ color: 'yellow' }"
216>
217 <template #toolbar="{ buttons, commands, isActive }">
218 <!--You can render the buttons as you wish (you can see in the source code how this is done).-->
219 <pre>{{ buttons }}</pre>
220 </template>
221</tiptap-vuetify>
222```
223
2242) Before `2.6.0`:
225
226```vue
227<tiptap-vuetify>
228 <div
229 slot="toolbar"
230 slot-scope="{ buttons, commands, isActive }"
231 >
232 <!--You can render the buttons as you wish (you can see in the source code how this is done).-->
233 <pre>{{ buttons }}</pre>
234 </div>
235</tiptap-vuetify>
236```
237
238### footer
239
240Footer of the Editor.
241
242### toolbar-before
243
244You can add content before the toolbar.
245
246### toolbar-after
247
248You can add content after the toolbar.
249
250
251## TODO
252
253- images uploading (free hosting by default)
254- emoticons