tiptapify 0.0.10 → 0.0.12

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 (107) hide show
  1. package/README.md +7 -3
  2. package/dist/tiptapify.css +1 -1
  3. package/dist/tiptapify.mjs +18524 -17801
  4. package/dist/tiptapify.umd.js +77 -38
  5. package/index.d.ts +2 -2
  6. package/package.json +41 -40
  7. package/src/components/MenuBubble.vue +8 -8
  8. package/src/components/Tiptapify.vue +5 -6
  9. package/src/components/Toolbar/Group.vue +2 -2
  10. package/src/components/Toolbar/GroupBtn.vue +12 -9
  11. package/src/components/Toolbar/GroupDropdown.vue +5 -19
  12. package/src/components/Toolbar/Index.vue +13 -9
  13. package/src/components/Toolbar/Items.vue +5 -8
  14. package/src/components/Toolbar/Toggle.vue +3 -5
  15. package/src/components/Toolbar/defaultExtensionComponents.ts +34 -13
  16. package/src/components/Toolbar/items.ts +53 -70
  17. package/src/components/UI/BtnIcon.vue +24 -0
  18. package/src/components/UI/{Dialog.vue → TiptapifyDialog.vue} +4 -3
  19. package/src/components/editorExtensions.ts +17 -2
  20. package/src/components/index.ts +8 -2
  21. package/src/composables/Toolbar/Actions/useRedo.ts +23 -0
  22. package/src/composables/Toolbar/Actions/useUndo.ts +23 -0
  23. package/src/composables/Toolbar/Alignment/useAlignmentCenter.ts +24 -0
  24. package/src/composables/Toolbar/Alignment/useAlignmentJustify.ts +24 -0
  25. package/src/composables/Toolbar/Alignment/useAlignmentLeft.ts +24 -0
  26. package/src/composables/Toolbar/Alignment/useAlignmentRight.ts +24 -0
  27. package/src/composables/Toolbar/Format/useBold.ts +24 -0
  28. package/src/composables/Toolbar/Format/useItalic.ts +24 -0
  29. package/src/composables/Toolbar/Format/useStrike.ts +24 -0
  30. package/src/composables/Toolbar/Format/useUnderline.ts +24 -0
  31. package/src/composables/Toolbar/FormatExtra/useBlockquote.ts +24 -0
  32. package/src/composables/Toolbar/FormatExtra/useCode.ts +24 -0
  33. package/src/composables/Toolbar/FormatExtra/useCodeBlock.ts +24 -0
  34. package/src/composables/Toolbar/FormatExtra/useSub.ts +24 -0
  35. package/src/composables/Toolbar/FormatExtra/useSup.ts +24 -0
  36. package/src/composables/Toolbar/List/useBullet.ts +23 -0
  37. package/src/composables/Toolbar/List/useIndent.ts +24 -0
  38. package/src/composables/Toolbar/List/useNumbered.ts +23 -0
  39. package/src/composables/Toolbar/List/useOutdent.ts +24 -0
  40. package/src/composables/Toolbar/List/useTask.ts +23 -0
  41. package/src/composables/Toolbar/Media/useImage.ts +24 -0
  42. package/src/composables/Toolbar/Media/useLink.ts +24 -0
  43. package/src/composables/Toolbar/Media/useTable.ts +188 -0
  44. package/src/composables/Toolbar/Misc/useBreak.ts +21 -0
  45. package/src/composables/Toolbar/Misc/useFormatClear.ts +23 -0
  46. package/src/composables/Toolbar/Misc/useInvisibleCharacters.ts +23 -0
  47. package/src/composables/Toolbar/Misc/useLine.ts +21 -0
  48. package/src/composables/Toolbar/Misc/usePreview.ts +20 -0
  49. package/src/composables/Toolbar/Misc/useSource.ts +21 -0
  50. package/src/composables/Toolbar/Style/useColor.ts +36 -0
  51. package/src/composables/Toolbar/Style/useFontFamily.ts +49 -0
  52. package/src/composables/Toolbar/Style/useFontSize.ts +50 -0
  53. package/src/composables/Toolbar/Style/useHeading.ts +64 -0
  54. package/src/composables/Toolbar/Style/useHighlight.ts +36 -0
  55. package/src/composables/Toolbar/Style/useLineHeight.ts +49 -0
  56. package/src/composables/Toolbar/useActionsItems.ts +9 -0
  57. package/src/composables/Toolbar/useAlignmentItems.ts +13 -0
  58. package/src/composables/Toolbar/useFormatExtraItems.ts +15 -0
  59. package/src/composables/Toolbar/useFormatItems.ts +13 -0
  60. package/src/composables/Toolbar/useListItems.ts +15 -0
  61. package/src/composables/Toolbar/useMediaItems.ts +11 -0
  62. package/src/composables/Toolbar/useMiscItems.ts +17 -0
  63. package/src/composables/Toolbar/useStyleItems.ts +17 -0
  64. package/src/{components/Toolbar/fonts.ts → constants/style.ts} +21 -0
  65. package/src/extensions/components/FontFamily.vue +82 -0
  66. package/src/extensions/components/FontSize.vue +83 -0
  67. package/src/extensions/components/ImageDialog.vue +7 -3
  68. package/src/extensions/components/LineHeight.vue +82 -0
  69. package/src/extensions/components/LinkDialog.vue +27 -7
  70. package/src/extensions/components/PreviewDialog.vue +11 -4
  71. package/src/extensions/components/ShowSourceDialog.vue +10 -6
  72. package/src/extensions/components/StyleColor.vue +2 -2
  73. package/src/extensions/components/slashCommands/CommandsList.vue +1 -4
  74. package/src/extensions/image.ts +2 -1
  75. package/src/extensions/link.ts +10 -1
  76. package/src/extensions/preview.ts +2 -1
  77. package/src/extensions/slash-commands.ts +1 -1
  78. package/src/extensions/view-source.ts +2 -1
  79. package/src/i18n/locales/ch.json +84 -82
  80. package/src/i18n/locales/cz.json +32 -30
  81. package/src/i18n/locales/de.json +28 -26
  82. package/src/i18n/locales/en.json +3 -1
  83. package/src/i18n/locales/es.json +30 -28
  84. package/src/i18n/locales/fr.json +30 -28
  85. package/src/i18n/locales/it.json +32 -30
  86. package/src/i18n/locales/la.json +61 -59
  87. package/src/i18n/locales/lt.json +38 -36
  88. package/src/i18n/locales/nl.json +31 -29
  89. package/src/i18n/locales/pl.json +32 -30
  90. package/src/i18n/locales/pt.json +29 -27
  91. package/src/i18n/locales/ru.json +3 -1
  92. package/src/i18n/locales/se.json +30 -28
  93. package/src/i18n/locales/ua.json +3 -1
  94. package/src/index.ts +3 -1
  95. package/src/types/extensionComponents.ts +22 -0
  96. package/src/types/toolbarItems.ts +43 -0
  97. package/src/types/toolbarSections.ts +11 -0
  98. package/src/components/Toolbar/items/actions.ts +0 -32
  99. package/src/components/Toolbar/items/alignment.ts +0 -60
  100. package/src/components/Toolbar/items/format.ts +0 -60
  101. package/src/components/Toolbar/items/formatExtra.ts +0 -73
  102. package/src/components/Toolbar/items/list.ts +0 -70
  103. package/src/components/Toolbar/items/media.ts +0 -211
  104. package/src/components/Toolbar/items/misc.ts +0 -59
  105. package/src/components/Toolbar/items/style.ts +0 -204
  106. package/src/types/overridable-extensions.ts +0 -6
  107. /package/src/{components → extensions/components}/CodeBlockComponent.vue +0 -0
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Editor } from "@tiptap/vue-3";
2
2
  import type { DefineComponent } from 'vue'
