tiptapify 0.0.5 → 0.0.7
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/README.md +7 -1
- package/dist/tiptapify.css +1 -1
- package/dist/{tiptapify.es.js → tiptapify.mjs} +52867 -51790
- package/dist/tiptapify.umd.js +41 -43
- package/package.json +8 -8
- package/src/components/Footer.vue +5 -6
- package/src/components/MenuBubble.vue +61 -47
- package/src/components/MenuFloating.vue +38 -34
- package/src/components/Tiptapify.vue +139 -23
- package/src/components/Toolbar/Group.vue +43 -0
- package/src/components/Toolbar/GroupDropdown.vue +85 -0
- package/src/components/Toolbar/Index.vue +51 -79
- package/src/components/Toolbar/Toggle.vue +33 -0
- package/src/components/Toolbar/items/actions.ts +32 -0
- package/src/components/Toolbar/items/alignment.ts +60 -0
- package/src/components/Toolbar/items/format.ts +73 -0
- package/src/components/Toolbar/items/formatExtra.ts +73 -0
- package/src/components/Toolbar/items/list.ts +70 -0
- package/src/components/Toolbar/items/media.ts +202 -0
- package/src/components/Toolbar/items/misc.ts +59 -0
- package/src/components/Toolbar/items/style.ts +146 -0
- package/src/components/Toolbar/items.ts +73 -545
- package/src/components/editorExtensions.ts +6 -4
- package/src/components/index.ts +13 -0
- package/src/{components/extensions → extensions}/components/LinkDialog.vue +11 -8
- package/src/extensions/components/PreviewDialog.vue +45 -0
- package/src/{components/extensions/components/ShowSource.vue → extensions/components/ShowSourceDialog.vue} +11 -7
- package/src/extensions/components/TableBuilder.vue +138 -0
- package/src/extensions/preview.ts +53 -0
- package/src/{components/extensions → extensions}/view-source.ts +1 -3
- package/src/i18n/locales/de.json +64 -45
- package/src/i18n/locales/en.json +21 -2
- package/src/i18n/locales/es.json +27 -8
- package/src/i18n/locales/fr.json +26 -7
- package/src/i18n/locales/it.json +36 -17
- package/src/i18n/locales/pl.json +28 -9
- package/src/i18n/locales/ru.json +21 -2
- package/src/i18n/locales/ua.json +21 -2
- package/src/utils/helpers.ts +17 -0
- package/src/composable/useEditor.ts +0 -35
- /package/src/{components/extensions → extensions}/components/slashCommands/CommandsList.vue +0 -0
- /package/src/{components/extensions → extensions}/components/slashCommands/suggestion.ts +0 -0
- /package/src/{components/extensions → extensions}/slash-commands.ts +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as mdi from "@mdi/js";
|
|
2
|
+
import { Editor } from "@tiptap/vue-3";
|
|
3
|
+
import TableBuilder from "@tiptapify/extensions/components/TableBuilder.vue";
|
|
4
|
+
import { computed, markRaw, Ref } from "vue";
|
|
5
|
+
|
|
6
|
+
export function getMediaItems(editor: Editor, toolbarLinkButton: Ref) {
|
|
7
|
+
return {
|
|
8
|
+
link: {
|
|
9
|
+
name: 'format.link',
|
|
10
|
+
tooltip: 'format.link',
|
|
11
|
+
icon: computed(() => editor.isActive('link') ? mdi.mdiLinkOff : mdi.mdiLink),
|
|
12
|
+
enabled: true,
|
|
13
|
+
props: {
|
|
14
|
+
color: computed(() => editor.isActive('link') ? 'primary' : ''),
|
|
15
|
+
disabled: computed(() => editor.isActive('code') || editor.isActive('codeBlock')),
|
|
16
|
+
},
|
|
17
|
+
attrs: {
|
|
18
|
+
click: computed(() => {
|
|
19
|
+
return editor.isActive('link')
|
|
20
|
+
? editor.chain().focus().unsetLink().run
|
|
21
|
+
: toolbarLinkButton?.value?.open
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
table: {
|
|
26
|
+
name: 'tables',
|
|
27
|
+
tooltip: 'format.tables.table',
|
|
28
|
+
icon: mdi.mdiTable,
|
|
29
|
+
modelValue: false,
|
|
30
|
+
enabled: true,
|
|
31
|
+
props: {
|
|
32
|
+
color: computed(() => editor.isActive('table') ? 'primary' : ''),
|
|
33
|
+
disabled: computed(() => !editor.can().chain().focus().insertTable().run()),
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
{
|
|
37
|
+
name: 'insert table',
|
|
38
|
+
tooltip: 'format.tables.insertTable',
|
|
39
|
+
icon: mdi.mdiTablePlus,
|
|
40
|
+
enabled: true,
|
|
41
|
+
props: {
|
|
42
|
+
disabled: computed(() => !editor.can().chain().focus().insertTable().run()),
|
|
43
|
+
activator: 'parent',
|
|
44
|
+
openOnClick: true,
|
|
45
|
+
openOnHover: false,
|
|
46
|
+
closeOnContentClick: false,
|
|
47
|
+
submenu: true
|
|
48
|
+
},
|
|
49
|
+
component: markRaw(TableBuilder),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'insert table',
|
|
53
|
+
tooltip: 'format.tables.deleteTable',
|
|
54
|
+
icon: mdi.mdiTableMinus,
|
|
55
|
+
enabled: true,
|
|
56
|
+
props: {
|
|
57
|
+
disabled: computed(() => !editor.can().chain().focus().deleteTable().run()),
|
|
58
|
+
},
|
|
59
|
+
attrs: {
|
|
60
|
+
click: () => editor.chain().focus().deleteTable().run()
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'table row',
|
|
65
|
+
tooltip: 'format.tables.row',
|
|
66
|
+
icon: mdi.mdiTableRow,
|
|
67
|
+
enabled: true,
|
|
68
|
+
props: {
|
|
69
|
+
disabled: computed(
|
|
70
|
+
() =>
|
|
71
|
+
!editor.can().chain().focus().addRowBefore().run() &&
|
|
72
|
+
!editor.can().chain().focus().addRowAfter().run() &&
|
|
73
|
+
!editor.can().chain().focus().deleteRow().run()
|
|
74
|
+
),
|
|
75
|
+
openOnHover: true,
|
|
76
|
+
openOnClick: true,
|
|
77
|
+
activator: 'parent',
|
|
78
|
+
submenu: true
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
{
|
|
82
|
+
name: 'insert row before',
|
|
83
|
+
tooltip: 'format.tables.insertRowBefore',
|
|
84
|
+
icon: mdi.mdiTableRowPlusBefore,
|
|
85
|
+
enabled: true,
|
|
86
|
+
props: {
|
|
87
|
+
disabled: computed(() => !editor.can().chain().focus().addRowBefore().run()),
|
|
88
|
+
},
|
|
89
|
+
attrs: {
|
|
90
|
+
click: () => editor.chain().focus().addRowBefore().run()
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'insert row after',
|
|
95
|
+
tooltip: 'format.tables.insertRowAfter',
|
|
96
|
+
icon: mdi.mdiTableRowPlusAfter,
|
|
97
|
+
enabled: true,
|
|
98
|
+
props: {
|
|
99
|
+
disabled: computed(() => !editor.can().chain().focus().addRowAfter().run()),
|
|
100
|
+
},
|
|
101
|
+
attrs: {
|
|
102
|
+
click: () => editor.chain().focus().addRowAfter().run()
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'delete row',
|
|
107
|
+
tooltip: 'format.tables.deleteRow',
|
|
108
|
+
icon: mdi.mdiTableRowRemove,
|
|
109
|
+
enabled: true,
|
|
110
|
+
props: {
|
|
111
|
+
disabled: computed(() => !editor.can().chain().focus().deleteRow().run()),
|
|
112
|
+
},
|
|
113
|
+
attrs: {
|
|
114
|
+
click: () => editor.chain().focus().deleteRow().run()
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'column',
|
|
121
|
+
tooltip: 'format.tables.col',
|
|
122
|
+
icon: mdi.mdiTableColumn,
|
|
123
|
+
enabled: true,
|
|
124
|
+
props: {
|
|
125
|
+
disabled: computed(
|
|
126
|
+
() =>
|
|
127
|
+
!editor.can().chain().focus().addColumnBefore().run() &&
|
|
128
|
+
!editor.can().chain().focus().addColumnAfter().run() &&
|
|
129
|
+
!editor.can().chain().focus().deleteColumn().run()
|
|
130
|
+
),
|
|
131
|
+
openOnHover: true,
|
|
132
|
+
openOnClick: true,
|
|
133
|
+
activator: 'parent',
|
|
134
|
+
submenu: true
|
|
135
|
+
},
|
|
136
|
+
children: [
|
|
137
|
+
{
|
|
138
|
+
name: 'insert col before',
|
|
139
|
+
tooltip: 'format.tables.insertColBefore',
|
|
140
|
+
icon: mdi.mdiTableColumnPlusBefore,
|
|
141
|
+
enabled: true,
|
|
142
|
+
props: {
|
|
143
|
+
disabled: computed(() => !editor.can().chain().focus().addColumnBefore().run()),
|
|
144
|
+
},
|
|
145
|
+
attrs: {
|
|
146
|
+
click: () => editor.chain().focus().addColumnBefore().run()
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'insert column after',
|
|
151
|
+
tooltip: 'format.tables.insertColAfter',
|
|
152
|
+
icon: mdi.mdiTableColumnPlusAfter,
|
|
153
|
+
enabled: true,
|
|
154
|
+
props: {
|
|
155
|
+
disabled: computed(() => !editor.can().chain().focus().addColumnAfter().run()),
|
|
156
|
+
},
|
|
157
|
+
attrs: {
|
|
158
|
+
click: () => editor.chain().focus().addColumnAfter().run()
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'delete column',
|
|
163
|
+
tooltip: 'format.tables.deleteCol',
|
|
164
|
+
icon: mdi.mdiTableColumnRemove,
|
|
165
|
+
enabled: true,
|
|
166
|
+
props: {
|
|
167
|
+
disabled: computed(() => !editor.can().chain().focus().deleteColumn().run()),
|
|
168
|
+
},
|
|
169
|
+
attrs: {
|
|
170
|
+
click: () => editor.chain().focus().deleteColumn().run()
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'merge cells',
|
|
177
|
+
tooltip: 'format.tables.mergeCells',
|
|
178
|
+
icon: mdi.mdiTableMergeCells,
|
|
179
|
+
enabled: true,
|
|
180
|
+
props: {
|
|
181
|
+
disabled: computed(() => !editor.can().chain().focus().mergeCells().run()),
|
|
182
|
+
},
|
|
183
|
+
attrs: {
|
|
184
|
+
click: () => editor.chain().focus().mergeCells().run()
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'split cell',
|
|
189
|
+
tooltip: 'format.tables.splitCell',
|
|
190
|
+
icon: mdi.mdiTableSplitCell,
|
|
191
|
+
enabled: true,
|
|
192
|
+
props: {
|
|
193
|
+
disabled: computed(() => !editor.can().chain().focus().splitCell().run()),
|
|
194
|
+
},
|
|
195
|
+
attrs: {
|
|
196
|
+
click: () => editor.chain().focus().splitCell().run()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as mdi from "@mdi/js";
|
|
2
|
+
import { Editor } from "@tiptap/vue-3";
|
|
3
|
+
import { computed, Ref } from "vue";
|
|
4
|
+
|
|
5
|
+
export function getMiscItems(editor: Editor) {
|
|
6
|
+
return {
|
|
7
|
+
line: {
|
|
8
|
+
name: 'line',
|
|
9
|
+
tooltip: 'format.line',
|
|
10
|
+
icon: mdi.mdiMinus,
|
|
11
|
+
enabled: true,
|
|
12
|
+
props: {},
|
|
13
|
+
attrs: {
|
|
14
|
+
click: () => editor.chain().focus().setHorizontalRule().run()
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
break: {
|
|
18
|
+
name: 'break',
|
|
19
|
+
tooltip: 'format.break',
|
|
20
|
+
icon: mdi.mdiFormatPageBreak,
|
|
21
|
+
enabled: true,
|
|
22
|
+
props: {},
|
|
23
|
+
attrs: {
|
|
24
|
+
click: () => editor.chain().focus().setHardBreak().run()
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
source: {
|
|
28
|
+
name: 'source',
|
|
29
|
+
tooltip: 'misc.source',
|
|
30
|
+
icon: mdi.mdiCodeTags,
|
|
31
|
+
enabled: true,
|
|
32
|
+
props: {},
|
|
33
|
+
attrs: {
|
|
34
|
+
click: () => editor.commands.showSource()
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
preview: {
|
|
38
|
+
name: 'preview',
|
|
39
|
+
tooltip: 'misc.preview',
|
|
40
|
+
icon: mdi.mdiFileEyeOutline,
|
|
41
|
+
enabled: true,
|
|
42
|
+
attrs: {
|
|
43
|
+
click: () => editor.commands.showPreview()
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
formatClear: {
|
|
47
|
+
name: 'format clear',
|
|
48
|
+
tooltip: 'format.formatClear',
|
|
49
|
+
icon: mdi.mdiFormatClear,
|
|
50
|
+
enabled: true,
|
|
51
|
+
props: {
|
|
52
|
+
disabled: computed(() => !editor.can().chain().focus().unsetAllMarks().run()),
|
|
53
|
+
},
|
|
54
|
+
attrs: {
|
|
55
|
+
click: () => editor.chain().focus().unsetAllMarks().clearNodes().run()
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as mdi from "@mdi/js";
|
|
2
|
+
import { Editor } from "@tiptap/vue-3";
|
|
3
|
+
import { fonts } from "@tiptapify/components/Toolbar/fonts";
|
|
4
|
+
import { computed, ref } from "vue";
|
|
5
|
+
|
|
6
|
+
interface MDIIcons {
|
|
7
|
+
[key: string]: string
|
|
8
|
+
}
|
|
9
|
+
const mdiIcons = mdi as MDIIcons
|
|
10
|
+
|
|
11
|
+
export function getStyleItems(editor: Editor, fontMeasure: string, customHeadingLevels: Array<number> = []) {
|
|
12
|
+
const headingLevels = ref([1, 2, 3, 4, 5, 6])
|
|
13
|
+
if (customHeadingLevels.length) {
|
|
14
|
+
customHeadingLevels.forEach(level => {
|
|
15
|
+
if (level <= 0 || level > 6) {
|
|
16
|
+
throw new Error('customHeadingLevels must be between 1 and 6')
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
headingLevels.value = customHeadingLevels
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const fontSizes = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 32, 48, 64, 96]
|
|
24
|
+
|
|
25
|
+
const lineHeights = [1, 1.5, 2, 3, 4]
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
heading: {
|
|
29
|
+
name: 'heading',
|
|
30
|
+
tooltip: 'style.heading',
|
|
31
|
+
icon: mdi.mdiFormatHeaderPound,
|
|
32
|
+
modelValue: null,
|
|
33
|
+
enabled: true,
|
|
34
|
+
props: {
|
|
35
|
+
color: computed(() => editor.isActive('heading') || editor.isActive('paragraph') ? 'primary' : ''),
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
{
|
|
39
|
+
name: `paragraph`,
|
|
40
|
+
tooltip: `style.paragraph`,
|
|
41
|
+
icon: mdiIcons[`mdiFormatParagraph`],
|
|
42
|
+
noI18n: true,
|
|
43
|
+
enabled: true,
|
|
44
|
+
props: {
|
|
45
|
+
color: computed(() => editor.isActive('paragraph') ? 'primary' : ''),
|
|
46
|
+
},
|
|
47
|
+
attrs: {
|
|
48
|
+
click: () => editor.chain().focus().setParagraph().run()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
].concat(
|
|
52
|
+
headingLevels.value.map(level => {
|
|
53
|
+
return {
|
|
54
|
+
name: `H${level}`,
|
|
55
|
+
tooltip: `style.headings.h${level}`,
|
|
56
|
+
icon: mdiIcons[`mdiFormatHeader${level}`],
|
|
57
|
+
noI18n: true,
|
|
58
|
+
enabled: true,
|
|
59
|
+
props: {
|
|
60
|
+
color: computed(() => editor.isActive('heading', { level: level }) ? 'primary' : ''),
|
|
61
|
+
},
|
|
62
|
+
attrs: {
|
|
63
|
+
click: () => editor.chain().focus().toggleHeading({ level }).run()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
},
|
|
69
|
+
fontFamily: {
|
|
70
|
+
name: 'font-family',
|
|
71
|
+
tooltip: 'style.fontFamily',
|
|
72
|
+
icon: mdi.mdiFormatFont,
|
|
73
|
+
modelValue: false,
|
|
74
|
+
enabled: true,
|
|
75
|
+
attrs: {
|
|
76
|
+
click: () => editor.chain().focus().unsetFontFamily().run()
|
|
77
|
+
},
|
|
78
|
+
children: fonts.map((font) => {
|
|
79
|
+
return {
|
|
80
|
+
name: font.name,
|
|
81
|
+
tooltip: '',
|
|
82
|
+
icon: '',
|
|
83
|
+
enabled: true,
|
|
84
|
+
noI18n: true,
|
|
85
|
+
props: {
|
|
86
|
+
color: computed(() => editor.isActive('textStyle', {fontFamily: font.fontFamily}) ? 'primary' : ''),
|
|
87
|
+
style: `font-family: ${font.fontFamily};`
|
|
88
|
+
},
|
|
89
|
+
attrs: {
|
|
90
|
+
click: () => editor.chain().focus().setFontFamily(font.fontFamily).run()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
fontSize: {
|
|
96
|
+
name: 'font-size',
|
|
97
|
+
tooltip: 'style.fontSize',
|
|
98
|
+
icon: mdi.mdiFormatSize,
|
|
99
|
+
modelValue: false,
|
|
100
|
+
enabled: true,
|
|
101
|
+
attrs: {
|
|
102
|
+
click: () => editor.chain().focus().unsetFontSize().run()
|
|
103
|
+
},
|
|
104
|
+
children: fontSizes.map((fontSize) => {
|
|
105
|
+
return {
|
|
106
|
+
name: `${fontSize}${fontMeasure}`,
|
|
107
|
+
tooltip: '',
|
|
108
|
+
icon: '',
|
|
109
|
+
enabled: true,
|
|
110
|
+
noI18n: true,
|
|
111
|
+
props: {
|
|
112
|
+
color: computed(() => editor.isActive('textStyle', {fontSizes: fontSize}) ? 'primary' : ''),
|
|
113
|
+
},
|
|
114
|
+
attrs: {
|
|
115
|
+
click: () => editor.chain().focus().setFontSize(`${fontSize}${fontMeasure}`).run()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
lineHeight: {
|
|
121
|
+
name: 'line-height',
|
|
122
|
+
tooltip: 'style.lineHeight',
|
|
123
|
+
icon: mdi.mdiFormatLineHeight,
|
|
124
|
+
modelValue: null,
|
|
125
|
+
enabled: true,
|
|
126
|
+
attrs: {
|
|
127
|
+
click: () => editor.chain().focus().unsetLineHeight().run()
|
|
128
|
+
},
|
|
129
|
+
children: lineHeights.map((lineHeight) => {
|
|
130
|
+
return {
|
|
131
|
+
name: lineHeight,
|
|
132
|
+
tooltip: '',
|
|
133
|
+
icon: '',
|
|
134
|
+
enabled: true,
|
|
135
|
+
noI18n: true,
|
|
136
|
+
props: {
|
|
137
|
+
color: computed(() => editor.isActive('textStyle', {lineHeights: lineHeight}) ? 'primary' : ''),
|
|
138
|
+
},
|
|
139
|
+
attrs: {
|
|
140
|
+
click: () => editor.chain().focus().setLineHeight(lineHeight.toString()).run()
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|