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
package/index.d.ts CHANGED
@@ -1,45 +1,67 @@
1
1
  import { Editor as TiptapEditor } from '@tiptap/vue-3'
2
- import type { DefineComponent } from 'vue'
3
- import { toolbarSections } from './src/types/toolbarTypes'
4
-
5
- export interface TiptapifyProps {
6
- content: string|object
7
- variantBtn: string
8
- variantField: string
9
- toolbar: boolean
10
- items: [string]
11
- itemsExclude: boolean
12
- bubbleMenu: boolean
13
- floatingMenu: boolean
14
- slashCommands: boolean
15
- placeholder: string
16
- showWordsCount: boolean
17
- showCharactersCount: boolean
18
- defaultFontFamily: string
19
- fontMeasure: string
20
- rounded: string
21
- customExtensions: toolbarSections
22
- }
2
+ import {
3
+ Extension,
4
+ ExtendableConfig,
5
+ InputRule,
6
+ PasteRule,
7
+ Node,
8
+ Mark,
9
+ markInputRule,
10
+ markPasteRule,
11
+ mergeAttributes
12
+ } from '@tiptap/core'
13
+ import type {
14
+ AnyExtension,
15
+ CanCommands,
16
+ ChainedCommands,
17
+ Command,
18
+ CommandProps,
19
+ Commands,
20
+ Content,
21
+ EditorOptions,
22
+ EditorEvents,
23
+ Extensions,
24
+ ExtensionConfig,
25
+ InputRuleMatch,
26
+ JSONContent,
27
+ MarkConfig,
28
+ NodeConfig,
29
+ PasteRuleMatch,
30
+ Range,
31
+ RawCommands,
32
+ SingleCommands,
33
+ } from '@tiptap/core'
23
34
 
24
- export interface TiptapifyEmits {
25
- [key: string]: ((...args: never[]) => never) | null
26
- 'editor-ready': (options: {
27
- getHTML: () => string
28
- getJSON: () => never
29
- editor: TiptapEditor
30
- }) => void
31
- }
35
+ import '@tiptap/extension-text-style'
36
+ import '@tiptap/extension-list'
37
+ import '@tiptap/extensions'
38
+ import '@tiptap/extension-document'
39
+ import '@tiptap/extension-text'
40
+ import '@tiptap/extension-paragraph'
41
+ import '@tiptap/extension-heading'
42
+ import '@tiptap/extension-bold'
43
+ import '@tiptap/extension-italic'
44
+ import '@tiptap/extension-strike'
45
+ import '@tiptap/extension-link'
46
+ import '@tiptap/extension-code'
47
+ import '@tiptap/extension-blockquote'
48
+ import '@tiptap/extension-hard-break'
49
+ import '@tiptap/extension-horizontal-rule'
50
+ import '@tiptap/extension-typography'
51
+ import '@tiptap/extension-highlight'
52
+ import '@tiptap/extension-image'
53
+ import '@tiptap/extension-youtube'
54
+ import '@tiptap/extension-superscript'
55
+ import '@tiptap/extension-subscript'
56
+ import '@tiptap/extension-text-align'
57
+ import '@tiptap/extension-underline'
58
+ import '@tiptap/extension-table'
59
+ import '@tiptap/extension-code-block-lowlight'
60
+ import '@tiptap/extension-invisible-characters'
32
61
 
33
- export declare const Tiptapify: DefineComponent<
34
- TiptapifyProps,
35
- object,
36
- object,
37
- Record<string, never>,
38
- Record<string, never>,
39
- object,
40
- object,
41
- TiptapifyEmits
42
- >
62
+ import Tiptapify from './src/components/Tiptapify.vue'
63
+ import TiptapifyDialog from './src/components/UI/TiptapifyDialog.vue'
64
+ import * as mdi from '@mdi/js'
43
65
 
