tiptapify 0.2.4 → 0.2.5

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 (63) hide show
  1. package/README.md +1 -1
  2. package/dist/tiptapify.css +1 -1
  3. package/dist/tiptapify.mjs +84644 -65141
  4. package/dist/tiptapify.umd.js +86 -84
  5. package/index.d.ts +23 -2
  6. package/package.json +45 -45
  7. package/src/components/Tiptapify.vue +83 -1
  8. package/src/components/Toolbar/Index.vue +2 -2
  9. package/src/components/Toolbar/Items.vue +9 -2
  10. package/src/components/UI/TiptapifyDialog.vue +7 -1
  11. package/src/extensions/components/ai/Button.vue +1 -1
  12. package/src/extensions/components/ai/Dialog.vue +337 -27
  13. package/src/extensions/components/ai/charLimit.test.ts +55 -0
  14. package/src/extensions/components/ai/charLimit.ts +30 -0
  15. package/src/extensions/components/ai/characterCount.test.ts +27 -0
  16. package/src/extensions/components/media/iframe/Button.vue +1 -2
  17. package/src/extensions/components/media/iframe/IframeDialog.vue +36 -31
  18. package/src/extensions/components/media/image/Button.vue +1 -1
  19. package/src/extensions/components/media/link/Button.vue +1 -1
  20. package/src/extensions/components/media/link/LinkDialog.vue +19 -36
  21. package/src/extensions/components/media/video/Button.vue +1 -1
  22. package/src/extensions/components/media/video/VideoDialog.vue +17 -17
  23. package/src/extensions/components/misc/source/Button.vue +1 -1
  24. package/src/i18n/locales/ar.json +165 -159
  25. package/src/i18n/locales/bg.json +212 -0
  26. package/src/i18n/locales/ch.json +165 -159
  27. package/src/i18n/locales/cz.json +165 -159
  28. package/src/i18n/locales/de.json +165 -159
  29. package/src/i18n/locales/el.json +212 -0
  30. package/src/i18n/locales/en.json +166 -159
  31. package/src/i18n/locales/es.json +165 -159
  32. package/src/i18n/locales/et.json +212 -0
  33. package/src/i18n/locales/fi.json +165 -159
  34. package/src/i18n/locales/fr.json +165 -159
  35. package/src/i18n/locales/he.json +212 -0
  36. package/src/i18n/locales/hi.json +212 -0
  37. package/src/i18n/locales/hr.json +212 -0
  38. package/src/i18n/locales/hu.json +165 -159
  39. package/src/i18n/locales/id.json +212 -0
  40. package/src/i18n/locales/it.json +165 -159
  41. package/src/i18n/locales/ja.json +165 -159
  42. package/src/i18n/locales/ko.json +165 -159
  43. package/src/i18n/locales/la.json +165 -159
  44. package/src/i18n/locales/lt.json +165 -159
  45. package/src/i18n/locales/nl.json +165 -159
  46. package/src/i18n/locales/no.json +212 -0
  47. package/src/i18n/locales/pl.json +165 -159
  48. package/src/i18n/locales/pt-BR.json +212 -0
  49. package/src/i18n/locales/pt.json +165 -159
  50. package/src/i18n/locales/ro.json +212 -0
  51. package/src/i18n/locales/ru.json +165 -159
  52. package/src/i18n/locales/se.json +165 -159
  53. package/src/i18n/locales/sk.json +212 -0
  54. package/src/i18n/locales/sl.json +212 -0
  55. package/src/i18n/locales/sr.json +212 -0
  56. package/src/i18n/locales/th.json +165 -159
  57. package/src/i18n/locales/tr.json +165 -159
  58. package/src/i18n/locales/uk.json +165 -159
  59. package/src/i18n/locales/vi.json +165 -159
  60. package/src/index.ts +3 -0
  61. package/src/types/editor.ts +23 -2
  62. package/src/utils/validateHref.test.ts +68 -0
  63. package/src/utils/validateHref.ts +21 -0
