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,18 +1,20 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import { Editor } from "@tiptap/vue-3";
4
- import TiptapifyDialog from "@tiptapify/components/UI/TiptapifyDialog.vue";
5
- import defaults from "@tiptapify/constants/defaults";
3
+ import { Editor } from '@tiptap/vue-3'
4
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
5
+ import defaults from '@tiptapify/constants/defaults'
6
+ import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
6
7
 
7
- import { computed, inject, onMounted, onUnmounted, Ref, ref } from 'vue'
8
+ import { computed, inject, onMounted, onUnmounted, PropType, Ref, ref, useTemplateRef } from 'vue'
9
+ import { ComposerTranslation } from 'vue-i18n'
8
10
 
9
11
  defineProps({
10
- variantBtn: { type: String, default() { return defaults.variantBtn }},
11
- variantField: { type: String, default() { return defaults.variantField }}
12
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
13
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return defaults.variantField } },
12
14
  })
13
15
 
14
16
  const editor = inject('tiptapifyEditor') as Ref<Editor>
15
- const { t } = inject('tiptapifyI18n') as any
17
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
16
18
 
17
19
  type videoAttrs = {
18
20
  src: string,
@@ -27,7 +29,7 @@ const generateVideoAttrs = () => ({
27
29
 
28
30
  const attrs = ref(generateVideoAttrs())
29
31
 
30
- const dialog = ref(null)
32
+ const dialog = useTemplateRef('dialog')
31
33
 
32
34
  const isDisabled = computed(() => {
33
35
  const { src } = attrs.value
@@ -97,20 +99,36 @@ onUnmounted(() => {
97
99
  <template #content>
98
100
  <VCardText>
99
101
  <VRow>
100
- <!-- <VCol cols="12">-->
101
- <!-- <VSelect v-model="attrs.type" density="compact" variant="outlined" :label="t('dialog.video.src')" />-->
102
- <!-- </VCol>-->
102
+ <!-- <VCol cols="12">-->
103
+ <!-- <VSelect v-model="attrs.type" density="compact" variant="outlined" :label="t('dialog.video.src')" />-->
104
+ <!-- </VCol>-->
103
105
 
104
106
  <VCol cols="12">
105
107
  <VTextField v-model="attrs.src" density="compact" variant="outlined" :label="t('dialog.video.src')" />
106
108
  </VCol>
107
109
 
108
110
  <VCol cols="12" md="3">
109
- <VTextField v-model="attrs.width" type="number" density="compact" variant="outlined" :precision="0" :min="1" :label="t('dialog.video.width')" />
111
+ <VTextField
112
+ v-model="attrs.width"
113
+ type="number"
114
+ density="compact"
115
+ variant="outlined"
116
+ :precision="0"
117
+ :min="1"
118
+ :label="t('dialog.video.width')"
119
+ />
110
120
  </VCol>
111
121
 
112
122
  <VCol cols="12" md="3">
113
- <VTextField v-model="attrs.height" type="number" density="compact" variant="outlined" :precision="0" :min="1" :label="t('dialog.video.height')" />
123
+ <VTextField
124
+ v-model="attrs.height"
125
+ type="number"
126
+ density="compact"
127
+ variant="outlined"
128
+ :precision="0"
129
+ :min="1"
130
+ :label="t('dialog.video.height')"
131
+ />
114
132
  </VCol>
115
133
  </VRow>
116
134
  </VCardText>
@@ -120,12 +138,12 @@ onUnmounted(() => {
120
138
  <VCardActions>
121
139
  <VRow>
122
140
  <VCol class="d-flex justify-start">
123
- <VBtn color="warning" v-if="editor.isActive('image')" :variant="variantBtn" :disabled="isDisabled" @click="clear">
141
+ <VBtn v-if="editor.isActive('image')" color="warning" :variant="variantBtn" :disabled="isDisabled" @click="clear">
124
142
  {{ t('dialog.clear') }}
125
143
  </VBtn>
126
144
  </VCol>
127
145
  <VCol class="d-flex justify-end">
128
- <VBtn :variant="variantBtn" @click="close" class="mr-2">
146
+ <VBtn :variant="variantBtn" class="mr-2" @click="close">
129
147
  {{ t('dialog.close') }}
130
148
  </VBtn>
131
149
  <VBtn color="primary" :variant="variantBtn" :disabled="isDisabled" @click="apply">
@@ -1,24 +1,26 @@
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 { 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
  </script>
19
21
 
20
22
  <template>
21
- <VBtn @click="editor.chain().focus().setHardBreak().run()" size="32" :variant="variantBtn">
23
+ <VBtn size="32" :variant="variantBtn" @click="editor.chain().focus().setHardBreak().run()">
22
24
  <VTooltip activator="parent">
23
25
  {{ t('format.break') }}
24
26
  </VTooltip>
@@ -1,29 +1,31 @@
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 { 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
  </script>
19
21
 
20
22
  <template>
21
23
  <VBtn
22
- :disabled="!editor.can().chain().focus().unsetAllMarks().run()"
23
- :variant="variantBtn"
24
- size="32"
25
- color=""
26
- @click="editor.chain().focus().unsetAllMarks().clearNodes().run()"
24
+ :disabled="!editor.can().chain().focus().unsetAllMarks().run()"
25
+ :variant="variantBtn"
26
+ size="32"
27
+ color=""
28
+ @click="editor.chain().focus().unsetAllMarks().clearNodes().run()"
27
29
  >
28
30
  <VTooltip activator="parent">
29
31
  {{ t('format.formatClear') }}
@@ -1,30 +1,32 @@
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, nextTick, ref, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
6
+ import { variantBtnTypes } from '@tiptapify/types/editor'
7
+ import { inject, nextTick, PropType, ref, 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
- const dialog = ref(false)
20
+ const showDialog = ref(false)
19
21
 
20
22
  async function dialogOpen() {
21
- dialog.value = true
23
+ showDialog.value = true
22
24
 
23
25
  await changeEditorContainer('tiptapify-editor', 'tiptapify-editor-fullscreen')
24
26
  }
25
27
 
26
28
  async function dialogClose() {
27
- dialog.value = false
29
+ showDialog.value = false
28
30
 
29
31
  await changeEditorContainer('tiptapify-editor-fullscreen', 'tiptapify-editor')
30
32
  }
@@ -32,31 +34,31 @@ async function dialogClose() {
32
34
  async function changeEditorContainer(source: string, target: string) {
33
35
  await nextTick()
34
36
 
35
- const sourceElm = document.querySelector(`#${source}-${editor.value.instanceId} > div`);
37
+ const sourceElm = document.querySelector(`#${source}-${editor.value.instanceId} > div`)
36
38
 
37
- const targetElm = document.querySelector(`#${target}-${editor.value.instanceId}`);
39
+ const targetElm = document.querySelector(`#${target}-${editor.value.instanceId}`)
38
40
 
39
- targetElm.appendChild(sourceElm);
41
+ targetElm.appendChild(sourceElm)
40
42
  }
41
43
 
42
44
  </script>
43
45
 
44
46
  <template>
45
47
  <VBtn
46
- @click="dialog ? dialogClose() : dialogOpen()"
47
- size="32"
48
- :color="dialog ? 'primary' : ''"
49
- :variant="variantBtn"
48
+ size="32"
49
+ :color="showDialog ? 'primary' : ''"
50
+ :variant="variantBtn"
51
+ @click="showDialog ? dialogClose() : dialogOpen()"
50
52
  >
51
53
  <VTooltip activator="parent">
52
54
  {{ t('misc.fullscreen') }}
53
55
  </VTooltip>
54
- <BtnIcon :icon="dialog ? `mdiSvg:${mdi.mdiFullscreenExit}` : `mdiSvg:${mdi.mdiFullscreen}`" />
56
+ <BtnIcon :icon="showDialog ? `mdiSvg:${mdi.mdiFullscreenExit}` : `mdiSvg:${mdi.mdiFullscreen}`" />
55
57
  </VBtn>
56
58
 
57
- <VDialog v-model="dialog" fullscreen @close="dialogClose()" @update:modelValue="!dialog ? dialogClose() : ''">
59
+ <VDialog v-model="showDialog" fullscreen @close="dialogClose()" @update:model-value="!showDialog ? dialogClose() : ''">
58
60
  <VCard>
59
- <div :id="`tiptapify-editor-fullscreen-${editor?.instanceId}`"></div>
61
+ <div :id="`tiptapify-editor-fullscreen-${editor?.instanceId}`" />
60
62
  </VCard>
61
63
  </VDialog>
62
64
  </template>
@@ -1,18 +1,20 @@
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 { inject, Ref } from "vue";
3
+ import { Editor } from '@tiptap/vue-3'
4
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
5
+ import { variantBtnTypes } from '@tiptapify/types/editor'
6
+ import { inject, PropType, Ref } from 'vue'
6
7
 
7
8
  import defaults from '@tiptapify/constants/defaults'
9
+ import { ComposerTranslation } from 'vue-i18n'
8
10
 
9
11
  defineProps({
10
- variantBtn: { type: String, default: defaults.variantBtn }
12
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
11
13
  })
12
14
 
13
15
  const editor = inject('tiptapifyEditor') as Ref<Editor>
14
16
 
15
- const { t } = inject('tiptapifyI18n') as any
17
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
16
18
 
17
19
  const icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path fill="currentColor" d="M256 64L512 64C529.7 64 544 78.3 544 96C544 113.7 529.7 128 512 128L480 128L480 544C480 561.7 465.7 576 448 576C430.3 576 416 561.7 416 544L416 128L368 128L368 544C368 561.7 353.7 576 336 576C318.3 576 304 561.7 304 544L304 384L256 384C167.6 384 96 312.4 96 224C96 135.6 167.6 64 256 64z"/></svg>'
18
20
 
@@ -20,10 +22,10 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><pat
20
22
 
21
23
  <template>
22
24
  <VBtn
23
- :color="editor.storage.invisibleCharacters.visibility() ? 'primary' : ''"
24
- :variant="variantBtn"
25
- @click="editor.commands.toggleInvisibleCharacters()"
26
- size="32"
25
+ :color="editor.storage.invisibleCharacters.visibility() ? 'primary' : ''"
26
+ :variant="variantBtn"
27
+ size="32"
28
+ @click="editor.commands.toggleInvisibleCharacters()"
27
29
  >
28
30
  <VTooltip activator="parent">
29
31
  {{ t('misc.toggleInvisibleCharacters') }}
@@ -1,28 +1,30 @@
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, onMounted, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.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
  </script>
19
21
 
20
22
  <template>
21
23
  <VBtn
22
- @click="editor.chain().focus().setHorizontalRule().run()"
23
- :color="editor.isActive('horizontalRule') ? 'primary' : ''"
24
- size="32"
25
- :variant="variantBtn"
24
+ :color="editor.isActive('horizontalRule') ? 'primary' : ''"
25
+ size="32"
26
+ :variant="variantBtn"
27
+ @click="editor.chain().focus().setHorizontalRule().run()"
26
28
  >
27
29
  <VTooltip activator="parent">
28
30
  {{ t('format.line') }}
@@ -1,27 +1,29 @@
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 TiptapifyDialog from "@tiptapify/components/UI/TiptapifyDialog.vue";
7
- import { inject, ref, Ref } from "vue";
4
+ import { Editor } from '@tiptap/vue-3'
5
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
6
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
7
+ import { variantBtnTypes } from '@tiptapify/types/editor'
8
+ import { inject, PropType, ref, Ref, useTemplateRef } from 'vue'
8
9
 
9
10
  import defaults from '@tiptapify/constants/defaults'
11
+ import { ComposerTranslation } from 'vue-i18n'
10
12
 
11
13
  defineProps({
12
- variantBtn: { type: String, default: defaults.variantBtn }
14
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
13
15
  })
14
16
 
15
17
  const editor = inject('tiptapifyEditor') as Ref<Editor>
16
18
 
17
- const { t } = inject('tiptapifyI18n') as any
19
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
18
20
 
19
- const dialog = ref(null)
21
+ const dialog = useTemplateRef('dialog')
20
22
 
21
23
  </script>
22
24
 
23
25
  <template>
24
- <VBtn @click="dialog.open()" size="32" color="" :variant="variantBtn">
26
+ <VBtn size="32" color="" :variant="variantBtn" @click="dialog.open()">
25
27
  <VTooltip activator="parent">
26
28
  {{ t('misc.preview') }}
27
29
  </VTooltip>
@@ -31,7 +33,7 @@ const dialog = ref(null)
31
33
  <TiptapifyDialog ref="dialog" module="preview" fullscreen>
32
34
  <template #content>
33
35
  <VCardItem>
34
- <div class="tiptap" v-html="editor.getHTML()"></div>
36
+ <div class="tiptap" v-html="editor.getHTML()" />
35
37
  </VCardItem>
36
38
  </template>
37
39
  </TiptapifyDialog>
@@ -1,19 +1,21 @@
1
1
  <script lang="ts" setup>
2
2
 
3
3
  import * as mdi from '@mdi/js'
4
- import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
5
- import ShowSourceDialog from "@tiptapify/extensions/components/misc/source/ShowSourceDialog.vue";
6
- import { inject, ref } from "vue";
4
+ import BtnIcon from '@tiptapify/components/UI/BtnIcon.vue'
5
+ import ShowSourceDialog from '@tiptapify/extensions/components/misc/source/ShowSourceDialog.vue'
6
+ import { variantBtnTypes } from '@tiptapify/types/editor'
7
+ import { inject, PropType, ref, useTemplateRef } 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
- const { t } = inject('tiptapifyI18n') as any
16
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
15
17
 
16
- const dialog = ref(null)
18
+ const dialog = useTemplateRef('dialog')
17
19
 
18
20
  function showDialog() {
19
21
  dialog.value.showDialog()
@@ -22,7 +24,7 @@ function showDialog() {
22
24
  </script>
23
25
 
24
26
  <template>
25
- <VBtn @click="showDialog()" size="32" color="" :variant="variantBtn">
27
+ <VBtn size="32" color="" :variant="variantBtn" @click="showDialog()">
26
28
  <VTooltip activator="parent">
27
29
  {{ t('misc.source') }}
28
30
  </VTooltip>
@@ -1,51 +1,53 @@
1
1
  <script setup lang="ts">
2
- import { Editor } from "@tiptap/vue-3";
3
- import TiptapifyDialog from "@tiptapify/components/UI/TiptapifyDialog.vue";
4
- import defaults from "@tiptapify/constants/defaults";
5
- import { ref, watch, inject, Ref } from 'vue'
2
+ import { Editor } from '@tiptap/vue-3'
3
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
4
+ import defaults from '@tiptapify/constants/defaults'
5
+ import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
6
+ import { ref, watch, inject, Ref, PropType, useTemplateRef } from 'vue'
7
+ import { ComposerTranslation } from 'vue-i18n'
6
8
 
7
9
  const props = defineProps({
8
10
  indent: { type: Number, default: 2 },
9
- variantBtn: { type: String, default: 'elevated' },
10
- variantField: { type: String, default: defaults.variantField }
11
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return 'elevated' } },
12
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return defaults.variantField } },
11
13
  })
12
14
 
13
15
  defineExpose({ showDialog })
14
16
 
15
- const { t } = inject('tiptapifyI18n') as any
17
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
16
18
 
17
19
  const editor = inject('tiptapifyEditor') as Ref<Editor>
18
20
 
19
- const dialog = ref(null)
21
+ const dialog = useTemplateRef('dialog')
20
22
  const formatted = ref(false)
21
23
  const sourceCode = ref('')
22
24
 
23
25
  const formatHtml = (html: string): string => {
24
26
  const singleTags = ['img', 'hr', 'br', 'input']
25
- let formatted = html.replace(/>/g, '>\n');
27
+ let formatted = html.replace(/>/g, '>\n')
26
28
 
27
- formatted = formatted.replace(/([^>\n])</g, '$1\n<');
29
+ formatted = formatted.replace(/([^>\n])</g, '$1\n<')
28
30
 
29
- const lines = formatted.split('\n');
30
- let indentLevel = 0;
31
+ const lines = formatted.split('\n')
32
+ let indentLevel = 0
31
33
 
32
34
  return lines
33
35
  .map(line => {
34
36
  if (line.match(/<\//)) {
35
- indentLevel = Math.max(0, indentLevel - 1);
37
+ indentLevel = Math.max(0, indentLevel - 1)
36
38
  }
37
39
 
38
- const indentedLine = ' '.repeat(indentLevel * props.indent) + line;
40
+ const indentedLine = ' '.repeat(indentLevel * props.indent) + line
39
41
 
40
42
  const tag = line.match(/<\/?(\S+).*>/) ?? []
41
43
  if (!singleTags.includes(tag[1] ?? '') && line.match(/<[^\/][^>]*>/) && !line.match(/<.*\/>/)) {
42
- indentLevel++;
44
+ indentLevel++
43
45
  }
44
46
 
45
- return indentedLine;
47
+ return indentedLine
46
48
  })
47
49
  .filter(line => line.trim())
48
- .join('\n');
50
+ .join('\n')
49
51
  }
50
52
 
51
53
  const unformatHtml = (html: string): string => {
@@ -58,11 +60,11 @@ const unformatHtml = (html: string): string => {
58
60
  function showDialog () {
59
61
  sourceCode.value = editor.value.getHTML()
60
62
 
61
- dialog.value.open()
63
+ dialog.value?.open()
62
64
  }
63
65
 
64
66
  const saveChanges = () => {
65
- dialog.value.close()
67
+ dialog.value?.close()
66
68
 
67
69
  editor.value.commands.setContent(sourceCode.value, true)
68
70
  }
@@ -87,18 +89,18 @@ watch(() => formatted.value, () => {
87
89
  </VContainer>
88
90
 
89
91
  <VTextarea
90
- v-model="sourceCode"
91
- no-resize
92
- rows="100"
93
- :variant="variantField"
94
- class="source-code-area"
92
+ v-model="sourceCode"
93
+ no-resize
94
+ rows="100"
95
+ :variant="variantField"
96
+ class="source-code-area"
95
97
  />
96
98
  </VCardText>
97
99
  </template>
98
100
 
99
101
  <template #actions>
100
102
  <VCardActions>
101
- <VSpacer></VSpacer>
103
+ <VSpacer />
102
104
  <VBtn :variant="variantBtn" @click="dialog.close()">
103
105
  {{ t('dialog.close') }}
104
106
  </VBtn>
@@ -84,7 +84,9 @@ defineExpose({
84
84
  <span class="item-title">{{ item.title }}</span>
85
85
  </button>
86
86
  </template>
87
- <div v-else class="no-result">No result</div>
87
+ <div v-else class="no-result">
88
+ No result
89
+ </div>
88
90
  </div>
89
91
  </template>
90
92
 
@@ -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 { computed, 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, close })
10
11
 
@@ -77,17 +78,17 @@ function calculateShadowColor(color: string): string {
77
78
  }
78
79
 
79
80
  function hexToRgb(hex: string): Color {
80
- const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
81
+ const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i
81
82
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
82
- return r + r + g + g + b + b;
83
- });
83
+ return r + r + g + g + b + b
84
+ })
84
85
 
85
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
86
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
86
87
  return {
87
88
  r: result ? parseInt(result[1], 16) : 0,
88
89
  g: result ? parseInt(result[2], 16) : 0,
89
90
  b: result ? parseInt(result[3], 16) : 0
90
- };
91
+ }
91
92
  }
92
93
 
93
94
  function hoverColor(color: string) {
@@ -150,16 +151,16 @@ function isColorActive(color: string): boolean {
150
151
  <div class="tiptapify-style-color-container">
151
152
  <template v-for="colorCode in colors">
152
153
  <div
153
- class="tiptapify-style-color-item"
154
- :class="isColorActive(colorCode) ? 'tiptapify-style-color-item-active' : ''"
155
- @mouseenter="hoverColor(colorCode)"
156
- @mouseleave="resetColor()"
157
- @click="setColor"
154
+ class="tiptapify-style-color-item"
155
+ :class="isColorActive(colorCode) ? 'tiptapify-style-color-item-active' : ''"
156
+ @mouseenter="hoverColor(colorCode)"
157
+ @mouseleave="resetColor()"
158
+ @click="setColor"
158
159
  >
159
160
  <div
160
- class="tiptapify-style-color-picker"
161
- :style="`background-color: ${colorCode}; box-shadow: 1px 1px 4px rgb(${calculateShadowColor(colorCode)});`"
162
- ></div>
161
+ class="tiptapify-style-color-picker"
162
+ :style="`background-color: ${colorCode}; box-shadow: 1px 1px 4px rgb(${calculateShadowColor(colorCode)});`"
163
+ />
163
164
  </div>
164
165
  </template>
165
166
  </div>
@@ -171,10 +172,9 @@ function isColorActive(color: string): boolean {
171
172
  <VBtn v-bind="menuProps" color="default" variant="flat" block>
172
173
  <template #prepend>
173
174
  <div
174
- class="tiptapify-style-color-picker"
175
- :style="`background-color: ${customColor}; box-shadow: 1px 1px 4px rgb(0, 0, 0, .35);`"
176
- >
177
- </div>
175
+ class="tiptapify-style-color-picker"
176
+ :style="`background-color: ${customColor}; box-shadow: 1px 1px 4px rgb(0, 0, 0, .35);`"
177
+ />
178
178
  </template>
179
179
  <template #default>
180
180
  {{ t('style.color.custom') }}
@@ -188,15 +188,19 @@ function isColorActive(color: string): boolean {
188
188
  </VCardItem>
189
189
 
190
190
  <VCardActions>
191
- <VBtn variant="flat" color="primary" @click="setColor">OK</VBtn>
192
- <VBtn variant="flat" color="grey-400" @click="colorPicker = !colorPicker; customColor = initialColor; resetColor()">Cancel</VBtn>
191
+ <VBtn variant="flat" color="primary" @click="setColor">
192
+ OK
193
+ </VBtn>
194
+ <VBtn variant="flat" color="grey-400" @click="colorPicker = !colorPicker; customColor = initialColor; resetColor()">
195
+ Cancel
196
+ </VBtn>
193
197
  </VCardActions>
194
198
  </VCard>
195
199
  </VMenu>
196
200
 
197
201
  <VDivider class="mt-2 mb-2" />
198
202
 
199
- <VBtn @click="unsetColor" color="default" block variant="flat">
203
+ <VBtn color="default" block variant="flat" @click="unsetColor">
200
204
  {{ t('style.color.unset') }}
201
205
  </VBtn>
202
206
  </VSheet>