44
66
  export interface TiptapifyOptions {
45
67
  i18n?: string
@@ -51,7 +73,43 @@ declare const TiptapifyPlugin: {
51
73
 
52
74
  export default TiptapifyPlugin
53
75
 
54
- export { TiptapEditor }
76
+ export {
77
+ mdi,
78
+ Tiptapify,
79
+ TiptapifyDialog,
80
+ TiptapEditor,
81
+ Extension,
82
+ ExtendableConfig,
83
+ InputRule,
84
+ Mark,
85
+ mergeAttributes,
86
+ markInputRule,
87
+ markPasteRule,
88
+ Node,
89
+ PasteRule,
90
+ }
91
+
92
+ export type {
93
+ AnyExtension,
94
+ CanCommands,
95
+ ChainedCommands,
96
+ Command,
97
+ CommandProps,
98
+ Commands,
99
+ Content,
100
+ EditorOptions,
101
+ EditorEvents,
102
+ Extensions,
103
+ ExtensionConfig,
104
+ InputRuleMatch,
105
+ JSONContent,
106
+ MarkConfig,
107
+ NodeConfig,
108
+ PasteRuleMatch,
109
+ Range,
110
+ RawCommands,
111
+ SingleCommands,
112
+ }
55
113
 
56
114
  declare module '@vue/runtime-core' {
57
115
  interface GlobalComponents {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tiptapify",
3
3
  "types": "./index.d.ts",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "description": "Tiptap3 editor with Vuetify3 menu implementation",
6
6
  "exports": {
7
7
  ".": {
@@ -30,7 +30,8 @@
30
30
  "dev": "vite",
31
31
  "build": "vite build",
32
32
  "lint": "eslint resources/ts --fix --ext .ts,.js,.cjs,.vue,.tsx,.jsx",
33
- "test": "echo \"Error: no test specified\" && exit 1",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest",
34
35
  "build:charmap": "tsx build-charmap.ts",
35
36
  "build:emojis": "tsx build-emojis.ts",
36
37
  "docs:dev": "pnpm --filter tiptapify-docs docs:dev",
@@ -55,6 +56,10 @@
55
56
  "material design icons",
56
57
  "wysiwyg",
57
58
  "wysiwyg toolbar",
59
+ "rich text editor",
60
+ "vue editor",
61
+ "vue rich text",
62
+ "vue wysiwyg",
58
63
  "markdown",
59
64
  "emoji",
60
65
  "emoticons"
@@ -62,85 +67,86 @@
62
67
  "author": "Igor Voytovich",
63
68
  "license": "MIT",
64
69
  "repository": "https://github.com/IVoyt/tiptapify",
65
- "packageManager": "pnpm@10.33.4",
70
+ "packageManager": "pnpm@11.8.0",
66
71
  "dependencies": {
67
- "@mdi/js": "^7.4.47",
68
- "@tiptap/core": "^3.23.5",
69
- "@tiptap/extension-blockquote": "^3.23.5",
70
- "@tiptap/extension-bold": "^3.23.5",
71
- "@tiptap/extension-bubble-menu": "^3.23.5",
72
- "@tiptap/extension-code": "^3.23.5",
73
- "@tiptap/extension-code-block": "^3.23.5",
74
- "@tiptap/extension-code-block-lowlight": "^3.23.5",
75
- "@tiptap/extension-color": "^3.23.5",
76
- "@tiptap/extension-document": "^3.23.5",
77
- "@tiptap/extension-floating-menu": "^3.23.5",
78
- "@tiptap/extension-font-family": "^3.23.5",
79
- "@tiptap/extension-hard-break": "^3.23.5",
80
- "@tiptap/extension-heading": "^3.23.5",
81
- "@tiptap/extension-highlight": "^3.23.5",
82
- "@tiptap/extension-horizontal-rule": "^3.23.5",
83
- "@tiptap/extension-image": "^3.23.5",
84
- "@tiptap/extension-invisible-characters": "^3.23.5",
85
- "@tiptap/extension-italic": "^3.23.5",
86
- "@tiptap/extension-link": "^3.23.5",
87
- "@tiptap/extension-list": "^3.23.5",
88
- "@tiptap/extension-list-item": "^3.23.5",
89
- "@tiptap/extension-paragraph": "^3.23.5",
90
- "@tiptap/extension-placeholder": "^3.23.5",
91
- "@tiptap/extension-strike": "^3.23.5",
92
- "@tiptap/extension-subscript": "^3.23.5",
93
- "@tiptap/extension-superscript": "^3.23.5",
94
- "@tiptap/extension-table": "^3.23.5",
95
- "@tiptap/extension-task-item": "^3.23.5",
96
- "@tiptap/extension-task-list": "^3.23.5",
97
- "@tiptap/extension-text": "^3.23.5",
98
- "@tiptap/extension-text-align": "^3.23.5",
99
- "@tiptap/extension-text-style": "^3.23.5",
100
- "@tiptap/extension-typography": "^3.23.5",
101
- "@tiptap/extension-underline": "^3.23.5",
102
- "@tiptap/extension-youtube": "^3.23.5",
103
- "@tiptap/extensions": "^3.23.5",
104
- "@tiptap/pm": "^3.23.5",
105
- "@tiptap/suggestion": "^3.23.5",
106
- "@tiptap/vue-3": "^3.23.5",
72
+ "@floating-ui/dom": "^1.7.6",
73
+ "@tiptap/core": "^3.27.1",
74
+ "@tiptap/extension-blockquote": "^3.27.1",
75
+ "@tiptap/extension-bold": "^3.27.1",
76
+ "@tiptap/extension-bubble-menu": "^3.27.1",
77
+ "@tiptap/extension-code": "^3.27.1",
78
+ "@tiptap/extension-code-block": "^3.27.1",
79
+ "@tiptap/extension-code-block-lowlight": "^3.27.1",
80
+ "@tiptap/extension-color": "^3.27.1",
81
+ "@tiptap/extension-document": "^3.27.1",
82
+ "@tiptap/extension-floating-menu": "^3.27.1",
83
+ "@tiptap/extension-font-family": "^3.27.1",
84
+ "@tiptap/extension-hard-break": "^3.27.1",
85
+ "@tiptap/extension-heading": "^3.27.1",
86
+ "@tiptap/extension-highlight": "^3.27.1",
87
+ "@tiptap/extension-horizontal-rule": "^3.27.1",
88
+ "@tiptap/extension-image": "^3.27.1",
89
+ "@tiptap/extension-invisible-characters": "^3.27.1",
90
+ "@tiptap/extension-italic": "^3.27.1",
91
+ "@tiptap/extension-link": "^3.27.1",
92
+ "@tiptap/extension-list": "^3.27.1",
93
+ "@tiptap/extension-list-item": "^3.27.1",
94
+ "@tiptap/extension-paragraph": "^3.27.1",
95
+ "@tiptap/extension-placeholder": "^3.27.1",
96
+ "@tiptap/extension-strike": "^3.27.1",
97
+ "@tiptap/extension-subscript": "^3.27.1",
98
+ "@tiptap/extension-superscript": "^3.27.1",
99
+ "@tiptap/extension-table": "^3.27.1",
100
+ "@tiptap/extension-task-item": "^3.27.1",
101
+ "@tiptap/extension-task-list": "^3.27.1",
102
+ "@tiptap/extension-text": "^3.27.1",
103
+ "@tiptap/extension-text-align": "^3.27.1",
104
+ "@tiptap/extension-text-style": "^3.27.1",
105
+ "@tiptap/extension-typography": "^3.27.1",
106
+ "@tiptap/extension-underline": "^3.27.1",
107
+ "@tiptap/extension-youtube": "^3.27.1",
108
+ "@tiptap/extensions": "^3.27.1",
109
+ "@tiptap/pm": "^3.27.1",
110
+ "@tiptap/suggestion": "^3.27.1",
111
+ "@tiptap/vue-3": "^3.27.1",
107
112
  "emoji.json": "^16.0.0",
108
113
  "highlight.js": "^11.11.1",
109
- "linkifyjs": "^4.3.2",
114
+ "linkifyjs": "^4.3.3",
110
115
  "lowlight": "^3.3.0"
111
116
  },
112
117
  "peerDependencies": {
113
- "vue": "^3.5.14",
114
- "vuetify": "^3.8.5 || ^4.0.0",
115
- "vue-i18n": "^11.3.0"
118
+ "@mdi/js": "^7.4.47",
119
+ "vue": "^3.5.38",
120
+ "vue-i18n": "^11.3.0",
121
+ "vuetify": "^3.8.5 || ^4.0.0"
116
122
  },
117
123
  "devDependencies": {
118
- "@intlify/unplugin-vue-i18n": "^11.1.1",
119
- "@rollup/plugin-alias": "^5.1.1",
120
- "@types/node": "^22.19.15",
121
- "@vitejs/plugin-vue": "^6.0.5",
124
+ "@intlify/unplugin-vue-i18n": "^11.2.4",
125
+ "@types/node": "^26.0.0",
126
+ "@vitejs/plugin-vue": "^6.0.7",
122
127
  "@vitejs/plugin-vue-jsx": "^5.1.5",
123
- "eslint": "^10.4.0",
124
- "eslint-import-resolver-typescript": "^4.4.4",
128
+ "eslint": "^10.5.0",
129
+ "eslint-import-resolver-typescript": "^4.4.5",
125
130
  "eslint-plugin-case-police": "^2.2.1",
126
131
  "eslint-plugin-import": "^2.32.0",
127
132
  "eslint-plugin-promise": "^7.3.0",
128
- "eslint-plugin-regexp": "2.7.0",
129
- "eslint-plugin-sonarjs": "1.0.4",
130
- "eslint-plugin-unicorn": "^64.0.0",
131
- "eslint-plugin-vue": "^10.9.1",
132
- "rollup-plugin-tsconfig-paths": "^1.5.2",
133
- "sass-embedded": "^1.98.0",
134
- "stylelint": "^17.12.0",
135
- "stylelint-config-standard-scss": "14.0.0",
136
- "tsx": "^4.21.0",
133
+ "eslint-plugin-regexp": "3.1.0",
134
+ "eslint-plugin-sonarjs": "2.0.4",
135
+ "eslint-plugin-unicorn": "^68.0.0",
136
+ "eslint-plugin-vue": "^10.9.2",
137
+ "jsdom": "^29.1.1",
138
+ "sass-embedded": "^1.100.0",
139
+ "stylelint": "^17.13.0",
140
+ "stylelint-config-standard-scss": "17.0.0",
141
+ "tsx": "^4.22.4",
137
142
  "typescript": "^6.0.3",
138
- "typescript-eslint": "^8.59.4",
139
- "unplugin-vue-components": "^28.8.0",
140
- "vite": "^7.3.1",
143
+ "typescript-eslint": "^8.61.1",
144
+ "unplugin-vue-components": "^32.1.0",
145
+ "vite": "^8.0.16",
141
146
  "vite-plugin-vuetify": "^2.1.3",
142
147
  "vite-svg-loader": "^5.1.1",
143
- "vite-tsconfig-paths": "^5.1.4",
144
- "vue-tsc": "^3.2.6"
148
+ "vitest": "^4.1.9",
149
+ "vue-eslint-parser": "^10.4.1",
150
+ "vue-tsc": "^3.3.5"
145
151
  }
146
152
  }
@@ -1,13 +1,14 @@
1
1
  <script setup lang="ts">
2
- import { Editor } from "@tiptap/vue-3";
3
- import { computed, inject, ref, Ref } from "vue";
2
+ import { Editor } from '@tiptap/vue-3'
3
+ import { computed, inject, ref, Ref } from 'vue'
4
+ import { ComposerTranslation } from 'vue-i18n'
4
5
 
5
6
  const props = defineProps({
6
7
  showWordsCount: { type: Boolean, default: true },
7
8
  showCharactersCount: { type: Boolean, default: true },
8
9
  })
9
10
 
10
- const { t } = inject('tiptapifyI18n') as any
11
+ const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
11
12
 
12
13
  const editor = inject('tiptapifyEditor') as Ref<Editor>
13
14
 
@@ -1,12 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { Editor } from "@tiptap/vue-3";
3
- import { computed, inject, Ref, ref } from "vue";
2
+ import { Editor } from '@tiptap/vue-3'
3
+ import { computed, inject, Ref, ref } from 'vue'
4
4
  import { BubbleMenu } from '@tiptap/vue-3/menus'
5
5
  import * as mdi from '@mdi/js'
6
6
 
7
7
  defineProps({
8
- variant: { type: String, default () { return 'flat' }},
9
- theme: { type: String, default () { return 'light' }},
8
+ variant: { type: String, default () { return 'flat' } },
9
+ theme: { type: String, default () { return 'light' } },
10
10
  })
11
11
 
12
12
  const editor = inject('tiptapifyEditor') as Ref<Editor>
@@ -85,19 +85,19 @@ const items = ref([
85
85
 
86
86
  <template>
87
87
  <BubbleMenu
88
- v-if="editor"
89
- :editor="editor"
90
- :options="{ placement: 'bottom' }"
91
- :shouldShow="({ editor, view, state, from, to }) => {
92
- if (editor.isActive('image') || editor.isActive('code') || editor.isActive('codeBlock')) {
93
- return false
94
- }
88
+ v-if="editor"
89
+ :editor="editor"
90
+ :options="{ placement: 'bottom' }"
91
+ :should-show="({ editor, view, state, from, to }) => {
92
+ if (editor.isActive('image') || editor.isActive('code') || editor.isActive('codeBlock')) {
93
+ return false
94
+ }
95
95
 
96
- const docSize = editor.state.doc.content.size
97
- const isAllSelected = from === 0 && to === docSize
96
+ const docSize = editor.state.doc.content.size
97
+ const isAllSelected = from === 0 && to === docSize
98
98
 
99
- return (from !== to) && !isAllSelected
100
- }"
99
+ return (from !== to) && !isAllSelected
100
+ }"
101
101
  >
102
102
  <div class="bubble-menu">
103
103
  <VCard>
@@ -105,7 +105,7 @@ const items = ref([
105
105
  <VToolbar :theme="theme" density="compact" height="auto" class="p-0">
106
106
  <VToolbarItems>
107
107
  <VBtnGroup divided density="compact">
108
- <VBtn v-for="(item, key) in items" :key="key" v-bind="item.props" @click="item.click" size="x-small">
108
+ <VBtn v-for="(item, key) in items" :key="key" v-bind="item.props" size="x-small" @click="item.click">
109
109
  <VIcon :icon="item.icon" size="20" />
110
110
  </VBtn>
111
111
  </VBtnGroup>
@@ -1,12 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { Editor } from "@tiptap/vue-3";
3
- import { inject, Ref } from "vue";
2
+ import { Editor } from '@tiptap/vue-3'
3
+ import { inject, Ref } from 'vue'
4
4
  import { FloatingMenu } from '@tiptap/vue-3/menus'
5
5
  import * as mdi from '@mdi/js'
6
6
 
7
7
  defineProps({
8
- variant: { type: String, default () { return '' }},
9
- theme: { type: String, default () { return 'light' }},
8
+ variant: { type: String, default () { return '' } },
9
+ theme: { type: String, default () { return 'light' } },
10
10
  })
11
11
 
12
12
  const editor = inject('tiptapifyEditor') as Ref<Editor>
@@ -21,23 +21,23 @@ const editor = inject('tiptapifyEditor') as Ref<Editor>
21
21
  <VToolbarItems>
22
22
  <VBtnGroup divided density="compact">
23
23
  <VBtn
24
- @click="editor.chain().focus().toggleHeading({ level: 1 }).run()"
25
- :color="`${editor.isActive('heading', { level: 1 }) ? 'primary' : ''}`"
26
- size="small"
24
+ :color="`${editor.isActive('heading', { level: 1 }) ? 'primary' : ''}`"
25
+ size="small"
26
+ @click="editor.chain().focus().toggleHeading({ level: 1 }).run()"
27
27
  >
28
28
  <VIcon :icon="mdi['mdiFormatHeader1']" size="16" />
29
29
  </VBtn>
30
30
  <VBtn
31
- @click="editor.chain().focus().toggleHeading({ level: 2 }).run()"
32
- :color="`${editor.isActive('heading', { level: 2 }) ? 'primary' : ''}`"
33
- size="small"
31
+ :color="`${editor.isActive('heading', { level: 2 }) ? 'primary' : ''}`"
32
+ size="small"
33
+ @click="editor.chain().focus().toggleHeading({ level: 2 }).run()"
34
34
  >
35
35
  <VIcon :icon="mdi['mdiFormatHeader2']" size="16" />
36
36
  </VBtn>
37
37
  <VBtn
38
- @click="editor.chain().focus().toggleBulletList().run()"
39
- :color="`${editor.isActive('bulletList') ? 'primary' : ''}`"
40
- size="small"
38
+ :color="`${editor.isActive('bulletList') ? 'primary' : ''}`"
39
+ size="small"
40
+ @click="editor.chain().focus().toggleBulletList().run()"
41
41
  >
42
42
  <VIcon :icon="mdi['mdiFormatListBulleted']" size="16" />
43
43
  </VBtn>
@@ -6,6 +6,7 @@ import { SlashCommandsConfig } from '@tiptapify/types/slashCommandsTypes'
6
6
  import { computed, onBeforeUnmount, PropType, provide, ref, ShallowRef } from 'vue'
7
7
  import { default as Toolbar } from '@tiptapify/components/Toolbar/Index.vue'
8
8
  import { Editor, EditorContent } from '@tiptap/vue-3'
9
+ import { TiptapifyEditor, variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
9
10
  import MenuBubble from '@tiptapify/components/MenuBubble.vue'
10
11
  import MenuFloating from '@tiptapify/components/MenuFloating.vue'
11
12
 
@@ -18,12 +19,12 @@ import { useTheme } from 'vuetify/framework'
18
19
 
19
20
  const props = defineProps({
20
21
  locale: { type: String, default () { return 'en' } },
21
- content: String|Object,
22
- height: { type: [Number,String], default () { return null } },
23
- variantBtn: { type: String, default () { return defaults.variantBtn } },
24
- variantField: { type: String, default () { return defaults.variantField } },
22
+ content: { type: [String, Object] as PropType<string | Record<string, never>>, required: true },
23
+ height: { type: [Number, String], default () { return null } },
24
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
25
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return defaults.variantField } },
25
26
  toolbar: { type: Boolean, default () { return true } },
26
- items: { type: [Array, Object as PropType<itemsPropType>], default() { return [] } },
27
+ items: { type: [Array, Object] as PropType<itemsPropType>, default() { return [] } },
27
28
  itemsExclude: { type: Boolean, default() { return false } },
28
29
  bubbleMenu: { type: Boolean, default () { return true } },
29
30
  floatingMenu: { type: Boolean, default () { return true } },
@@ -58,8 +59,8 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
58
59
  props.slashCommands,
59
60
  props.customExtensions,
60
61
  contentChanged,
61
- (editorInstance) => {
62
- editorInstance.interactiveStyles = props.interactiveStyles
62
+ (editorInstance: Editor) => {
63
+ (<TiptapifyEditor>editorInstance).interactiveStyles = props.interactiveStyles
63
64
  emit('editor-ready', {
64
65
  editor: editorInstance,
65
66
  getHTML: () => editorInstance.getHTML(),
@@ -75,6 +76,15 @@ provide('tiptapifyI18n', { t })
75
76
 
76
77
  editor.value?.chain().setFontFamily(props.defaultFontFamily).run()
77
78
 
79
+ const computeResizableHeight = computed(() => {
80
+ let height = props.height
81
+ if (typeof height === 'string') {
82
+ height = parseInt(height)
83
+ }
84
+
85
+ return height > 0 ? `height: ${height}px` : ''
86
+ })
87
+
78
88
  onBeforeUnmount(() => {
79
89
  editor.value?.destroy()
80
90
  })
@@ -99,7 +109,7 @@ onBeforeUnmount(() => {
99
109
 
100
110
  <VProgressLinear v-model="loadingProgress" :color="loadingColor" :height="loadingHeight" :indeterminate="loading" />
101
111
 
102
- <div class="pa-2 tiptapify-container resizable" :style="`${height > 0 ? `height: ${height}px` : ''}`">
112
+ <div class="pa-2 tiptapify-container resizable" :style="computeResizableHeight">
103
113
  <MenuFloating v-if="floatingMenu" :variant="variantBtn" :theme="currentTheme" />
104
114
 
105
115
  <MenuBubble v-if="bubbleMenu" :variant="variantBtn" :theme="currentTheme" />
@@ -170,7 +180,7 @@ onBeforeUnmount(() => {
170
180
  font-size: .875rem;
171
181
  font-weight: 500;
172
182
  line-height: 1.15;
173
- margin: none;
183
+ margin: unset;
174
184
  padding: .375rem .625rem;
175
185
  transition: all .2s cubic-bezier(.65,.05,.36,1);
176
186
  }
@@ -1,16 +1,17 @@
1
1
  <script setup lang="ts">
2
- import { Editor } from "@tiptap/vue-3";
3
- import Items from "@tiptapify/components/Toolbar/Items.vue";
4
- import defaults from "@tiptapify/constants/defaults";
2
+ import { Editor } from '@tiptap/vue-3'
3
+ import Items from '@tiptapify/components/Toolbar/Items.vue'
4
+ import defaults from '@tiptapify/constants/defaults'
5
+ import { variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
5
6
  import { computed, inject, PropType, Ref } from 'vue'
6
7
  import { itemsPropType, toolbarSections } from '@tiptapify/types/toolbarTypes'
7
8
 
8
- import { default as items, availableItems } from "@tiptapify/components/Toolbar/items";
9
+ import { default as toolbarItemsGroups, availableItems } from '@tiptapify/components/Toolbar/items'
9
10
 
10
11
  const props = defineProps({
11
- variantBtn: { type: String, default () { return defaults.variantBtn } },
12
- variantField: { type: String, default () { return defaults.variantField } },
13
- items: { type: [Array, Object as PropType<itemsPropType>], default() { return [] } },
12
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
13
+ variantField: { type: String as PropType<variantFieldTypes>, default() { return defaults.variantField } },
14
+ items: { type: [Array, Object] as PropType<itemsPropType>, default() { return [] } },
14
15
  itemsExclude: { type: Boolean, default() { return false } },
15
16
  fontMeasure: { type: String, default () { return 'px' } },
16
17
  customFonts: { type: Array<string>, default () { return [] } },
@@ -24,20 +25,23 @@ const props = defineProps({
24
25
  const editor = inject('tiptapifyEditor') as Ref<Editor>
25
26
 
26
27
  const propsItems = computed(() => props.items)
27
- const propsItemsIsList = computed(() => Array.isArray(propsItems.value))
28
28
  const propsItemsExclude = computed(() => props.itemsExclude)
29
29
 
30
30
  // this prevents from overriding the default items
31
- let toolbarItems = [...Object.values(items)]
31
+ let toolbarItems = [...Object.values(toolbarItemsGroups)]
32
32
  const availableItemsKeys = Object.keys(availableItems)
33
33
 
34
34
  type toolbarItemsType = { [key: string]: { section: string, group: boolean, components: any[] } }
35
- propsItemsExclude.value ? prepareExcludeToolbarItems() : prepareToolbarItems()
35
+ if (propsItemsExclude.value) {
36
+ prepareExcludeToolbarItems()
37
+ } else {
38
+ prepareToolbarItems()
39
+ }
36
40
 
37
41
  function prepareToolbarItems() {
38
42
  const _toolbarItems: toolbarItemsType = {}
39
43
 
40
- if (!propsItemsIsList.value) {
44
+ if (!Array.isArray(propsItems.value)) {
41
45
  for (const propsItemSection in propsItems.value as itemsPropType) {
42
46
  if (propsItems.value[propsItemSection].length === 0) {
43
47
  continue
@@ -94,15 +98,15 @@ function prepareExcludeToolbarItems() {
94
98
  toolbarItems = Object.values(_toolbarItems)
95
99
  }
96
100
 
97
- function addToolbarItem(_toolbarItems: toolbarItemsType, itemsList: any, itemTitle: string, group: boolean|null = null): boolean {
101
+ function addToolbarItem(_toolbarItems: toolbarItemsType, itemsList: Array<any>, itemTitle: string, group: boolean|null = null): boolean {
98
102
  const item = itemTitle.split(':')
99
103
  const _itemTitle = item[0]
100
104
  const _itemOptions = item[1] ? item[1].split(',') : []
101
105
 
102
106
  const itemSection = availableItems[_itemTitle]
103
- const section = items[itemSection]
107
+ const section = toolbarItemsGroups[itemSection]
104
108
 
105
- const component = section?.components.find((component: any) => component.name === _itemTitle)
109
+ const component = section?.components.find((component: { name: string }) => component.name === _itemTitle)
106
110
 
107
111
  let itemExists = itemsList.includes(itemTitle)
108
112
  itemExists = propsItemsExclude.value ? itemExists : !itemExists
@@ -111,7 +115,7 @@ function addToolbarItem(_toolbarItems: toolbarItemsType, itemsList: any, itemTit
111
115
  }
112
116
 
113
117
  if (group === null) {
114
- group = section.group
118
+ group = section.group ?? true
115
119
  }
116
120
 
117
121
  if (typeof _toolbarItems[itemSection] === 'undefined') {
@@ -123,7 +127,7 @@ function addToolbarItem(_toolbarItems: toolbarItemsType, itemsList: any, itemTit
123
127
  }
124
128
 
125
129
  if (_itemTitle === 'heading' && _itemOptions.length > 0) {
126
- const paragraphIndex = _itemOptions.findIndex((item: any) => item === 'p')
130
+ const paragraphIndex = _itemOptions.findIndex((item: string) => item === 'p')
127
131
  const withParagraph = paragraphIndex > -1
128
132
  if (withParagraph) {
129
133
  _itemOptions.splice(paragraphIndex, 1)
@@ -131,7 +135,7 @@ function addToolbarItem(_toolbarItems: toolbarItemsType, itemsList: any, itemTit
131
135
 
132
136
  component.props = {
133
137
  withParagraph,
134
- customHeadingLevels: _itemOptions,
138
+ customHeadingLevels: _itemOptions.map((item: string) => parseInt(item)),
135
139
  }
136
140
  }
137
141
 
@@ -1,12 +1,13 @@
1
1
  <script setup lang="ts">
2
2
 
3
3
  import defaults from '@tiptapify/constants/defaults'
4
+ import { variantBtnTypes } from '@tiptapify/types/editor'
4
5
  import { PropType } from 'vue'
5
6
 
6
7
  import { toolbarSections } from '@tiptapify/types/toolbarTypes'
7
8
 
8
9
  defineProps({
9
- variantBtn: { type: String, default () { return defaults.variantBtn } },
10
+ variantBtn: { type: String as PropType<variantBtnTypes>, default() { return defaults.variantBtn } },
10
11
  items: { type: Array as PropType<toolbarSections>, default() { return {} } },
11
12
  })
12
13