@@ -113,8 +113,8 @@ watch(() => attrs.value.src, () => {
113
113
  <TiptapifyDialog ref="dialog" module="iframe" :title="t('dialog.iframe.dialog_title')" :max-width="800">
114
114
  <template #content>
115
115
  <VCardText>
116
- <VRow>
117
- <VCol cols="12">
116
+ <div class="tiptapify-dialog-grid">
117
+ <div class="tiptapify-dialog-col">
118
118
  <VTextField
119
119
  v-model="attrs.src"
120
120
  density="compact"
@@ -122,23 +122,23 @@ watch(() => attrs.value.src, () => {
122
122
  :label="t('dialog.iframe.src')"
123
123
  :error-messages="srcInvalid ? t('dialog.iframe.src_invalid') : ''"
124
124
  />
125
- </VCol>
125
+ </div>
126
126
 
127
- <VCol cols="12" md="6">
128
- <VRow>
129
- <VCol cols="12">
127
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--6">
128
+ <div class="tiptapify-dialog-grid">
129
+ <div class="tiptapify-dialog-col">
130
130
  <VTextField v-model="attrs.name" density="compact" variant="outlined" :label="t('dialog.iframe.name')" />
131
- </VCol>
131
+ </div>
132
132
 
133
- <VCol cols="12">
133
+ <div class="tiptapify-dialog-col">
134
134
  <VTextField v-model="attrs.title" density="compact" variant="outlined" :label="t('dialog.iframe.title')" />
135
- </VCol>
136
- </VRow>
137
- </VCol>
135
+ </div>
136
+ </div>
137
+ </div>
138
138
 
139
- <VCol cols="12" md="6">
140
- <VRow>
141
- <VCol cols="12" md="6">
139
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--6">
140
+ <div class="tiptapify-dialog-grid">
141
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--6">
142
142
  <VTextField
143
143
  v-model="attrs.width"
144
144
  type="number"
@@ -148,9 +148,9 @@ watch(() => attrs.value.src, () => {
148
148
  :min="1"
149
149
  :label="t('dialog.iframe.width')"
150
150
  />
151
- </VCol>
151
+ </div>
152
152
 
153
- <VCol cols="12" md="6">
153
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--6">
154
154
  <VTextField
155
155
  v-model="attrs.height"
156
156
  type="number"
@@ -160,34 +160,39 @@ watch(() => attrs.value.src, () => {
160
160
  :min="1"
161
161
  :label="t('dialog.iframe.height')"
162
162
  />
163
- </VCol>
164
-
165
- <VCol cols="12" class="ml-2">
166
- <VSwitch v-model="attrs.frameborder" density="compact" :hide-details="true" :label="t('dialog.iframe.frameborder')" />
167
- </VCol>
168
- </VRow>
169
- </VCol>
170
- </VRow>
163
+ </div>
164
+
165
+ <div class="tiptapify-dialog-col">
166
+ <VSwitch
167
+ v-model="attrs.frameborder"
168
+ density="compact"
169
+ :hide-details="true"
170
+ :label="t('dialog.iframe.frameborder')"
171
+ />
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
171
176
  </VCardText>
172
177
  </template>
173
178
 
174
179
  <template #actions>
175
180
  <VCardActions>
176
- <VRow>
177
- <VCol class="d-flex justify-start">
181
+ <div class="tiptapify-dialog-actions">
182
+ <div class="tiptapify-dialog-actions__start">
178
183
  <VBtn v-if="editor.isActive('image')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
179
184
  {{ t('dialog.clear') }}
180
185
  </VBtn>
181
- </VCol>
182
- <VCol class="d-flex justify-end">
183
- <VBtn :variant="variantBtn" class="mr-2" @click="close">
186
+ </div>
187
+ <div class="tiptapify-dialog-actions__end">
188
+ <VBtn :variant="variantBtn" @click="close">
184
189
  {{ t('dialog.close') }}
185
190
  </VBtn>
186
191
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled" @click="apply">
187
192
  {{ t('dialog.apply') }}
188
193
  </VBtn>
189
- </VCol>
190
- </VRow>
194
+ </div>
195
+ </div>
191
196
  </VCardActions>
192
197
  </template>
193
198
  </TiptapifyDialog>
@@ -33,7 +33,7 @@ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
33
33
  <BtnIcon :icon="`mdiSvg:${mdi.mdiImage}`" />
34
34
  </VBtn>
35
35
 
36
- <ImageDialog />
36
+ <ImageDialog :variant-btn="variantBtn" />
37
37
  </template>
38
38
 
39
39
  <style lang="scss" scoped>
@@ -34,7 +34,7 @@ const icon = computed(() => editor.value.isActive('tiptapifyLink') ? `mdiSvg:${m
34
34
  <BtnIcon :icon="icon" />
35
35
  </VBtn>
36
36
 
37
- <LinkDialog />
37
+ <LinkDialog :variant-btn="variantBtn" />
38
38
  </template>
39
39
 
40
40
  <style lang="scss" scoped>
@@ -3,6 +3,7 @@
3
3
  import { Editor } from '@tiptap/vue-3'
4
4
  import defaults from '@tiptapify/constants/defaults'
5
5
  import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
6
+ import { isValidHref } from '@tiptapify/utils/validateHref'
6
7
 
7
8
  import { computed, inject, onMounted, onUnmounted, PropType, Ref, ref, useTemplateRef, watch } from 'vue'
8
9
 
@@ -86,25 +87,7 @@ onUnmounted(() => {
86
87
  })
87
88
 
88
89
  watch(() => attrs.value.href, () => {
89
- const azAZ09 = 'a-zA-Z0-9'
90
-
91
- const regexHrefProto = 'https?:\\/\\/'
92
- const regexHrefAuth = `([${azAZ09}]+(:[${azAZ09}]+)?@)?`
93
- const regexHrefDomain = `[${azAZ09}]+(\\.[${azAZ09}]+(-?[${azAZ09}]+)?)+`
94
- const regexHrefPath = `(\\/[${azAZ09}\\-]+)*`
95
- const regexHrefFragment = '(#[^\\s]*)?'
96
- const regexHrefQueryParam = `(\\?[${azAZ09}\\-_]+((\\[[${azAZ09}]+\\])?=[${azAZ09}\\-_%]+)?)?`
97
- const regexHrefQueryParamExtra = `(&[${azAZ09}\\-_]+((\\[[${azAZ09}]+\\])?=[${azAZ09}\\-_%]+)?)*`
98
- const regexHref = `${regexHrefProto}${regexHrefAuth}${regexHrefDomain}${regexHrefPath}${regexHrefFragment}${regexHrefQueryParam}${regexHrefQueryParamExtra}`
99
-
100
- const regexMailto = `mailto:\\w+@[${azAZ09}]+(\\.[${azAZ09}]+)*`
101
- const regexTel = 'tel:\\+?[0-9]+'
102
-
103
- const regexAll = [regexHref, regexMailto, regexTel].join('|')
104
-
105
- const regex = new RegExp(`^(${regexAll})$`, 'i')
106
-
107
- hrefInvalid.value = (attrs.value.href || '') !== '' && !regex.test(attrs.value.href)
90
+ hrefInvalid.value = (attrs.value.href || '') !== '' && !isValidHref(attrs.value.href)
108
91
  })
109
92
  </script>
110
93
 
@@ -112,8 +95,8 @@ watch(() => attrs.value.href, () => {
112
95
  <TiptapifyDialog ref="dialog" module="link">
113
96
  <template #content>
114
97
  <VCardText>
115
- <VRow>
116
- <VCol cols="12">
98
+ <div class="tiptapify-dialog-grid">
99
+ <div class="tiptapify-dialog-col">
117
100
  <VTextField
118
101
  v-model="attrs.href"
119
102
  density="compact"
@@ -122,9 +105,9 @@ watch(() => attrs.value.href, () => {
122
105
  :error-messages="hrefInvalid ? t('dialog.link.href_error') : ''"
123
106
  autofocus
124
107
  />
125
- </VCol>
108
+ </div>
126
109
 
127
- <VCol cols="12" md="4">
110
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--4">
128
111
  <VSelect
129
112
  v-model="attrs.target"
130
113
  :items="targetAttrs"
@@ -133,13 +116,13 @@ watch(() => attrs.value.href, () => {
133
116
  return-object
134
117
  density="compact"
135
118
  />
136
- </VCol>
119
+ </div>
137
120
 
138
- <VCol cols="12" md="8">
121
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--8">
139
122
  <VTextField v-model="attrs.cssClass" density="compact" variant="outlined" :label="t('dialog.link.class')" />
140
- </VCol>
123
+ </div>
141
124
 
142
- <VCol cols="12">
125
+ <div class="tiptapify-dialog-col">
143
126
  <VSelect
144
127
  v-model="attrs.rel"
145
128
  :items="relAttrs"
@@ -151,28 +134,28 @@ watch(() => attrs.value.href, () => {
151
134
  clearable
152
135
  density="compact"
153
136
  />
154
- </VCol>
155
- </VRow>
137
+ </div>
138
+ </div>
156
139
  </VCardText>
157
140
  </template>
158
141
 
159
142
  <template #actions>
160
143
  <VCardActions>
161
- <VRow>
162
- <VCol class="d-flex justify-start">
144
+ <div class="tiptapify-dialog-actions">
145
+ <div class="tiptapify-dialog-actions__start">
163
146
  <VBtn v-if="editor.isActive('link')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
164
147
  {{ t('dialog.clear') }}
165
148
  </VBtn>
166
- </VCol>
167
- <VCol class="d-flex justify-end">
168
- <VBtn :variant="variantBtn" class="mr-2" @click="close">
149
+ </div>
150
+ <div class="tiptapify-dialog-actions__end">
151
+ <VBtn :variant="variantBtn" @click="close">
169
152
  {{ t('dialog.close') }}
170
153
  </VBtn>
171
154
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled || hrefInvalid" @click="apply">
172
155
  {{ t('dialog.apply') }}
173
156
  </VBtn>
174
- </VCol>
175
- </VRow>
157
+ </div>
158
+ </div>
176
159
  </VCardActions>
177
160
  </template>
178
161
  </TiptapifyDialog>
@@ -33,7 +33,7 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" vie
33
33
  <BtnIcon :icon="icon" />
34
34
  </VBtn>
35
35
 
36
- <VideoDialog />
36
+ <VideoDialog :variant-btn="variantBtn" />
37
37
  </template>
38
38
 
39
39
  <style lang="scss" scoped>
@@ -98,16 +98,16 @@ onUnmounted(() => {
98
98
  <TiptapifyDialog ref="dialog" module="video" :max-width="800">
99
99
  <template #content>
100
100
  <VCardText>
101
- <VRow>
102
- <!-- <VCol cols="12">-->
101
+ <div class="tiptapify-dialog-grid">
102
+ <!-- <div class="tiptapify-dialog-col">-->
103
103
  <!-- <VSelect v-model="attrs.type" density="compact" variant="outlined" :label="t('dialog.video.src')" />-->
104
- <!-- </VCol>-->
104
+ <!-- </div>-->
105
105
 
106
- <VCol cols="12">
106
+ <div class="tiptapify-dialog-col">
107
107
  <VTextField v-model="attrs.src" density="compact" variant="outlined" :label="t('dialog.video.src')" />
108
- </VCol>
108
+ </div>
109
109
 
110
- <VCol cols="12" md="3">
110
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--3">
111
111
  <VTextField
112
112
  v-model="attrs.width"
113
113
  type="number"
@@ -117,9 +117,9 @@ onUnmounted(() => {
117
117
  :min="1"
118
118
  :label="t('dialog.video.width')"
119
119
  />
120
- </VCol>
120
+ </div>
121
121
 
122
- <VCol cols="12" md="3">
122
+ <div class="tiptapify-dialog-col tiptapify-dialog-col--3">
123
123
  <VTextField
124
124
  v-model="attrs.height"
125
125
  type="number"
@@ -129,28 +129,28 @@ onUnmounted(() => {
129
129
  :min="1"
130
130
  :label="t('dialog.video.height')"
131
131
  />
132
- </VCol>
133
- </VRow>
132
+ </div>
133
+ </div>
134
134
  </VCardText>
135
135
  </template>
136
136
 
137
137
  <template #actions>
138
138
  <VCardActions>
139
- <VRow>
140
- <VCol class="d-flex justify-start">
139
+ <div class="tiptapify-dialog-actions">
140
+ <div class="tiptapify-dialog-actions__start">
141
141
  <VBtn v-if="editor.isActive('image')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
142
142
  {{ t('dialog.clear') }}
143
143
  </VBtn>
144
- </VCol>
145
- <VCol class="d-flex justify-end">
146
- <VBtn :variant="variantBtn" class="mr-2" @click="close">
144
+ </div>
145
+ <div class="tiptapify-dialog-actions__end">
146
+ <VBtn :variant="variantBtn" @click="close">
147
147
  {{ t('dialog.close') }}
148
148
  </VBtn>
149
149
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled" @click="apply">
150
150
  {{ t('dialog.apply') }}
151
151
  </VBtn>
152
- </VCol>
153
- </VRow>
152
+ </div>
153
+ </div>
154
154
  </VCardActions>
155
155
  </template>
156
156
  </TiptapifyDialog>
@@ -31,7 +31,7 @@ function showDialog() {
31
31
  <BtnIcon :icon="`mdiSvg:${mdi.mdiCodeTags}`" />
32
32
  </VBtn>
33
33
 
34
- <ShowSourceDialog ref="dialog" />
34
+ <ShowSourceDialog ref="dialog" :variant-btn="variantBtn" />
35
35
  </template>
36
36
 
37
37
  <style lang="scss" scoped>