tiptapify 0.2.2 → 0.2.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 +13797 -13510
- package/dist/tiptapify.umd.js +55 -55
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Footer.vue +69 -3
- package/src/components/Tiptapify.vue +14 -2
- package/src/components/editorExtensions.ts +0 -1
- package/src/i18n/locales/ar.json +2 -1
- package/src/i18n/locales/ch.json +2 -1
- package/src/i18n/locales/cz.json +2 -1
- package/src/i18n/locales/de.json +2 -1
- package/src/i18n/locales/en.json +2 -1
- package/src/i18n/locales/es.json +2 -1
- package/src/i18n/locales/fi.json +2 -1
- package/src/i18n/locales/fr.json +2 -1
- package/src/i18n/locales/hu.json +2 -1
- package/src/i18n/locales/it.json +2 -1
- package/src/i18n/locales/ja.json +2 -1
- package/src/i18n/locales/ko.json +2 -1
- package/src/i18n/locales/la.json +2 -1
- package/src/i18n/locales/lt.json +2 -1
- package/src/i18n/locales/nl.json +2 -1
- package/src/i18n/locales/pl.json +2 -1
- package/src/i18n/locales/pt.json +2 -1
- package/src/i18n/locales/ru.json +2 -1
- package/src/i18n/locales/se.json +2 -1
- package/src/i18n/locales/th.json +2 -1
- package/src/i18n/locales/tr.json +2 -1
- package/src/i18n/locales/uk.json +2 -1
- package/src/i18n/locales/vi.json +2 -1
- package/src/index.ts +2 -0
- package/src/types/editor.ts +2 -0
package/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ import Tiptapify from './src/components/Tiptapify.vue'
|
|
|
64
64
|
import TiptapifyDialog from './src/components/UI/TiptapifyDialog.vue'
|
|
65
65
|
import * as mdi from '@mdi/js'
|
|
66
66
|
|
|
67
|
+
export type TiptapifyFooterAlignment = 'start' | 'center' | 'end'
|
|
68
|
+
|
|
67
69
|
export interface TiptapifyOptions {
|
|
68
70
|
i18n?: string
|
|
69
71
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { Editor } from '@tiptap/vue-3'
|
|
3
|
-
import {
|
|
3
|
+
import { TiptapifyFooterAlignment } from '@tiptapify/types/editor'
|
|
4
|
+
import { computed, inject, PropType, ref, Ref } from 'vue'
|
|
4
5
|
import { ComposerTranslation } from 'vue-i18n'
|
|
5
6
|
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
showWordsCount: { type: Boolean, default: true },
|
|
8
9
|
showCharactersCount: { type: Boolean, default: true },
|
|
10
|
+
limit: { type: Number, default: 0 },
|
|
11
|
+
limitDefaultColor: { type: String, default: 'purple' },
|
|
12
|
+
limitAlertColor: { type: String, default: 'orange' },
|
|
13
|
+
limitWarningColor: { type: String, default: 'red' },
|
|
14
|
+
alignment: { type: String as PropType<TiptapifyFooterAlignment>, default: 'end' },
|
|
9
15
|
})
|
|
10
16
|
|
|
11
17
|
const { t } = inject('tiptapifyI18n') as { t: ComposerTranslation }
|
|
@@ -25,6 +31,18 @@ const statusItems = ref([
|
|
|
25
31
|
}
|
|
26
32
|
])
|
|
27
33
|
|
|
34
|
+
const percentage = computed(() => {
|
|
35
|
+
if (props.limit === 0) {
|
|
36
|
+
return 100
|
|
37
|
+
}
|
|
38
|
+
return Math.round((100 / props.limit) * editor.value.storage.characterCount.characters())
|
|
39
|
+
})
|
|
40
|
+
const limitText = computed(() => {
|
|
41
|
+
const current = editor.value.storage.characterCount.characters().toLocaleString('en-US').replace(/,/g, ' ')
|
|
42
|
+
const limit = props.limit.toLocaleString('en-US').replace(/,/g, ' ')
|
|
43
|
+
return `${t('footer.limit')}<br>${current} / ${limit}`
|
|
44
|
+
})
|
|
45
|
+
|
|
28
46
|
function printStatusItemText(text: string): string {
|
|
29
47
|
return t(text)
|
|
30
48
|
}
|
|
@@ -37,10 +55,45 @@ function showFooter() {
|
|
|
37
55
|
<template>
|
|
38
56
|
<div v-if="showFooter()" class="tiptapify-footer">
|
|
39
57
|
<VRow>
|
|
40
|
-
<VCol class="d-flex
|
|
58
|
+
<VCol class="d-flex align-center" :class="`justify-${alignment}`">
|
|
59
|
+
<template v-if="limit > 0">
|
|
60
|
+
<VTooltip>
|
|
61
|
+
<template #default>
|
|
62
|
+
<span v-html="limitText" />
|
|
63
|
+
</template>
|
|
64
|
+
<template #activator="{ props }">
|
|
65
|
+
<svg
|
|
66
|
+
height="25"
|
|
67
|
+
width="25"
|
|
68
|
+
viewBox="0 0 20 20"
|
|
69
|
+
v-bind="props"
|
|
70
|
+
:class="{
|
|
71
|
+
'character-count': true,
|
|
72
|
+
'character-count--alert': percentage > 75,
|
|
73
|
+
'character-count--warning': editor.storage.characterCount.characters() >= limit,
|
|
74
|
+
}"
|
|
75
|
+
>
|
|
76
|
+
<circle r="8" cx="10" cy="10" fill="#e9ecef" />
|
|
77
|
+
<circle
|
|
78
|
+
r="5"
|
|
79
|
+
cx="10"
|
|
80
|
+
cy="10"
|
|
81
|
+
fill="transparent"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
stroke-width="6"
|
|
84
|
+
:stroke-dasharray="`calc(${percentage} * 31.4 / 100) 31.4`"
|
|
85
|
+
transform="rotate(-90) translate(-20)"
|
|
86
|
+
/>
|
|
87
|
+
<circle r="6" cx="10" cy="10" fill="white" />
|
|
88
|
+
</svg>
|
|
89
|
+
</template>
|
|
90
|
+
</VTooltip>
|
|
91
|
+
|
|
92
|
+
<VDivider class="tiptapify-footer--divider" vertical />
|
|
93
|
+
</template>
|
|
41
94
|
<template v-for="statusItem in statusItems" :key="statusItem.text">
|
|
42
95
|
<span v-if="statusItem.enabled" class="tiptapify-footer--status-item">
|
|
43
|
-
{{ printStatusItemText(statusItem.text) }}: {{ statusItem.value }}
|
|
96
|
+
{{ printStatusItemText(statusItem.text) }}: {{ statusItem.value.toLocaleString('en-US').replace(/,/g, ' ') }}
|
|
44
97
|
</span>
|
|
45
98
|
|
|
46
99
|
<VDivider class="tiptapify-footer--divider" vertical />
|
|
@@ -67,4 +120,17 @@ function showFooter() {
|
|
|
67
120
|
.tiptapify-footer--divider:last-child {
|
|
68
121
|
display: none;
|
|
69
122
|
}
|
|
123
|
+
|
|
124
|
+
/* Character count */
|
|
125
|
+
.character-count {
|
|
126
|
+
color: v-bind(limitDefaultColor);
|
|
127
|
+
|
|
128
|
+
&--alert {
|
|
129
|
+
color: v-bind(limitAlertColor);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&--warning {
|
|
133
|
+
color: v-bind(limitWarningColor);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
70
136
|
</style>
|
|
@@ -6,7 +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 { TiptapifyAiOptions, TiptapifyEditor, variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
|
|
9
|
+
import { TiptapifyAiOptions, TiptapifyEditor, TiptapifyFooterAlignment, variantBtnTypes, variantFieldTypes } from '@tiptapify/types/editor'
|
|
10
10
|
import MenuBubble from '@tiptapify/components/MenuBubble.vue'
|
|
11
11
|
import MenuFloating from '@tiptapify/components/MenuFloating.vue'
|
|
12
12
|
|
|
@@ -33,6 +33,10 @@ const props = defineProps({
|
|
|
33
33
|
showWordsCount: { type: Boolean, default () { return true } },
|
|
34
34
|
showCharactersCount: { type: Boolean, default () { return true } },
|
|
35
35
|
limit: { type: Number as PropType<number | null>, default () { return null } },
|
|
36
|
+
limitDefaultColor: { type: String, default () { return 'purple' } },
|
|
37
|
+
limitAlertColor: { type: String, default () { return 'orange' } },
|
|
38
|
+
limitWarningColor: { type: String, default () { return 'red' } },
|
|
39
|
+
footerAlignment: { type: String as PropType<TiptapifyFooterAlignment>, default () { return 'end' } },
|
|
36
40
|
defaultFontFamily: { type: String, default () { return 'Inter' } },
|
|
37
41
|
fontMeasure: { type: String, default () { return 'px' } },
|
|
38
42
|
rounded: { type: String, default () { return '0' } },
|
|
@@ -154,7 +158,15 @@ onBeforeUnmount(() => {
|
|
|
154
158
|
<EditorContent :editor="editor" class="tiptapify-editor" />
|
|
155
159
|
</div>
|
|
156
160
|
|
|
157
|
-
<Footer
|
|
161
|
+
<Footer
|
|
162
|
+
:show-words-count="showWordsCount"
|
|
163
|
+
:show-characters-count="showCharactersCount"
|
|
164
|
+
:limit="limit ?? 0"
|
|
165
|
+
:limit-default-color="limitDefaultColor"
|
|
166
|
+
:limit-alert-color="limitAlertColor"
|
|
167
|
+
:limit-warning-color="limitWarningColor"
|
|
168
|
+
:alignment="footerAlignment"
|
|
169
|
+
/>
|
|
158
170
|
</div>
|
|
159
171
|
</div>
|
|
160
172
|
</template>
|
|
@@ -39,7 +39,6 @@ import { toolbarSections } from '@tiptapify/types/toolbarTypes'
|
|
|
39
39
|
|
|
40
40
|
// load all languages with "all" or common languages with "common"
|
|
41
41
|
import { common, createLowlight } from 'lowlight'
|
|
42
|
-
|
|
43
42
|
// create a lowlight instance
|
|
44
43
|
// using all available languages
|
|
45
44
|
const lowlight = createLowlight(common)
|
package/src/i18n/locales/ar.json
CHANGED
package/src/i18n/locales/ch.json
CHANGED
package/src/i18n/locales/cz.json
CHANGED
package/src/i18n/locales/de.json
CHANGED
package/src/i18n/locales/en.json
CHANGED
package/src/i18n/locales/es.json
CHANGED
package/src/i18n/locales/fi.json
CHANGED
package/src/i18n/locales/fr.json
CHANGED
package/src/i18n/locales/hu.json
CHANGED
package/src/i18n/locales/it.json
CHANGED
package/src/i18n/locales/ja.json
CHANGED
package/src/i18n/locales/ko.json
CHANGED
package/src/i18n/locales/la.json
CHANGED
package/src/i18n/locales/lt.json
CHANGED
package/src/i18n/locales/nl.json
CHANGED
package/src/i18n/locales/pl.json
CHANGED
package/src/i18n/locales/pt.json
CHANGED
package/src/i18n/locales/ru.json
CHANGED
package/src/i18n/locales/se.json
CHANGED
package/src/i18n/locales/th.json
CHANGED
package/src/i18n/locales/tr.json
CHANGED
package/src/i18n/locales/uk.json
CHANGED
package/src/i18n/locales/vi.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'vue'
|
|
2
2
|
import Tiptapify from '@tiptapify/components/Tiptapify.vue'
|
|
3
3
|
import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
|
|
4
|
+
import { TiptapifyFooterAlignment } from '@tiptapify/types/editor'
|
|
4
5
|
|
|
5
6
|
import { Editor as TipTapEditor, nodeViewProps, NodeViewWrapper, VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
6
7
|
import { Node, Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'
|
|
@@ -43,6 +44,7 @@ export {
|
|
|
43
44
|
mergeAttributes,
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
export type { TiptapifyFooterAlignment }
|
|
46
48
|
export type { CommandProps, InputRuleMatch, PasteRuleMatch }
|
|
47
49
|
export type {
|
|
48
50
|
TiptapifyAiMode,
|
package/src/types/editor.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { TiptapifyEditor }
|
|
|
9
9
|
export type variantBtnTypes = 'outlined' | 'plain' | 'flat' | 'text' | 'elevated' | 'tonal' | undefined
|
|
10
10
|
export type variantFieldTypes = 'outlined' | 'plain' | 'filled' | 'solo' | 'solo-filled' | 'solo-inverted' | 'underlined' | undefined
|
|
11
11
|
|
|
12
|
+
export type TiptapifyFooterAlignment = 'start' | 'center' | 'end'
|
|
13
|
+
|
|
12
14
|
export type TiptapifyAiMode = 'insert' | 'replace' | 'append'
|
|
13
15
|
|
|
14
16
|
export type TiptapifyAiPromptExample = {
|