tiptapify 0.0.11 → 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 (94) hide show
  1. package/README.md +6 -2
  2. package/dist/tiptapify.css +1 -1
  3. package/dist/tiptapify.mjs +16191 -15808
  4. package/dist/tiptapify.umd.js +73 -33
  5. package/index.d.ts +2 -2
  6. package/package.json +2 -1
  7. package/src/components/MenuBubble.vue +8 -8
  8. package/src/components/Tiptapify.vue +4 -5
  9. package/src/components/Toolbar/Group.vue +2 -2
  10. package/src/components/Toolbar/GroupBtn.vue +11 -8
  11. package/src/components/Toolbar/GroupDropdown.vue +3 -17
  12. package/src/components/Toolbar/Index.vue +13 -10
  13. package/src/components/Toolbar/Items.vue +3 -6
  14. package/src/components/Toolbar/Toggle.vue +2 -4
  15. package/src/components/Toolbar/defaultExtensionComponents.ts +34 -13
  16. package/src/components/Toolbar/items.ts +43 -60
  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 +16 -1
  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 +5 -31
  57. package/src/composables/Toolbar/useAlignmentItems.ts +9 -59
  58. package/src/composables/Toolbar/useFormatExtraItems.ts +11 -72
  59. package/src/composables/Toolbar/useFormatItems.ts +9 -59
  60. package/src/composables/Toolbar/useListItems.ts +11 -69
  61. package/src/composables/Toolbar/useMediaItems.ts +7 -209
  62. package/src/composables/Toolbar/useMiscItems.ts +13 -58
  63. package/src/composables/Toolbar/useStyleItems.ts +14 -228
  64. package/src/extensions/components/ImageDialog.vue +7 -3
  65. package/src/extensions/components/LinkDialog.vue +7 -3
  66. package/src/extensions/components/PreviewDialog.vue +11 -4
  67. package/src/extensions/components/ShowSourceDialog.vue +7 -4
  68. package/src/extensions/components/StyleColor.vue +2 -2
  69. package/src/extensions/components/slashCommands/CommandsList.vue +1 -4
  70. package/src/extensions/image.ts +2 -1
  71. package/src/extensions/link.ts +2 -1
  72. package/src/extensions/preview.ts +2 -1
  73. package/src/extensions/view-source.ts +2 -1
  74. package/src/i18n/index.ts +1 -0
  75. package/src/i18n/locales/ch.json +2 -1
  76. package/src/i18n/locales/cz.json +2 -1
  77. package/src/i18n/locales/de.json +2 -1
  78. package/src/i18n/locales/en.json +2 -1
  79. package/src/i18n/locales/es.json +2 -1
  80. package/src/i18n/locales/fr.json +2 -1
  81. package/src/i18n/locales/it.json +2 -1
  82. package/src/i18n/locales/la.json +2 -1
  83. package/src/i18n/locales/lt.json +2 -1
  84. package/src/i18n/locales/nl.json +2 -1
  85. package/src/i18n/locales/pl.json +2 -1
  86. package/src/i18n/locales/pt.json +2 -1
  87. package/src/i18n/locales/ru.json +2 -1
  88. package/src/i18n/locales/se.json +2 -1
  89. package/src/i18n/locales/ua.json +2 -1
  90. package/src/index.ts +3 -1
  91. package/src/types/extensionComponents.ts +22 -0
  92. package/src/types/toolbarItems.ts +43 -0
  93. package/src/types/toolbarSections.ts +11 -0
  94. package/src/types/overridable-extensions.ts +0 -6
