tiptapify 0.2.1 → 0.2.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 +13798 -13508
- package/dist/tiptapify.umd.js +55 -55
- package/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/Footer.vue +67 -2
- 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 +4 -1
- package/src/types/editor.ts +2 -0
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Editor as TiptapEditor } from '@tiptap/vue-3'
|
|
1
|
+
import { Editor as TiptapEditor, nodeViewProps, NodeViewWrapper, VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
2
2
|
import {
|
|
3
3
|
Extension,
|
|
4
4
|
ExtendableConfig,
|
|
@@ -147,6 +147,9 @@ export {
|
|
|
147
147
|
Tiptapify,
|
|
148
148
|
TiptapifyDialog,
|
|
149
149
|
TiptapEditor,
|
|
150
|
+
nodeViewProps,
|
|
151
|
+
NodeViewWrapper,
|
|
152
|
+
VueNodeViewRenderer,
|
|
150
153
|
Extension,
|
|
151
154
|
ExtendableConfig,
|
|
152
155
|
InputRule,
|
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,17 @@ 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()
|
|
42
|
+
return `${t('footer.limit')}<br>${current} / ${props.limit}`
|
|
43
|
+
})
|
|
44
|
+
|
|
28
45
|
function printStatusItemText(text: string): string {
|
|
29
46
|
return t(text)
|
|
30
47
|
}
|
|
@@ -37,7 +54,42 @@ function showFooter() {
|
|
|
37
54
|
<template>
|
|
38
55
|
<div v-if="showFooter()" class="tiptapify-footer">
|
|
39
56
|
<VRow>
|
|
40
|
-
<VCol class="d-flex
|
|
57
|
+
<VCol class="d-flex align-center" :class="`justify-${alignment}`">
|
|
58
|
+
<template v-if="limit > 0">
|
|
59
|
+
<VTooltip>
|
|
60
|
+
<template #default>
|
|
61
|
+
<span v-html="limitText" />
|
|
62
|
+
</template>
|
|
63
|
+
<template #activator="{ props }">
|
|
64
|
+
<svg
|
|
65
|
+
height="25"
|
|
66
|
+
width="25"
|
|
67
|
+
viewBox="0 0 20 20"
|
|
68
|
+
v-bind="props"
|
|
69
|
+
:class="{
|
|
70
|
+
'character-count': true,
|
|
71
|
+
'character-count--alert': percentage > 75,
|
|
72
|
+
'character-count--warning': editor.storage.characterCount.characters() === limit,
|
|
73
|
+
}"
|
|
74
|
+
>
|
|
75
|
+
<circle r="8" cx="10" cy="10" fill="#e9ecef" />
|
|
76
|
+
<circle
|
|
77
|
+
r="5"
|
|
78
|
+
cx="10"
|
|
79
|
+
cy="10"
|
|
80
|
+
fill="transparent"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
stroke-width="6"
|
|
83
|
+
:stroke-dasharray="`calc(${percentage} * 31.4 / 100) 31.4`"
|
|
84
|
+
transform="rotate(-90) translate(-20)"
|
|
85
|
+
/>
|
|
86
|
+
<circle r="6" cx="10" cy="10" fill="white" />
|
|
87
|
+
</svg>
|
|
88
|
+
</template>
|
|
89
|
+
</VTooltip>
|
|
90
|
+
|
|
91
|
+
<VDivider class="tiptapify-footer--divider" vertical />
|
|
92
|
+
</template>
|
|
41
93
|
<template v-for="statusItem in statusItems" :key="statusItem.text">
|
|
42
94
|
<span v-if="statusItem.enabled" class="tiptapify-footer--status-item">
|
|
43
95
|
{{ printStatusItemText(statusItem.text) }}: {{ statusItem.value }}
|
|
@@ -67,4 +119,17 @@ function showFooter() {
|
|
|
67
119
|
.tiptapify-footer--divider:last-child {
|
|
68
120
|
display: none;
|
|
69
121
|
}
|
|
122
|
+
|
|
123
|
+
/* Character count */
|
|
124
|
+
.character-count {
|
|
125
|
+
color: v-bind(limitDefaultColor);
|
|
126
|
+
|
|
127
|
+
&--alert {
|
|
128
|
+
color: v-bind(limitAlertColor);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&--warning {
|
|
132
|
+
color: v-bind(limitWarningColor);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
70
135
|
</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
|
@@ -2,7 +2,7 @@ import { Plugin } from 'vue'
|
|
|
2
2
|
import Tiptapify from '@tiptapify/components/Tiptapify.vue'
|
|
3
3
|
import TiptapifyDialog from '@tiptapify/components/UI/TiptapifyDialog.vue'
|
|
4
4
|
|
|
5
|
-
import { Editor as TipTapEditor } from '@tiptap/vue-3'
|
|
5
|
+
import { Editor as TipTapEditor, nodeViewProps, NodeViewWrapper, VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
6
6
|
import { Node, Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'
|
|
7
7
|
import type { CommandProps, InputRuleMatch, PasteRuleMatch } from '@tiptap/core'
|
|
8
8
|
|
|
@@ -31,6 +31,9 @@ export default TiptapifyPlugin
|
|
|
31
31
|
export {
|
|
32
32
|
mdi,
|
|
33
33
|
TipTapEditor,
|
|
34
|
+
nodeViewProps,
|
|
35
|
+
NodeViewWrapper,
|
|
36
|
+
VueNodeViewRenderer,
|
|
34
37
|
Tiptapify,
|
|
35
38
|
TiptapifyDialog,
|
|
36
39
|
Node,
|
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 = {
|