tiptapify 0.1.1 → 0.1.3

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.
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Editor } from "@tiptap/vue-3";
1
+ import { Editor as TiptapEditor } from '@tiptap/vue-3'
2
2
  import type { DefineComponent } from 'vue'
3
- import { toolbarSections } from "./src/types/toolbarTypes";
3
+ import { toolbarSections } from './src/types/toolbarTypes'
4
4
 
5
5
  export interface TiptapifyProps {
6
6
  content: string|object
@@ -22,26 +22,37 @@ export interface TiptapifyProps {
22
22
  }
23
23
 
24
24
  export interface TiptapifyEmits {
25
+ [key: string]: ((...args: never[]) => never) | null
25
26
  'editor-ready': (options: {
26
27
  getHTML: () => string
27
- getJSON: () => any
28
- editor: Editor
28
+ getJSON: () => never
29
+ editor: TiptapEditor
29
30
  }) => void
30
31
  }
31
32
 
32
- export declare const Tiptapify: DefineComponent<TiptapifyProps, {}, {}, {}, {}, {}, {}, TiptapifyEmits>
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
+ >
33
43
 
34
- // Плагин
35
44
  export interface TiptapifyOptions {
36
- locale?: string
45
+ i18n?: string
37
46
  }
38
47
 
39
48
  declare const TiptapifyPlugin: {
40
- install: (app: any, options?: TiptapifyOptions) => void
49
+ install: (app: never, options?: TiptapifyOptions) => void
41
50
  }
42
51
 
43
52
  export default TiptapifyPlugin
44
53
 
54
+ export { TiptapEditor }
55
+
45
56
  declare module '@vue/runtime-core' {
46
57
  interface GlobalComponents {
47
58
  Tiptapify: typeof Tiptapify
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tiptapify",
3
3
  "types": "./index.d.ts",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "description": "Tiptap3 editor with Vuetify3 menu implementation",
6
6
  "exports": {
7
7
  ".": {
@@ -29,6 +29,7 @@
29
29
  "scripts": {
30
30
  "dev": "vite",
31
31
  "build": "vite build",
32
+ "lint": "eslint resources/ts --fix --ext .ts,.js,.cjs,.vue,.tsx,.jsx",
32
33
  "test": "echo \"Error: no test specified\" && exit 1",
33
34
  "build:charmap": "tsx build-charmap.ts",
34
35
  "build:emojis": "tsx build-emojis.ts",
@@ -63,55 +64,55 @@
63
64
  "repository": "https://github.com/IVoyt/tiptapify",
64
65
  "packageManager": "pnpm@10.33.4",
65
66
  "dependencies": {
66
- "@tiptap/core": "^3.20.4",
67
- "@tiptap/extension-blockquote": "^3.20.4",
68
- "@tiptap/extension-bold": "^3.20.4",
69
- "@tiptap/extension-bubble-menu": "^3.20.4",
70
- "@tiptap/extension-code": "^3.20.4",
71
- "@tiptap/extension-code-block": "^3.20.4",
72
- "@tiptap/extension-code-block-lowlight": "^3.20.4",
73
- "@tiptap/extension-color": "^3.20.4",
74
- "@tiptap/extension-document": "^3.20.4",
75
- "@tiptap/extension-floating-menu": "^3.20.4",
76
- "@tiptap/extension-font-family": "^3.20.4",
77
- "@tiptap/extension-hard-break": "^3.20.4",
78
- "@tiptap/extension-heading": "^3.20.4",
79
- "@tiptap/extension-highlight": "^3.20.4",
80
- "@tiptap/extension-horizontal-rule": "^3.20.4",
81
- "@tiptap/extension-image": "^3.20.4",
82
- "@tiptap/extension-invisible-characters": "^3.20.4",
83
- "@tiptap/extension-italic": "^3.20.4",
84
- "@tiptap/extension-link": "^3.20.4",
85
- "@tiptap/extension-list": "^3.20.4",
86
- "@tiptap/extension-list-item": "^3.20.4",
87
- "@tiptap/extension-paragraph": "^3.20.4",
88
- "@tiptap/extension-placeholder": "^3.20.4",
89
- "@tiptap/extension-strike": "^3.20.4",
90
- "@tiptap/extension-subscript": "^3.20.4",
91
- "@tiptap/extension-superscript": "^3.20.4",
92
- "@tiptap/extension-table": "^3.20.4",
93
- "@tiptap/extension-task-item": "^3.20.4",
94
- "@tiptap/extension-task-list": "^3.20.4",
95
- "@tiptap/extension-text": "^3.20.4",
96
- "@tiptap/extension-text-align": "^3.20.4",
97
- "@tiptap/extension-text-style": "^3.20.4",
98
- "@tiptap/extension-typography": "^3.20.4",
99
- "@tiptap/extension-underline": "^3.20.4",
100
- "@tiptap/extension-youtube": "^3.20.4",
101
- "@tiptap/extensions": "^3.20.4",
102
- "@tiptap/pm": "^3.20.4",
103
- "@tiptap/suggestion": "^3.20.4",
104
- "@tiptap/vue-3": "^3.20.4",
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",
105
107
  "emoji.json": "^16.0.0",
106
108
  "highlight.js": "^11.11.1",
107
109
  "linkifyjs": "^4.3.2",
108
- "lowlight": "^3.3.0",
109
- "vue-i18n": "^11.3.0"
110
+ "lowlight": "^3.3.0"
110
111
  },
111
112
  "peerDependencies": {
112
- "@mdi/js": "^7.4.47",
113
113
  "vue": "^3.5.14",
114
- "vuetify": "^3.8.5 || ^4.0.0"
114
+ "vuetify": "^3.8.5 || ^4.0.0",
115
+ "vue-i18n": "^11.3.0"
115
116
  },
116
117
  "devDependencies": {
117
118
  "@intlify/unplugin-vue-i18n": "^11.1.1",
@@ -119,10 +120,22 @@
119
120
  "@types/node": "^22.19.15",
120
121
  "@vitejs/plugin-vue": "^6.0.5",
121
122
  "@vitejs/plugin-vue-jsx": "^5.1.5",
123
+ "eslint": "^10.4.0",
124
+ "eslint-import-resolver-typescript": "^4.4.4",
125
+ "eslint-plugin-case-police": "^2.2.1",
126
+ "eslint-plugin-import": "^2.32.0",
127
+ "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",
122
132
  "rollup-plugin-tsconfig-paths": "^1.5.2",
123
133
  "sass-embedded": "^1.98.0",
134
+ "stylelint": "^17.12.0",
135
+ "stylelint-config-standard-scss": "14.0.0",
124
136
  "tsx": "^4.21.0",
125
- "typescript": "^5.9.3",
137
+ "typescript": "^6.0.3",
138
+ "typescript-eslint": "^8.59.4",
126
139
  "unplugin-vue-components": "^28.8.0",
127
140
  "vite": "^7.3.1",
128
141
  "vite-plugin-vuetify": "^2.1.3",
@@ -1,22 +1,20 @@
1
1
  <script setup lang="ts">
2
2
 
3
- import defaults from "@tiptapify/constants/defaults";
4
- import { itemsPropType, toolbarSections } from "@tiptapify/types/toolbarTypes";
5
- import { SlashCommandsConfig } from "@tiptapify/types/slashCommandsTypes";
6
- import { computed, onBeforeUnmount, PropType, provide, ref, ShallowRef, watch } from "vue";
7
- import { default as Toolbar } from "@tiptapify/components/Toolbar/Index.vue";
3
+ import defaults from '@tiptapify/constants/defaults'
4
+ import { itemsPropType, toolbarSections } from '@tiptapify/types/toolbarTypes'
5
+ import { SlashCommandsConfig } from '@tiptapify/types/slashCommandsTypes'
6
+ import { computed, onBeforeUnmount, PropType, provide, ref, ShallowRef } from 'vue'
7
+ import { default as Toolbar } from '@tiptapify/components/Toolbar/Index.vue'
8
8
  import { Editor, EditorContent } from '@tiptap/vue-3'
9
9
  import MenuBubble from '@tiptapify/components/MenuBubble.vue'
10
10
  import MenuFloating from '@tiptapify/components/MenuFloating.vue'
11
11
 
12
- import { useLocale } from "@tiptapify/i18n";
12
+ import { useI18n } from 'vue-i18n'
13
13
 
14
- import { getTiptapEditor } from "@tiptapify/components/index";
14
+ import { getTiptapEditor } from '@tiptapify/components/index'
15
15
 
16
16
  import Footer from '@tiptapify/components/Footer.vue'
17
- import { useTheme } from "vuetify/framework";
18
-
19
- const { t, i18n, setLocale } = useLocale();
17
+ import { useTheme } from 'vuetify/framework'
20
18
 
21
19
  const props = defineProps({
22
20
  locale: { type: String, default () { return 'en' } },
@@ -25,7 +23,7 @@ const props = defineProps({
25
23
  variantBtn: { type: String, default () { return defaults.variantBtn } },
26
24
  variantField: { type: String, default () { return defaults.variantField } },
27
25
  toolbar: { type: Boolean, default () { return true } },
28
- items: { type: [Array, Object as PropType<itemsPropType>], default() { return [] }},
26
+ items: { type: [Array, Object as PropType<itemsPropType>], default() { return [] } },
29
27
  itemsExclude: { type: Boolean, default() { return false } },
30
28
  bubbleMenu: { type: Boolean, default () { return true } },
31
29
  floatingMenu: { type: Boolean, default () { return true } },
@@ -40,14 +38,11 @@ const props = defineProps({
40
38
  interactiveStyles: { type: Boolean, default() { return true } },
41
39
  })
42
40
 
41
+ const { t } = useI18n()
42
+
43
43
  const appTheme = useTheme()
44
44
  const currentTheme = ref(appTheme.global.name)
45
45
 
46
- const propsItems = computed(() => props.items)
47
- const propsItemsExclude = computed(() => props.itemsExclude)
48
-
49
- const interactiveStyles = computed(() => props.interactiveStyles)
50
-
51
46
  function contentChanged() {
52
47
  emit('content-changed', { html: editor.value?.getHTML(), json: editor.value?.getJSON() })
53
48
  }
@@ -57,38 +52,24 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
57
52
  computed(() => props.placeholder || t('content.placeholder')).value,
58
53
  props.slashCommands,
59
54
  props.customExtensions,
60
- contentChanged
55
+ contentChanged,
56
+ (editorInstance) => {
57
+ editorInstance.interactiveStyles = props.interactiveStyles
58
+ emit('editor-ready', {
59
+ editor: editorInstance,
60
+ getHTML: () => editorInstance.getHTML(),
61
+ getJSON: () => editorInstance.getJSON(),
62
+ })
63
+ },
61
64
  )
62
65
 
63
- const emit = defineEmits(['update:modelValue', 'editor-ready', 'content-changed']);
66
+ const emit = defineEmits(['update:modelValue', 'editor-ready', 'content-changed'])
64
67
 
65
68
  provide('tiptapifyEditor', editor)
66
- provide('tiptapifyI18n', { t, setLocale })
69
+ provide('tiptapifyI18n', { t })
67
70
 
68
71
  editor.value?.chain().setFontFamily(props.defaultFontFamily).run()
69
72
 
70
- watch(() => editor.value, (editorInstance) => {
71
- if (editorInstance instanceof Editor) {
72
- editor.value.interactiveStyles = interactiveStyles.value
73
- emit('editor-ready', {
74
- editor: editorInstance,
75
- setLocale,
76
- getHTML: () => editorInstance.getHTML(),
77
- getJSON: () => editorInstance.getJSON(),
78
- });
79
- }
80
- }, { immediate: true });
81
-
82
- watch(() => props.locale, () => {
83
- setLocale(props.locale)
84
- }, { immediate: true });
85
-
86
- watch(() => props.interactiveStyles, (_interactiveStyles) => {
87
- if (editor.value instanceof Editor) {
88
- editor.value.interactiveStyles = interactiveStyles
89
- }
90
- })
91
-
92
73
  onBeforeUnmount(() => {
93
74
  editor.value?.destroy()
94
75
  })
@@ -99,15 +80,15 @@ onBeforeUnmount(() => {
99
80
  <div>
100
81
  <template v-if="toolbar">
101
82
  <Toolbar
102
- v-if="editor"
103
- :variant-btn="variantBtn"
104
- :variant-field="variantField"
105
- :font-measure="fontMeasure"
106
- :items="propsItems"
107
- :items-exclude="propsItemsExclude"
108
- :rounded="rounded"
109
- :custom-extensions="customExtensions"
110
- :theme="currentTheme"
83
+ v-if="editor"
84
+ :variant-btn="variantBtn"
85
+ :variant-field="variantField"
86
+ :font-measure="fontMeasure"
87
+ :items="items"
88
+ :items-exclude="itemsExclude"
89
+ :rounded="rounded"
90
+ :custom-extensions="customExtensions"
91
+ :theme="currentTheme"
111
92
  />
112
93
  </template>
113
94
 
@@ -9,13 +9,15 @@ export function getTiptapEditor (
9
9
  placeholder: string,
10
10
  slashCommands: SlashCommandsConfig = true,
11
11
  customExtensions: toolbarSections,
12
- onUpdate: Function = () => {}
12
+ onUpdate: Function = () => {},
13
+ onCreate?: (editor: Editor) => void,
13
14
  ): ShallowRef<Editor | undefined> {
14
15
  const extensions = editorExtensions(placeholder, slashCommands, customExtensions)
15
16
 
16
17
  return useEditor({
17
18
  content,
18
19
  extensions,
19
- onUpdate: ({ editor }) => onUpdate()
20
+ onUpdate: ({ editor }) => onUpdate(),
21
+ onCreate: onCreate ? ({ editor }) => onCreate(editor) : undefined,
20
22
  })
21
23
  }
@@ -1,9 +1,9 @@
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 { inject, Ref } from 'vue'
7
7
 
8
8
  import defaults from '@tiptapify/constants/defaults'
9
9
 
@@ -19,14 +19,14 @@ const { t } = inject('tiptapifyI18n') as any
19
19
 
20
20
  <template>
21
21
  <VBtn
22
- :color="editor.isActive('underline') ? 'primary' : ''"
23
- :disabled="!editor.can().chain().focus().toggleUnderline().run()"
24
- :variant="variantBtn"
25
- @click="editor.commands.toggleUnderline()"
26
- size="32"
22
+ :color="editor.isActive('underline') ? 'primary' : ''"
23
+ :disabled="!editor.can().chain().focus().toggleUnderline().run()"
24
+ :variant="variantBtn"
25
+ size="32"
26
+ @click="editor.commands.toggleUnderline()"
27
27
  >
28
28
  <VTooltip activator="parent">
29
- {{ t('format.strike') }}
29
+ {{ t('format.underline') }}
30
30
  </VTooltip>
31
31
  <BtnIcon :icon="`mdiSvg:${mdi.mdiFormatUnderline}`" />
32
32
  </VBtn>
@@ -3,7 +3,8 @@ import { Editor } from '@tiptap/core'
3
3
  import Suggestion from '@tiptap/suggestion'
4
4
  import { VueRenderer, posToDOMRect } from '@tiptap/vue-3'
5
5
  import { computePosition, flip, shift } from '@floating-ui/dom'
6
- import { useLocale } from '@tiptapify/i18n'
6
+ // import { useLocale } from '@tiptapify/i18n'
7
+ import { useI18n } from 'vue-i18n'
7
8
  import CommandsList from '@tiptapify/extensions/components/slashCommands/CommandsList.vue'
8
9
  import PickerDialog from '@tiptapify/extensions/components/slashCommands/PickerDialog.vue'
9
10
  import { PickerEventBus } from '@tiptapify/extensions/PickerEventBus'
@@ -99,7 +100,7 @@ export default Extension.create<SlashCommandsExtensionOptions>(
99
100
  editor.chain().focus().deleteRange(range).run()
100
101
  closePicker()
101
102
 
102
- const { t } = useLocale()
103
+ const { t } = useI18n()
103
104
 
104
105
  pickerComponent = new VueRenderer(PickerDialog, {
105
106
  props: {
package/src/i18n/index.ts CHANGED
@@ -1,35 +1,7 @@
1
- import { createI18n } from 'vue-i18n'
2
- import { ref, computed } from 'vue'
3
-
4
1
  const messages = Object.fromEntries(
5
2
  Object.entries(
6
3
  import.meta.glob<{ default: any }>('./locales/*.json', { eager: true }))
7
4
  .map(([key, value]) => [key.slice(10, -5), value.default]),
8
5
  )
9
6
 
10
- export function useLocale(initialLocale: string = 'en') {
11
- const currentLocale = ref(initialLocale)
12
-
13
- const i18n = createI18n({
14
- legacy: false,
15
- locale: currentLocale.value,
16
- fallbackLocale: 'en',
17
- messages
18
- })
19
-
20
- const { t, locale } = i18n.global
21
-
22
- const setLocale = (newLocale: string) => {
23
- if (messages[newLocale]) {
24
- currentLocale.value = newLocale
25
- locale.value = newLocale
26
- }
27
- }
28
-
29
- return {
30
- i18n,
31
- t,
32
- locale: computed(() => currentLocale.value),
33
- setLocale
34
- }
35
- }
7
+ export { messages }
package/src/index.ts CHANGED
@@ -1,17 +1,33 @@
1
- import { Plugin } from 'vue';
2
- import Tiptapify from '@tiptapify/components/Tiptapify.vue';
3
- import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue';
1
+ import { Plugin } from 'vue'
2
+ import Tiptapify from '@tiptapify/components/Tiptapify.vue'
3
+ import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
4
+
5
+ import { Editor as TipTapEditor } from '@tiptap/vue-3'
6
+ import { Node, mergeAttributes } from '@tiptap/core'
7
+
8
+ import * as mdi from '@mdi/js'
9
+
10
+ import { messages } from './i18n'
4
11
 
5
12
  interface PackageOptions {
6
- locale?: string;
13
+ i18n?: any;
7
14
  }
8
15
 
9
16
  const TiptapifyPlugin: Plugin = {
10
17
  install(app, options: PackageOptions = {}) {
11
- app.component('Tiptapify', Tiptapify);
12
- app.component('TiptapifyDialog', TiptapifyDialog);
18
+ app.component('Tiptapify', Tiptapify)
19
+ app.component('TiptapifyDialog', TiptapifyDialog)
20
+
21
+ const i18n = options.i18n
22
+ for (const locale of Object.keys(messages)) {
23
+ i18n.global.mergeLocaleMessage(locale, messages[locale])
24
+ }
13
25
  }
14
- };
26
+ }
27
+
28
+ export { Tiptapify, TiptapifyDialog }
29
+ export default TiptapifyPlugin
15
30
 
16
- export { Tiptapify, TiptapifyDialog };
17
- export default TiptapifyPlugin;
31
+ export { mdi }
32
+ export { TipTapEditor }
33
+ export { Node, mergeAttributes }