@@ -0,0 +1,188 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import TableBuilder from "@tiptapify/extensions/components/TableBuilder.vue";
4
+ import { computed, inject, markRaw, Ref } from "vue";
5
+ import { useI18n } from "vue-i18n";
6
+
7
+ export function useTable() {
8
+ const { t } = useI18n();
9
+
10
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
11
+
12
+ return {
13
+ name: 'tables',
14
+ tooltip: computed(() => t('media.tables.table')),
15
+ icon: `mdiSvg:${mdi.mdiTable}`,
16
+ modelValue: false,
17
+ enabled: true,
18
+ props: {
19
+ color: computed(() => editor.value.isActive('table') ? 'primary' : ''),
20
+ disabled: computed(() => !editor.value.can().chain().focus().insertTable().run()),
21
+ },
22
+ children: [
23
+ {
24
+ name: 'insert table',
25
+ tooltip: computed(() => t('media.tables.insertTable')),
26
+ icon: `mdiSvg:${mdi.mdiTablePlus}`,
27
+ enabled: true,
28
+ props: {
29
+ disabled: computed(() => !editor.value.can().chain().focus().insertTable().run()),
30
+ activator: 'parent',
31
+ openOnClick: true,
32
+ openOnHover: false,
33
+ closeOnContentClick: false,
34
+ submenu: true
35
+ },
36
+ component: markRaw(TableBuilder),
37
+ },
38
+ {
39
+ name: 'delete table',
40
+ tooltip: computed(() => t('media.tables.deleteTable')),
41
+ icon: `mdiSvg:${mdi.mdiTableMinus}`,
42
+ enabled: true,
43
+ props: {
44
+ disabled: computed(() => !editor.value.can().chain().focus().deleteTable().run()),
45
+ },
46
+ attrs: {
47
+ click: () => editor.value.chain().focus().deleteTable().run()
48
+ }
49
+ },
50
+ {
51
+ name: 'table row',
52
+ tooltip: computed(() => t('media.tables.row')),
53
+ icon: `mdiSvg:${mdi.mdiTableRow}`,
54
+ enabled: true,
55
+ props: {
56
+ disabled: computed(
57
+ () =>
58
+ !editor.value.can().chain().focus().addRowBefore().run() &&
59
+ !editor.value.can().chain().focus().addRowAfter().run() &&
60
+ !editor.value.can().chain().focus().deleteRow().run()
61
+ ),
62
+ openOnHover: true,
63
+ openOnClick: true,
64
+ activator: 'parent',
65
+ submenu: true
66
+ },
67
+ children: [
68
+ {
69
+ name: 'insert row before',
70
+ tooltip: computed(() => t('media.tables.insertRowBefore')),
71
+ icon: `mdiSvg:${mdi.mdiTableRowPlusBefore}`,
72
+ enabled: true,
73
+ props: {
74
+ disabled: computed(() => !editor.value.can().chain().focus().addRowBefore().run()),
75
+ },
76
+ attrs: {
77
+ click: () => editor.value.chain().focus().addRowBefore().run()
78
+ }
79
+ },
80
+ {
81
+ name: 'insert row after',
82
+ tooltip: computed(() => t('media.tables.insertRowAfter')),
83
+ icon: `mdiSvg:${mdi.mdiTableRowPlusAfter}`,
84
+ enabled: true,
85
+ props: {
86
+ disabled: computed(() => !editor.value.can().chain().focus().addRowAfter().run()),
87
+ },
88
+ attrs: {
89
+ click: () => editor.value.chain().focus().addRowAfter().run()
90
+ }
91
+ },
92
+ {
93
+ name: 'delete row',
94
+ tooltip: computed(() => t('media.tables.deleteRow')),
95
+ icon: `mdiSvg:${mdi.mdiTableRowRemove}`,
96
+ enabled: true,
97
+ props: {
98
+ disabled: computed(() => !editor.value.can().chain().focus().deleteRow().run()),
99
+ },
100
+ attrs: {
101
+ click: () => editor.value.chain().focus().deleteRow().run()
102
+ }
103
+ },
104
+ ]
105
+ },
106
+ {
107
+ name: 'column',
108
+ tooltip: computed(() => t('media.tables.col')),
109
+ icon: `mdiSvg:${mdi.mdiTableColumn}`,
110
+ enabled: true,
111
+ props: {
112
+ disabled: computed(
113
+ () =>
114
+ !editor.value.can().chain().focus().addColumnBefore().run() &&
115
+ !editor.value.can().chain().focus().addColumnAfter().run() &&
116
+ !editor.value.can().chain().focus().deleteColumn().run()
117
+ ),
118
+ openOnHover: true,
119
+ openOnClick: true,
120
+ activator: 'parent',
121
+ submenu: true
122
+ },
123
+ children: [
124
+ {
125
+ name: 'insert col before',
126
+ tooltip: computed(() => t('media.tables.insertColBefore')),
127
+ icon: `mdiSvg:${mdi.mdiTableColumnPlusBefore}`,
128
+ enabled: true,
129
+ props: {
130
+ disabled: computed(() => !editor.value.can().chain().focus().addColumnBefore().run()),
131
+ },
132
+ attrs: {
133
+ click: () => editor.value.chain().focus().addColumnBefore().run()
134
+ }
135
+ },
136
+ {
137
+ name: 'insert column after',
138
+ tooltip: computed(() => t('media.tables.insertColAfter')),
139
+ icon: `mdiSvg:${mdi.mdiTableColumnPlusAfter}`,
140
+ enabled: true,
141
+ props: {
142
+ disabled: computed(() => !editor.value.can().chain().focus().addColumnAfter().run()),
143
+ },
144
+ attrs: {
145
+ click: () => editor.value.chain().focus().addColumnAfter().run()
146
+ }
147
+ },
148
+ {
149
+ name: 'delete column',
150
+ tooltip: computed(() => t('media.tables.deleteCol')),
151
+ icon: `mdiSvg:${mdi.mdiTableColumnRemove}`,
152
+ enabled: true,
153
+ props: {
154
+ disabled: computed(() => !editor.value.can().chain().focus().deleteColumn().run()),
155
+ },
156
+ attrs: {
157
+ click: () => editor.value.chain().focus().deleteColumn().run()
158
+ }
159
+ }
160
+ ]
161
+ },
162
+ {
163
+ name: 'merge cells',
164
+ tooltip: computed(() => t('media.tables.mergeCells')),
165
+ icon: `mdiSvg:${mdi.mdiTableMergeCells}`,
166
+ enabled: true,
167
+ props: {
168
+ disabled: computed(() => !editor.value.can().chain().focus().mergeCells().run()),
169
+ },
170
+ attrs: {
171
+ click: () => editor.value.chain().focus().mergeCells().run()
172
+ }
173
+ },
174
+ {
175
+ name: 'split cell',
176
+ tooltip: computed(() => t('media.tables.splitCell')),
177
+ icon: `mdiSvg:${mdi.mdiTableSplitCell}`,
178
+ enabled: true,
179
+ props: {
180
+ disabled: computed(() => !editor.value.can().chain().focus().splitCell().run()),
181
+ },
182
+ attrs: {
183
+ click: () => editor.value.chain().focus().splitCell().run()
184
+ }
185
+ }
186
+ ]
187
+ }
188
+ }
@@ -0,0 +1,21 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed, inject, Ref } from "vue";
4
+ import { useI18n } from "vue-i18n";
5
+
6
+ export function useBreak() {
7
+ const { t } = useI18n();
8
+
9
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
10
+
11
+ return {
12
+ name: 'break',
13
+ tooltip: computed(() => t('format.break')),
14
+ icon: `mdiSvg:${mdi.mdiFormatPageBreak}`,
15
+ enabled: true,
16
+ props: {},
17
+ attrs: {
18
+ click: () => editor.value.chain().focus().setHardBreak().run()
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed, inject, Ref } from "vue";
4
+ import { useI18n } from "vue-i18n";
5
+
6
+ export function useFormatClear() {
7
+ const { t } = useI18n();
8
+
9
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
10
+
11
+ return {
12
+ name: 'format clear',
13
+ tooltip: computed(() => t('format.formatClear')),
14
+ icon: `mdiSvg:${mdi.mdiFormatClear}`,
15
+ enabled: true,
16
+ props: {
17
+ disabled: computed(() => !editor.value.can().chain().focus().unsetAllMarks().run()),
18
+ },
19
+ attrs: {
20
+ click: () => editor.value.chain().focus().unsetAllMarks().clearNodes().run()
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ import { Editor } from "@tiptap/vue-3";
2
+ import { computed, inject, Ref } from "vue";
3
+ import { useI18n } from "vue-i18n";
4
+
5
+ export function useInvisibleCharacters() {
6
+ const { t } = useI18n();
7
+
8
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
9
+
10
+ return {
11
+ name: 'show/hide invisible characters',
12
+ tooltip: computed(() => t('misc.toggleInvisibleCharacters')),
13
+ svg: true,
14
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path 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>`,
15
+ enabled: true,
16
+ props: {
17
+ color: computed(() => editor.value.storage.invisibleCharacters.visibility() ? 'primary' : ''),
18
+ },
19
+ attrs: {
20
+ click: () => editor.value.commands.toggleInvisibleCharacters()
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,21 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed, inject, Ref } from "vue";
4
+ import { useI18n } from "vue-i18n";
5
+
6
+ export function useLine() {
7
+ const { t } = useI18n();
8
+
9
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
10
+
11
+ return {
12
+ name: 'line',
13
+ tooltip: computed(() => t('format.line')),
14
+ icon: `mdiSvg:${mdi.mdiMinus}`,
15
+ enabled: true,
16
+ props: {},
17
+ attrs: {
18
+ click: () => editor.value.chain().focus().setHorizontalRule().run()
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,20 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed, inject, Ref } from "vue";
4
+ import { useI18n } from "vue-i18n";
5
+
6
+ export function usePreview() {
7
+ const { t } = useI18n();
8
+
9
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
10
+
11
+ return {
12
+ name: 'preview',
13
+ tooltip: computed(() => t('misc.preview')),
14
+ icon: `mdiSvg:${mdi.mdiFileEyeOutline}`,
15
+ enabled: true,
16
+ attrs: {
17
+ click: () => editor.value.commands.showPreview()
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed, inject, Ref } from "vue";
4
+ import { useI18n } from "vue-i18n";
5
+
6
+ export function useSource() {
7
+ const { t } = useI18n();
8
+
9
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
10
+
11
+ return {
12
+ name: 'source',
13
+ tooltip: computed(() => t('misc.source')),
14
+ icon: `mdiSvg:${mdi.mdiCodeTags}`,
15
+ enabled: true,
16
+ props: {},
17
+ attrs: {
18
+ click: () => editor.value.commands.showSource()
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,36 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import StyleColor from "@tiptapify/extensions/components/StyleColor.vue";
4
+ import { computed, inject, markRaw, Ref } from "vue";
5
+ import { useI18n } from "vue-i18n";
6
+
7
+ export function useColor(theme: any) {
8
+ const { t } = useI18n();
9
+
10
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
11
+
12
+ return {
13
+ name: 'color',
14
+ tooltip: computed(() => t('style.color.text')),
15
+ icon: `mdiSvg:${mdi.mdiFormatColorText}`,
16
+ icon2: `mdiSvg:${mdi.mdiColorHelper}`,
17
+ enabled: true,
18
+ props: {
19
+ disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
20
+ },
21
+ icon2Props: {
22
+ disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
23
+ color: computed(() => {
24
+ const defaultColor = theme.global.current.value.dark ? '#fff' : '#000'
25
+ return editor.value.getAttributes('textStyle').color || defaultColor
26
+ }),
27
+ style: 'filter: drop-shadow(rgba(0, 0, 0, .75) 1px 1px 2px);'
28
+ },
29
+ component: markRaw(StyleColor),
30
+ componentProps: {
31
+ fontColor: true,
32
+ backgroundColor: false,
33
+ color: computed(() => editor.value.getAttributes('textStyle').color || ''),
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,49 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { fonts } from "@tiptapify/constants/style";
4
+ import FontFamily from "@tiptapify/extensions/components/FontFamily.vue";
5
+ import { computed, inject, markRaw, Ref } from "vue";
6
+ import { useI18n } from "vue-i18n";
7
+
8
+ export function useFontFamily() {
9
+ const { t } = useI18n();
10
+
11
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
12
+
13
+ return {
14
+ name: 'font-family',
15
+ tooltip: computed(() => t('style.fontFamily')),
16
+ icon: `mdiSvg:${mdi.mdiFormatFont}`,
17
+ modelValue: false,
18
+ enabled: true,
19
+ props: {
20
+ disabled: computed(() => !editor.value.can().chain().focus().unsetFontFamily().run()),
21
+ color: computed(() => {
22
+ let color = ''
23
+ for (const font in fonts) {
24
+ if (editor.value.isActive('textStyle', { fontFamily: fonts[font].fontFamily })) {
25
+ color = 'primary'
26
+ break;
27
+ }
28
+ }
29
+
30
+ return color
31
+ }),
32
+ },
33
+ component: markRaw(FontFamily),
34
+ componentProps: {
35
+ fonts: fonts,
36
+ fontFamily: computed(() => {
37
+ let fontFamily = ''
38
+ for (const font in fonts) {
39
+ if (editor.value.isActive('textStyle', { fontFamily: fonts[font].fontFamily })) {
40
+ fontFamily = fonts[font].fontFamily
41
+ break;
42
+ }
43
+ }
44
+
45
+ return fontFamily
46
+ }),
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,50 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { fontSizes } from "@tiptapify/constants/style";
4
+ import FontSize from "@tiptapify/extensions/components/FontSize.vue";
5
+ import { computed, inject, markRaw, Ref } from "vue";
6
+ import { useI18n } from "vue-i18n";
7
+
8
+ export function useFontSize(fontMeasure: string) {
9
+ const { t } = useI18n();
10
+
11
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
12
+
13
+ return {
14
+ name: 'font-size',
15
+ tooltip: computed(() => t('style.fontSize')),
16
+ icon: `mdiSvg:${mdi.mdiFormatSize}`,
17
+ modelValue: false,
18
+ enabled: true,
19
+ props: {
20
+ disabled: computed(() => !editor.value.can().chain().focus().unsetFontSize().run()),
21
+ color: computed(() => {
22
+ let color = ''
23
+ for (const size of fontSizes) {
24
+ if (editor.value.isActive('textStyle', { fontSize: `${size}${fontMeasure}` })) {
25
+ color = 'primary'
26
+ break;
27
+ }
28
+ }
29
+
30
+ return color
31
+ }),
32
+ },
33
+ component: markRaw(FontSize),
34
+ componentProps: {
35
+ sizes: fontSizes,
36
+ measure: fontMeasure,
37
+ fontSize: computed(() => {
38
+ let fontSize = null
39
+ for (const size of fontSizes) {
40
+ if (editor.value.isActive('textStyle', { fontSize: `${size}${fontMeasure}` })) {
41
+ fontSize = size
42
+ break;
43
+ }
44
+ }
45
+
46
+ return fontSize
47
+ }),
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,64 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Level } from "@tiptap/extension-heading";
3
+ import { Editor } from "@tiptap/vue-3";
4
+ import { headingLevels, setHeadingLevels } from "@tiptapify/constants/style";
5
+ import { computed, inject, Ref } from "vue";
6
+ import { useI18n } from "vue-i18n";
7
+
8
+ interface MDIIcons {
9
+ [key: string]: string
10
+ }
11
+ const mdiIcons = mdi as MDIIcons
12
+
13
+ export function useHeading(customHeadingLevels: Array<number> = []) {
14
+ const { t } = useI18n();
15
+
16
+ setHeadingLevels(customHeadingLevels)
17
+
18
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
19
+
20
+ return {
21
+ name: 'heading',
22
+ tooltip: computed(() => t('style.heading')),
23
+ icon: `mdiSvg:${mdi.mdiFormatHeaderPound}`,
24
+ modelValue: null,
25
+ enabled: true,
26
+ props: {
27
+ color: computed(() => editor.value.isActive('heading') || editor.value.isActive('paragraph') ? 'primary' : ''),
28
+ },
29
+ children: [
30
+ {
31
+ name: 'paragraph',
32
+ tooltip: computed(() => t('style.paragraph')),
33
+ // icon: mdiIcons['mdiFormatParagraph'],
34
+ icon: `mdiSvg:${mdiIcons['mdiFormatParagraph']}`,
35
+ noI18n: true,
36
+ enabled: true,
37
+ props: {
38
+ color: computed(() => editor.value.isActive('paragraph') ? 'primary' : ''),
39
+ },
40
+ attrs: {
41
+ click: () => editor.value.chain().focus().setParagraph().run()
42
+ }
43
+ }
44
+ ].concat(
45
+ headingLevels.value.map(level => {
46
+ const headingLevel: Level = level as Level
47
+ return {
48
+ name: `H${level}`,
49
+ tooltip: computed(() => t(`style.headings.h${level}`)),
50
+ // icon: mdiIcons[`mdiFormatHeader${level}`],
51
+ icon: `mdiSvg:${mdiIcons[`mdiFormatHeader${level}`]}`,
52
+ noI18n: true,
53
+ enabled: true,
54
+ props: {
55
+ color: computed(() => editor.value.isActive('heading', {level: level}) ? 'primary' : ''),
56
+ },
57
+ attrs: {
58
+ click: () => editor.value.chain().focus().toggleHeading({level: headingLevel}).run()
59
+ }
60
+ }
61
+ })
62
+ )
63
+ }
64
+ }
@@ -0,0 +1,36 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import StyleColor from "@tiptapify/extensions/components/StyleColor.vue";
4
+ import { computed, inject, markRaw, Ref } from "vue";
5
+ import { useI18n } from "vue-i18n";
6
+
7
+ export function useHighlight(theme: any) {
8
+ const { t } = useI18n();
9
+
10
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
11
+
12
+ return {
13
+ name: 'highlight',
14
+ tooltip: computed(() => t('style.color.highlight')),
15
+ icon: `mdiSvg:${mdi.mdiFormatColorFill}`,
16
+ icon2: `mdiSvg:${mdi.mdiColorHelper}`,
17
+ enabled: true,
18
+ props: {
19
+ disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
20
+ },
21
+ icon2Props: {
22
+ disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
23
+ color: computed(() => {
24
+ const defaultColor = theme.global.current.value.dark ? '#fff' : '#000'
25
+ return editor.value.getAttributes('highlight').color || defaultColor
26
+ }),
27
+ style: 'filter: drop-shadow(rgba(0, 0, 0, .75) 1px 1px 2px);'
28
+ },
29
+ component: markRaw(StyleColor),
30
+ componentProps: {
31
+ fontColor: false,
32
+ backgroundColor: true,
33
+ color: computed(() => editor.value.getAttributes('highlight').color || ''),
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,49 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { lineHeights } from "@tiptapify/constants/style";
4
+ import LineHeight from "@tiptapify/extensions/components/LineHeight.vue";
5
+ import { computed, inject, markRaw, Ref } from "vue";
6
+ import { useI18n } from "vue-i18n";
7
+
8
+ export function useLineHeight() {
9
+ const { t } = useI18n();
10
+
11
+ const editor = inject('tiptapifyEditor') as Ref<Editor>
12
+
13
+ return {
14
+ name: 'line-height',
15
+ tooltip: computed(() => t('style.lineHeight')),
16
+ icon: `mdiSvg:${mdi.mdiFormatLineHeight}`,
17
+ modelValue: null,
18
+ enabled: true,
19
+ props: {
20
+ disabled: computed(() => !editor.value.can().chain().focus().unsetLineHeight().run()),
21
+ color: computed(() => {
22
+ let color = ''
23
+ for (const height of lineHeights) {
24
+ if (editor.value.isActive('textStyle', { lineHeight: height.toString() })) {
25
+ color = 'primary'
26
+ break;
27
+ }
28
+ }
29
+
30
+ return color
31
+ }),
32
+ },
33
+ component: markRaw(LineHeight),
34
+ componentProps: {
35
+ lineHeights,
36
+ lineHeight: computed(() => {
37
+ let lineHeight = null
38
+ for (const height of lineHeights) {
39
+ if (editor.value.isActive('textStyle', { lineHeight: height.toString() })) {
40
+ lineHeight = height
41
+ break;
42
+ }
43
+ }
44
+
45
+ return lineHeight
46
+ }),
47
+ }
48
+ }
49
+ }
@@ -1,35 +1,9 @@
1
- import * as mdi from "@mdi/js";
2
- import { Editor } from "@tiptap/vue-3";
3
- import { computed } from "vue";
4
- import { useI18n } from "vue-i18n";
5
-
6
- export function useActionsItems(editor: Editor) {
7
- const { t } = useI18n();
1
+ import { useRedo } from "@tiptapify/composables/Toolbar/Actions/useRedo";
2
+ import { useUndo } from "@tiptapify/composables/Toolbar/Actions/useUndo";
8
3
 
4
+ export function useActionsItems() {
9
5
  return {
10
- undo: {
11
- name: 'undo',
12
- tooltip: computed(() => t('action.undo')),
13
- icon: mdi.mdiUndo,
14
- enabled: true,
15
- props: {
16
- disabled: computed(() => !editor.can().chain().focus().undo().run()),
17
- },
18
- attrs: {
19
- click: () => editor.chain().focus().undo().run()
20
- }
21
- },
22
- redo: {
23
- name: 'redo',
24
- tooltip: computed(() => t('action.redo')),
25
- icon: mdi.mdiRedo,
26
- enabled: true,
27
- props: {
28
- disabled: computed(() => !editor.can().chain().focus().redo().run()),
29
- },
30
- attrs: {
31
- click: () => editor.chain().focus().redo().run()
32
- }
33
- }
6
+ undo: useUndo(),
7
+ redo: useRedo()
34
8
  }
35
9
  }