tiptapify 0.1.4 → 0.1.6

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 (113) hide show
  1. package/dist/tiptapify.css +2 -1
  2. package/dist/tiptapify.mjs +68619 -55059
  3. package/dist/tiptapify.umd.js +90 -80
  4. package/index.d.ts +98 -40
  5. package/package.json +73 -67
  6. package/src/components/Footer.vue +4 -3
  7. package/src/components/MenuBubble.vue +16 -16
  8. package/src/components/MenuFloating.vue +13 -13
  9. package/src/components/Tiptapify.vue +19 -9
  10. package/src/components/Toolbar/Index.vue +21 -17
  11. package/src/components/Toolbar/Items.vue +2 -1
  12. package/src/components/Toolbar/actions.ts +3 -3
  13. package/src/components/Toolbar/alignment.ts +5 -5
  14. package/src/components/Toolbar/format.ts +5 -5
  15. package/src/components/Toolbar/formatExtra.ts +6 -6
  16. package/src/components/Toolbar/items.ts +8 -8
  17. package/src/components/Toolbar/list.ts +6 -6
  18. package/src/components/Toolbar/media.ts +8 -8
  19. package/src/components/Toolbar/misc.ts +8 -8
  20. package/src/components/Toolbar/style.ts +7 -7
  21. package/src/components/UI/TiptapifyDialog.vue +14 -13
  22. package/src/components/editorExtensions.ts +4 -2
  23. package/src/components/index.ts +6 -6
  24. package/src/constants/style.test.ts +49 -0
  25. package/src/constants/style.ts +4 -3
  26. package/src/extensions/PickerEventBus.test.ts +38 -0
  27. package/src/extensions/charmap/arrows.ts +700 -700
  28. package/src/extensions/charmap/box_drawing.ts +184 -184
  29. package/src/extensions/charmap/currency.ts +93 -93
  30. package/src/extensions/charmap/cyrillic.ts +368 -368
  31. package/src/extensions/charmap/diacritics.ts +60 -60
  32. package/src/extensions/charmap/extended_letters.ts +748 -748
  33. package/src/extensions/charmap/greek.ts +252 -252
  34. package/src/extensions/charmap/hebrew.ts +105 -105
  35. package/src/extensions/charmap/math.ts +1684 -1684
  36. package/src/extensions/charmap/punctuation.ts +68 -68
  37. package/src/extensions/charmap/symbols.ts +288 -288
  38. package/src/extensions/charmap/typography.ts +284 -284
  39. package/src/extensions/components/CodeBlockComponent.vue +2 -2
  40. package/src/extensions/components/actions/redo/Button.vue +12 -10
  41. package/src/extensions/components/actions/undo/Button.vue +12 -10
  42. package/src/extensions/components/alignment/center/Button.vue +11 -9
  43. package/src/extensions/components/alignment/justify/Button.vue +11 -9
  44. package/src/extensions/components/alignment/left/Button.vue +11 -9
  45. package/src/extensions/components/alignment/right/Button.vue +11 -9
  46. package/src/extensions/components/format/bold/Button.vue +12 -10
  47. package/src/extensions/components/format/italic/Button.vue +12 -10
  48. package/src/extensions/components/format/strike/Button.vue +12 -10
  49. package/src/extensions/components/format/underline/Button.vue +5 -3
  50. package/src/extensions/components/formatExtra/code/Button.vue +12 -10
  51. package/src/extensions/components/formatExtra/codeBlock/Button.vue +12 -10
  52. package/src/extensions/components/formatExtra/quote/Button.vue +12 -10
  53. package/src/extensions/components/formatExtra/sub/Button.vue +12 -10
  54. package/src/extensions/components/formatExtra/sup/Button.vue +12 -10
  55. package/src/extensions/components/list/bullet/Button.vue +21 -19
  56. package/src/extensions/components/list/bullet/index.ts +1 -1
  57. package/src/extensions/components/list/indent/Button.vue +13 -11
  58. package/src/extensions/components/list/numbered/Button.vue +12 -10
  59. package/src/extensions/components/list/outdent/Button.vue +13 -11
  60. package/src/extensions/components/list/task/Button.vue +12 -10
  61. package/src/extensions/components/media/charmap/Button.vue +8 -5
  62. package/src/extensions/components/media/charmap/Picker.vue +20 -18
  63. package/src/extensions/components/media/emoji/Button.vue +8 -6
  64. package/src/extensions/components/media/emoji/Picker.vue +20 -18
  65. package/src/extensions/components/media/iframe/Button.vue +13 -11
  66. package/src/extensions/components/media/iframe/IframeDialog.vue +27 -25
  67. package/src/extensions/components/media/image/Button.vue +12 -10
  68. package/src/extensions/components/media/image/ImageDialog.vue +46 -42
  69. package/src/extensions/components/media/link/Button.vue +12 -11
  70. package/src/extensions/components/media/link/LinkDialog.vue +39 -37
  71. package/src/extensions/components/media/link/index.ts +6 -7
  72. package/src/extensions/components/media/table/Button.vue +21 -19
  73. package/src/extensions/components/media/table/ColumnActions.vue +5 -4
  74. package/src/extensions/components/media/table/RowActions.vue +5 -4
  75. package/src/extensions/components/media/table/TableBuilder.vue +15 -13
  76. package/src/extensions/components/media/video/Button.vue +12 -10
  77. package/src/extensions/components/media/video/VideoDialog.vue +33 -15
  78. package/src/extensions/components/misc/break/Button.vue +8 -6
  79. package/src/extensions/components/misc/formatClear/Button.vue +12 -10
  80. package/src/extensions/components/misc/fullscreen/Button.vue +20 -18
  81. package/src/extensions/components/misc/invisibleChar/Button.vue +11 -9
  82. package/src/extensions/components/misc/line/Button.vue +11 -9
  83. package/src/extensions/components/misc/preview/Button.vue +11 -9
  84. package/src/extensions/components/misc/source/Button.vue +9 -7
  85. package/src/extensions/components/misc/source/ShowSourceDialog.vue +27 -25
  86. package/src/extensions/components/slashCommands/CommandsList.vue +3 -1
  87. package/src/extensions/components/style/StyleColor.vue +26 -22
  88. package/src/extensions/components/style/color/Button.vue +19 -17
  89. package/src/extensions/components/style/fontFamily/Button.vue +16 -14
  90. package/src/extensions/components/style/fontFamily/FontFamily.vue +3 -2
  91. package/src/extensions/components/style/fontSize/Button.vue +17 -15
  92. package/src/extensions/components/style/fontSize/FontSize.vue +4 -3
  93. package/src/extensions/components/style/heading/Button.vue +19 -16
  94. package/src/extensions/components/style/highlight/Button.vue +19 -17
  95. package/src/extensions/components/style/lineHeight/Button.vue +16 -14
  96. package/src/extensions/components/style/lineHeight/FontFamily.vue +3 -2
  97. package/src/extensions/components/style/lineHeight/LineHeight.vue +3 -2
  98. package/src/extensions/emoji/activities.ts +534 -534
  99. package/src/extensions/emoji/animals_and_nature.ts +978 -978
  100. package/src/extensions/emoji/component.ts +54 -54
  101. package/src/extensions/emoji/flags.ts +1644 -1644
  102. package/src/extensions/emoji/food_and_drink.ts +810 -810
  103. package/src/extensions/emoji/objects.ts +1608 -1608
  104. package/src/extensions/emoji/people_and_body.ts +2022 -2022
  105. package/src/extensions/emoji/smileys_and_emotion.ts +1038 -1038
  106. package/src/extensions/emoji/symbols.ts +1290 -1290
  107. package/src/extensions/emoji/travel_and_places.ts +1332 -1332
  108. package/src/index.ts +15 -5
  109. package/src/types/editor.ts +10 -0
  110. package/src/types/slashCommandsTypes.ts +1 -1
  111. package/src/types/toolbarTypes.ts +3 -1
  112. package/src/utils/helpers.test.ts +32 -0
  113. package/src/utils/helpers.ts +1 -1
