tiptapify 0.1.2 → 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/dist/tiptapify.css +1 -1
- package/dist/tiptapify.mjs +36088 -39425
- package/dist/tiptapify.umd.js +66 -71
- package/index.d.ts +19 -17
- package/package.json +5 -5
- package/src/components/Tiptapify.vue +4 -9
- package/src/extensions/components/format/underline/Button.vue +9 -9
- package/src/extensions/slash-commands.ts +3 -2
- package/src/i18n/index.ts +1 -29
- package/src/index.ts +25 -9
package/index.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { Editor } from
|
|
2
|
-
import {
|
|
3
|
-
Component,
|
|
4
|
-
ComponentOptionsMixin, ComponentProvideOptions,
|
|
5
|
-
ComputedOptions, Directive,
|
|
6
|
-
EmitsOptions,
|
|
7
|
-
ExtractDefaultPropTypes,
|
|
8
|
-
MethodOptions,
|
|
9
|
-
PublicProps, SlotsType
|
|
10
|
-
} from "@vue/runtime-core";
|
|
1
|
+
import { Editor as TiptapEditor } from '@tiptap/vue-3'
|
|
11
2
|
import type { DefineComponent } from 'vue'
|
|
12
|
-
import { toolbarSections } from
|
|
3
|
+
import { toolbarSections } from './src/types/toolbarTypes'
|
|
13
4
|
|
|
14
5
|
export interface TiptapifyProps {
|
|
15
6
|
content: string|object
|
|
@@ -31,26 +22,37 @@ export interface TiptapifyProps {
|
|
|
31
22
|
}
|
|
32
23
|
|
|
33
24
|
export interface TiptapifyEmits {
|
|
34
|
-
[key: string]: ((...args:
|
|
25
|
+
[key: string]: ((...args: never[]) => never) | null
|
|
35
26
|
'editor-ready': (options: {
|
|
36
27
|
getHTML: () => string
|
|
37
|
-
getJSON: () =>
|
|
38
|
-
editor:
|
|
28
|
+
getJSON: () => never
|
|
29
|
+
editor: TiptapEditor
|
|
39
30
|
}) => void
|
|
40
31
|
}
|
|
41
32
|
|
|
42
|
-
export declare const Tiptapify: DefineComponent<
|
|
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
|
+
>
|
|
43
43
|
|
|
44
44
|
export interface TiptapifyOptions {
|
|
45
|
-
|
|
45
|
+
i18n?: string
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
declare const TiptapifyPlugin: {
|
|
49
|
-
install: (app:
|
|
49
|
+
install: (app: never, options?: TiptapifyOptions) => void
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export default TiptapifyPlugin
|
|
53
53
|
|
|
54
|
+
export { TiptapEditor }
|
|
55
|
+
|
|
54
56
|
declare module '@vue/runtime-core' {
|
|
55
57
|
interface GlobalComponents {
|
|
56
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.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"description": "Tiptap3 editor with Vuetify3 menu implementation",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"repository": "https://github.com/IVoyt/tiptapify",
|
|
65
65
|
"packageManager": "pnpm@10.33.4",
|
|
66
66
|
"dependencies": {
|
|
67
|
+
"@mdi/js": "^7.4.47",
|
|
67
68
|
"@tiptap/core": "^3.23.5",
|
|
68
69
|
"@tiptap/extension-blockquote": "^3.23.5",
|
|
69
70
|
"@tiptap/extension-bold": "^3.23.5",
|
|
@@ -106,13 +107,12 @@
|
|
|
106
107
|
"emoji.json": "^16.0.0",
|
|
107
108
|
"highlight.js": "^11.11.1",
|
|
108
109
|
"linkifyjs": "^4.3.2",
|
|
109
|
-
"lowlight": "^3.3.0"
|
|
110
|
-
"vue-i18n": "^11.3.0"
|
|
110
|
+
"lowlight": "^3.3.0"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
|
-
"@mdi/js": "^7.4.47",
|
|
114
113
|
"vue": "^3.5.14",
|
|
115
|
-
"vuetify": "^3.8.5 || ^4.0.0"
|
|
114
|
+
"vuetify": "^3.8.5 || ^4.0.0",
|
|
115
|
+
"vue-i18n": "^11.3.0"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@intlify/unplugin-vue-i18n": "^11.1.1",
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import defaults from '@tiptapify/constants/defaults'
|
|
4
4
|
import { itemsPropType, toolbarSections } from '@tiptapify/types/toolbarTypes'
|
|
5
5
|
import { SlashCommandsConfig } from '@tiptapify/types/slashCommandsTypes'
|
|
6
|
-
import { computed, onBeforeUnmount, PropType, provide, ref, ShallowRef
|
|
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
9
|
import MenuBubble from '@tiptapify/components/MenuBubble.vue'
|
|
10
10
|
import MenuFloating from '@tiptapify/components/MenuFloating.vue'
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { useI18n } from 'vue-i18n'
|
|
13
13
|
|
|
14
14
|
import { getTiptapEditor } from '@tiptapify/components/index'
|
|
15
15
|
|
|
@@ -38,7 +38,7 @@ const props = defineProps({
|
|
|
38
38
|
interactiveStyles: { type: Boolean, default() { return true } },
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
const { t
|
|
41
|
+
const { t } = useI18n()
|
|
42
42
|
|
|
43
43
|
const appTheme = useTheme()
|
|
44
44
|
const currentTheme = ref(appTheme.global.name)
|
|
@@ -57,7 +57,6 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
|
|
|
57
57
|
editorInstance.interactiveStyles = props.interactiveStyles
|
|
58
58
|
emit('editor-ready', {
|
|
59
59
|
editor: editorInstance,
|
|
60
|
-
setLocale,
|
|
61
60
|
getHTML: () => editorInstance.getHTML(),
|
|
62
61
|
getJSON: () => editorInstance.getJSON(),
|
|
63
62
|
})
|
|
@@ -67,14 +66,10 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
|
|
|
67
66
|
const emit = defineEmits(['update:modelValue', 'editor-ready', 'content-changed'])
|
|
68
67
|
|
|
69
68
|
provide('tiptapifyEditor', editor)
|
|
70
|
-
provide('tiptapifyI18n', { t
|
|
69
|
+
provide('tiptapifyI18n', { t })
|
|
71
70
|
|
|
72
71
|
editor.value?.chain().setFontFamily(props.defaultFontFamily).run()
|
|
73
72
|
|
|
74
|
-
watch(() => props.locale, () => {
|
|
75
|
-
setLocale(props.locale)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
73
|
onBeforeUnmount(() => {
|
|
79
74
|
editor.value?.destroy()
|
|
80
75
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
|
|
3
3
|
import * as mdi from '@mdi/js'
|
|
4
|
-
import { Editor } from
|
|
5
|
-
import BtnIcon from
|
|
6
|
-
import { inject, Ref } from
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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.
|
|
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 } =
|
|
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
|
|
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
|
-
|
|
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 {
|
|
17
|
-
export
|
|
31
|
+
export { mdi }
|
|
32
|
+
export { TipTapEditor }
|
|
33
|
+
export { Node, mergeAttributes }
|