tiptapify 0.1.2 → 0.1.4
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 +33898 -37221
- package/dist/tiptapify.umd.js +66 -71
- package/index.d.ts +19 -17
- package/package.json +5 -5
- package/src/components/Tiptapify.vue +17 -17
- package/src/components/Toolbar/Items.vue +8 -8
- 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.4",
|
|
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
|
|
|
@@ -36,9 +36,14 @@ const props = defineProps({
|
|
|
36
36
|
rounded: { type: String, default () { return '0' } },
|
|
37
37
|
customExtensions: { type: Array as PropType<toolbarSections>, default() { return [] } },
|
|
38
38
|
interactiveStyles: { type: Boolean, default() { return true } },
|
|
39
|
+
loading: { type: Boolean, default() { return false } },
|
|
40
|
+
loadingColor: { type: String, default() { return 'default' } },
|
|
41
|
+
loadingHeight: { type: String, default() { return '1px' } },
|
|
39
42
|
})
|
|
40
43
|
|
|
41
|
-
const
|
|
44
|
+
const loadingProgress = ref(0)
|
|
45
|
+
|
|
46
|
+
const { t } = useI18n()
|
|
42
47
|
|
|
43
48
|
const appTheme = useTheme()
|
|
44
49
|
const currentTheme = ref(appTheme.global.name)
|
|
@@ -57,7 +62,6 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
|
|
|
57
62
|
editorInstance.interactiveStyles = props.interactiveStyles
|
|
58
63
|
emit('editor-ready', {
|
|
59
64
|
editor: editorInstance,
|
|
60
|
-
setLocale,
|
|
61
65
|
getHTML: () => editorInstance.getHTML(),
|
|
62
66
|
getJSON: () => editorInstance.getJSON(),
|
|
63
67
|
})
|
|
@@ -67,14 +71,10 @@ const editor: ShallowRef<Editor | undefined> = getTiptapEditor(
|
|
|
67
71
|
const emit = defineEmits(['update:modelValue', 'editor-ready', 'content-changed'])
|
|
68
72
|
|
|
69
73
|
provide('tiptapifyEditor', editor)
|
|
70
|
-
provide('tiptapifyI18n', { t
|
|
74
|
+
provide('tiptapifyI18n', { t })
|
|
71
75
|
|
|
72
76
|
editor.value?.chain().setFontFamily(props.defaultFontFamily).run()
|
|
73
77
|
|
|
74
|
-
watch(() => props.locale, () => {
|
|
75
|
-
setLocale(props.locale)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
78
|
onBeforeUnmount(() => {
|
|
79
79
|
editor.value?.destroy()
|
|
80
80
|
})
|
|
@@ -82,7 +82,7 @@ onBeforeUnmount(() => {
|
|
|
82
82
|
|
|
83
83
|
<template>
|
|
84
84
|
<div :id="`tiptapify-editor-${editor?.instanceId}`">
|
|
85
|
-
<div>
|
|
85
|
+
<div :class="`border border-t-0 rounded-t-${rounded} rounded-b-${rounded}`">
|
|
86
86
|
<template v-if="toolbar">
|
|
87
87
|
<Toolbar
|
|
88
88
|
v-if="editor"
|
|
@@ -97,17 +97,17 @@ onBeforeUnmount(() => {
|
|
|
97
97
|
/>
|
|
98
98
|
</template>
|
|
99
99
|
|
|
100
|
-
<
|
|
101
|
-
<div class="pa-2 tiptapify-container resizable" :style="`${height > 0 ? `height: ${height}px` : ''}`">
|
|
102
|
-
<MenuFloating v-if="floatingMenu" :variant="variantBtn" :theme="currentTheme" />
|
|
100
|
+
<VProgressLinear v-model="loadingProgress" :color="loadingColor" :height="loadingHeight" :indeterminate="loading" />
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
<div class="pa-2 tiptapify-container resizable" :style="`${height > 0 ? `height: ${height}px` : ''}`">
|
|
103
|
+
<MenuFloating v-if="floatingMenu" :variant="variantBtn" :theme="currentTheme" />
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
</div>
|
|
105
|
+
<MenuBubble v-if="bubbleMenu" :variant="variantBtn" :theme="currentTheme" />
|
|
108
106
|
|
|
109
|
-
<
|
|
107
|
+
<EditorContent :editor="editor" class="tiptapify-editor" />
|
|
110
108
|
</div>
|
|
109
|
+
|
|
110
|
+
<Footer :show-words-count="showWordsCount" :show-characters-count="showCharactersCount" />
|
|
111
111
|
</div>
|
|
112
112
|
</div>
|
|
113
113
|
</template>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
|
|
3
|
-
import defaults from
|
|
3
|
+
import defaults from '@tiptapify/constants/defaults'
|
|
4
4
|
import { PropType } from 'vue'
|
|
5
5
|
|
|
6
|
-
import { toolbarSections } from
|
|
6
|
+
import { toolbarSections } from '@tiptapify/types/toolbarTypes'
|
|
7
7
|
|
|
8
8
|
defineProps({
|
|
9
|
-
variantBtn: { type: String, default () { return defaults.variantBtn }},
|
|
10
|
-
items: { type: Array as PropType<toolbarSections>, default() { return {} }},
|
|
9
|
+
variantBtn: { type: String, default () { return defaults.variantBtn } },
|
|
10
|
+
items: { type: Array as PropType<toolbarSections>, default() { return {} } },
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<VToolbarItems class="py-
|
|
16
|
+
<VToolbarItems class="px-2 py-3">
|
|
17
17
|
<template v-for="item in items" :key="item.section">
|
|
18
18
|
<template v-if="item.section === '__separator__'">
|
|
19
|
-
<div class="menu-divider"
|
|
19
|
+
<div class="menu-divider" />
|
|
20
20
|
</template>
|
|
21
21
|
<template v-else>
|
|
22
22
|
<VBtnGroup v-if="item.group" elevation="4">
|
|
@@ -26,13 +26,13 @@ defineProps({
|
|
|
26
26
|
</VBtnGroup>
|
|
27
27
|
<template v-else>
|
|
28
28
|
<component
|
|
29
|
+
:is="sectionItem.component"
|
|
29
30
|
v-for="sectionItem in item.components"
|
|
30
31
|
:key="sectionItem.name"
|
|
31
|
-
:is="sectionItem.component"
|
|
32
32
|
v-bind="{ variantBtn, ...sectionItem.props ?? {} }"
|
|
33
33
|
/>
|
|
34
34
|
</template>
|
|
35
|
-
<div class="menu-divider"
|
|
35
|
+
<div class="menu-divider" />
|
|
36
36
|
</template>
|
|
37
37
|
</template>
|
|
38
38
|
</VToolbarItems>
|
|
@@ -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 }
|