@kvass/rich-text 1.4.9 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -4
  2. package/src/Component.vue +38 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvass/rich-text",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "description": "rich text component for kvass",
5
5
  "main": "src/Component.vue",
6
6
  "scripts": {
@@ -24,8 +24,8 @@
24
24
  "homepage": "https://github.com/Kvass-App/rich-text#readme",
25
25
  "devDependencies": {
26
26
  "cz-conventional-changelog": "^3.3.0",
27
- "semantic-release-cli": "^5.4.0",
28
- "semantic-release": "^17.3.0"
27
+ "semantic-release": "^17.3.0",
28
+ "semantic-release-cli": "^5.4.0"
29
29
  },
30
30
  "config": {
31
31
  "commitizen": {
@@ -36,8 +36,9 @@
36
36
  "@kvass/storage": "^1.1.0",
37
37
  "@tiptap/extension-image": "^2.0.0-beta.220",
38
38
  "@tiptap/extension-link": "^2.0.0-beta.220",
39
- "@tiptap/starter-kit": "^2.0.0-beta.220",
39
+ "@tiptap/extension-superscript": "^2.2.1",
40
40
  "@tiptap/pm": "^2.0.0-beta.220",
41
+ "@tiptap/starter-kit": "^2.0.0-beta.220",
41
42
  "@tiptap/vue-2": "^2.0.0-beta.220"
42
43
  }
43
44
  }
package/src/Component.vue CHANGED
@@ -74,10 +74,20 @@
74
74
  import { Editor, EditorContent, BubbleMenu } from '@tiptap/vue-2'
75
75
  import Link from '@tiptap/extension-link'
76
76
  import Image from '@tiptap/extension-image'
77
+ import Superscript from '@tiptap/extension-superscript'
77
78
  import CallToAction from './extensions/cta'
78
79
  import StarterKit from '@tiptap/starter-kit'
79
80
 
80
- const DefaultCommands = ['heading', 'bold', 'italic', 'orderedList', 'bulletList', 'link', 'cta']
81
+ const DefaultCommands = [
82
+ 'heading',
83
+ 'bold',
84
+ 'italic',
85
+ 'superscript',
86
+ 'orderedList',
87
+ 'bulletList',
88
+ 'link',
89
+ 'cta',
90
+ ]
81
91
  const DefaultLabels = { primary: 'Primær', secondary: 'Sekundær' }
82
92
 
83
93
  export { DefaultCommands }
@@ -139,7 +149,7 @@ export default {
139
149
  icon: ['far', 'bold'],
140
150
  appearance: {
141
151
  menu: true,
142
- bubble: false,
152
+ bubble: true,
143
153
  },
144
154
  },
145
155
  {
@@ -148,7 +158,7 @@ export default {
148
158
  icon: ['far', 'italic'],
149
159
  appearance: {
150
160
  menu: true,
151
- bubble: false,
161
+ bubble: true,
152
162
  },
153
163
  },
154
164
  {
@@ -169,14 +179,25 @@ export default {
169
179
  bubble: false,
170
180
  },
171
181
  },
182
+ {
183
+ stateKey: 'superscript',
184
+ commandKey: 'toggleSuperscript',
185
+ icon: ['far', 'superscript'],
186
+ extension: Superscript,
187
+ appearance: {
188
+ menu: false,
189
+ bubble: true,
190
+ },
191
+ },
172
192
  {
173
193
  stateKey: 'link',
174
194
  commandKey: '---',
175
195
  customFunc: () => {
176
196
  this.bubbleState = 'link'
177
197
  },
178
- disabled: this.editor.state.selection.empty,
198
+ disabled: this.editor && this.editor.state.selection.empty,
179
199
  icon: ['far', 'link'],
200
+ extension: Link,
180
201
  appearance: {
181
202
  menu: true,
182
203
  bubble: false,
@@ -187,6 +208,7 @@ export default {
187
208
  commandKey: '---',
188
209
  customFunc: () => {},
189
210
  icon: ['far', 'image'],
211
+ extension: Image,
190
212
  appearance: {
191
213
  menu: false,
192
214
  bubble: false,
@@ -198,8 +220,9 @@ export default {
198
220
  customFunc: () => {
199
221
  this.bubbleState = 'cta'
200
222
  },
201
- disabled: this.editor.state.selection.empty,
223
+ disabled: this.editor && this.editor.state.selection.empty,
202
224
  icon: ['far', 'mouse-pointer'],
225
+ extension: CallToAction,
203
226
  appearance: {
204
227
  menu: true,
205
228
  bubble: false,
@@ -243,7 +266,7 @@ export default {
243
266
  },
244
267
  bubbleShouldShow({ editor }) {
245
268
  return (
246
- this.availableCommands
269
+ this.getCommands()
247
270
  .filter(a => a.appearance.bubble)
248
271
  .map(a => a.stateKey)
249
272
  .some(k => editor.isActive(k)) || !this.editor.state.selection.empty
@@ -252,12 +275,17 @@ export default {
252
275
  isInternalUrl(value) {
253
276
  if (!typeof value === 'string') return
254
277
  return ['/', '#'].some(v => value.startsWith(v))
255
- }
278
+ },
256
279
  },
257
280
  mounted() {
258
281
  this.editor = new Editor({
259
282
  editable: !this.disabled,
260
- extensions: [StarterKit, Link, Image, CallToAction],
283
+ extensions: [
284
+ StarterKit,
285
+ ...this.getCommands()
286
+ .map(({ extension }) => extension)
287
+ .filter(Boolean),
288
+ ],
261
289
  content: this.value,
262
290
  onUpdate: () => {
263
291
  let html = this.editor.getHTML().replace(/^<p>\s*<\/p>$/, '')
@@ -388,10 +416,11 @@ export default {
388
416
  }
389
417
  }
390
418
 
391
- &__button {
419
+ &-button {
392
420
  width: initial;
393
421
  padding: 0.5rem 0.75rem !important;
394
422
  color: white;
423
+ font-size: 0.6em;
395
424
 
396
425
  & + button {
397
426
  border-left: 1px solid rgba(white, 0.2) !important;