@@ -1,19 +1,21 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import * as mdi from "@mdi/js";
4
- import { Editor } from "@tiptap/vue-3";
5
- import TiptapifyDialog from "@tiptapify/components/UI/TiptapifyDialog.vue";
6
- import defaults from "@tiptapify/constants/defaults";
3
+ import * as mdi from '@mdi/js'
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
6
+ import defaults from '@tiptapify/constants/defaults'
7
+ import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
7
8
 
8
- import { computed, inject, onMounted, onUnmounted, Ref, ref } from 'vue'
9
+ import { computed, inject, onMounted, onUnmounted, PropType, Ref, ref, useTemplateRef } from 'vue'
10
+ import { ComposerTranslation } from 'vue-i18n'
9
11
 
10
12
  defineProps({
11
- variantBtn: { type: String, default() { return defaults.variantBtn }},
12
- variantField: { type: String, default() { return defaults.variantField }}
13
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
14
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return defaults.variantField } },
13
15
  })
14
16
 
15
17
  const editor = inject('tiptapifyEditor') as Ref<Editor>
16
- const { t } = inject('tiptapifyI18n') as any
18
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
17
19
 
18
20
  const generateImageAttrs = () => ({
19
21
  src: '',
@@ -25,7 +27,7 @@ const generateImageAttrs = () => ({
25
27
 
26
28
  const attrs = ref(generateImageAttrs())
27
29
 
28
- const dialog = ref(null)
30
+ const dialog = useTemplateRef('dialog')
29
31
 
30
32
  const isDisabled = computed(() => {
31
33
  const { src } = attrs.value
@@ -33,7 +35,7 @@ const isDisabled = computed(() => {
33
35
  })
34
36
 
35
37
  const keepRatio = ref(true)
36
- const ratio = ref(null)
38
+ const ratio: Ref<string> = ref('')
37
39
  function setRatio(force: boolean = false) {
38
40
  if (!keepRatio.value && !force) {
39
41
  return
@@ -60,7 +62,7 @@ function updateSizeRatio(dim: string) {
60
62
 
61
63
  const target = source === 'width' ? 'height' : 'width'
62
64
 
63
- attrs.value[target] = parseFloat(sizeRatio).toFixed(0)
65
+ attrs.value[target] = parseFloat(String(sizeRatio)).toFixed(0)
64
66
  }
65
67
 
66
68
  function apply() {
@@ -97,7 +99,7 @@ function clear() {
97
99
  }
98
100
 
99
101
  function close() {
100
- dialog.value.close()
102
+ dialog.value?.close()
101
103
 
102
104
  attrs.value = generateImageAttrs()
103
105
  ratio.value = null
@@ -114,7 +116,7 @@ const showTiptapifyImage = (event: CustomEvent) => {
114
116
  attrs.value.width = event.detail.image?.width
115
117
  attrs.value.height = event.detail.image?.height
116
118
 
117
- dialog.value.open()
119
+ dialog.value?.open()
118
120
  }
119
121
 
120
122
  onMounted(() => {
@@ -139,51 +141,53 @@ onUnmounted(() => {
139
141
  <div class="tiptapify-grid-row">
140
142
  <div>
141
143
  <VTextField
142
- v-model="attrs.alt"
143
- density="comfortable"
144
- :label="t('dialog.image.alt')" />
144
+ v-model="attrs.alt"
145
+ density="comfortable"
146
+ :label="t('dialog.image.alt')"
147
+ />
145
148
  </div>
146
149
  </div>
147
150
 
148
151
  <div class="tiptapify-grid-row">
149
152
  <div>
150
153
  <VTextField
151
- v-model="attrs.title"
152
- density="comfortable"
153
- :label="t('dialog.image.title')" />
154
+ v-model="attrs.title"
155
+ density="comfortable"
156
+ :label="t('dialog.image.title')"
157
+ />
154
158
  </div>
155
159
  </div>
156
160
 
157
161
  <div class="tiptapify-grid-row">
158
162
  <div class="tiptapify-image-inputs-container">
159
163
  <VTextField
160
- v-model="attrs.width"
161
- type="number"
162
- density="comfortable"
163
- :precision="0"
164
- :min="1"
165
- :label="t('dialog.image.width')"
166
- @change="setRatio"
167
- @update:model-value="updateSizeRatio('width')"
164
+ v-model="attrs.width"
165
+ type="number"
166
+ density="comfortable"
167
+ :precision="0"
168
+ :min="1"
169
+ :label="t('dialog.image.width')"
170
+ @change="setRatio"
171
+ @update:model-value="updateSizeRatio('width')"
168
172
  />
169
173
  <VTextField
170
- v-model="attrs.height"
171
- type="number"
172
- density="comfortable"
173
- :precision="0"
174
- :min="1"
175
- :label="t('dialog.image.height')"
176
- @change="setRatio"
177
- @update:model-value="updateSizeRatio('height')"
174
+ v-model="attrs.height"
175
+ type="number"
176
+ density="comfortable"
177
+ :precision="0"
178
+ :min="1"
179
+ :label="t('dialog.image.height')"
180
+ @change="setRatio"
181
+ @update:model-value="updateSizeRatio('height')"
178
182
  />
179
183
  </div>
180
184
  <div>
181
185
  <VBtn
182
- v-model="keepRatio"
183
- :color="keepRatio ? 'primary' : 'secondary'"
184
- size="48"
185
- :variant="variantBtn"
186
- @click="keepRatio = !keepRatio"
186
+ v-model="keepRatio"
187
+ :color="keepRatio ? 'primary' : 'secondary'"
188
+ size="48"
189
+ :variant="variantBtn"
190
+ @click="keepRatio = !keepRatio"
187
191
  >
188
192
  <VIcon :icon="keepRatio ? `mdiSvg:${mdi.mdiLock}` : `mdiSvg:${mdi.mdiLockOpenVariant}`" />
189
193
  <VTooltip activator="parent">
@@ -199,12 +203,12 @@ onUnmounted(() => {
199
203
  <VCardActions>
200
204
  <VRow>
201
205
  <VCol class="d-flex justify-start">
202
- <VBtn color="warning" v-if="editor.isActive('image')" :variant="variantBtn" :disabled="isDisabled" @click="clear">
206
+ <VBtn v-if="editor.isActive('image')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
203
207
  {{ t('dialog.clear') }}
204
208
  </VBtn>
205
209
  </VCol>
206
210
  <VCol class="d-flex justify-end">
207
- <VBtn :variant="variantBtn" @click="close" class="mr-2">
211
+ <VBtn :variant="variantBtn" class="mr-2" @click="close">
208
212
  {{ t('dialog.close') }}
209
213
  </VBtn>
210
214
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled" @click="apply">
@@ -1,20 +1,21 @@
1
1
  <script lang="ts" setup>
2
2
 
3
3
  import * as mdi from '@mdi/js'
4
- import { Editor } from "@tiptap/vue-3";
5
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
6
- import LinkDialog from "@tiptapify/extensions/components/media/link/LinkDialog.vue";
7
- import { computed, inject, Ref } from "vue";
4
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
5
+ import LinkDialog from '@tiptapify/extensions/components/media/link/LinkDialog.vue'
6
+ import { TiptapifyEditor, variantBtnTypes } from '@tiptapify/types/editor'
7
+ import { computed, inject, PropType, Ref } from 'vue'
8
8
 
9
9
  import defaults from '@tiptapify/constants/defaults'
10
+ import { ComposerTranslation } from 'vue-i18n'
10
11
 
11
12
  defineProps({
12
- variantBtn: { type: String, default: defaults.variantBtn }
13
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
13
14
  })
14
15
 
15
- const editor = inject('tiptapifyEditor') as Ref<Editor>
16
+ const editor = inject('tiptapifyEditor') as Ref<TiptapifyEditor>
16
17
 
17
- const { t } = inject('tiptapifyI18n') as any
18
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
18
19
 
19
20
  const icon = computed(() => editor.value.isActive('tiptapifyLink') ? `mdiSvg:${mdi.mdiLinkOff}` : `mdiSvg:${mdi.mdiLink}`)
20
21
 
@@ -22,10 +23,10 @@ const icon = computed(() => editor.value.isActive('tiptapifyLink') ? `mdiSvg:${m
22
23
 
23
24
  <template>
24
25
  <VBtn
25
- :color="editor.isActive('link') ? 'primary' : ''"
26
- :variant="variantBtn"
27
- @click="editor.commands.showLink()"
28
- size="32"
26
+ :color="editor.isActive('link') ? 'primary' : ''"
27
+ :variant="variantBtn"
28
+ size="32"
29
+ @click="editor.commands.showLink()"
29
30
  >
30
31
  <VTooltip activator="parent">
31
32
  {{ t('media.link') }}
@@ -1,25 +1,27 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import { Editor } from "@tiptap/vue-3";
4
- import defaults from "@tiptapify/constants/defaults";
3
+ import { Editor } from '@tiptap/vue-3'
4
+ import defaults from '@tiptapify/constants/defaults'
5
+ import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
5
6
 
6
- import { computed, inject, onMounted, onUnmounted, Ref, ref, watch } from 'vue'
7
+ import { computed, inject, onMounted, onUnmounted, PropType, Ref, ref, useTemplateRef, watch } from 'vue'
7
8
 
8
- import TiptapifyDialog from "@tiptapify/components/UI/TiptapifyDialog.vue"
9
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
10
+ import { ComposerTranslation } from 'vue-i18n'
9
11
 
10
12
  defineProps({
11
- variantBtn: { type: String, default() { return defaults.variantBtn }},
12
- variantField: { type: String, default() { return 'outlined' }}
13
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
14
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return 'outlined' } },
13
15
  })
14
16
 
15
17
  const editor = inject('tiptapifyEditor') as Ref<Editor>
16
- const { t } = inject('tiptapifyI18n') as any
18
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
17
19
 
18
20
  const generateLinkAttrs = () => ({
19
21
  href: '',
20
22
  target: targetAttrs.value[0],
21
23
  cssClass: '',
22
- rel: ''
24
+ rel: []
23
25
  })
24
26
 
25
27
  const relAttrs = ['alternate', 'author', 'bookmark', 'external', 'help', 'license', 'me', 'next', 'nofollow', 'noopener', 'noreferrer', 'opener', 'prev', 'privacy-policy', 'search', 'tag', 'terms-of-service']
@@ -32,7 +34,7 @@ const targetAttrs = computed(() => [
32
34
  const attrs = ref(generateLinkAttrs())
33
35
  const hrefInvalid = ref(false)
34
36
 
35
- const dialog = ref(null)
37
+ const dialog = useTemplateRef('dialog')
36
38
 
37
39
  const isDisabled = computed(() => {
38
40
  const { href } = attrs.value
@@ -41,10 +43,10 @@ const isDisabled = computed(() => {
41
43
 
42
44
  function apply() {
43
45
  let { href, target, rel, cssClass } = attrs.value
44
- rel = rel?.length ? rel.join(' ') : null
46
+ const relStr = rel?.length ? rel.join(' ') : null
45
47
 
46
48
  if (href) {
47
- editor.value.chain().focus().extendMarkRange('link').setLink({ href, target: target.value, rel, class: cssClass }).run()
49
+ editor.value.chain().focus().extendMarkRange('link').setLink({ href, target: target.value, rel: relStr, class: cssClass }).run()
48
50
  }
49
51
 
50
52
  close()
@@ -59,7 +61,7 @@ function clear() {
59
61
  function close() {
60
62
  attrs.value = generateLinkAttrs()
61
63
 
62
- dialog.value.close()
64
+ dialog.value?.close()
63
65
  }
64
66
 
65
67
  const showLink = (event: CustomEvent) => {
@@ -68,11 +70,11 @@ const showLink = (event: CustomEvent) => {
68
70
  }
69
71
 
70
72
  attrs.value.href = event.detail.link?.href ?? ''
71
- attrs.value.target = targetAttrs.value.find(item => item.value === event.detail.link?.target) ?? targetAttrs[0]
73
+ attrs.value.target = targetAttrs.value.find(item => item.value === event.detail.link?.target) ?? targetAttrs.value[0]
72
74
  attrs.value.rel = event.detail.link?.rel?.split(' ')
73
75
  attrs.value.cssClass = event.detail.link?.class
74
76
 
75
- dialog.value.open()
77
+ dialog.value?.open()
76
78
  }
77
79
 
78
80
  onMounted(() => {
@@ -113,23 +115,23 @@ watch(() => attrs.value.href, () => {
113
115
  <VRow>
114
116
  <VCol cols="12">
115
117
  <VTextField
116
- v-model="attrs.href"
117
- density="compact"
118
- variant="outlined"
119
- :label="t('dialog.link.href')"
120
- :error-messages="hrefInvalid ? t('dialog.link.href_error') : ''"
121
- autofocus
118
+ v-model="attrs.href"
119
+ density="compact"
120
+ variant="outlined"
121
+ :label="t('dialog.link.href')"
122
+ :error-messages="hrefInvalid ? t('dialog.link.href_error') : ''"
123
+ autofocus
122
124
  />
123
125
  </VCol>
124
126
 
125
127
  <VCol cols="12" md="4">
126
128
  <VSelect
127
- v-model="attrs.target"
128
- :items="targetAttrs"
129
- :label="t('dialog.link.target')"
130
- variant="outlined"
131
- return-object
132
- density="compact"
129
+ v-model="attrs.target"
130
+ :items="targetAttrs"
131
+ :label="t('dialog.link.target')"
132
+ variant="outlined"
133
+ return-object
134
+ density="compact"
133
135
  />
134
136
  </VCol>
135
137
 
@@ -139,15 +141,15 @@ watch(() => attrs.value.href, () => {
139
141
 
140
142
  <VCol cols="12">
141
143
  <VSelect
142
- v-model="attrs.rel"
143
- :items="relAttrs"
144
- :label="t('dialog.link.rel')"
145
- variant="outlined"
146
- multiple
147
- chips
148
- closable-chips
149
- clearable
150
- density="compact"
144
+ v-model="attrs.rel"
145
+ :items="relAttrs"
146
+ :label="t('dialog.link.rel')"
147
+ variant="outlined"
148
+ multiple
149
+ chips
150
+ closable-chips
151
+ clearable
152
+ density="compact"
151
153
  />
152
154
  </VCol>
153
155
  </VRow>
@@ -158,12 +160,12 @@ watch(() => attrs.value.href, () => {
158
160
  <VCardActions>
159
161
  <VRow>
160
162
  <VCol class="d-flex justify-start">
161
- <VBtn color="warning" v-if="editor.isActive('link')" :variant="variantBtn" :disabled="isDisabled" @click="clear">
163
+ <VBtn v-if="editor.isActive('link')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
162
164
  {{ t('dialog.clear') }}
163
165
  </VBtn>
164
166
  </VCol>
165
167
  <VCol class="d-flex justify-end">
166
- <VBtn :variant="variantBtn" @click="close" class="mr-2">
168
+ <VBtn :variant="variantBtn" class="mr-2" @click="close">
167
169
  {{ t('dialog.close') }}
168
170
  </VBtn>
169
171
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled || hrefInvalid" @click="apply">
@@ -1,23 +1,22 @@
1
- import Link from "@tiptap/extension-link";
2
-
3
- const name: string = 'link'
1
+ import { CommandProps } from '@tiptap/core'
2
+ import Link from '@tiptap/extension-link'
4
3
 
5
4
  declare module '@tiptap/core' {
6
5
  interface Commands<ReturnType> {
7
- link: {
6
+ tiptapify_link: {
8
7
  showLink: () => ReturnType
9
8
  }
10
9
  }
11
10
  }
12
11
 
13
12
  export const TiptapifyLink = Link.extend({
14
- name,
13
+ name: 'tiptapify_link',
15
14
 
16
15
  addCommands() {
17
16
  return {
18
17
  ...this.parent?.(),
19
- showLink: () => ({ editor }) => {
20
- const event = new CustomEvent(`tiptapify-show-${name}`, {
18
+ showLink: () => ({ editor }: CommandProps) => {
19
+ const event = new CustomEvent('tiptapify-show-link', {
21
20
  detail: {
22
21
  link: editor.getAttributes('link'),
23
22
  editorId: editor.instanceId
@@ -1,22 +1,24 @@
1
1
  <script lang="ts" setup>
2
2
 
3
3
  import * as mdi from '@mdi/js'
4
- import { Editor } from "@tiptap/vue-3";
5
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
6
- import ColumnActions from "@tiptapify/extensions/components/media/table/ColumnActions.vue";
7
- import RowActions from "@tiptapify/extensions/components/media/table/RowActions.vue";
8
- import TableBuilder from "@tiptapify/extensions/components/media/table/TableBuilder.vue";
9
- import { inject, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
6
+ import ColumnActions from '@tiptapify/extensions/components/media/table/ColumnActions.vue'
7
+ import RowActions from '@tiptapify/extensions/components/media/table/RowActions.vue'
8
+ import TableBuilder from '@tiptapify/extensions/components/media/table/TableBuilder.vue'
9
+ import { variantBtnTypes } from '@tiptapify/types/editor'
10
+ import { inject, PropType, Ref } from 'vue'
10
11
 
11
12
  import defaults from '@tiptapify/constants/defaults'
13
+ import { ComposerTranslation } from 'vue-i18n'
12
14
 
13
15
  defineProps({
14
- variantBtn: { type: String, default: defaults.variantBtn }
16
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
15
17
  })
16
18
 
17
19
  const editor = inject('tiptapifyEditor') as Ref<Editor>
18
20
 
19
- const { t } = inject('tiptapifyI18n') as any
21
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
20
22
 
21
23
 
22
24
  const rowActionsDisabled = () => {
@@ -34,11 +36,11 @@ const columnActionsDisabled = () => {
34
36
 
35
37
  <template>
36
38
  <VBtn
37
- :id="`tiptapify-table-button-${editor.instanceId}`"
38
- :color="editor.isActive('table') ? 'primary' : ''"
39
- :disabled="!editor.can().chain().focus().insertTable().run()"
40
- :variant="variantBtn"
41
- size="32"
39
+ :id="`tiptapify-table-button-${editor.instanceId}`"
40
+ :color="editor.isActive('table') ? 'primary' : ''"
41
+ :disabled="!editor.can().chain().focus().insertTable().run()"
42
+ :variant="variantBtn"
43
+ size="32"
42
44
  >
43
45
  <BtnIcon :icon="`mdiSvg:${mdi.mdiTable}`" />
44
46
  </VBtn>
@@ -54,12 +56,12 @@ const columnActionsDisabled = () => {
54
56
  </VListItemTitle>
55
57
 
56
58
  <VMenu
57
- submenu
58
- activator="parent"
59
- :open-on-hover="true"
60
- open-on-click
61
- :close-on-content-click="false"
62
- :disabled="!editor.can().chain().focus().insertTable().run()"
59
+ submenu
60
+ activator="parent"
61
+ :open-on-hover="true"
62
+ open-on-click
63
+ :close-on-content-click="false"
64
+ :disabled="!editor.can().chain().focus().insertTable().run()"
63
65
  >
64
66
  <TableBuilder />
65
67
  </VMenu>
@@ -1,13 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
 
3
3
  import * as mdi from '@mdi/js'
4
- import { Editor } from "@tiptap/vue-3";
5
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
6
- import { inject, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
6
+ import { inject, Ref } from 'vue'
7
+ import { ComposerTranslation } from 'vue-i18n'
7
8
 
8
9
  const editor = inject('tiptapifyEditor') as Ref<Editor>
9
10
 
10
- const { t } = inject('tiptapifyI18n') as any
11
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
11
12
 
12
13
  const columnCanAddBefore = () => {
13
14
  return editor.value.can().chain().focus().addColumnBefore().run()
@@ -1,13 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
 
3
3
  import * as mdi from '@mdi/js'
4
- import { Editor } from "@tiptap/vue-3";
5
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
6
- import { inject, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
6
+ import { inject, Ref } from 'vue'
7
+ import { ComposerTranslation } from 'vue-i18n'
7
8
 
8
9
  const editor = inject('tiptapifyEditor') as Ref<Editor>
9
10
 
10
- const { t } = inject('tiptapifyI18n') as any
11
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
11
12
 
12
13
  const rowCanAddBefore = () => {
13
14
  return editor.value.can().chain().focus().addRowBefore().run()
@@ -1,10 +1,11 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import { Editor } from "@tiptap/vue-3";
3
+ import { Editor } from '@tiptap/vue-3'
4
4
 
5
5
  import { inject, Ref, ref } from 'vue'
6
+ import { ComposerTranslation } from 'vue-i18n'
6
7
 
7
- const { t } = inject('tiptapifyI18n') as any
8
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
8
9
 
9
10
  defineExpose({ open })
10
11
 
@@ -48,22 +49,23 @@ function printSelection() {
48
49
  <template>
49
50
  <VSheet class="pa-2">
50
51
  <VCheckbox
51
- v-model="withHeaderRow"
52
- density="compact"
53
- color="primary"
54
- :label="t('media.tables.insertWithHeaderRow')" hide-details
52
+ v-model="withHeaderRow"
53
+ density="compact"
54
+ color="primary"
55
+ :label="t('media.tables.insertWithHeaderRow')"
56
+ hide-details
55
57
  />
56
58
 
57
59
  <div v-for="rowNum in maxRows" :key="`row-${rowNum}`" class="tiptapify-insert-table-row">
58
60
  <div
59
- v-for="colNum in maxCols"
60
- class="tiptapify-insert-table-col"
61
- :class="{'tiptapify-insert-table-col-hovered': rowNum <= rowHover && colNum <= colHover}"
62
- @click="insertTable(rowNum, colNum)"
63
- @mouseover="hoverCell($el.querySelector('.tiptapify-insert-table-col'), rowNum, colNum)"
64
- @mouseout="leaveCell($el.querySelector('.tiptapify-insert-table-col'))"
61
+ v-for="colNum in maxCols"
62
+ class="tiptapify-insert-table-col"
63
+ :class="{'tiptapify-insert-table-col-hovered': rowNum <= rowHover && colNum <= colHover}"
64
+ @click="insertTable(rowNum, colNum)"
65
+ @mouseover="hoverCell($el.querySelector('.tiptapify-insert-table-col'), rowNum, colNum)"
66
+ @mouseout="leaveCell($el.querySelector('.tiptapify-insert-table-col'))"
65
67
  >
66
- <div class="tiptapify-insert-table-col-button"></div>
68
+ <div class="tiptapify-insert-table-col-button" />
67
69
  </div>
68
70
  </div>
69
71
 
@@ -1,29 +1,31 @@
1
1
  <script lang="ts" setup>
2
2
 
3
- import { Editor } from "@tiptap/vue-3";
4
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
5
- import VideoDialog from "@tiptapify/extensions/components/media/video/VideoDialog.vue";
6
- import { inject, Ref } from "vue";
3
+ import { Editor } from '@tiptap/vue-3'
4
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
5
+ import VideoDialog from '@tiptapify/extensions/components/media/video/VideoDialog.vue'
6
+ import { variantBtnTypes } from '@tiptapify/types/editor'
7
+ import { inject, PropType, Ref } from 'vue'
7
8
 
8
9
  import defaults from '@tiptapify/constants/defaults'
10
+ import { ComposerTranslation } from 'vue-i18n'
9
11
 
10
12
  defineProps({
11
- variantBtn: { type: String, default: defaults.variantBtn }
13
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
12
14
  })
13
15
 
14
16
  const editor = inject('tiptapifyEditor') as Ref<Editor>
15
17
 
16
- const { t } = inject('tiptapifyI18n') as any
18
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
17
19
 
18
20
  const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M4 6H2v14a2 2 0 0 0 2 2h14v-2H4zm16-4H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2m-8 12.5v-9l6 4.5z"/></svg>'
19
21
  </script>
20
22
 
21
23
  <template>
22
24
  <VBtn
23
- :color="editor.isActive('video') ? 'primary' : ''"
24
- :variant="variantBtn"
25
- @click="editor.commands.showTiptapifyVideo()"
26
- size="32"
25
+ :color="editor.isActive('video') ? 'primary' : ''"
26
+ :variant="variantBtn"
27
+ size="32"
28
+ @click="editor.commands.showTiptapifyVideo()"
27
29
  >
28
30
  <VTooltip activator="parent">
29
31
  {{ t('media.video') }}