3
- import { extensionsComponents } from "./src/types/overridable-extensions";
3
+ import { extensionComponents } from "./src/types/extensionComponents";
4
4
 
5
5
  export interface TiptapifyProps {
6
6
  content: string|object
@@ -18,7 +18,7 @@ export interface TiptapifyProps {
18
18
  defaultFontFamily: string
19
19
  fontMeasure: string
20
20
  rounded: string
21
- overrideExtensionsComponents: extensionsComponents
21
+ customExtensions: extensionComponents
22
22
  }
23
23
 
24
24
  export interface TiptapifyEmits {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tiptapify",
3
3
  "types": "./index.d.ts",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "description": "Tiptap3 editor with Vuetify3 menu implementation",
6
6
  "exports": {
7
7
  ".": {
@@ -53,48 +53,49 @@
53
53
  "repository": "https://github.com/IVoyt/tiptapify",
54
54
  "packageManager": "pnpm@10.12.1",
55
55
  "dependencies": {
56
- "@tiptap/core": "next",
57
- "@tiptap/extension-blockquote": "next",
58
- "@tiptap/extension-bold": "next",
59
- "@tiptap/extension-bubble-menu": "next",
60
- "@tiptap/extension-code": "next",
61
- "@tiptap/extension-code-block": "next",
62
- "@tiptap/extension-code-block-lowlight": "next",
63
- "@tiptap/extension-color": "next",
64
- "@tiptap/extension-document": "next",
65
- "@tiptap/extension-floating-menu": "next",
66
- "@tiptap/extension-font-family": "next",
67
- "@tiptap/extension-hard-break": "next",
68
- "@tiptap/extension-heading": "next",
69
- "@tiptap/extension-highlight": "next",
70
- "@tiptap/extension-horizontal-rule": "next",
71
- "@tiptap/extension-image": "next",
72
- "@tiptap/extension-italic": "next",
73
- "@tiptap/extension-link": "next",
74
- "@tiptap/extension-list": "next",
75
- "@tiptap/extension-list-item": "next",
76
- "@tiptap/extension-paragraph": "next",
77
- "@tiptap/extension-placeholder": "next",
78
- "@tiptap/extension-strike": "next",
79
- "@tiptap/extension-subscript": "next",
80
- "@tiptap/extension-superscript": "next",
81
- "@tiptap/extension-table": "next",
82
- "@tiptap/extension-task-item": "next",
83
- "@tiptap/extension-task-list": "next",
84
- "@tiptap/extension-text": "next",
85
- "@tiptap/extension-text-align": "next",
86
- "@tiptap/extension-text-style": "next",
87
- "@tiptap/extension-typography": "next",
88
- "@tiptap/extension-underline": "next",
89
- "@tiptap/extensions": "next",
90
- "@tiptap/pm": "next",
91
- "@tiptap/starter-kit": "next",
92
- "@tiptap/suggestion": "next",
93
- "@tiptap/vue-3": "next",
56
+ "@tiptap/core": "^3.0.7",
57
+ "@tiptap/extension-blockquote": "^3.0.7",
58
+ "@tiptap/extension-bold": "^3.0.7",
59
+ "@tiptap/extension-bubble-menu": "^3.0.7",
60
+ "@tiptap/extension-code": "^3.0.7",
61
+ "@tiptap/extension-code-block": "^3.0.7",
62
+ "@tiptap/extension-code-block-lowlight": "^3.0.7",
63
+ "@tiptap/extension-color": "^3.0.7",
64
+ "@tiptap/extension-document": "^3.0.7",
65
+ "@tiptap/extension-floating-menu": "^3.0.7",
66
+ "@tiptap/extension-font-family": "^3.0.7",
67
+ "@tiptap/extension-hard-break": "^3.0.7",
68
+ "@tiptap/extension-heading": "^3.0.7",
69
+ "@tiptap/extension-highlight": "^3.0.7",
70
+ "@tiptap/extension-horizontal-rule": "^3.0.7",
71
+ "@tiptap/extension-image": "^3.0.7",
72
+ "@tiptap/extension-invisible-characters": "^3.0.7",
73
+ "@tiptap/extension-italic": "^3.0.7",
74
+ "@tiptap/extension-link": "^3.0.7",
75
+ "@tiptap/extension-list": "^3.0.7",
76
+ "@tiptap/extension-list-item": "^3.0.7",
77
+ "@tiptap/extension-paragraph": "^3.0.7",
78
+ "@tiptap/extension-placeholder": "^3.0.7",
79
+ "@tiptap/extension-strike": "^3.0.7",
80
+ "@tiptap/extension-subscript": "^3.0.7",
81
+ "@tiptap/extension-superscript": "^3.0.7",
82
+ "@tiptap/extension-table": "^3.0.7",
83
+ "@tiptap/extension-task-item": "^3.0.7",
84
+ "@tiptap/extension-task-list": "^3.0.7",
85
+ "@tiptap/extension-text": "^3.0.7",
86
+ "@tiptap/extension-text-align": "^3.0.7",
87
+ "@tiptap/extension-text-style": "^3.0.7",
88
+ "@tiptap/extension-typography": "^3.0.7",
89
+ "@tiptap/extension-underline": "^3.0.7",
90
+ "@tiptap/extensions": "^3.0.7",
91
+ "@tiptap/pm": "^3.0.7",
92
+ "@tiptap/starter-kit": "^3.0.7",
93
+ "@tiptap/suggestion": "^3.0.7",
94
+ "@tiptap/vue-3": "^3.0.7",
94
95
  "highlight.js": "^11.11.1",
95
96
  "linkifyjs": "^4.3.1",
96
97
  "lowlight": "^3.3.0",
97
- "vue-i18n": "^11.1.9"
98
+ "vue-i18n": "^11.1.10"
98
99
  },
99
100
  "peerDependencies": {
100
101
  "@mdi/js": "^7.4.47",
@@ -14,7 +14,7 @@ const editor = inject('tiptapifyEditor') as Ref<Editor>
14
14
  const items = ref([
15
15
  {
16
16
  name: 'bold',
17
- icon: mdi.mdiFormatBold,
17
+ icon: `mdiSvg:${mdi.mdiFormatBold}`,
18
18
  props: {
19
19
  disabled: computed(() => !editor?.value.can().chain().focus().toggleBold().run()),
20
20
  color: computed(() => editor.value.isActive('bold') ? 'primary' : ''),
@@ -23,7 +23,7 @@ const items = ref([
23
23
  },
24
24
  {
25
25
  name: 'italic',
26
- icon: mdi.mdiFormatItalic,
26
+ icon: `mdiSvg:${mdi.mdiFormatItalic}`,
27
27
  props: {
28
28
  disabled: computed(() => !editor.value.can().chain().focus().toggleItalic().run()),
29
29
  color: computed(() => editor.value.isActive('italic') ? 'primary' : ''),
@@ -32,7 +32,7 @@ const items = ref([
32
32
  },
33
33
  {
34
34
  name: 'strike',
35
- icon: mdi.mdiFormatStrikethroughVariant,
35
+ icon: `mdiSvg:${mdi.mdiFormatStrikethroughVariant}`,
36
36
  props: {
37
37
  disabled: computed(() => !editor.value.can().chain().focus().toggleStrike().run()),
38
38
  color: computed(() => editor.value.isActive('strike') ? 'primary' : ''),
@@ -41,7 +41,7 @@ const items = ref([
41
41
  },
42
42
  {
43
43
  name: 'underline',
44
- icon: mdi.mdiFormatUnderline,
44
+ icon: `mdiSvg:${mdi.mdiFormatUnderline}`,
45
45
  props: {
46
46
  disabled: computed(() => !editor.value.can().chain().focus().toggleUnderline().run()),
47
47
  color: computed(() => editor.value.isActive('underline') ? 'primary' : ''),
@@ -50,7 +50,7 @@ const items = ref([
50
50
  },
51
51
  {
52
52
  name: 'highlight',
53
- icon: mdi.mdiFormatColorHighlight,
53
+ icon: `mdiSvg:${mdi.mdiFormatColorHighlight}`,
54
54
  props: {
55
55
  disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
56
56
  color: computed(() => editor.value.isActive('highlight') ? 'primary' : ''),
@@ -59,7 +59,7 @@ const items = ref([
59
59
  },
60
60
  {
61
61
  name: 'code',
62
- icon: mdi.mdiXml,
62
+ icon: `mdiSvg:${mdi.mdiXml}`,
63
63
  props: {
64
64
  disabled: computed(() => !editor.value.can().chain().focus().toggleCode().run()),
65
65
  color: computed(() => editor.value.isActive('code') ? 'primary' : ''),
@@ -68,7 +68,7 @@ const items = ref([
68
68
  },
69
69
  {
70
70
  name: 'link',
71
- icon: computed(() => editor.value.isActive('link') ? mdi.mdiLinkOff : mdi.mdiLink),
71
+ icon: computed(() => editor.value.isActive('link') ? `mdiSvg:${mdi.mdiLinkOff}` : `mdiSvg:${mdi.mdiLink}`),
72
72
  props: {
73
73
  color: computed(() => editor.value.isActive('link') ? 'primary' : ''),
74
74
  disabled: computed(() => editor.value.isActive('code') || editor.value.isActive('codeBlock')),
@@ -77,7 +77,7 @@ const items = ref([
77
77
  },
78
78
  {
79
79
  name: 'format clear',
80
- icon: mdi.mdiFormatClear,
80
+ icon: `mdiSvg:${mdi.mdiFormatClear}`,
81
81
  click: () => editor.value.chain().focus().unsetAllMarks().clearNodes().run(),
82
82
  }
83
83
  ])
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import { extensionsComponents } from "@tiptapify/types/overridable-extensions";
3
+ import { extensionComponents } from "@tiptapify/types/extensionComponents";
4
4
  import { computed, onBeforeUnmount, PropType, provide, ref, ShallowRef, watch } from "vue";
5
5
  import { default as Toolbar } from "@tiptapify/components/Toolbar/Index.vue";
6
6
  import { Editor, EditorContent } from '@tiptap/vue-3'
@@ -32,18 +32,17 @@ const props = defineProps({
32
32
  defaultFontFamily: { type: String, default () { return 'Inter' } },
33
33
  fontMeasure: { type: String, default () { return 'px' } },
34
34
  rounded: { type: String, default () { return '0' } },
35
- overrideExtensionsComponents: { type: Object as PropType<extensionsComponents>, default() { return {} } },
35
+ customExtensions: { type: Object as PropType<extensionComponents>, default() { return {} } },
36
36
  })
37
37
 
38
- // console.log('override extension components', computed(() => props.overrideExtensionsComponents).value)
39
-
40
38
  const appTheme = useTheme()
41
39
  const currentTheme = ref(appTheme.global.name)
42
40
 
43
41
  const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
44
42
  props.content,
45
43
  computed(() => props.placeholder || t('content.placeholder')).value,
46
- props.slashCommands
44
+ props.slashCommands,
45
+ props.customExtensions
47
46
  )
48
47
 
49
48
  const emit = defineEmits(['update:modelValue', 'editor-ready']);
@@ -80,7 +79,7 @@ onBeforeUnmount(() => {
80
79
  :items="items"
81
80
  :items-exclude="itemsExclude"
82
81
  :rounded="rounded"
83
- :override-extensions-components="overrideExtensionsComponents"
82
+ :custom-extensions="customExtensions"
84
83
  :theme="currentTheme"
85
84
  />
86
85
  </template>
@@ -3,7 +3,7 @@ import GroupBtn from "@tiptapify/components/Toolbar/GroupBtn.vue";
3
3
  import GroupDropdown from "@tiptapify/components/Toolbar/GroupDropdown.vue";
4
4
  import { defineProps, PropType } from 'vue'
5
5
 
6
- import { ToolbarItemSection } from "@tiptapify/components/Toolbar/items";
6
+ import { ToolbarItemSection } from "@tiptapify/types/toolbarItems";
7
7
 
8
8
  defineProps({
9
9
  variant: { type: String, default () { return 'flat' }},
@@ -20,7 +20,7 @@ defineProps({
20
20
  <GroupDropdown :toolbar-item="toolbarItem" :variant="variant" />
21
21
  </template>
22
22
 
23
- <VMenu v-else-if="toolbarItem?.component" v-model="toolbarItem.modelValue" :close-on-content-click="false">
23
+ <VMenu v-else-if="toolbarItem?.component" v-model="toolbarItem.modelValue" :close-on-content-click="false" v-bind="toolbarItem.props">
24
24
  <template #activator="{ props: menuProps }">
25
25
  <GroupBtn v-bind="menuProps" :toolbar-item="toolbarItem" :variant="variant" />
26
26
  </template>
@@ -1,27 +1,30 @@
1
1
  <script setup lang="ts">
2
+ import BtnIcon from "@tiptapify/components/UI/BtnIcon.vue";
2
3
  import { defineProps, PropType } from 'vue'
3
- import { useI18n } from "vue-i18n";
4
4
 
5
- import { ToolbarItem } from "@tiptapify/components/Toolbar/items";
5
+
6
+ import { ToolbarItem } from '@tiptapify/types/toolbarItems'
6
7
 
7
8
  defineProps({
8
9
  variant: { type: String, default () { return 'flat' }},
9
10
  toolbarItem: { type: Object as PropType<ToolbarItem>, default() { return {} }}
10
11
  })
11
12
 
12
- const { t } = useI18n();
13
13
  </script>
14
14
 
15
15
  <template>
16
16
  <VBtn v-bind="toolbarItem?.props ?? {}" v-on="toolbarItem?.attrs ?? {}" size="32">
17
- <VTooltip :text="t(toolbarItem.tooltip)" location="top" activator="parent" />
17
+ <VTooltip :text="toolbarItem.tooltip" location="top" activator="parent" />
18
18
 
19
- <VIcon v-if="toolbarItem.icon" :icon="toolbarItem.icon" size="small" />
20
- <span v-else class="menu-item-title">
21
- {{ t(toolbarItem.name) }}
22
- </span>
19
+ <BtnIcon :icon="toolbarItem.icon" />
23
20
 
24
- <VIcon v-if="toolbarItem.icon2" v-bind="toolbarItem?.icon2Props ?? {}" :icon="toolbarItem.icon2" size="small" style="position: absolute;" />
21
+ <VIcon
22
+ v-if="toolbarItem.icon2"
23
+ v-bind="toolbarItem?.icon2Props ?? {}"
24
+ :icon="toolbarItem.icon2"
25
+ size="small"
26
+ style="position: absolute;"
27
+ />
25
28
  </VBtn>
26
29
  </template>
27
30
 
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { defineProps, PropType } from 'vue'
3
- import { useI18n } from "vue-i18n";
3
+ import * as mdi from '@mdi/js'
4
4
 
5
5
  import { ToolbarItem } from "@tiptapify/components/Toolbar/items";
6
6
 
@@ -10,20 +10,15 @@ defineProps({
10
10
  toolbarItem: { type: Object as PropType<ToolbarItem>, default() { return {} }}
11
11
  })
12
12
 
13
- const { t } = useI18n();
14
-
15
13
  </script>
16
14
 
17
15
  <template>
18
16
  <VMenu v-model="toolbarItem.modelValue" v-bind="toolbarItem.props">
19
17
  <template v-if="!nested" #activator="{ props: menuProps }">
20
18
  <VBtn v-bind="{ ...menuProps, ...toolbarItem.props }" size="32">
21
- <VTooltip :text="t(toolbarItem.tooltip)" location="top" activator="parent" />
19
+ <VTooltip :text="toolbarItem.tooltip" location="top" activator="parent" />
22
20
 
23
- <VIcon v-if="toolbarItem.icon" :icon="toolbarItem.icon" size="small" />
24
- <span v-else class="menu-item-title">
25
- {{ t(toolbarItem.name) }}
26
- </span>
21
+ <VIcon :icon="toolbarItem.icon || `mdiSvg:${mdi.mdiImageBrokenVariant}`" size="small" />
27
22
  </VBtn>
28
23
  </template>
29
24
 
@@ -43,18 +38,9 @@ const { t } = useI18n();
43
38
  v-bind="item.props ?? {}"
44
39
  v-on="item?.attrs ?? {}"
45
40
  >
46
- <VTooltip v-if="item.tooltip" :text="t(item.tooltip)" location="top" activator="parent" />
47
-
48
- <VIcon v-if="item.icon" :icon="item.icon" size="small" />
41
+ <VTooltip v-if="item.tooltip" :text="item.tooltip" location="top" activator="parent" />
49
42
 
50
- <span v-else class="menu-item-title">
51
- <template v-if="item.noI18n">
52
- {{ item.name }}
53
- </template>
54
- <template v-else>
55
- {{ t(item.toggle) }}
56
- </template>
57
- </span>
43
+ <VIcon :icon="item.icon || `mdiSvg:${mdi.mdiImageBrokenVariant}`" size="small" />
58
44
 
59
45
  <VMenu
60
46
  v-if="item.component"
@@ -2,8 +2,8 @@
2
2
  import { Editor } from "@tiptap/vue-3";
3
3
  import { getDefaultComponents } from "@tiptapify/components/Toolbar/defaultExtensionComponents";
4
4
  import Items from "@tiptapify/components/Toolbar/Items.vue";
5
- import { computed, defineProps, inject, PropType, ref, Ref, ShallowRef, shallowRef, triggerRef } from 'vue'
6
- import { extensionsComponents } from '@tiptapify/types/overridable-extensions'
5
+ import { computed, defineProps, inject, PropType, Ref, ShallowRef, shallowRef } from 'vue'
6
+ import { extensionComponents, ToolbarItemType } from '@tiptapify/types/extensionComponents'
7
7
 
8
8
  import { toolbarItems } from "@tiptapify/components/Toolbar/items";
9
9
  import { useTheme } from "vuetify/framework";
@@ -20,7 +20,7 @@ const props = defineProps({
20
20
  theme: { type: String, default() { return 'light' } },
21
21
  rounded: { type: String, default() { return '0' } },
22
22
  toolbarScrollable: { type: Boolean, default() { return false } },
23
- overrideExtensionsComponents: { type: Object as PropType<extensionsComponents>, default() { return {} } },
23
+ customExtensions: { type: Object as PropType<extensionComponents>, default() { return {} } },
24
24
  })
25
25
 
26
26
  const editor = inject('tiptapifyEditor') as Ref<Editor>
@@ -28,18 +28,21 @@ const editor = inject('tiptapifyEditor') as Ref<Editor>
28
28
  const appTheme = useTheme()
29
29
 
30
30
  const items = toolbarItems(
31
- editor,
32
31
  appTheme,
33
32
  computed(() => props.fontMeasure).value,
34
33
  { list: computed(() => props.items).value, exclude: computed(() => props.itemsExclude).value },
35
- computed(() => props.headingLevels).value
34
+ computed(() => props.headingLevels).value,
35
+ props.customExtensions
36
36
  )
37
37
 
38
- const defaultComponents: extensionsComponents = getDefaultComponents(props.variantField)
38
+ const defaultComponents: extensionComponents = getDefaultComponents(props.variantField)
39
39
 
40
- const extensions: ShallowRef<extensionsComponents> = shallowRef({})
40
+ const extensions: ShallowRef<extensionComponents> = shallowRef({})
41
41
  Object.keys(defaultComponents).forEach(extension => {
42
- extensions.value[extension] = props.overrideExtensionsComponents[extension] ?? defaultComponents[extension]
42
+ extensions.value[extension] = defaultComponents[extension]
43
+ })
44
+ Object.keys(props.customExtensions).forEach(extension => {
45
+ extensions.value[extension] = props.customExtensions[extension]
43
46
  })
44
47
 
45
48
  </script>
@@ -54,8 +57,9 @@ Object.keys(defaultComponents).forEach(extension => {
54
57
  <Items v-else :items="items" />
55
58
  </VToolbar>
56
59
 
60
+ <!-- mount built-in and/or custom components -->
57
61
  <template v-for="extension in extensions">
58
- <component :is="extension.component" v-bind="extension?.props ?? {}" />
62
+ <component v-if="extension.type !== ToolbarItemType.dropdown" :is="extension.component" v-bind="{ ...extension?.props ?? {}, ...extension?.componentProps ?? {} }" />
59
63
  </template>
60
64
  </div>
61
65
  </template>
@@ -2,17 +2,14 @@
2
2
  import Group from "@tiptapify/components/Toolbar/Group.vue";
3
3
  import Toggle from "@tiptapify/components/Toolbar/Toggle.vue";
4
4
  import { computed, defineProps, PropType, Ref, ref } from 'vue'
5
- import { useI18n } from "vue-i18n";
6
5
 
7
- import { ToolbarItemSections } from "@tiptapify/components/Toolbar/items";
6
+ import { ToolbarItemSections } from "@tiptapify/types/toolbarItems";
8
7
 
9
8
  const props = defineProps({
10
9
  variantBtn: { type: String, default () { return 'elevated' }},
11
10
  items: { type: Object as PropType<ToolbarItemSections>, default() { return {} }},
12
11
  })
13
12
 
14
- const { t } = useI18n();
15
-
16
13
  const toolbarItemsRef: Ref<ToolbarItemSections> = ref(computed(() => props.items).value)
17
14
 
18
15
  </script>
@@ -29,18 +26,18 @@ const toolbarItemsRef: Ref<ToolbarItemSections> = ref(computed(() => props.items
29
26
  v-for="(toolbarItem, itemKey) in toolbarSection.items"
30
27
  :key="itemKey"
31
28
  :variant="variantBtn"
32
- v-bind="toolbarItem.props"
33
- v-on="toolbarItem.attrs"
29
+ v-bind="toolbarItem?.props ?? {}"
30
+ v-on="toolbarItem?.attrs ?? {}"
34
31
  class="menu-button"
35
32
  size="32"
36
33
  elevation="4"
37
34
  rounded="sm"
38
35
  >
39
- <VTooltip :text="t(toolbarItem.tooltip)" location="top" activator="parent" />
36
+ <VTooltip :text="toolbarItem.tooltip" location="top" activator="parent" />
40
37
 
41
38
  <VIcon v-if="toolbarItem.icon" :icon="toolbarItem.icon" size="16" />
42
39
  <span v-else class="menu-item-title">
43
- {{ t(toolbarItem.name) }}
40
+ {{ toolbarItem.name }}
44
41
  </span>
45
42
  </VBtn>
46
43
 
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { defineProps, PropType } from 'vue'
3
3
  import { useI18n } from "vue-i18n";
4
+ import * as mdi from '@mdi/js'
4
5
 
5
6
  import { ToolbarItemSection } from "@tiptapify/components/Toolbar/items";
6
7
 
@@ -17,12 +18,9 @@ const { t } = useI18n();
17
18
  <VBtnToggle :variant="variant" elevation="4">
18
19
  <template v-for="(item, key) in toolbarSection.items" :key="key">
19
20
  <VBtn v-bind="item.props" v-on="item.attrs" size="32">
20
- <VTooltip :text="t(item.name)" location="top" activator="parent" />
21
+ <VTooltip :text="item.name" location="top" activator="parent" />
21
22
 
22
- <VIcon v-if="item.icon" :icon="item.icon" size="small" />
23
- <span v-else class="menu-item-title">
24
- {{ t(item.name) }}
25
- </span>
23
+ <VIcon :icon="item.icon || `mdiSvg:${mdi.mdiImageBrokenVariant}`" size="small" />
26
24
  </VBtn>
27
25
  </template>
28
26
  </VBtnToggle>
@@ -1,32 +1,53 @@
1
+ import { useImage } from "@tiptapify/composables/Toolbar/Media/useImage";
2
+ import { useLink } from "@tiptapify/composables/Toolbar/Media/useLink";
3
+ import { usePreview } from "@tiptapify/composables/Toolbar/Misc/usePreview";
4
+ import { useSource } from "@tiptapify/composables/Toolbar/Misc/useSource";
1
5
  import ImageDialog from "@tiptapify/extensions/components/ImageDialog.vue";
2
6
  import LinkDialog from "@tiptapify/extensions/components/LinkDialog.vue";
3
7
  import PreviewDialog from "@tiptapify/extensions/components/PreviewDialog.vue";
4
8
  import ShowSourceDialog from "@tiptapify/extensions/components/ShowSourceDialog.vue";
5
- import { extensionsComponents } from "@tiptapify/types/overridable-extensions";
6
- import { computed } from "vue";
9
+ import { extensionComponents } from "@tiptapify/types/extensionComponents";
10
+ import { ToolbarSections } from "@tiptapify/types/toolbarSections";
11
+ import { computed, markRaw } from "vue";
7
12
 
8
- export function getDefaultComponents(variantField: string): extensionsComponents {
13
+ export function getDefaultComponents(variantField: string): extensionComponents {
9
14
  return {
10
15
  image: {
11
- component: ImageDialog,
12
- props: {
16
+ component: markRaw(ImageDialog),
17
+ componentProps: {
13
18
  variantField: computed(() => variantField).value,
14
- }
19
+ },
20
+ section: ToolbarSections.media,
21
+ name: useImage().name,
22
+ tooltip: useImage().tooltip,
23
+ icon: useImage().icon,
15
24
  },
16
25
  link: {
17
- component: LinkDialog,
18
- props: {
26
+ component: markRaw(LinkDialog),
27
+ componentProps: {
19
28
  variantField: computed(() => variantField).value,
20
- }
29
+ },
30
+ section: ToolbarSections.media,
31
+ name: useLink().name,
32
+ tooltip: useLink().tooltip,
33
+ icon: useLink().icon,
21
34
  },
22
35
  preview: {
23
- component: PreviewDialog,
36
+ component: markRaw(PreviewDialog),
37
+ section: ToolbarSections.misc,
38
+ name: usePreview().name,
39
+ tooltip: usePreview().tooltip,
40
+ icon: usePreview().icon,
24
41
  },
25
42
  showSource: {
26
- component: ShowSourceDialog,
27
- props: {
43
+ component: markRaw(ShowSourceDialog),
44
+ componentProps: {
28
45
  variantField: computed(() => variantField).value,
29
- }
46
+ },
47
+ section: ToolbarSections.misc,
48
+ name: useSource().name,
49
+ tooltip: useSource().tooltip,
50
+ icon: useSource().icon,
30
51
  }
31
52
  }
32
53
  }