@kvass/rich-text 1.4.9 → 1.4.11

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 +9 -8
  2. package/src/Component.vue +47 -11
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.11",
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": {
@@ -34,10 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@kvass/storage": "^1.1.0",
37
- "@tiptap/extension-image": "^2.0.0-beta.220",
38
- "@tiptap/extension-link": "^2.0.0-beta.220",
39
- "@tiptap/starter-kit": "^2.0.0-beta.220",
40
- "@tiptap/pm": "^2.0.0-beta.220",
41
- "@tiptap/vue-2": "^2.0.0-beta.220"
37
+ "@tiptap/extension-image": "^2.2.2",
38
+ "@tiptap/extension-link": "^2.2.2",
39
+ "@tiptap/extension-superscript": "^2.2.2",
40
+ "@tiptap/pm": "^2.2.2",
41
+ "@tiptap/starter-kit": "^2.2.2",
42
+ "@tiptap/vue-2": "^2.2.2"
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,17 +179,28 @@ 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
- bubble: false,
203
+ bubble: true,
183
204
  },
184
205
  },
185
206
  {
@@ -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,11 +220,12 @@ 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
- bubble: false,
228
+ bubble: true,
206
229
  },
207
230
  },
208
231
  ]
@@ -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,17 +275,25 @@ 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>$/, '')
264
292
  this.$emit('input', html)
265
293
  },
294
+ onSelectionUpdate: ({ editor }) => {
295
+ if (!this.bubbleShouldShow({ editor })) this.bubbleState = null
296
+ },
266
297
  })
267
298
  },
268
299
  beforeDestroy() {
@@ -288,6 +319,10 @@ export default {
288
319
  background-color: var(--vue-elder-input-color, #fafafa);
289
320
  }
290
321
 
322
+ .tippy-content > div {
323
+ visibility: visible !important; // Fix for visibility bug
324
+ }
325
+
291
326
  &:not(.richtext--disabled):focus-within {
292
327
  outline: 1px solid var(--primary);
293
328
  border-radius: var(--border-radius, 3px);
@@ -388,10 +423,11 @@ export default {
388
423
  }
389
424
  }
390
425
 
391
- &__button {
426
+ &-button {
392
427
  width: initial;
393
428
  padding: 0.5rem 0.75rem !important;
394
429
  color: white;
430
+ font-size: 0.6em;
395
431
 
396
432
  & + button {
397
433
  border-left: 1px solid rgba(white, 0.2) !important;